Open JoaoFelipe3 opened 1 week ago
The existing behavior is intentional. https://github.com/highlightjs/highlight.js/issues/3288
Regex is really hard to deal with without a full context-aware parser. I'll leave this open a bit to see if anyone wants to try and tackle this - and solve BOTH issues... but eventually if no one shows up we'll auto-close it a cant-fix.
If a template literal with a regular expression that contains an odd number of quotes is highlighted, the last quote is treated as beginning a string and extends until closing it, at which point you still need to close the placeholder and the template literal itself.
I am testing with the
javascript
, but the same goes for thetypescript
grammar.I am not using the language detection.
Here is some example code to test this on:
I expected the quote to not open a string at all, and just be treated as part of the regular expression.
Here's the code this was found in (TypeScript):