question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update regex of VSCode grammars to be used with `github/linguist`

See original GitHub issue

As 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:closed
  • Created a year ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kindoflewcommented, Nov 1, 2022

Hopefully last update: I added a fix to the syntax for injections in svelte-atom (https://github.com/sveltejs/svelte-atom/pull/21) and thanks to @umanghome’s fork of NovaLightshow, we have soft confirmation that it works. The maintainer of github/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!

1reaction
umanghomecommented, Oct 27, 2022

I’m working on updating the VS Code grammar to make it usable with linguist.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Outstanding Grammar Issues #3924 - github/linguist
Invalid regex in grammar: source.abapcds (in syntaxes/cds. ... repository vendor/grammars/godot-vscode-plugin (from ...
Read more >
Add support for Svelte · Issue #5830 · github/linguist
Linguist already has support for Svelte: ... Update regex of VSCode grammars to be used with github/linguist sveltejs/language-tools#1571.
Read more >
Change grammar source for Svelte #5963 - github/linguist
Changes the source for Svelte from a seemingly abandoned fork to the original, active, repository. This change is prompted by a bug in...
Read more >
linguist/README.md at master - GitHub
This is a list of grammars that Linguist selects to provide syntax highlighting on GitHub. If you've encountered an error with highlighting, please...
Read more >
Help with figuring out what's wrong with Svelte grammar #6164
If the https://github.com/sveltejs/svelte-atom grammar has been updated to address the limitations, I'll use that instead.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found