1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
use std::borrow::Cow;

mod from;

use std::fmt::{self, Display, Formatter};

#[derive(Debug, Clone)]
pub struct Highlighter<'a> {
    pub lang: &'static str,
    pub code: Cow<'a, str>,
    pub inline: bool,
    pub high_line: Vec<usize>,
}

impl<'a> Display for Highlighter<'a> {
    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
        write!(f, "{mark}{lang}\n{body}\n{mark}", mark = "`".repeat(3), lang = self.lang, body = self.code)
    }
}