Skip to main content

Module lexical

Module lexical 

Source
Expand description

Lexical predicates: grammar facts for formatters.

A markdown formatter constantly synthesizes new line starts (joining lines for prose wrap, stripping indent, removing escapes). Whether the synthesized line would open a block is a grammar fact, and approximating it downstream is the classic printer failure mode (Prettier’s /^>|^(?:[*+-]|#{1,6}|\d+[).])$/ misses :::, fences, <, and |. Each a documented meaning-breaking bug). This module exposes the parser’s own classification instead: line_start runs the exact probe table the block engine uses, so the two cannot drift.

Policy-free: these functions state what the grammar would do with a line, never what a formatter should do about it.

Enums§

LineStart
What a line would open at flow position. One variant per block construct; the payload-free mirror of the engine’s probe result.

Functions§

line_start
Classifies what line (one line, no line ending) would start as a block, or None for paragraph text. in_paragraph enables the constructs that only exist relative to an open paragraph.
ordered_number
The number of an ordered list marker (123. / 123)), for a printer that renumbers. CommonMark caps markers at 9 digits, so the value always fits; None for a bullet.
table_delimiter_activates
Whether delimiter row row opens a table under header, the paragraph line right above it.