Expand description
A syntax highlighting library using TextMate grammars and themes and producing the same output as VSCode.
§Example
ⓘ
use giallo::{HighlightOptions, HtmlRenderer, Options, Registry, ThemeVariant};
// Using the `dump` feature and loading the prebuilt assets
let registry = Registry::load_from_file("builtin.zst")?;
let code = "let x = 42;";
let options = HighlightOptions::new("javascript", ThemeVariant::Single("catppuccin-frappe"));
let highlighted = registry.highlight(code, options)?;
let render_options = Options {
show_line_numbers: true,
..Default::default()
};
let html = HtmlRenderer::default().render(&highlighted, &render_options);Structs§
- Color
- RGBA color with 8-bit components
- Compiled
Theme - Compiled theme optimized for fast lookups
- Extra
Html Content - Extra HTML content to include in the
<pre>block. - Font
Style - A compressed representation of all available textmate font styles
- Highlight
Options - Options for highlighting by the registry, NOT rendering.
- Highlighted
Code - Highlighted code with language, theme, and tokens
- Highlighted
Text - A token with associated styling information
- Html
Renderer - A renderer that will output proper HTML code
- Parsed
Fence - A parsed code block parameters
- Registry
- The main struct in giallo.
- Render
Options - All options you can select across renderers
- Style
- A complete, concrete, style with foreground, background colors and font styling
- Terminal
Renderer - Terminal renderer via ANSI escape codes. Requires a terminal that supports truecolor
Enums§
- Data
Attr Position - Where to put the additional attributes
- Error
- Errors that can occur during giallo usage
- Theme
Variant - Generic enum for single or dual (light/dark) theme values
Constants§
- GIALLO_
CSS - The CSS needed for the line number gutter to display properly
- PLAIN_
GRAMMAR_ NAME - The default grammar name, where nothing is highlighted
Functions§
- parse_
markdown_ fence - Parses a markdown fence in the same shape as Zola’s.