use crate::foundations::{func, Cast, Content, Smart};
use crate::math::EquationElem;
#[func(keywords = ["mathbf"])]
pub fn bold(
body: Content,
) -> Content {
body.styled(EquationElem::set_bold(true))
}
#[func(keywords = ["mathup"])]
pub fn upright(
body: Content,
) -> Content {
body.styled(EquationElem::set_italic(Smart::Custom(false)))
}
#[func(keywords = ["mathit"])]
pub fn italic(
body: Content,
) -> Content {
body.styled(EquationElem::set_italic(Smart::Custom(true)))
}
#[func(keywords = ["mathrm"])]
pub fn serif(
body: Content,
) -> Content {
body.styled(EquationElem::set_variant(MathVariant::Serif))
}
#[func(title = "Sans Serif", keywords = ["mathsf"])]
pub fn sans(
body: Content,
) -> Content {
body.styled(EquationElem::set_variant(MathVariant::Sans))
}
#[func(title = "Calligraphic", keywords = ["mathcal", "mathscr"])]
pub fn cal(
body: Content,
) -> Content {
body.styled(EquationElem::set_variant(MathVariant::Cal))
}
#[func(title = "Fraktur", keywords = ["mathfrak"])]
pub fn frak(
body: Content,
) -> Content {
body.styled(EquationElem::set_variant(MathVariant::Frak))
}
#[func(title = "Monospace", keywords = ["mathtt"])]
pub fn mono(
body: Content,
) -> Content {
body.styled(EquationElem::set_variant(MathVariant::Mono))
}
#[func(title = "Blackboard Bold", keywords = ["mathbb"])]
pub fn bb(
body: Content,
) -> Content {
body.styled(EquationElem::set_variant(MathVariant::Bb))
}
#[func(title = "Display Size", keywords = ["displaystyle"])]
pub fn display(
body: Content,
#[named]
#[default(false)]
cramped: bool,
) -> Content {
body.styled(EquationElem::set_size(MathSize::Display))
.styled(EquationElem::set_cramped(cramped))
}
#[func(title = "Inline Size", keywords = ["textstyle"])]
pub fn inline(
body: Content,
#[named]
#[default(false)]
cramped: bool,
) -> Content {
body.styled(EquationElem::set_size(MathSize::Text))
.styled(EquationElem::set_cramped(cramped))
}
#[func(title = "Script Size", keywords = ["scriptstyle"])]
pub fn script(
body: Content,
#[named]
#[default(true)]
cramped: bool,
) -> Content {
body.styled(EquationElem::set_size(MathSize::Script))
.styled(EquationElem::set_cramped(cramped))
}
#[func(title = "Script-Script Size", keywords = ["scriptscriptstyle"])]
pub fn sscript(
body: Content,
#[named]
#[default(true)]
cramped: bool,
) -> Content {
body.styled(EquationElem::set_size(MathSize::ScriptScript))
.styled(EquationElem::set_cramped(cramped))
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Cast, Hash)]
pub enum MathSize {
ScriptScript,
Script,
Text,
Display,
}
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq, Cast, Hash)]
pub enum MathVariant {
#[default]
Serif,
Sans,
Cal,
Frak,
Mono,
Bb,
}