Reference

Parser

Parser

The @tanstack/markdown/parser entry exports only the document parser and its transitive implementation.

ts
import { parseMarkdown } from '@tanstack/markdown/parser'

parseMarkdown

ts
function parseMarkdown(
  markdown: string,
  options?: ParseOptions,
): MarkdownDocument

Normalizes and parses a complete Markdown source string into a deterministic MarkdownDocument.

Options

OptionDefaultBehavior
allowHtmlfalseRecognize raw block and inline HTML nodes
frontmattertrueExtract a leading --- frontmatter block
headingIdstrueGenerate IDs, disable them, or provide an ID function
extensions[]Run custom parser and transform hooks in array order
referencesinternalProvide normalized reference definitions to nested parsing
footnotesinternalProvide normalized footnote definitions to nested parsing
footnoteOrderinternalTrack first-reference order through nested parsing
footnoteCountsinternalTrack repeated references for back links

The last four state fields are public so extension-driven nested parsing can preserve parser context. Ordinary calls should leave them unset.

Result

The result always has type: 'root' and a children array. It may also include raw frontmatter and extension-derived headings.

See Parsing for behavior and Types for complete contracts.