Replies: 1 comment 8 replies
-
I've done some digging and the issue is going to be down to GitHub's old highlighting engine which still parses these TextMate-based grammars. The problem is it doesn't expand scope matches and instead treats the 'tags-lang':
begin: '<(script|style|template)'
end: '</\\1\\s*>|/>'
beginCaptures:
'0':
patterns: [include: '#tags-start-node']
endCaptures:
'0':
patterns: [include: '#tags-end-node']
name: 'meta.$1.svelte'. #<---------------- HERE
patterns: [
begin: '\\G(?=\\s*[^>]*?(type|lang)\\s*=\\s*([\'"]|)(?:text/)?(\\w+)\\2)'
end: '(?=</|/>)'
name: 'meta.lang.$3.svelte'
patterns: [include: '#tags-lang-start-attributes']
,
include: '#tags-lang-start-attributes'
] This means it will not match any of your injections which are expecting the This is news to me. It's also unfortunately been like this for well over 8 years and unfortunately isn't going to change as this old parser is no longer getting internal funding for fixes or improvements in favour of the newer tree-sitter based highlighting. This means the only solution is to be explicit with the scope names and not rely on the regex matches, or wait for the Svelte tree-sitter grammar (I think this is it) to be pulled in by the team that maintains the highlighting engines. If the tree-sitter grammar is at least as functionally complete as the TextMate grammar (lemme know, as I don't know), I can have a word with the team and put it on their radar for consideration. |
Beta Was this translation helpful? Give feedback.
-
I opened a PR in the upstream Svelte grammar to attempt to fix broken syntax highlighting (sveltejs/svelte-atom#21), but without any solid way to test it, we were left waiting for the new release of
linguist
to see if it worked or not.Another dev opened a PR here (#6144) before the new release, but closed it, because we determined that the fix in
svelte-atom
should have worked.That dev made a fork of the community fork of Lightshow (https://umanghome.github.io/NovaLightshow/) that allowed us to test the grammar. Using that, I found that
NovaLightshow
was getting tripped up bysvelte-atom
's.cson
grammar -- it was throwing aYAMLError
. If I converted it manually to JSON (I used this site: https://www.convertsimple.com/convert-cson-to-json/) and pasted it in the Grammar box, syntax highlighting worked.It was also my understanding that
linguist
converts.cson
files to.json
when building its grammars: https://github.com/github/linguist/blob/32ec19c013a7f81ffaeead25e6e8f9668c7ed574/tools/grammars/compiler/proto.go#L65-L69 So I assumed that meant the "fixed" upstream grammar would work once converted to JSON.However, after the release of
7.24.0
, Svelte syntax highlighting is still broken on GitHub. Is there anyone who knows more about this stuff who could possibly help figure out what is going wrong here? Thanks!Beta Was this translation helpful? Give feedback.
All reactions