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}
33
34impl Default for Theme {
35 fn default() -> Self {
37 Self {
38 html_block_style: Style::new().fg_color(Some(AnsiColor::Green.into())),
39 inline_html_style: Style::new().fg_color(Some(AnsiColor::Green.into())),
40 code_style: Style::new().fg_color(Some(AnsiColor::Yellow.into())),
41 link_style: Style::new().fg_color(Some(AnsiColor::Blue.into())),
42 image_link_style: Style::new().fg_color(Some(AnsiColor::Magenta.into())),
43 rule_color: AnsiColor::Green.into(),
44 code_block_border_color: AnsiColor::Green.into(),
45 heading_style: Style::new().fg_color(Some(AnsiColor::Blue.into())).bold(),
46 }
47 }
48}
49
50pub trait CombineStyle {
52 fn on_top_of(self, other: &Self) -> Self;
57}
58
59impl CombineStyle for Style {
60 fn on_top_of(self, other: &Style) -> Style {
62 Style::new()
63 .fg_color(self.get_fg_color().or(other.get_fg_color()))
64 .bg_color(self.get_bg_color().or(other.get_bg_color()))
65 .effects(other.get_effects() | self.get_effects())
66 .underline_color(self.get_underline_color().or(other.get_underline_color()))
67 }
68}