Skip to main content

CodeHighlighter

Trait CodeHighlighter 

Source
pub trait CodeHighlighter:
    Send
    + Sync
    + 'static {
    // Required method
    fn highlight(&self, request: &HighlightRequest<'_>) -> Vec<HighlightSpan>;

    // Provided method
    fn languages(&self) -> Vec<String> { ... }
}
Expand description

A code highlighting plugin. Results are cached per code block content, language and background.

Required Methods§

Source

fn highlight(&self, request: &HighlightRequest<'_>) -> Vec<HighlightSpan>

Colours for one code block. Return an empty list for unknown languages.

Provided Methods§

Source

fn languages(&self) -> Vec<String>

Language names offered in the toolbar’s language list. When empty, the editor offers COMMON_LANGUAGES.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl CodeHighlighter for SyntectHighlighter

Available on crate feature syntect only.