mathml_core/numbers/
display.rs1use super::*;
2
3impl Display for MathNumber {
4 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
5 write!(f, "<mn>{}</mn>", self.number)
6 }
7}
8
9impl Display for MathError {
10 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
11 write!(f, "<merror>{}</merror>", self.message)
12 }
13}
14
15impl Display for MathFraction {
16 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
17 match self.line_thickness {
18 LineThickness::Thin => {
19 write!(f, r#"<mfrac linethickness="thin">"#)?;
20 }
21 LineThickness::Medium => {
22 write!(f, r#"<mfrac>"#)?;
23 }
24 LineThickness::Thick => {
25 write!(f, r#"<mfrac linethickness="medium">"#)?;
26 }
27 LineThickness::Length(value) => {
28 write!(f, r#"<mfrac linethickness="{}">"#, value)?;
29 }
30 }
31 write!(f, "{}", self.numerator)?;
32 write!(f, "{}", self.denominator)?;
33 write!(f, "</mfrac>")
34 }
35}