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 calls this and then adjusts the one option, so the divergence reads as an explicit delta at the call site instead of being invisibly re-hand-rolled. There is no such delta today: this comment used to cite the newsletter walker omitting ENABLE_FOOTNOTES, which stopped being true when email gained footnote arms — with the bit off, CommonMark reads [^x]: <url> as a link reference definition and deletes the note outright.

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.

ENABLE_TASKLISTS carries the same obligation, and it is met by Inline::TaskMarker: the flag makes pulldown emit Event::TaskListMarker as the first event inside Tag::Item, and both the leaf arm in parse_inline and the whitelist in parse_inline_event model it. Turning the flag on WITHOUT those arms silently deletes the checkbox — measured on - [ ] todo\n- [x] done, which rendered <ul><li>todo</li><li>done</li></ul>. See ADR-035 § Task lists.