Skip to main content

SyntaxHighlighter

Trait SyntaxHighlighter 

Source
pub trait SyntaxHighlighter {
    // Required method
    fn highlight_line<'a>(&self, line: &'a str, spans: &mut Vec<Span<'a>>);

    // Provided method
    fn highlight_segment<'a>(&self, text: &'a str, spans: &mut Vec<Span<'a>>) { ... }
}
Expand description

Trait for language-specific syntax highlighting.

Implement this for your language (SQL, JSON, YAML, etc.) and pass it to the render module. See PlainHighlighter for a no-op reference implementation.

Required Methods§

Source

fn highlight_line<'a>(&self, line: &'a str, spans: &mut Vec<Span<'a>>)

Highlight a full line and append styled Spans.

Provided Methods§

Source

fn highlight_segment<'a>(&self, text: &'a str, spans: &mut Vec<Span<'a>>)

Highlight a segment of a line (used when part of the line has visual selection). Defaults to highlight_line.

Implementors§