-
-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Path to supporting 100% of grammars in the JS engine #876
Comments
@antfu Would it be a good idea to add a requirement for new grammars added to https://github.com/shikijs/textmate-grammars-themes that they need to support the JS engine? As you can see above, this will rarely be a factor, and when it is, it might be because of a bug in the grammar or Oniguruma itself that the author didn't account for. |
That's astonishing work you have done. Thanks a lot for all the effort!
Oh yeah, that would be great! We could introduce verification scripts to that repo, so we could catch them up in the CI. We could whitelist the known incompatible ones, so it always covers the new grammar. |
Here is where the the invalid regex is located: This needs to be patched in the upstream grammar. Since it is erroring in both the JS and WASM engines (but silently in the WASM engine), using the |
Shiki's JS engine uses Oniguruma-To-ES under the hood to emulate Oniguruma regexes. As of the latest version, the vast majority of grammars (which contain dozens to thousands of regexes each) are supported.
Following is what's needed to support the remaining grammars.
Mismatched
These are grammars that produce different results in Shiki's JS and WASM engines for the provided grammar samples.
Includes a regex that triggers an Oniguruma bug, so in fact the JS engine (not the WASM engine) is producing the correct highlighting. The Oniguruma bug needs to be worked around in the Kusto grammar.Upstream issue here.Unsupported
These are grammars that throw an error for at least one regex in Shiki's JS engine, which by default does not silence errors like the WASM engine. A few of these grammars are also showing mismatches, but those are likely to be resolved by resolving the errors (since errors can lead to different results either directly or for subsequent regex matches).
Includes an invalid Oniguruma regex.Upstream PR here.(?(…)…|…)
(the only grammar that does so) in three regexes.(?~…)
(the only grammar that does so) in two regexes.type-name
astype_name$1
or just removing the name), but handling this comprehensively adds some complications. It's probably better to just file an issue upstream to rename the problematic groups in the Razor grammar.Resolving all of the above would result in 100% JS engine support for Shiki's grammar samples. Quite a remarkable feat if you're familiar with the challenges and complexity of getting to this point.
Any help with getting these grammars supported in the JS engine (e.g. liking or commenting on the existing issues I linked here, filing the needed issues described above, investigating the source of NGINX mismatches, submitting PRs for grammars that need refactoring, or contributions to Oniguruma-To-ES) would be very welcome.
The text was updated successfully, but these errors were encountered: