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
70
71
72
73
use crate::{
    helpers::{safe_html_char, safe_html_str},
    traits::{write_tag_close, write_tag_self_close, write_tag_start},
    MathElement, MathML,
};
use std::{
    collections::BTreeMap,
    fmt::{Display, Formatter},
    iter::repeat,
};
mod constructors;
mod display;

/// The [`<mo>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo) element represents an operator in a broad sense.
///
/// Besides operators in strict mathematical meaning, this element also includes "operators" like parentheses, separators like comma and semicolon, or "absolute value" bars.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MathOperator {
    operator: String,
    attributes: BTreeMap<String, String>,
}

/// The [`<mspace>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mspace) element is used to display a blank space, whose size is set by its attributes.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MathSpace {
    attributes: BTreeMap<String, String>,
}

/// The [`<mroot>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mroot) or [`<msqrt>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msqrt) element is used to display roots with an explicit index.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MathSqrt {
    base: MathML,
    surd: Option<MathML>,
}

/// The [`<mmultiscripts>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mmultiscripts) element is used to attach an arbitrary number of subscripts and superscripts to an expression at once
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MathMultiScript {
    base: MathML,
    ru: Vec<MathML>,
    rd: Vec<MathML>,
    lu: Vec<MathML>,
    ld: Vec<MathML>,
    attributes: BTreeMap<String, String>,
}

/// The [`<munderover>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/munderover) element is used to attach accents or limits both under and over an expression.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MathUnderOver {
    base: MathML,
    under: Option<MathML>,
    over: Option<MathML>,
    attributes: BTreeMap<String, String>,
}

/// The [`<mfenced>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfenced) element provides the possibility to add custom opening and closing parentheses and separators to an expression.
///
/// ## Polyfill
///
/// Since it is deprecated by the MathML standard, we provide a polyfill to `<mrow>` for this element.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MathFenced {
    base: Vec<MathML>,
    open: char,
    close: char,
    separators: String,
}