**Show HN: Syntax Highlighting Library in Rust that Matches VSCode**

Rust developers, take note! A new syntax highlighting library has been released, written entirely in Rust and designed to produce the same stunning output as Visual Studio Code (VSCode). This innovative library, dubbed Giallo, utilizes TextMate grammars and themes to provide a comprehensive and accurate syntax highlighting experience.

But what sets Giallo apart from other syntax highlighting libraries like Syntect? For one, it leverages the curated grammars and themes from shikijs/textmate-grammars-themes, providing a robust starting kit for users. However, users can also start from scratch if they prefer. The library's dump feature allows users to easily load and manage their own grammars and themes.

The dump feature is a critical component of Giallo, as it enables the use of Registry::builtin() or creation/loading of custom dumps. This functionality is necessary for utilizing the built-in starting kit and testing features. However, please note that the dump file itself is not tracked in git due to its frequent changes. The dump is generated by the CI release script and currently stands at a compressed 1.72MB MessagePack file.

But don't worry about performance – Giallo has been carefully optimized for speed. In fact, it uses a fork of Rust's onig library until a new version is released on crates.io (currently pending with issue #210). Once this update is available, Giallo will seamlessly switch back to the original rust-onig crate.

To get started with Giallo, check out the examples directory for a range of use cases. Highlighting code is a breeze regardless of your display platform – simply implement your own renderer or utilize one of the pre-built renderers provided by Giallo.

The default renderer outputs the text wrapped in <pre><code>..., complete with color-coding and attribute settings. It also escapes HTML content to ensure compatibility across different browsers and platforms. If you're interested in using line numbers, Giallo will set classes on elements that can be targeted via CSS for a customized look.

Bonus feature: Giallo comes equipped with automatic light/dark mode switching when highlighting text with two themes using the `light-dark` function in the style attribute. Alternatively, you can have Giallo generate a CSS file for any theme and let the HTML renderer use its classes – perfect for implementing a light/dark theme switch.

What's more, if you opt to use the dump feature, Giallo provides an impressive 220+ grammars and ~60 themes. To explore these options in action, visit the Shiki playground or open VSCode and behold the beauty of syntax highlighting.

Giallo was born out of a need to replace Syntect usage in Zola. While other projects like bat maintain their own curated sets of grammars, Giallo's aim is to provide a more comprehensive and up-to-date syntax highlighting experience. Unlike Syntect, which relies on old Sublime Text syntaxes that lack features from recent syntaxes (as seen in issue #271), Giallo is designed to keep pace with the evolving needs of developers.

Giallo has undergone significant development to address performance concerns. Initially, it started as a tree-sitter highlighter, but the grammars were too large (approaching 100MB+ for ~50 languages) and queries were slow to load (issue #1787). Giallo has since optimized its performance, resulting in a binary size of <2MB for 4x more languages. This makes it an attractive option for projects like Zola that require efficient syntax highlighting.