Expand description
Convert LaTeX math to MathML Core.
For more background on what that means and on what to do with the resulting MathML code, see the repo’s README: https://github.com/tmke8/math-core
§Usage
The main struct of this library is LatexToMathML. In order to use the library, create an
instance of this struct and then call one of the convert functions. The constructor of the
struct expects a config object in the form of an instance of MathCoreConfig.
Basic use looks like this:
use math_core::{LatexToMathML, MathCoreConfig, MathDisplay};
let latex = r#"\erf ( x ) = \frac{ 2 }{ \sqrt{ \pi } } \int_0^x e^{- t^2} \, dt"#;
let config = MathCoreConfig::default();
let converter = LatexToMathML::new(config).unwrap();
let result = converter.convert_with_local_state(latex, MathDisplay::Block).unwrap();
println!("{}", result.mathml);§Features
std(enabled by default): Uses the Rust standard library. Disabling this feature (withdefault-features = false) makes the crateno_std; thealloccrate is still required. Note that disablingstdalso disables some speedups in dependencies (e.g.memchrthen can no longer use runtime CPU feature detection).serde: With this feature,MathCoreConfigimplements serde’sSerializeandDeserialize.ariadne: AddsLatexError::to_report(), which converts an error into anariadnereport for pretty-printing the error together with a source code snippet. Theariadnecrate itself requiresstd, so this feature is not usable onno_stdtargets.
Structs§
- Convert
Result - The result of a LaTeX to MathML conversion.
- CssClass
Names - Latex
Error - Represents an error that occurred during LaTeX parsing.
- Latex
ToMathML - A converter that transforms LaTeX math equations into MathML Core.
- Math
Core Config - Configuration object for the LaTeX to MathML conversion.
- MaxExpansions
- The maximum number of custom command expansions allowed in one snippet.
- Warnings
Enums§
- Indent
Keyword - Indentation
- Math
Display - Display mode for the LaTeX math equations.
- Pretty
Print - Configuration for pretty-printing the MathML output.
- Unicode
Substitution - Configuration for using Unicode symbols in the MathML output.
Type Aliases§
- Macro
Parse Error - The error type returned when parsing a custom macro definition fails. Contains the parsing
error, the index of the macro definition in the
macrosvector and the macro definition itself.