16 comments

  • joshka13 hours ago
    <a href="https:&#x2F;&#x2F;fasterthanli.me&#x2F;articles&#x2F;my-gift-to-the-rust-docs-team" rel="nofollow">https:&#x2F;&#x2F;fasterthanli.me&#x2F;articles&#x2F;my-gift-to-the-rust-docs-te...</a> is a better link (the author&#x27;s article about this rather than the artifact produced)
    • brabel12 hours ago
      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!
      • solarkraft9 hours ago
        I agree! Not only do they write engaging blog posts, they also produce engaging videos!<p><a href="https:&#x2F;&#x2F;youtube.com&#x2F;@fasterthanlime" rel="nofollow">https:&#x2F;&#x2F;youtube.com&#x2F;@fasterthanlime</a>
        • falcor846 hours ago
          I suppose this isn&#x27;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.
          • tombh6 hours ago
            Some people just genuinely deserve praise.
          • brabel2 hours ago
            Haha, I confess I did sound like a bot... but sorry to disappoint, I am human!
            • psychoslave46 minutes ago
              That&#x27;s what a bot would typically say.<p>On this side, I&#x27;m not a bot, and fortunately even in 2025 nobody on the internet knows that you are a dog.
  • catapart2 hours ago
    Daaang! On the one hand, as someone developing a code-example custom element[0] that includes highlighting, this is kind of a &quot;so close, but not quite&quot; situation where I really wish this was something I could use for that, but it&#x27;s probably too heavy to ship around for something so &quot;simple&quot; (as far as users&#x27; default expectation; not implying that highlighting text is simple).<p>But then, on the other hand, I had given up on a scratch code editor for a game development project I&#x27;m working on, and just loosely wrapped up the monaco editor which I&#x27;m guessing is going to be pretty bare when I actually get around to trying to code with it, in browser (I&#x27;m aware that it is robust, but from what I gather, a lot of its features come from third-party dev as a way to keep the core functionality pure). Given that I want to be able to script in C# (aside from just js&#x2F;ts), I was sure I was going to have to figure something complicated out.<p>But, honestly, I think this solves all of my most concerning issues! What a sweet little library!<p>[0] <a href="https:&#x2F;&#x2F;magnitce-code-example-e81613.gitlab.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;magnitce-code-example-e81613.gitlab.io&#x2F;</a> (please excuse the unfinished-ness; I&#x27;m working on a JSDoc-to-documentation library that automates the documentation for me so there are minor issues, like the install text not changing on selection)
  • ComputerGuru1 hour ago
    Completely appalled to learn that docs.rs lets you inject any html&#x2F;css&#x2F;js you want into the live site (on pages documenting your crate). I love the flexibility but shudder at the security hole the size of, oh, I don’t know, the Grand Canyon.<p>It’s not a new discovery, I just didn’t know docs.rs (intentionally) wasn’t blocking this. Cf <a href="https:&#x2F;&#x2F;docs.rs&#x2F;pwnies&#x2F;0.0.13&#x2F;pwnies&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;pwnies&#x2F;0.0.13&#x2F;pwnies&#x2F;</a><p>(This all makes more sense if you read the blog post instead of the direct arborium link: <a href="https:&#x2F;&#x2F;fasterthanli.me&#x2F;articles&#x2F;my-gift-to-the-rust-docs-team" rel="nofollow">https:&#x2F;&#x2F;fasterthanli.me&#x2F;articles&#x2F;my-gift-to-the-rust-docs-te...</a>)
  • mg13 hours ago
    I&#x27;m currently building an online 3D-Editor that supports OpenSCAD and Python as the input language.<p>The ease of use to highlight static text via Arborium seems nice:<p><pre><code> &lt;script src=&quot;arborium.iife.js&quot;&gt;&lt;&#x2F;script&gt; &lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt; def hello(name): print(&quot;Hello &quot; + name); &lt;&#x2F;code&gt;&lt;&#x2F;pre&gt; </code></pre> But does it support editing highlighted text? If not, one would have to do some trickery by hiding a textarea and updating the &lt;code&gt; element on each keypress, I guess. Which probably has a thousand corner cases one would have to deal with.<p>And how would one add SCAD support?
    • debazel8 hours ago
      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.<p>The code isn&#x27;t minified so you can see how they do it by looking at the `doHighlight()` function here <a href="https:&#x2F;&#x2F;arborium.bearcove.eu&#x2F;pkg&#x2F;app.generated.js" rel="nofollow">https:&#x2F;&#x2F;arborium.bearcove.eu&#x2F;pkg&#x2F;app.generated.js</a>
      • mg5 hours ago
        Oh, you are right!<p>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 &quot;next&quot; button.<p>I wonder if that is fixable.
        • debazel2 hours ago
          There is a neat `inert` html attribute you can use to disable all interactions as well as hide the text from ctrl+f searches. (Sadly Safari is the weird one out, and does not exclude the content from searches.)<p><a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;HTML&#x2F;Reference&#x2F;Global_attributes&#x2F;inert" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;HTML&#x2F;Reference&#x2F;...</a>
        • knallfrosch2 hours ago
          One simply needs the Highlight API. I held back, but now even Firefox ESR supports it.<p><a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;Highlight" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;Highlight</a><p>All the trickery vanishes and you get first-class CSS support.
    • metmac7 hours ago
      I’m now just curious about your project
      • mg5 hours ago
        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.
  • aarol9 hours ago
    I&#x27;ve been toying around with tree-sitter and have seen the potential for a proper, non-regex based highlighter. It&#x27;s really powerful because it actually parses the text into an AST. With the AST it&#x27;s possible for example to make variables the same colour everywhere. A function passed as a parameter could be highlighted as a function even in the parameter list.<p>I&#x27;m happy to see that tree sitter highlighting on the web is finally a thing. This seems really solid although the bundle size is a lot.
  • pornel2 hours ago
    There&#x27;s also a pure-Rust implementation of a syntax highlighter, which uses TextMate&#x2F;SublimeText grammars: <a href="https:&#x2F;&#x2F;lib.rs&#x2F;syntect" rel="nofollow">https:&#x2F;&#x2F;lib.rs&#x2F;syntect</a>
    • zeon2568 minutes ago
      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
  • danielvaughn4 hours ago
    If you haven&#x27;t tried building a grammar with tree-sitter, I highly recommend you do so. It&#x27;s incredibly fun once you get into a flow state. The docs call it a zen-like experience, and that&#x27;s a perfect way to describe it. It&#x27;s so, so good.
  • jasonjmcghee13 hours ago
    The sponsorships achieved by the author is admirable - they really make a lot of valuable oss.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;sponsors&#x2F;fasterthanlime" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sponsors&#x2F;fasterthanlime</a>
  • divyeshio5 hours ago
    This is cool! How does it compares with Shiki or Highlighter.js in terms of performance?
  • pseudo_meta10 hours ago
    Treesitter is fantastic. It has builtin support in nvim, and there are a lot of plugins that make use of it.<p>My favorite is nvim-treesitter-textobjects which gives you dozens of new targets for vim motions, such as a function call or the condition of a loop.
  • Tepix11 hours ago
    <i>Tree-sitter</i>:<p>Tree-sitter is a parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited.
  • f311a5 hours ago
    I had to wait for about 10 seconds for it to load on my crappy mobile connection.<p>They also load 1 mb of fonts. In total, this page is close to 3 mb.<p>Also, when you select a language, the grammar file gets downloaded twice.
  • mintflow10 hours ago
    Great project, I really love tree-sitter, recently I added a ini variant config profile support to my app, and just use gemini to write a grammar and combine it with another great project called runestone to support highlight the config profile, the total progress is quite smooth.
  • teo_zero13 hours ago
    Sorry, but I can&#x27;t understand what this actually is. A library, a stand-alone tool, a Rust crate? What users does it target? Text editors, website creators?
    • GolDDranks11 hours ago
      It&#x27;s a Rust library (comprised of a bunch of crates) that wraps a high-performance, high-accuracy syntax highlighter (called Tree-sitter) with vetted support for almost 100 programming&#x2F;markup languages.<p>You can use it as a normal Rust library, or you can use the JavaScript&#x2F;WASM wrapper to highlight source code on a web page.
      • oersted10 hours ago
        &gt; high-accuracy syntax highlighter (called Tree-sitter)<p>Just wanted to note that tree-sitter is lower-level and more general: it&#x27;s an incremental parser that is specialised for gracefully and efficiently parsing partially-correct code snippets or code being edited live.<p>It&#x27;s an important building block of the highlighter, but it needs more on top to complete the package. It can be used for anything that requires awareness of code structure in an editor.
        • debugnik3 hours ago
          If only it were usable for really-correct parsing. In my experience error recovery is so aggressive it will accept broken ASTs without marking any node as an error. Plus, you can&#x27;t really solve some ambiguities without C-based lexer hacks.<p>I wonder if targeting the Tree-sitter ABI directly could be a viable way to write more accurate parsers in an actual programming language while piggybacking on the ecosystem. Could tree-sitter&#x27;s runtime ABI be adapted for GLL parsers instead of GLR? I haven&#x27;t looked deep into it yet.
          • conartist62 hours ago
            Now you&#x27;re in my wheelhouse! Come check out <a href="https:&#x2F;&#x2F;github.com&#x2F;bablr-lang&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bablr-lang&#x2F;</a>. I&#x27;m gearing up for a big release announcement here once I fix these bugs and ship all the latest code.
        • GolDDranks10 hours ago
          Thanks for the correction!
      • gorjusborg3 hours ago
        Is the &#x27;regex hater club&#x27; subtitle related to using regex to &#x27;parse&#x27; rather than using something like tree-sitter that actually parses?<p>I also had a hard time understanding the context given just the link.
    • joshka13 hours ago
      See <a href="https:&#x2F;&#x2F;fasterthanli.me&#x2F;articles&#x2F;my-gift-to-the-rust-docs-team" rel="nofollow">https:&#x2F;&#x2F;fasterthanli.me&#x2F;articles&#x2F;my-gift-to-the-rust-docs-te...</a>
    • jasonjmcghee13 hours ago
      GitHub repo is a bit more helpful, but users or building of text editors that use tree-sitter.<p>Or... website text editors which historically have had imperfect syntax highlighting.<p>Notice the Zed sponsorship.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;bearcove&#x2F;arborium" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bearcove&#x2F;arborium</a>
      • tombh6 hours ago
        &gt; Batteries-included tree-sitter grammar collection with HTML rendering and WASM support.<p>That&#x27;s the best one sentence description there is and it&#x27;s at the top of the Github README. I think that would fit nice at the top of <a href="https:&#x2F;&#x2F;arborium.bearcove.eu" rel="nofollow">https:&#x2F;&#x2F;arborium.bearcove.eu</a> too
    • discord913 hours ago
      I think this gives some context?:<a href="https:&#x2F;&#x2F;fasterthanli.me&#x2F;articles&#x2F;my-gift-to-the-rust-docs-team" rel="nofollow">https:&#x2F;&#x2F;fasterthanli.me&#x2F;articles&#x2F;my-gift-to-the-rust-docs-te...</a> TLDR: for rust doc highlighting stuff in document
    • Rodmine13 hours ago
      Not for you then. You don&#x27;t need to understand everything.
  • unrealhoang14 hours ago
    The get started section seems to be broken or missing content.
  • virajk_3115 hours ago
    This is cool, was looking for something similar