Types
Types#
All shared types are exported from @tanstack/markdown.
Documents and unions#
MarkdownInput#
string | MarkdownDocument. Accepted by the complete-document renderers.
MarkdownDocument#
The root object with type: 'root', children: BlockNode[], optional raw frontmatter, and optional collected headings.
BlockNode#
Union of HeadingNode, ParagraphNode, CodeBlockNode, ListNode, BlockquoteNode, TableNode, FootnotesNode, ThematicBreakNode, HtmlBlockNode, CalloutNode, and ComponentNode.
InlineNode#
Union of TextNode, CodeSpanNode, StrongNode, EmphasisNode, StrikeNode, FootnoteReferenceNode, LinkNode, ImageNode, BreakNode, HtmlInlineNode, and InlineComponentNode.
Block nodes#
HeadingNode#
Contains depth from 1 through 6, optional id and framework, and inline children.
ParagraphNode#
Contains inline children.
CodeBlockNode#
Contains raw value plus optional lang, meta, title, file, framework, and highlightLines metadata.
ListNode#
Contains ordered, optional start, optional loose, and items: ListItemNode[]. A true loose value preserves paragraph wrappers in every item.
ListItemNode#
Contains block children and optional task-list checked state.
BlockquoteNode#
Contains nested block children.
TableNode#
Contains per-column align, a header, and body rows made from TableCellNode values.
TableCellNode#
Contains inline children.
FootnotesNode#
Generated document block containing items: FootnoteItemNode[].
FootnoteItemNode#
Contains a collision-safe id, display number, optional referenceCount, and block children.
ThematicBreakNode#
Marker node with type: 'thematicBreak'.
HtmlBlockNode#
Contains raw HTML value. It is created only when HTML parsing is enabled.
CalloutNode#
Contains a callout kind, display title, and block children. It is produced by the callouts extension.
ComponentNode#
Contains source name, parsed attributes, block children, and optional rendered tagName and string properties. Docs transforms use it for tabs and framework panels.
Inline nodes#
TextNode#
Contains plain text value.
CodeSpanNode#
Contains inline code value.
StrongNode#
Contains inline children rendered as strong text.
EmphasisNode#
Contains inline children rendered as emphasized text.
StrikeNode#
Contains inline children rendered as deleted text.
FootnoteReferenceNode#
Contains normalized footnote id, display number, and optional referenceIndex for repeated references.
LinkNode#
Contains policy-processed href, optional title, and inline children.
ImageNode#
Contains policy-processed src, text alt, and optional title.
BreakNode#
Marker node with type: 'break'.
HtmlInlineNode#
Contains raw inline HTML value. It is created only when HTML parsing is enabled.
InlineComponentNode#
Contains type: 'inlineComponent', name, source attributes, inline children, and optional rendered tagName and string properties. Uses the same component replacements as ComponentNode, with a <span> fallback when no tag is provided. See Custom components.
Parsing and rendering options#
ParseOptions#
Configures allowHtml, urlTransform, frontmatter, headingIds, and extensions. It also exposes references, footnotes, footnoteOrder, and footnoteCounts state used by nested parser contexts.
UrlTransform#
Synchronous callback (url: string, kind: 'link' | 'image', defaultUrl: string) => string | null. Return the default screened URL, a trusted replacement, or null to keep only the label content. Applies during Markdown parsing, not to raw HTML or supplied ASTs. See Custom URL policy.
RenderOptions#
Extends ParseOptions with highlighter, codeLineNumbers, and headingAnchors.
CodeHighlighter#
Synchronous callback (code, lang?, options?) => string. The returned string is trusted HTML for the contents of <code>.
CodeHighlightOptions#
Contains optional raw fence meta, highlightLines, and lineNumbers passed to a CodeHighlighter.
HeadingAnchorOptions#
Configures anchor content, className, ariaHidden, and tabIndex.
Extension contracts#
MarkdownExtension#
Named hook object with optional parseBlock, transformDocument, transformInline, and renderHtml functions, plus an optional inlineParser.
BlockParseContext#
Provides source lines, current index, active options, nested parseInline and parseBlocks helpers, and consume.
InlineParser#
Contains literal starting UTF-16 code-unit markers and a synchronous parse(context) callback returning InlineParseResult | undefined. Runs at matching source positions after escapes and code spans, before other built-in inline rules.
InlineParseContext#
Provides current-container source, UTF-16 index, active options, inLink, and a nested parseInline(value) helper that shares the recursion and scan budget.
InlineParseResult#
Contains one standard InlineNode as node and a positive integer length in UTF-16 code units. The range must fit in the current source. Invalid lengths throw RangeError.
InlineTransformContext#
Provides active parse options to inline transforms.
DocumentTransformContext#
Provides active parse options to document transforms.
HtmlRenderContext#
Provides active render options and recursive renderBlock and renderInline functions.
Supporting data#
MarkdownHeading#
Collected heading data with id, text, numeric level, and optional framework.
LinkReferenceDefinition#
Normalized reference data with href and optional title.
FootnoteDefinition#
Footnote source data with original label, Markdown content, and optional generated id.