Skip to main content

Module math

Module math 

Source
Expand description

Math parsing for both inline and display math.

This module handles all math-related parsing:

  • Inline math: $...$, \(...\), \\(...\\) - single line only
  • Display math: $$...$$, \[...\], \\[...\\] - can span multiple lines

Display math can appear both inline (within paragraphs) and as block-level elements. The parsing functions return Option<(usize, &str)> tuples containing the length consumed and the math content, allowing calling contexts to emit appropriate nodes.

Functions§

emit_display_math
Emit a display math node to the builder (when occurring inline in paragraph).
emit_display_math_environment
Emit a display math environment node using raw \begin…\end… markers.
emit_double_backslash_display_math
Emit a double backslash display math node: \[…\]
emit_double_backslash_inline_math
Emit a double backslash inline math node: \(…\)
emit_gfm_inline_math
Emit a GFM inline math node: $...$
emit_inline_math
Emit an inline math node to the builder.
emit_single_backslash_display_math
Emit a single backslash display math node: […]
emit_single_backslash_inline_math
Emit a single backslash inline math node: (…)
try_parse_display_math
Try to parse display math ($$…$$) starting at the current position. Returns the number of characters consumed and the math content if successful. Display math can span multiple lines in inline contexts.
try_parse_double_backslash_display_math
Try to parse double backslash display math: \[…\] Extension: tex_math_double_backslash
try_parse_double_backslash_inline_math
Try to parse double backslash inline math: \(…\) Extension: tex_math_double_backslash
try_parse_gfm_inline_math
Try to parse GFM inline math: $...$ Extension: tex_math_gfm
try_parse_inline_math
Try to parse an inline math span starting at the current position. Returns the number of characters consumed if successful, or None if not inline math.
try_parse_math_environment
Try to parse a LaTeX math environment (\begin{equation}…\end{equation}) as display math. Returns (total_len, begin_marker, content, end_marker).
try_parse_single_backslash_display_math
Try to parse single backslash display math: […] Extension: tex_math_single_backslash
try_parse_single_backslash_inline_math
Try to parse single backslash inline math: (…) Extension: tex_math_single_backslash