Syntax highlighting is broken with (nested?) template strings
See original GitHub issueHello,
I’ve just seen the announcement on Twitter, congrats!
I’ve tried looking at the latest sveltejs, and at approximately 1/3 of the file all the code is highlighted as a string.
Offending file: https://runpkg.com/?svelte@3.3.0/internal.js
Offending code:
const animation = node.style.animation || '';
node.style.animation = `${animation ? `${animation}, ` : ``}${name} ${duration}ms linear ${delay}ms 1 both`;
// starting from the column everything is highlighted as a string
This is a very raw bug report, I literally heard about runpkg 5 minutes ago, so I made no further investigation. I hope this helps uncover a real bug somewhere!
End of report!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
I kinda don't get the whole "put html in template literals ...
I kinda don't get the whole "put html in template literals". Wouldn't there be no syntax highlighting? And the framework is either putting...
Read more >Wrong syntax highlighting in TS/JS file with template strings in ...
The following construction is correctly starting the string, but not terminating it, and all the text after is written in red:
Read more >How to define template strings in textmate language ...
I got this working by using special scopes from textmate language grammar:
Read more >Syntax Highlight Guide | Visual Studio Code Extension API
A guide to syntax highlighting. ... Tokens are used for syntax highlighting, but also to classify the source code into areas of comments,...
Read more >How to avoid broken formulas - Microsoft Support
You'll return to the cell with the broken formula, which will be in edit mode, and Excel will highlight the spot where it's...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Wow, that was fast. I don’t know another package that has nested string literals, I really stumbled upon this pattern by chance. Looks good on Svelte (I know it’s a bit late since you already merged).
Happy to have been helpful to the project. Cheers!
Ok, I lied. I think I have a fix!
Please see the relevant PR https://github.com/FormidableLabs/runpkg/pull/68
Would love for you to try it out and give feedback @DjebbZ . See the link to view the branch in the comment by
now bot
on that PREdit: @lukejacksonn and I are happy with the fix, and - evidently - prism are, too. Merged!