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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
pub mod attribute;
mod display;

use crate::{
    ast::attribute::{Accent, ColumnAlign},
    operators::MathOperator,
    MathFraction, MathIdentifier, MathNumber, MathPhantom, MathRoot, MathSub, MathSubSup, MathSup,
};
use std::fmt::{Display, Formatter};

/// AST node
#[derive(Debug, Clone, PartialEq)]
pub enum MathML {
    Root(Box<MathRoot>),
    Number(Box<MathNumber>),
    /// `<mi>`
    Letter(Box<MathIdentifier>),
    Text(String),
    Operator(Box<MathOperator>),
    Sub(Box<MathSub>),
    Sup(Box<MathSup>),
    SubSup(Box<MathSubSup>),
    Function(String, Option<Box<MathML>>),
    Space(f32),
    OverOp(char, Accent, Box<MathML>),
    UnderOp(char, Accent, Box<MathML>),
    Overset {
        over: Box<MathML>,
        target: Box<MathML>,
    },
    Underset {
        under: Box<MathML>,
        target: Box<MathML>,
    },
    Under(Box<MathML>, Box<MathML>),
    UnderOver {
        target: Box<MathML>,
        under: Box<MathML>,
        over: Box<MathML>,
    },
    Sqrt(Option<Box<MathML>>, Box<MathML>),
    Frac(Box<MathFraction>),
    Phantom(Box<MathPhantom>),
    Row(Vec<MathML>),
    Fenced {
        open: &'static str,
        close: &'static str,
        content: Box<MathML>,
    },
    StrechedOp(bool, String),
    OtherOperator(&'static str),
    SizedParen {
        size: &'static str,
        paren: &'static str,
    },
    Matrix(Vec<MathML>, ColumnAlign),
    Ampersand,
    NewLine,
    Slashed(Box<MathML>),
    Style(Option<DisplayStyle>, Box<MathML>),
    Undefined(String),
}

/// display style
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DisplayStyle {
    Block,
    Inline,
}