We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Custom Puzzles: Less than symbol must be escaped in template literal

Home Forums Programming Custom Puzzles: Less than symbol must be escaped in template literal

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #36983
    jem
    Customer

    I was working on a simple custom puzzle today and I encountered an error. In the developer console in the puzzle editor, I received an error that said:

    puzzles.min.js:1 BlockError(xxx/convertListToDictionary): error parsing .block file – “This page contains the following errors:error on line 28 at column 36: StartTag: invalid element name
    Below is a rendering of the page up to the first error.

    The invalid element was the less than symbol, “<“. This JavaScript code was in a template literal, per the documentation. Apparently, this symbol causes the parser to fail. I do not think that template literals should have an issue with this symbol. The MDN page for template literals states that template literals support Unicode escape sequences, so I replaced “<” with “\u003c”. This fixed the error. Now this section of code looks something like the code in the attached image.

    This is probably not a bug, but it is an issue to watch for when developing plugins.

    Attachments:
    You must be logged in to view attached files.

    Jeremy Wernick

    #36988
    GLiFTeK
    Customer

    Hi,
    Do you know how to escape the “/n” used to end text lines?

    I’m having a same type of issue with using that in a JavaScript section of my .block file.

    #37015

    Hi Jeremy,

    We have fixed many issues with Verge3D plugins in pre1 and pre2 updates, that were particularly concerned with debugging the plugins. You might check if the issue is still present.

    Chief 3D Verger | LinkedIn | Twitter

    #37024
    jem
    Customer

    Hi Yuri,
    This issue occurred in the pre2 build. I can email a copy of the project with the error if you want to look into it.
    This is not a high priority since there is an easy workaround. Also, I do not know if the issue is with Verge3D or in the core Blockly code.
    I do like the enhanced error messages in pre2. The error message made locating the issue easy.
    Thank you

    Jeremy Wernick

    #37026

    Ah I see. Yes, having a sample project to debug would be helpful. Please feel free to email it our way!

    Chief 3D Verger | LinkedIn | Twitter

    #37048
    jem
    Customer

    Hi Yuri,
    I removed all of the customer information, so I can post it here in the forums. The project is attached here. The code is simple. It compares two number inputs with the less than operator “<“. You can see the error message in the Chrome dev tools console in one of the attached screenshots.
    console parsing error

    Remove line 23 of the ‘isLessThan.block’ file and Uncomment line 24 and the block should work.

    Using the greater than symbol “>” causes a different parser error.

    Using Unicode escapes is a workaround.

    On a related subject, I would like a design pattern that would allow me to get my code (rather than the API code) out of string literals. VSCode does not apply Intellisense to the code in a string literal. The editor will not match brackets, quote marks, check syntax, etc. The best approach that I found was to first implement and de-bug my code outside of the puzzle system in app.ExternalInterface and then copy the working code into the puzzle system.
    code in VSCode
    Still, puzzle plugins are a great solution for us! Thank you.

    Attachments:
    You must be logged in to view attached files.

    Jeremy Wernick

    #37167

    Thanks for the examples! We’ll check it out!

    Chief 3D Verger | LinkedIn | Twitter

    #38286

    Fixed in Verge3D 3.6.

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #38291
    jem
    Customer

    Thank you. I look forward to developing custom v3d puzzles!

    Jeremy Wernick

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.