1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use super::*;

impl Display for MathML {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        match self {
            MathML::Root(v) => Display::fmt(v, f),
            MathML::Row(v) => Display::fmt(v, f),
            MathML::Function(v) => Display::fmt(v, f),
            MathML::Number(v) => Display::fmt(v, f),
            MathML::Identifier(v) => Display::fmt(v, f),
            MathML::Operator(v) => Display::fmt(v, f),
            MathML::MultiScripts(v) => Display::fmt(v, f),
            MathML::OverOp(op, acc, target) => write!(f, r#"<mover>{}<mo accent="{}">{}</mo></mover>"#, target, acc, op),
            MathML::UnderOp(op, acc, target) => write!(f, r#"<munder>{}<mo accent="{}">{}</mo></munder>"#, target, acc, op),
            MathML::UnderOver(v) => Display::fmt(v, f),
            MathML::Sqrt(v) => Display::fmt(v, f),
            MathML::Frac(v) => Display::fmt(v, f),
            MathML::Phantom(v) => Display::fmt(v, f),
            MathML::Fenced(v) => Display::fmt(v, f),
            MathML::StrechedOp(stretchy, op) => write!(f, r#"<mo stretchy="{}">{}</mo>"#, stretchy, op),
            MathML::SizedParen { size, paren } => {
                write!(f, r#"<mrow><mo maxsize="{0}" minsize="{0}">{1}</mro></mrow>"#, size, paren)
            }
            MathML::Slashed(node) => match &**node {
                // force set math-variant here
                MathML::Identifier(mi) => {
                    write!(f, "{:}", mi)
                }
                MathML::Operator(x) => write!(f, "<mo>{}&#x0338;</mo>", x),
                n => write!(f, "{}", n),
            },
            MathML::Table(v) => Display::fmt(v, f),
            MathML::Space(v) => Display::fmt(v, f),
            MathML::Text(v) => Display::fmt(v, f),
            MathML::Style(v) => Display::fmt(v, f),
            MathML::Ampersand => Ok(()),
            MathML::NewLine => Ok(()),
            MathML::Undefined(_) => {
                todo!()
            }
        }
    }
}