Update regex of VSCode grammars to be used with `github/linguist`
See original GitHub issueAs of right now, syntax highlighting is broken on GitHub for anything inside <script>
, <style>
, and <template>
tags in .svelte
files.
This started (I believe) with this PR: https://github.com/github/linguist/pull/5963. That points the source for svelte
files to https://github.com/sveltejs/svelte-atom. However, there is apparently some bug in the injections
section of that grammar that is breaking syntax highlighting (https://github.com/github/linguist/issues/5830#issuecomment-1195653540).
Since Atom is going to be sunsetted, and the VSCode grammars in this repo use TextMate grammar, I was going to open a PR in github/linguist
to update the source to point to the grammars here. However, when I attempted to add it to that repo, it failed linguist
’s compiler check with these errors:
- Invalid regex in grammar: `markdown.svelte.codeblock.script` (in `packages/svelte-vscode/syntaxes/markdown-svelte-js.json`) contains a malformed regex (regex "`(?<=script.*>)(?!</)`": lookbehind assertion is not fixed length (at offset 13))
- Invalid regex in grammar: `svelte.pug.tags` (in `packages/svelte-vscode/syntaxes/pug-svelte-tags.json`) contains a malformed regex (regex "`\b(?<=[\w$\-_]*)\s*?(!=|=)\s*?([`...": group name must start with a non-digit (at offset 56))
- Invalid regex in grammar: `svelte.pug.tags` (in `packages/svelte-vscode/syntaxes/pug-svelte-tags.json`) contains a malformed regex (regex "`\b(?<=[\w$\-_]*)\s*?(!=|=)\s*?([`...": group name must start with a non-digit (at offset 58))
- Invalid regex in grammar: `svelte.pug.tags` (in `packages/svelte-vscode/syntaxes/pug-svelte-tags.json`) contains a malformed regex (regex "`\b(?<=[\w$\-_]*)\s*?(!=|=)\s*?(?`...": lookbehind assertion is not fixed length (at offset 15))
- Invalid regex in grammar: `svelte.pug` (in `packages/svelte-vscode/syntaxes/pug-svelte.json`) contains a malformed regex (regex "`(?<=^\s*?|#\[\s*?|:\s+?)([A-Z][a`...": lookbehind assertion is not fixed length (at offset 9))
- Invalid regex in grammar: `svelte.pug` (in `packages/svelte-vscode/syntaxes/pug-svelte.json`) contains a malformed regex (regex "`(?<=^\s*?|#\[\s*?|:\s+?)([A-Z][a`...": lookbehind assertion is not fixed length (at offset 9))
- Invalid regex in grammar: `svelte.pug` (in `packages/svelte-vscode/syntaxes/pug-svelte.json`) contains a malformed regex (regex "`(?<=^\s*?|#\[\s*?|:\s+?)(\+)(deb`...": group name must start with a non-digit (at offset 104))
- Invalid regex in grammar: `svelte.pug` (in `packages/svelte-vscode/syntaxes/pug-svelte.json`) contains a malformed regex (regex "`(?<=each\s*?\(\s*?')(.*)\s+?(as\`...": lookbehind assertion is not fixed length (at offset 19))
- Invalid regex in grammar: `svelte.pug` (in `packages/svelte-vscode/syntaxes/pug-svelte.json`) contains a malformed regex (regex "`(?<=each\s*?\(\s*?')(.*)\s+?(as\`...": lookbehind assertion is not fixed length (at offset 19))
- Invalid regex in grammar: `svelte.pug` (in `packages/svelte-vscode/syntaxes/pug-svelte.json`) contains a malformed regex (regex "`(?<=await\s*?\(\s*?')(.*)\s+?(th`...": lookbehind assertion is not fixed length (at offset 20))
- Invalid regex in grammar: `svelte.pug` (in `packages/svelte-vscode/syntaxes/pug-svelte.json`) contains a malformed regex (regex "`(?<=debug\s*?\(\s*?')(\w+?)(,|$)`": lookbehind assertion is not fixed length (at offset 20))
- Invalid regex in grammar: `svelte.pug` (in `packages/svelte-vscode/syntaxes/pug-svelte.json`) contains a malformed regex (regex "`(?<=^\s*?|#\[\s*?|:\s+?)(\+)(els`...": lookbehind assertion is not fixed length (at offset 9))
- Invalid regex in grammar: `markdown.svelte.codeblock.style` (in `packages/svelte-vscode/syntaxes/markdown-svelte-css.json`) contains a malformed regex (regex "`(?<=style.*>)(?!</)`": lookbehind assertion is not fixed length (at offset 12))
I admittedly know nothing about TextMate grammars and only basic regex, but I was wondering if these are things that could be changed/fixed so that we can point linguist
here to fix syntax highlighting? If not, we can close this. Thanks!
RELATED ISSUES:
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top GitHub Comments
Hopefully last update: I added a fix to the syntax for
injections
insvelte-atom
(https://github.com/sveltejs/svelte-atom/pull/21) and thanks to @umanghome’s fork ofNovaLightshow
, we have soft confirmation that it works. The maintainer ofgithub/linguist
says the next release will be the week of Nov 14 the earliest, so hopefully we get syntax highlighting back before Christmas 😂.Closing this as it’s being solved in other repos. Thanks for the help everyone!
I’m working on updating the VS Code grammar to make it usable with linguist.