Skip to main content

Module content_expr

Module content_expr 

Source
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§

ContentExpr
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.
MatchFailure
Match failure: the observed sequence does not satisfy the expression. failed_at is the index into the observed sequence (== its length when the body ended too early); expected_next lists the display forms of the terminals legal at that position; found is the display form of the offending block (None at end-of-body).
Terminal
One terminal of a compiled expression: a block name plus its optional attribute constraint.

Enums§

ContentExprError
Typed parse/validation failure for a content expression. offender carries the offending token so loader errors can name it.
ObservedBlock
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).