termimad/
inline.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::fmt;

use crate::{
    composite::FmtComposite,
    skin::MadSkin,
};

/// A directly printable markdown snippet, complete
///  with the reference to a skin so that it can
///  implement the Display trait.
///
/// Use this when you don't have a text but just
///  part of a line
pub struct FmtInline<'k, 's> {
    pub skin: &'k MadSkin,
    pub composite: FmtComposite<'s>,
}

impl fmt::Display for FmtInline<'_, '_> {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        self.skin
            .write_fmt_composite(f, &self.composite, None, false, true)
    }
}