Live data from Hacker News

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

arborium.bearcove.eu

21–30 of 48 posts

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

#21
post #8

I'm currently building an online 3D-Editor that supports OpenSCAD and Python as the input language. The ease of use to highlight static text via Arborium seems nice: def hello(name): print("Hello " + name); But does it support editing highlighted text? If not, one would have to do some trickery by hiding a textarea and updating the element on each keypress, I guess. Which probably has a thousand corner cases one woul…

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

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

#22
post #8

I'm currently building an online 3D-Editor that supports OpenSCAD and Python as the input language. The ease of use to highlight static text via Arborium seems nice: def hello(name): print("Hello " + name); But does it support editing highlighted text? If not, one would have to do some trickery by hiding a textarea and updating the element on each keypress, I guess. Which probably has a thousand corner cases one woul…

I’m now just curious about your project

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

#23
post #12

Earlier quoted context omitted.

What a genius this dev is. Just a few weeks ago I tried to do something very similar for my blog, but quickly gave up as it’s not easy to do! Kudos to the author, they did an awesome job and went beyond by actually fixing up even the grammars and highlighting queries so it all works perfectly!

I agree! Not only do they write engaging blog posts, they also produce engaging videos! https://youtube.com/@fasterthanlime

I suppose this isn't the case here, but found it funny how these 3 successive positive comments read almost exactly like those bot comment chains that I see on other platforms trying to pull people into crypto scams.

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

#24

Earlier quoted context omitted.

I agree! Not only do they write engaging blog posts, they also produce engaging videos! https://youtube.com/@fasterthanlime

I suppose this isn't the case here, but found it funny how these 3 successive positive comments read almost exactly like those bot comment chains that I see on other platforms trying to pull people into crypto scams.

Some people just genuinely deserve praise.

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

#25
post #4

Sorry, but I can't understand what this actually is. A library, a stand-alone tool, a Rust crate? What users does it target? Text editors, website creators?

GitHub repo is a bit more helpful, but users or building of text editors that use tree-sitter. Or... website text editors which historically have had imperfect syntax highlighting. Notice the Zed sponsorship. https://github.com/bearcove/arborium

> Batteries-included tree-sitter grammar collection with HTML rendering and WASM support.

That's the best one sentence description there is and it's at the top of the Github README. I think that would fit nice at the top of https://arborium.bearcove.eu too

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

#27
post #22
post #8

I'm currently building an online 3D-Editor that supports OpenSCAD and Python as the input language. The ease of use to highlight static text via Arborium seems nice: def hello(name): print("Hello " + name); But does it support editing highlighted text? If not, one would have to do some trickery by hiding a textarea and updating the element on each keypress, I guess. Which probably has a thousand corner cases one woul…

I’m now just curious about your project

Give me a few more weeks and I will probably have something online. You can find me on social media or feel free to connect via email.

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

#29
post #21
post #8

I'm currently building an online 3D-Editor that supports OpenSCAD and Python as the input language. The ease of use to highlight static text via Arborium seems nice: def hello(name): print("Hello " + name); But does it support editing highlighted text? If not, one would have to do some trickery by hiding a textarea and updating the element on each keypress, I guess. Which probably has a thousand corner cases one woul…

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.

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

#30
If you haven't tried building a grammar with tree-sitter, I highly recommend you do so. It's incredibly fun once you get into a flow state. The docs call it a zen-like experience, and that's a perfect way to describe it. It's so, so good.
Post reply on HN