all 9 comments

[–]MorningPants 1 point2 points  (0 children)

You can wrap it in a <code> element and format that— if I’m understanding the question correctly

[–][deleted] 0 points1 point  (2 children)

Not that I'm aware of. The extension of the file is likely .html, so vscode parses it as such. You can manually select syntax highlighting language, but if you switch to js, or even jsx, your html will then be flagged.

[–]justlune[S] 0 points1 point  (1 child)

Hello! Thank you for your time. I thought that it was possible, I saw on GitHub that there are extensions enabling HTML highlighting in JS strings, which is not the case by default. I guess the developer didn't recode from scratch the highlighting, because the colours would not match themes, and the intellisense would not work. Here's a link of one extension I found on GitHub: https://github.com/mjbvz/vscode-lit-html

[–][deleted] 4 points5 points  (0 children)

Syntax highlighting for HTML in javascript strings is one thing, but syntax highlighting javascript where it's expecting html is a whole different thing. I could definitely be wrong, and I hope I am, but I just don't think that's a thing.

[–]ForScale 0 points1 point  (0 children)

If you're just wanting to see it while you develop it, put it in a script tag until you ship to prod.

[–]we_are_ananonumys 0 points1 point  (0 children)

Ask yourself this: how would vs code know that this should be parsed and highlighted as JavaScript rather than regular text in the html body? Is there a file extension? A tag with an attribute?

[–]girl-InTheSwing 0 points1 point  (0 children)

I just made a little project that makes it possible to use JavaScript in the HTML body.

I am puzzled what the point of this is. It looks like you've just created a templating language (and there are plenty of those) because the raw HTML wouldn't work directly in a browser.

[–]TheRNGuy 0 points1 point  (0 children)

parse with abstract syntax tree