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
#![allow(non_snake_case)]
#![allow(unused_variables)]

mod matrix;

use crate::{LineThickness, MathFraction, MathML, MathMultiScript, MathRow, MathTable};

pub use self::matrix::*;

pub fn frac(numerator: MathML, denominator: MathML) -> MathML {
    MathFraction::new(numerator, denominator).into()
}

// noinspection SpellCheckingInspection
pub fn dfrac(numerator: MathML, denominator: MathML) -> MathML {
    todo!()
}

// noinspection SpellCheckingInspection
pub fn cfrac(numerator: MathML, denominator: MathML) -> MathML {
    todo!()
}

pub fn binom(numerator: MathML, denominator: MathML) -> MathML {
    MathFraction::new(numerator, denominator).with_thickness(LineThickness::Length(0)).into()
}

// noinspection SpellCheckingInspection
pub fn cbinom(numerator: MathML, denominator: MathML) -> MathML {
    MathMultiScript::sub_super_script(MathML::identifier("C"), numerator, denominator).into()
}

pub fn legendre_symbols(numerator: MathML, denominator: MathML) -> MathML {
    todo!()
}

pub fn isotope(nucleus: usize, atomic_number: usize, mass_number: usize) -> MathML {
    todo!()
}

#[inline(always)]
pub fn safe_html_char<W>(writer: &mut W, c: char) -> std::fmt::Result
where
    W: std::fmt::Write,
{
    match c {
        '<' => writer.write_str("&lt;"),
        '>' => writer.write_str("&gt;"),
        '&' => writer.write_str("&amp;"),
        '"' => writer.write_str("&quot;"),
        '\'' => writer.write_str("&apos;"),
        _ => writer.write_char(c),
    }
}

#[inline(always)]
pub fn safe_html_str<W>(writer: &mut W, s: &str) -> std::fmt::Result
where
    W: std::fmt::Write,
{
    for c in s.chars() {
        safe_html_char(writer, c)?;
    }
    Ok(())
}