devongovett / atom-jade

Jade TextMate bundle converted for Atom
51 stars 26 forks source link

Error in embedded languages breaks syntax highlighting due to pattern scope #74

Open alexchandel opened 7 years ago

alexchandel commented 7 years ago

The following highlights somewhat correctly (ignoring the bad highlighting of the first style's content):

html
    head
        style(type='text/css').
            div { foo bar; }
        style(type='text/css')
            include markdown.css

However in this case, syntax highlighting is broken for the rest of the file:

html
    head
        style(type='text/css').
            div { foo: bar;
        style(type='text/css')
            include markdown.css
    body
        +content()

The problem is that you're allowing the patterns for the embedded grammar to consume past the end of the style block's contents, which is illegal in jade.

You need to mark that the content of the style (i.e. the lines between the style. and the next line that is less-indented than the style.) is source.css first, and then match css grammar inside of it.

Because while the second example contains embedded invalid css, it's valid jade itself.