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, OpRoles, 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//!                 roles: OpRoles::empty(),
21//!                 left: Some(MathSpacing::Zero),
22//!                 right: None,
23//!                 size: None,
24//!             },
25//!             symbol: &Node::IdentifierChar('i'.into(), LetterAttr::Default),
26//!         },
27//!         &Node::IdentifierChar('i'.into(), LetterAttr::Default),
28//!      ],
29//!      attrs: RowAttrs::DEFAULT,
30//! };
31//!
32//! let label_map = FxHashMap::default();
33//! let css_classes = CssClassNames::default();
34//! let mut emitter = Emitter::new(String::new(), &label_map, &css_classes, Indentation::default(), "");
35//! emitter.emit(&ast, 0).unwrap();
36//! let output = emitter.into_string();
37//! assert_eq!(
38//!     output,
39//!     "<mrow><munder><mo lspace=\"0\">∑</mo><mi>i</mi></munder><mi>i</mi></mrow>"
40//! );
41//! ```
42#![cfg_attr(not(any(feature = "std", test)), no_std)]
43
44extern crate alloc;
45
46/// Hash map with a fast, non-cryptographic hasher, backed by `hashbrown` so it works in `no_std`.
47pub(crate) type FxHashMap<K, V> = hashbrown::HashMap<K, V, rustc_hash::FxBuildHasher>;
48
49pub mod arena;
50pub mod ast;
51pub mod attribute;
52mod escaping;
53pub mod fmt;
54mod itoa;
55pub mod length;
56pub mod super_char;
57pub mod symbol;
58pub mod table;