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 crate::{MathElement, MathIdentifier, MathML};
use std::{
collections::BTreeMap,
fmt::{Debug, Display, Formatter},
};
mod constructors;
mod display;
/// The [`<math>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math) element is the top-level MathML element,
/// used to write a single mathematical formula.
///
/// It can be placed in HTML content where flow content is permitted.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MathRoot {
children: Vec<MathML>,
attributes: BTreeMap<String, String>,
}
/// Mark a function with arguments.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MathFunction {
name: String,
body: Vec<MathML>,
}
/// The [`<mrow>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mrow) element is used to group sub-expressions,
/// which usually contain one or more operators with their respective operands, such as `<mi>` and `<mn>`.
///
/// This element renders as a horizontal row containing its arguments.
///
/// When writing a MathML expression, you should group elements within an `<mrow>` in the same way as they are grouped in the mathematical interpretation of the expression.
///
/// Proper grouping helps the rendering of the expression in several ways:
///
/// - It can improve the display by possibly affecting spacing and preventing line breaks.
/// - It simplifies the interpretation of the expression by automated systems such as computer algebra systems and audio renderers.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MathRow {
grouped: bool,
children: Vec<MathML>,
}
/// The [`<mphantom>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mphantom) element is rendered invisibly,
/// but dimensions such as height, width, and baseline position, are still kept.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MathPhantom {
inner: MathML,
}
/// The [`<mspace>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mspace) element is used to insert space characters into a mathematical formula.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MathStyle {
base: MathML,
attributes: BTreeMap<String, String>,
}
/// The [`<mtable>`](https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtable) element allows you to create tables or matrices.
///
/// Its children are `<mtr>` elements, representing rows.
///
/// Each of them having `<mtd>` elements as its children, representing cells.
///
/// These elements are similar to `<table>`, `<tr>` and `<td>` elements of HTML.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MathTable {
stream: Vec<MathML>,
attributes: BTreeMap<String, String>,
}