pub struct Highlighter { /* private fields */ }Expand description
Parses and highlights one language.
Implementations§
Source§impl Highlighter
impl Highlighter
Sourcepub fn new(language: Language) -> Option<Self>
pub fn new(language: Language) -> Option<Self>
Build a highlighter, or None if the grammar and its queries disagree — a
mismatch between the grammar crate and its query file is a packaging problem, and
an editor that refuses to open a file over it would be worse than one that shows
it unhighlighted.
Sourcepub fn highlight(&mut self, text: &str) -> Vec<Span> ⓘ
pub fn highlight(&mut self, text: &str) -> Vec<Span> ⓘ
Highlight text.
Returns spans in char offsets, non-overlapping and in document order. On any parse failure the answer is “no highlighting” rather than an error: unhighlighted code is perfectly editable, and half-coloured code from a partial parse is not better.
Auto Trait Implementations§
impl Freeze for Highlighter
impl RefUnwindSafe for Highlighter
impl Send for Highlighter
impl Sync for Highlighter
impl Unpin for Highlighter
impl UnsafeUnpin for Highlighter
impl UnwindSafe for Highlighter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more