gandm / language-babel

ES2017, flow, React JSX and GraphQL grammar and transpilation for ATOM
https://atom.io/packages/language-babel
MIT License
476 stars 83 forks source link

Syntax highlighting bleeds out of markdown codeblocks #489

Open aryzing opened 6 years ago

aryzing commented 6 years ago

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

gandm commented 6 years ago

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 topmostrule stackof the called grammar. In my case when aconst,letorvaris detected I call a newrule stackwhich 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!