Add ToMathML trait and implementation for greek letters

pull/1/head
trivernis 4 years ago
parent 74caac521f
commit 367bade807

@ -0,0 +1,50 @@
use crate::tokens::Greek;
pub trait ToMathML {
fn to_mathml(&self) -> String;
}
impl ToMathML for Greek {
fn to_mathml(&self) -> String {
let inner = match self {
Greek::Alpha => "α",
Greek::Beta => "β",
Greek::Gamma => "γ",
Greek::BigGamma => "Γ",
Greek::Delta => "δ",
Greek::BigDelta => "Δ",
Greek::Epsilon => "ε",
Greek::VarEpsilon => "ε",
Greek::Zeta => "ζ",
Greek::Eta => "η",
Greek::Theta => "θ",
Greek::BigTheta => "Θ",
Greek::VarTheta => "θ",
Greek::Iota => "ι",
Greek::Kappa => "κ",
Greek::Lambda => "λ",
Greek::BigLambda => "Λ",
Greek::Mu => "μ",
Greek::Nu => "ν",
Greek::Xi => "ξ",
Greek::BigXi => "Ξ",
Greek::Pi => "π",
Greek::BigPi => "Π",
Greek::Rho => "ρ",
Greek::Sigma => "σ",
Greek::BigSigma => "Σ",
Greek::Tau => "τ",
Greek::Upsilon => "υ",
Greek::Phi => "φ",
Greek::BigPhi => "Φ",
Greek::VarPhi => "φ",
Greek::Chi => "χ",
Greek::Psi => "ψ",
Greek::BigPsi => "Ψ",
Greek::Omega => "ω",
Greek::BigOmega => "Ω",
};
format!("<mi>{}</mi>", inner)
}
}

@ -0,0 +1 @@
pub mod mathml;

@ -12,6 +12,7 @@ use crate::parsing::tokenizer::Tokenizer;
use crate::parsing::tree_parser::TreeParser;
pub mod elements;
pub mod format;
pub mod parsing;
pub mod tokens;
pub(crate) mod utils;

Loading…
Cancel
Save