Skip to main content

Module ast

Module ast 

Source
Expand description

AST node definitions.

Node taxonomy (heading / paragraph / list / html / emphasis / …), sibling order and spans follow CommonMark’s grammar; a printer’s dispatch is written per this unit.

Beyond that the shapes deliberately diverge from mdast:

  • No cooked values: consumers slice the original source through Spans. Inline node spans are original-source offsets, never rebuilt-buffer ones.
  • Style facts a printer would otherwise re-derive by peeking at the source (markers, fence chars, reference kinds, break kinds, …) are first-class fields.
  • Formatter policy (sentence splitting, CJK classification, alignment judgment) stays out; the AST records lexical facts only.

Blank lines are not stored on nodes: ParserReturn::blanks lists them once, and sibling spans locate the ones between two blocks (List::tight is computed from it).

Structs§

Autolink
<https://example.com> / <user@example.com>.
AutolinkLiteral
GFM autolink literal (www.example.com, bare https://… / email).
Blockquote
CodeBlock
CodeSpan
ContainerDirective
A container directive:
Definition
A link reference definition: [label]: dest "title".
Destination
A link/image destination, excluding the title.
Emphasis
FootnoteDefinition
FootnoteReference
GFM [^label].
HardBreak
Heading
HtmlBlock
A raw HTML block. Contents are never parsed or formatted.
HtmlInline
A raw inline HTML tag or comment. The tag is a verbatim token; text around it is markdown.
Image
![alt](dest "title") and the reference forms.
Link
[text](dest "title") or [text][label] / [text][] / [text].
Liquid
A {% … %} / {{ … }} template tag, block-level or inline. Never interpreted: the whole construct, delimiters included, is kept verbatim.
List
ListItem
MathBlock
$$ … $$ display math, content is kept raw. As with code fences, the fence length is not stored (printers normalize to $$; the $ run at span.start gives it if ever needed).
MathSpan
$ … $ inline math. The whole construct, $ sequences included, is kept raw; content is never trimmed or decoded.
MdxEsm
An MDX import/export statement. The parser only establishes the boundary (via the host’s JS parser callback); the content stays raw for embedded formatting.
MdxExpression
An MDX {expr}. Boundary only; the expression stays raw.
MdxJsxFlow
An MDX JSX element at flow level. Tags stay raw for embedded formatting; children are markdown blocks.
MdxJsxText
An MDX JSX element in text. Children are inline markdown.
Paragraph
Root
The document.
SoftBreak
Strikethrough
GFM ~~x~~ (~x~ too with gfm_strikethrough_single_tilde).
Strong
Table
TableCell
TableRow
TaskCheckbox
[ ], [x] or [X] (the raw span keeps the case).
Text
ThematicBreak
WikiLink
[[target]], alias-less. Always single-line; the target is span + 2 .. span - 2, kept raw.

Enums§

Block
Flow (block-level) content.
CodeBlockKind
HardBreakKind
HeadingKind
Inline
Phrasing (inline) content.
LinkKind
Titles and labels are logical-line pieces for the same reason as on Definition.
ListMarker
ReferenceKind
Reference-link form. Only Full is reformatted; the others are printed verbatim.
TableAlign