Expand description
In-tree TeX math content parser.
Produces a lossless structural CST for the content between math
delimiters (the delimiters themselves are owned by the host INLINE_MATH /
DISPLAY_MATH nodes, see parser/inlines/math.rs). The returned subtree is
rooted at SyntaxKind::MATH_CONTENT and is spliced directly into the host
document tree, replacing the opaque content TEXT token.
This is a syntactic parse, not a semantic one: TeX is a Turing-complete
macro language, so we only capture structure that a formatter can safely act
on — brace groups, \begin/\end environments, control sequences,
alignment tabs (&), line breaks (\\), sub/superscript markers, comments,
and whitespace. Everything else is an ordinary-atom run (MATH_TEXT).
Two outputs, two channels — the same split YAML uses (see
parser/yaml/model.rs) and that texlab uses for LaTeX:
- the CST is lossless and never fails (
node.text() == contentfor every input; worst case is a singleMATH_TEXTatom), and - errors ride a side-channel (
MathParseReport::diagnostics) so the linter (and by proxy the LSP) can surface unbalanced braces and mismatched environments without the parser ever rejecting input.
Modules§
- diagnostic_
codes - Stable diagnostic codes for math content. Mirrors
yaml::diagnostic_codes.
Structs§
- Math
Diagnostic - A non-fatal problem found while parsing math content. Byte offsets are relative to the math content string (the caller offsets them into host document coordinates when surfacing through the linter/LSP).
- Math
Parse Options - Flavor-/extension-dependent parsing options for math content. Default is all-off (pure TeX). The math grammar itself is flavor-agnostic; only constructs layered on top of TeX by a Markdown flavor live here.
- Math
Parse Report - The lossless CST plus any diagnostics gathered on the side-channel.
Functions§
- parse_
math_ content - Parse math content into a lossless
MATH_CONTENTgreen node, discarding diagnostics.contentis the raw text between (but excluding) the math delimiters. - parse_
math_ report - Parse math content into a lossless CST plus a side-channel of diagnostics.