Skip to main content

parser_options

Function parser_options 

Source
pub fn parser_options(math: bool) -> Options
Expand description

The pulldown-cmark option set moss parses markdown with.

Every parser construction site in the repo must call this rather than hand-assembling its own Options — moss previously had five independent Options blocks (typed AST, newsletter ×2, llms_txt, the markdown pipeline), and each one that drifted became a surface where the same document parsed differently depending on which output it was headed for. A site that legitimately needs a different set (the newsletter walker deliberately omits ENABLE_FOOTNOTES, because footnote backlinks are meaningless in an inbox) calls this and then removes the one option, so the divergence reads as an explicit delta at the call site instead of being invisibly re-hand-rolled.

math gates ENABLE_MATH ($…$ / $$…$$Event::InlineMath / Event::DisplayMath). It is a parameter rather than part of the base set because it changes the meaning of a character that appears in ordinary prose ($5), so it is the one option a site must opt into — production wires it from [site].math on SiteConfig.

Enabling math obliges the caller’s event walker to handle both math events. pulldown emits them as leaf inline events; a walker that pattern-matches known events and ignores the rest will silently delete every equation in the document (measured: Energy $E = mc^2$.<p>Energy .</p>). See src-tauri/tests/math_wiring_invariant_test.rs, which fails any site that turns math on without arms in the same walker.