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
74
use super::*;

impl MathIdentifier {
    /// Creates a new [`MathIdentifier`] with the given [`FontVariant`].
    pub fn new<S>(text: S, variant: FontVariant) -> Self
    where
        S: ToString,
    {
        Self { identifier: text.to_string(), variant }
    }
    /// Creates a new [`MathIdentifier`] with the [`FontVariant::Normal`] variant.
    pub fn normal<S>(text: S) -> Self
    where
        S: ToString,
    {
        Self { identifier: text.to_string(), variant: FontVariant::Normal }
    }
    /// Creates a new [`MathIdentifier`] with the [`FontVariant::Italic`] variant.
    pub fn italic<S>(text: S) -> Self
    where
        S: ToString,
    {
        Self { identifier: text.to_string(), variant: FontVariant::Italic }
    }
    /// Gets the font variant of the identifier.
    pub fn get_variant(&self) -> FontVariant {
        self.variant
    }
    /// Gets the identifier of the identifier.
    pub fn get_identifier(&self) -> &str {
        &self.identifier
    }
}

impl MathText {
    /// Creates a new [`MathText`] with the given [`FontVariant`].
    pub fn text<S>(text: S) -> Self
    where
        S: ToString,
    {
        Self { text: text.to_string(), is_string: false }
    }
    /// Creates a new [`MathText`] with the [`FontVariant::Normal`] variant.
    pub fn string<S>(text: S) -> Self
    where
        S: ToString,
    {
        Self { text: text.to_string(), is_string: true }
    }
}

impl MathML {
    /// Creates a new [`MathIdentifier`] with the [`FontVariant::Italic`] variant.
    pub fn identifier<S>(text: S) -> Self
    where
        S: ToString,
    {
        MathIdentifier::italic(text).into()
    }
    /// Creates a new [`MathText`] with the [`FontVariant::Normal`] variant.
    pub fn text<S>(text: S) -> Self
    where
        S: ToString,
    {
        MathText::text(text).into()
    }
    /// Creates a new [`MathText`] with the [`FontVariant::Normal`] variant.
    pub fn string<S>(text: S) -> Self
    where
        S: ToString,
    {
        MathText::string(text).into()
    }
}