use anstyle::{AnsiColor, Color, Style};
#[derive(Debug, Clone)]
pub struct Theme {
pub(crate) html_block_style: Style,
pub(crate) inline_html_style: Style,
pub(crate) code_style: Style,
pub(crate) link_style: Style,
pub(crate) image_link_style: Style,
pub(crate) rule_color: Color,
pub(crate) code_block_border_color: Color,
pub(crate) quote_bar_color: Color,
pub(crate) heading_style: Style,
}
impl Default for Theme {
fn default() -> Self {
Self {
html_block_style: Style::new().fg_color(Some(AnsiColor::Green.into())),
inline_html_style: Style::new().fg_color(Some(AnsiColor::Green.into())),
code_style: Style::new().fg_color(Some(AnsiColor::Yellow.into())),
link_style: Style::new().fg_color(Some(AnsiColor::Blue.into())),
image_link_style: Style::new().fg_color(Some(AnsiColor::Magenta.into())),
rule_color: AnsiColor::Green.into(),
code_block_border_color: AnsiColor::Green.into(),
quote_bar_color: AnsiColor::BrightBlack.into(),
heading_style: Style::new().fg_color(Some(AnsiColor::Blue.into())).bold(),
}
}
}
pub trait CombineStyle {
fn on_top_of(self, other: &Self) -> Self;
}
impl CombineStyle for Style {
fn on_top_of(self, other: &Style) -> Style {
Style::new()
.fg_color(self.get_fg_color().or(other.get_fg_color()))
.bg_color(self.get_bg_color().or(other.get_bg_color()))
.effects(other.get_effects() | self.get_effects())
.underline_color(self.get_underline_color().or(other.get_underline_color()))
}
}