1use 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) quote_bar_color: Color,
32 pub(crate) heading_style: Style,
34}
35
36impl Default for Theme {
37 fn default() -> Self {
39 Self {
40 html_block_style: Style::new().fg_color(Some(AnsiColor::Green.into())),
41 inline_html_style: Style::new().fg_color(Some(AnsiColor::Green.into())),
42 code_style: Style::new().fg_color(Some(AnsiColor::Yellow.into())),
43 link_style: Style::new().fg_color(Some(AnsiColor::Blue.into())),
44 image_link_style: Style::new().fg_color(Some(AnsiColor::Magenta.into())),
45 rule_color: AnsiColor::Green.into(),
46 code_block_border_color: AnsiColor::Green.into(),
47 quote_bar_color: AnsiColor::BrightBlack.into(),
48 heading_style: Style::new().fg_color(Some(AnsiColor::Blue.into())).bold(),
49 }
50 }
51}
52
53pub trait CombineStyle {
55 fn on_top_of(self, other: &Self) -> Self;
60}
61
62impl CombineStyle for Style {
63 fn on_top_of(self, other: &Style) -> Style {
65 Style::new()
66 .fg_color(self.get_fg_color().or(other.get_fg_color()))
67 .bg_color(self.get_bg_color().or(other.get_bg_color()))
68 .effects(other.get_effects() | self.get_effects())
69 .underline_color(self.get_underline_color().or(other.get_underline_color()))
70 }
71}