Skip to main content

Crate zalo

Crate zalo 

Source
Expand description

A syntax highlighting library using TextMate grammars and themes and producing the same output as VSCode.

§Example

ⓘ
use zalo::{HighlightOptions, HtmlRenderer, Options, Registry, ThemeVariant};

// Using the `dump` feature and loading the prebuilt assets
let registry = Registry::load_from_file("builtin.msgpack")?;
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
CompiledTheme
Compiled theme optimized for fast lookups
FontStyle
A compressed representation of all available textmate font styles
HighlightOptions
Options for highlighting by the registry, NOT rendering.
HighlightedCode
Highlighted code with language, theme, and tokens
HighlightedText
A token with associated styling information
HtmlRenderer
A renderer that will output proper HTML code
ParsedFence
A parsed code block parameters
Registry
The main struct in zalo.
RenderOptions
All options you can select across renderers
Style
A complete, concrete, style with foreground, background colors and font styling
SummarizedTheme
Summarized theme information for listings
TerminalRenderer
Terminal renderer via ANSI escape codes. Requires a terminal that supports truecolor

Enums§

DataAttrPosition
Where to put the additional attributes
Error
Errors that can occur during zalo usage
ThemeVariant
Generic enum for single or dual (light/dark) theme values

Constants§

PLAIN_GRAMMAR_NAME
The default grammar name, where nothing is highlighted
ZALO_CSS
The CSS needed for the line number gutter to display properly

Functions§

parse_markdown_fence
Parses a markdown fence in the same shape as Zola’s.