mathml_core/numbers/mod.rs
1use crate::{MathElement, MathML};
2use std::{
3 collections::BTreeMap,
4 fmt::{Display, Formatter},
5};
6
7mod constructors;
8mod display;
9
10/// The [`<mn>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mn) element represents a numeric literal
11/// which is normally a sequence of digits with a possible separator, such as a dot or a comma.
12///
13/// However, it is also allowed to have arbitrary text in it which is actually a numeric quantity, for example "eleven".
14#[derive(Debug, Clone, PartialEq)]
15#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
16pub struct MathNumber {
17 number: String,
18}
19
20/// The [`<mfrac>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfrac) element is used to display fractions.
21///
22/// It can also be used to mark up fraction-like objects such as binomial coefficients and Legendre symbols.
23#[derive(Clone, Debug, PartialEq)]
24#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
25pub struct MathFraction {
26 numerator: MathML,
27 denominator: MathML,
28 line_thickness: LineThickness,
29}
30
31/// Line thickness for [`<mfrac>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfrac),
32/// used as [`linethickness`](https://developer.mozilla.org/en-US/docs/Web/MathML/Values#legacy_mathml_lengths) attribute.
33///
34/// ## Polyfill
35///
36/// We provide a polyfill for this attribute, which supports deprecated values `thin`, `medium`, `thick` and `length`.
37#[derive(Debug, Clone, Copy, PartialEq)]
38#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
39pub enum LineThickness {
40 /// `1rem`
41 Thin,
42 /// `1rem`
43 Medium,
44 /// `1rem`
45 Thick,
46 /// `1rem`
47 Length(u8),
48}
49
50/// The [`<merror>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/merror) element is used to display contents as error messages.
51///
52/// The intent of this element is to provide a standard way for programs that generate MathML from other input to report syntax errors.
53#[derive(Clone, Debug, PartialEq)]
54#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
55pub struct MathError {
56 message: String,
57}