Skip to main content

math_core_renderer_internal/
lib.rs

1//! Internal library for the `math-core` crate for rendering MathML.
2//!
3//! This library allows you to construct an AST representing MathML and then render it to a string.
4//!
5//! # Example
6//!
7//! ```rust
8//! use hashbrown::HashMap as FxHashMap;
9//!
10//! use math_core_renderer_internal::ast::{CssClassNames, Emitter, Indentation, Node};
11//! use math_core_renderer_internal::symbol;
12//! use math_core_renderer_internal::attribute::{MathSpacing, LetterAttr, OpAttrs, RowAttrs};
13//!
14//! let ast = Node::Row {
15//!     nodes: &[
16//!         &Node::Under {
17//!             target: &Node::Operator {
18//!                 op: symbol::N_ARY_SUMMATION.as_op(),
19//!                 attrs: OpAttrs::empty(),
20//!                 left: Some(MathSpacing::Zero),
21//!                 right: None,
22//!                 size: None,
23//!             },
24//!             symbol: &Node::IdentifierChar('i'.into(), LetterAttr::Default),
25//!         },
26//!         &Node::IdentifierChar('i'.into(), LetterAttr::Default),
27//!      ],
28//!      attrs: RowAttrs::DEFAULT,
29//! };
30//!
31//! let label_map = FxHashMap::default();
32//! let css_classes = CssClassNames::default();
33//! let mut emitter = Emitter::new(String::new(), &label_map, &css_classes, Indentation::default(), "");
34//! emitter.emit(&ast, 0).unwrap();
35//! let output = emitter.into_string();
36//! assert_eq!(
37//!     output,
38//!     "<mrow><munder><mo lspace=\"0\">∑</mo><mi>i</mi></munder><mi>i</mi></mrow>"
39//! );
40//! ```
41#![cfg_attr(not(any(feature = "std", test)), no_std)]
42
43extern crate alloc;
44
45/// Hash map with a fast, non-cryptographic hasher, backed by `hashbrown` so it works in `no_std`.
46pub(crate) type FxHashMap<K, V> = hashbrown::HashMap<K, V, rustc_hash::FxBuildHasher>;
47
48pub mod arena;
49pub mod ast;
50pub mod attribute;
51mod escaping;
52pub mod fmt;
53mod itoa;
54pub mod length;
55pub mod super_char;
56pub mod symbol;
57pub mod table;