pub trait Highlighter {
// Required methods
fn supports(&self, lang: &str) -> bool;
fn highlight_line(
&self,
lang: &str,
line: &str,
state: State,
out: &mut Vec<Span>,
) -> State;
// Provided method
fn highlight(&self, lang: &str, text: &str, out: &mut Vec<Span>) { ... }
}Expand description
A syntax highlighting engine. Builtin is the lexers of this crate; a bigger engine (a
grammar-based one, say) can implement this and be used by the same views.
Required Methods§
Sourcefn supports(&self, lang: &str) -> bool
fn supports(&self, lang: &str) -> bool
Whether this engine highlights lang (a name, alias or extension).
Sourcefn highlight_line(
&self,
lang: &str,
line: &str,
state: State,
out: &mut Vec<Span>,
) -> State
fn highlight_line( &self, lang: &str, line: &str, state: State, out: &mut Vec<Span>, ) -> State
Highlights one line starting in state, appending line-relative spans to out, and
returns the state the next line starts in. Spans must follow the rules of Span; an
engine without line states may return state unchanged.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".