use std::fmt::Display;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct RenderConfig<'a> {
pub display_mode: DisplayMode,
pub annotation: Option<&'a str>,
pub error_color: (u8, u8, u8),
pub xml: bool,
pub math_style: MathStyle,
}
impl<'a> RenderConfig<'a> {
pub fn with_annotation(annotation: &'a str) -> Self {
Self {
annotation: Some(annotation),
..Self::default()
}
}
}
impl<'a> Default for RenderConfig<'a> {
fn default() -> Self {
Self {
display_mode: DisplayMode::Inline,
annotation: None,
error_color: (178, 34, 34),
xml: false,
math_style: MathStyle::TeX,
}
}
}
#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub enum MathStyle {
#[default]
TeX,
ISO,
French,
Upright,
}
impl MathStyle {
pub(crate) fn should_be_upright(self, c: char) -> bool {
match self {
MathStyle::TeX => c.is_uppercase() && !c.is_ascii_uppercase(),
MathStyle::ISO => false,
MathStyle::French => !c.is_ascii_lowercase(),
MathStyle::Upright => true,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum DisplayMode {
#[default]
Inline,
Block,
}
impl Display for DisplayMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
DisplayMode::Inline => f.write_str("inline"),
DisplayMode::Block => f.write_str("block"),
}
}
}