Shiki Syntax Highlighter
shiki.matsu.io
shiki.matsu.io
Tree-sitter's drawbacks compared to TextMate and other regex-based solutions are slower speeds and chance of edits breaking parse trees, which are not issues here. Its advantages are that the grammar definition can be more expressive and is much more readable.
Not saying you should abandon using TextMate, "if it ain't broke..." and I doubt all of the grammars you support right now have as pretty tree-sitter equivalents. But maybe add support for tree-sitter as well, especially because it seems to be growing in popularity, with growing support in emacs and neovim.
TextMate 1.x was the king of Mac text editors back in its day. Is anyone actually still using TextMate today?
I don’t use TextMate anymore but I surely would have stuck with it longer if it had a debugger and language server. I panned all of the non-native editors that came between, but sadly had to admit that VSCode fit my workflow a lot better.
It's ok for things like editor but using it in a SSG for example is hard when just loading the syntaxes will take multiple times the time it takes to render the whole thing with a regex based highlighter.
Several TextMate grammars suffer from inaccuracy bugs, and issues of maintainability. Perhaps the biggest hindrance in the adoption of tree-sitter, is that the most popular editor, VSCode, still doesn't support it.
[1]: https://github.com/microsoft/vscode/pull/161479
I'd only use it if it's absolutely necessary that your syntax highlighting exactly matches VS Code. (It's also a shame that VS Code requires Oniguruma)
https://cdn.jsdelivr.net/npm/shiki@0.14.1/dist/
https://cdn.jsdelivr.net/npm/esbuild-wasm/
That's no knock on esbuild. esbuild benefits from having been built with golang and wasn't designed to be run in the browser. (tinygo can run go in much smaller but you give up some of golang's power)
WASM is fast becoming a standard thing.
Are there any alternatives that supports VS Code syntax but faster?
This more important than you state. I have many JS syntax highlighters and most of them are garbage. Like, they don't even recognize some obvious keywords like `const`, `async` and `await` for Javascript. I'd rather chose something with better inbuilt grammar. I am not sure what the slowdown is like, but I don't imagine it'd be much. And with SSR, you can even offload it to a server and cache the generated HTML.
https://vim.fandom.com/wiki/Pasting_code_with_syntax_colorin...
ALSO awesome is Shiki Twoslash[1], for displaying TypeScript editor feedback in code examples.
I’ve written one myself, it’s pretty simple to walk a tree-sitter parse tree and generate spans with classes based on the type of each node. Then syntax highlighting is “just” a matter of writing a bit of CSS.