Home › Forums › Programming › Custom Puzzles: Less than symbol must be escaped in template literal
- This topic has 8 replies, 4 voices, and was last updated 3 years, 10 months ago by jem.
-
AuthorPosts
-
2020-12-31 at 12:46 am #36983jemCustomer
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
2020-12-31 at 1:53 am #36988GLiFTeKCustomerHi,
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.
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2021-01-01 at 11:55 am #37015Yuri KovelenovStaff2021-01-01 at 11:31 pm #37024jemCustomerHi 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 youJeremy Wernick
2021-01-02 at 9:59 am #37026Yuri KovelenovStaff2021-01-02 at 11:37 pm #37048jemCustomerHi 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.
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.
Still, puzzle plugins are a great solution for us! Thank you.Attachments:
You must be logged in to view attached files.Jeremy Wernick
2021-01-08 at 9:36 am #37167Yuri KovelenovStaff2021-02-09 at 4:45 pm #38286Alexander KovelenovStaffFixed in Verge3D 3.6.
2021-02-09 at 5:18 pm #38291jemCustomerThank you. I look forward to developing custom v3d puzzles!
Jeremy Wernick
-
AuthorPosts
- You must be logged in to reply to this topic.