pulldown_cmark_mdcat/
theme.rs1use anstyle::{AnsiColor, Color, Style};
10
11#[derive(Debug, Clone)]
15pub struct Theme {
16 pub(crate) html_block_style: Style,
18 pub(crate) inline_html_style: Style,
20 pub(crate) code_style: Style,
22 pub(crate) link_style: Style,
24 pub(crate) image_link_style: Style,
26 pub(crate) rule_color: Color,
28 pub(crate) code_block_border_color: Color,
30 pub(crate) heading_style: Style,
32 pub(crate) footnote_style: Style,
34 pub(crate) math_style: Style,
36}
37
38impl Default for Theme {
39 fn default() -> Self {
41 Self {
42 html_block_style: Style::new().fg_color(Some(AnsiColor::Green.into())),
43 inline_html_style: Style::new().fg_color(Some(AnsiColor::Green.into())),
44 code_style: Style::new().fg_color(Some(AnsiColor::Yellow.into())),
45 link_style: Style::new().fg_color(Some(AnsiColor::Blue.into())),
46 image_link_style: Style::new().fg_color(Some(AnsiColor::Magenta.into())),
47 rule_color: AnsiColor::Green.into(),
48 code_block_border_color: AnsiColor::Green.into(),
49 heading_style: Style::new().fg_color(Some(AnsiColor::Blue.into())).bold(),
50 footnote_style: Style::new().fg_color(Some(AnsiColor::Cyan.into())),
51 math_style: Style::new().fg_color(Some(AnsiColor::Yellow.into())),
52 }
53 }
54}
55
56pub trait CombineStyle {
58 fn on_top_of(self, other: &Self) -> Self;
63}
64
65impl CombineStyle for Style {
66 fn on_top_of(self, other: &Style) -> Style {
68 Style::new()
69 .fg_color(self.get_fg_color().or(other.get_fg_color()))
70 .bg_color(self.get_bg_color().or(other.get_bg_color()))
71 .effects(other.get_effects() | self.get_effects())
72 .underline_color(self.get_underline_color().or(other.get_underline_color()))
73 }
74}