Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions crates/math-core/src/character_class.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use mathml_renderer::attribute::TextTransform;

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum Class {
/// `mathord`
Expand All @@ -20,3 +22,36 @@ pub enum Class {
/// A class indicating the end of the current formula.
End,
}

#[derive(Debug, Clone, Copy)]
pub enum ParenType {
Left = 1,
Right,
Middle,
}

/// <mi> mathvariant attribute
#[derive(Debug, Clone, Copy)]
pub enum MathVariant {
/// This is enforced by setting `mathvariant="normal"`.
Normal,
/// This is enforced by transforming the characters themselves.
Transform(TextTransform),
}

#[cfg(test)]
mod tests {
use super::{MathVariant, TextTransform};

#[test]
fn size_test() {
assert_eq!(
std::mem::size_of::<MathVariant>(),
std::mem::size_of::<TextTransform>()
);
assert_eq!(
std::mem::size_of::<Option<MathVariant>>(),
std::mem::size_of::<TextTransform>()
);
}
}
23 changes: 14 additions & 9 deletions crates/math-core/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use mathml_renderer::attribute::{
FracAttr, HtmlTextStyle, MathVariant, Notation, OpAttrs, ParenType, Size, Style, TextTransform,
FracAttr, HtmlTextStyle, Notation, OpAttrs, Size, Style, TextTransform,
};
use mathml_renderer::symbol::{self, Rel};

use crate::character_class::{MathVariant, ParenType};
use crate::predefined;
use crate::specifications::LatexUnit;
use crate::token::{
Expand Down Expand Up @@ -40,10 +41,12 @@ static COMMANDS: phf::Map<&'static str, Token> = phf::phf_map! {
"Beta" => UprightLetter(symbol::GREEK_CAPITAL_LETTER_BETA),
"Big" => Big(Size::Scale2, None),
"Bigg" => Big(Size::Scale4, None),
"Biggl" => Big(Size::Scale4, Some(ParenType::Open)),
"Biggr" => Big(Size::Scale4, Some(ParenType::Close)),
"Bigl" => Big(Size::Scale2, Some(ParenType::Open)),
"Bigr" => Big(Size::Scale2, Some(ParenType::Close)),
"Biggl" => Big(Size::Scale4, Some(ParenType::Left)),
"Biggm" => Big(Size::Scale4, Some(ParenType::Middle)),
"Biggr" => Big(Size::Scale4, Some(ParenType::Right)),
"Bigl" => Big(Size::Scale2, Some(ParenType::Left)),
"Bigm" => Big(Size::Scale2, Some(ParenType::Middle)),
"Bigr" => Big(Size::Scale2, Some(ParenType::Right)),
"Box" => Letter(symbol::WHITE_MEDIUM_SQUARE, Mode::Math),
"Bumpeq" => Relation(symbol::GEOMETRICALLY_EQUIVALENT_TO),
"Cap" => BinaryOp(symbol::DOUBLE_INTERSECTION),
Expand Down Expand Up @@ -169,13 +172,15 @@ static COMMANDS: phf::Map<&'static str, Token> = phf::phf_map! {
"bigdoublevee" => Op(symbol::TWO_LOGICAL_OR_OPERATOR),
"bigdoublewedge" => Op(symbol::TWO_LOGICAL_AND_OPERATOR),
"bigg" => Big(Size::Scale3, None),
"biggl" => Big(Size::Scale3, Some(ParenType::Open)),
"biggr" => Big(Size::Scale3, Some(ParenType::Close)),
"bigl" => Big(Size::Scale1, Some(ParenType::Open)),
"biggl" => Big(Size::Scale3, Some(ParenType::Left)),
"biggm" => Big(Size::Scale3, Some(ParenType::Middle)),
"biggr" => Big(Size::Scale3, Some(ParenType::Right)),
"bigl" => Big(Size::Scale1, Some(ParenType::Left)),
"bigm" => Big(Size::Scale1, Some(ParenType::Middle)),
"bigodot" => Op(symbol::N_ARY_CIRCLED_DOT_OPERATOR),
"bigoplus" => Op(symbol::N_ARY_CIRCLED_PLUS_OPERATOR),
"bigotimes" => Op(symbol::N_ARY_CIRCLED_TIMES_OPERATOR),
"bigr" => Big(Size::Scale1, Some(ParenType::Close)),
"bigr" => Big(Size::Scale1, Some(ParenType::Right)),
"bigsqcap" => Op(symbol::N_ARY_SQUARE_INTERSECTION_OPERATOR),
"bigsqcup" => Op(symbol::N_ARY_SQUARE_UNION_OPERATOR),
"bigstar" => Letter(symbol::BLACK_STAR, Mode::Math),
Expand Down
Loading
Loading