miette/highlighters/
blank.rs

1use owo_colors::Style;
2
3use crate::SpanContents;
4
5use super::{Highlighter, HighlighterState};
6
7/// The default syntax highlighter. It applies `Style::default()` to input text.
8/// This is used by default when no syntax highlighting features are enabled.
9#[derive(Debug, Clone)]
10pub struct BlankHighlighter;
11
12impl Highlighter for BlankHighlighter {
13    fn start_highlighter_state<'h>(
14        &'h self,
15        _source: &dyn SpanContents<'_>,
16    ) -> Box<dyn super::HighlighterState + 'h> {
17        Box::new(BlankHighlighterState)
18    }
19}
20
21impl Default for BlankHighlighter {
22    fn default() -> Self {
23        BlankHighlighter
24    }
25}
26
27/// The default highlighter state. It applies `Style::default()` to input text.
28/// This is used by default when no syntax highlighting features are enabled.
29#[derive(Debug, Clone)]
30pub struct BlankHighlighterState;
31
32impl HighlighterState for BlankHighlighterState {
33    fn highlight_line<'s>(&mut self, line: &'s str) -> Vec<owo_colors::Styled<&'s str>> {
34        vec![Style::default().style(line)]
35    }
36}