Expand description
Content expressions — the compiled half of the section-format vocabulary (agent-toolbox plan 08).
A section can declare its markdown shape as a flat expression over
the mdast block-node vocabulary, verbatim: paragraph, list,
table, code, blockquote, heading, thematicBreak, html.
Operators: sequence (space), alternation of names
((paragraph | list)), repetition + * ? on names and on
parenthesized groups. The grammar is deliberately regular — no
nesting, no recursion — the ProseMirror precedent: a deterministic
content model is what lets a refusal say “expected X at position N”
instead of “the structure didn’t match”.
This module owns parsing, validation, and matching. It knows
nothing about markdown itself — the consumer (the engine’s
section-format evaluator) reduces a section body to a sequence of
ObservedBlocks with a real CommonMark parser and hands it to
ContentExpr::match_blocks.
Structs§
- Content
Expr - A parsed, validated content expression. Matching runs an NFA simulation over the observed block sequence so a failure can report the exact position and the terminals that would have been legal there.
- Match
Failure - Match failure: the observed sequence does not satisfy the
expression.
failed_atis the index into the observed sequence (== its length when the body ended too early);expected_nextlists the display forms of the terminals legal at that position;foundis the display form of the offending block (Noneat end-of-body). - Terminal
- One terminal of a compiled expression: a block name plus its optional attribute constraint.
Enums§
- Content
Expr Error - Typed parse/validation failure for a content expression.
offendercarries the offending token so loader errors can name it. - Observed
Block - One observed top-level block of a section body, as reduced by the consumer’s markdown parser. Carries exactly the attributes the expression vocabulary can constrain.
Constants§
- BLOCK_
NAMES - The mdast block-node names the vocabulary admits, verbatim
(including
thematicBreak’s camelCase — mdast names are used unchanged because they are the vocabulary agents already know from the remark/MDX ecosystem).