language-babel icon indicating copy to clipboard operation
language-babel copied to clipboard

Syntax highlighting bleeds out of markdown codeblocks

Open aryzing opened this issue 7 years ago • 1 comments

When writing jsx codeblocks in markdown files, I believe that the syntax highlighting is provided by language-babel. However, when trying to close the codeblock, the syntax highlighting for jsx bleeds outside the closing ```.

image

aryzing avatar Apr 05 '18 10:04 aryzing

This is problematic. The Markdown grammar should end the JS parsing when it finds a ``` but because of the way TextMate grammars work it will only see the ``` at the topmost rule stack of the called grammar. In my case when a const, let or var is detected I call a new rule stack which isn't terminated until an end or new statement is detected ( a semi-colon, EOF or JS keyword - if, else etc) so markdown isn't processing the ```.

I could put a check in for a line containing only ``` and terminate the rule stack but ``` is actualy valid JS so I'm a bit loathe to do so.

You could just put a ; at the end of the statement or on a new line and it will work. For normal code that doesn't end on a var definition of this type it should work without semi-colons. Not ideal if you don't like semi's!

gandm avatar Apr 05 '18 15:04 gandm