Remove boilerplate grammar, fix CSS syntax highlighting#7
Conversation
Moving 'text.xml' include below style/script capture groups makes them reachable, otherwise the xml grammar takes precedence.
Many of the grammar changes are based on how the HTML grammar is done (style and script tag grammars copied nearly wholesale). Specific SVG tags have also been targeted to add them to groups (structural, descriptive, shape, animation) like how the HTML grammar targets block tags and inline tags. I could have taken this further, but this is a nice start. A "repository" has been added which includes #tag-stuff, which was referenced before but undefined. Some snippets have also been fixed: all on* snippets were stacked and unreachable, and tag snippets have been removed when within a tag or embedded context.
Path data in the d attribute is tokenized as a "meta.instruction-list", if there's a better existing scope name I'd like to hear it. Each instruction (beginning with a letter) is grouped, and the instruction type, commas, and values are individually tokenized. I selfishly wanted the letter tokens highlighted automatically, which meant scoping them as a "keyword" which may not be technically correct, but it gets picked up by pretty much every syntax theme so they stand out from the rest of the string.
|
Is there anything I can do to nudge this forward and get these updates pushed to the Atom package repo? |
|
Just wanted to check in again on this pull request. I totally get the life and other responsibilities get in the way, but this is the defacto SVG language package for Atom and it is languishing. Currently this package is basically a collection of autocomplete snippets but it could be so much more with a real grammar instead of being a passthrough for the XML grammar. I'd love for this to get to a point that the official language-html package would consider defaulting to this package for embedded SVG tags! But to get to that point, I think we need to add tree-sitter compatibility, as the old-style TextMate grammars may be deprecated eventually. I would absolutely be interested in helping to maintain this package if that's something you'd be open to. |
|
My bad, I somehow managed to miss this PR :/ Thank you so much for contributing. |
|
Hey no problem, I'm a little out of sync with this stuff too at the moment! But I'm glad it did get your attention. Let me know if there's something further I should do to get this merged. |
This was initially meant to address issue #6 only (CSS syntax highlighting), but I got carried away after I noticed some boilerplate TextMate grammar code. I've cleaned this up and made strides towards a proper SVG grammar tokenization, which includes categorizing a subset of tags according to their "collections" taken from the official W3C spec (v1.1).
I've included a few things that we don't get from the inclusion of the XML grammar, specifically id and class attribute tokenization, as well as path data tokenization within the d attribute.
In regards to CSS syntax, the new grammar instructions include the main CSS grammar for style tags and also style attributes. This doesn't mean that full syntax highlighting will appear in style attributes (my current Atom theme does not) but the key-value pairs are properly tokenized.