Live data from Hacker News

Arborium: Tree-sitter code highlighting with Native and WASM targets

arborium.bearcove.eu

41–48 of 48 posts

Re: Arborium: Tree-sitter code highlighting with Native and WASM targets

#41
post #38

There's also a pure-Rust implementation of a syntax highlighter, which uses TextMate/SublimeText grammars: https://lib.rs/syntect

Tree-sitter produces more accurate highlighting tho. We used syntect for our web editing cos it’s faster (and lighter in terms of size) and tree-sitter for rendered pages in our company and the difference is stark

Re: Arborium: Tree-sitter code highlighting with Native and WASM targets

#42
post #29
post #21

Earlier quoted context omitted.

The example on their website is editable and it looks like they overlay the highlighted output on top of the textarea with `pointer-events: none` like you mentioned. The code isn't minified so you can see how they do it by looking at the `doHighlight()` function here https://arborium.bearcove.eu/pkg/app.generated.js

Oh, you are right! Hmm .. and the approach already shows its weaknesses when I play with it: When I search for something on the page, it gives me twice as many hits as there are. And jumps around two times to each hit when I use the "next" button. I wonder if that is fixable.

GitHub had to solve the same problem when speeding up there code viewer.

https://github.blog/engineering/architecture-optimization/cr...

Re: Arborium: Tree-sitter code highlighting with Native and WASM targets

#43
post #29

Earlier quoted context omitted.

Oh, you are right! Hmm .. and the approach already shows its weaknesses when I play with it: When I search for something on the page, it gives me twice as many hits as there are. And jumps around two times to each hit when I use the "next" button. I wonder if that is fixable.

One simply needs the Highlight API. I held back, but now even Firefox ESR supports it. https://developer.mozilla.org/en-US/docs/Web/API/Highlight All the trickery vanishes and you get first-class CSS support.

And there's an open issue for that already: https://github.com/bearcove/arborium/issues/62

Re: Arborium: Tree-sitter code highlighting with Native and WASM targets

#46
post #29

Earlier quoted context omitted.

Oh, you are right! Hmm .. and the approach already shows its weaknesses when I play with it: When I search for something on the page, it gives me twice as many hits as there are. And jumps around two times to each hit when I use the "next" button. I wonder if that is fixable.

One simply needs the Highlight API. I held back, but now even Firefox ESR supports it. https://developer.mozilla.org/en-US/docs/Web/API/Highlight All the trickery vanishes and you get first-class CSS support.

That works on the text inside a textarea? Is there a demo showcasing this somewhere?

Re: Arborium: Tree-sitter code highlighting with Native and WASM targets

#47
post #37

Earlier quoted context omitted.

Haha, I confess I did sound like a bot... but sorry to disappoint, I am human!

That's what a bot would typically say. On this side, I'm not a bot, and fortunately even in 2025 nobody on the internet knows that you are a dog.

I think I sound a bit like a bot because half of what I read on the Internet is actually written by bots and that is influencing me!

Re: Arborium: Tree-sitter code highlighting with Native and WASM targets

#48
post #47

Earlier quoted context omitted.

That's what a bot would typically say. On this side, I'm not a bot, and fortunately even in 2025 nobody on the internet knows that you are a dog.

I think I sound a bit like a bot because half of what I read on the Internet is actually written by bots and that is influencing me!

woof, woof!
Post reply on HN