{"library":"mdast-util-from-markdown","title":"Markdown to mdast AST Parser","description":"mdast-util-from-markdown is a foundational utility in the syntax-tree ecosystem, designed to parse Markdown input into an mdast (Markdown Abstract Syntax Tree) syntax tree. It leverages the micromark tokenizer internally and transforms its output into a tree structure. The current stable version is 2.0.3, with frequent patch and minor releases, while major versions like 2.0.0 introduce significant breaking changes such as the shift to ESM-only and a minimum Node.js 16 requirement. This package provides a lower-level API for direct AST manipulation, making it suitable for developers who need fine-grained control over the parsing process or wish to integrate custom syntax extensions like GFM, MDX, Math, or Frontmatter. It is distinct from micromark (which focuses on direct HTML output) and remark-parse (which offers a higher-level, more abstracted content processing experience within the remark ecosystem).","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install mdast-util-from-markdown"],"cli":null},"imports":["import { fromMarkdown } from 'mdast-util-from-markdown'","import type { Extension } from 'mdast-util-from-markdown'","import type { Options } from 'mdast-util-from-markdown'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import fs from 'node:fs/promises'\nimport {fromMarkdown} from 'mdast-util-from-markdown'\n\nasync function parseExample() {\n  // Assume 'example.md' contains '## Hello, *World*!'\n  const doc = await fs.readFile('example.md', 'utf8')\n  const tree = fromMarkdown(doc)\n\n  console.log(JSON.stringify(tree, null, 2))\n  // Expected output:\n  // {\n  //   \"type\": \"root\",\n  //   \"children\": [\n  //     {\n  //       \"type\": \"heading\",\n  //       \"depth\": 2,\n  //       \"children\": [\n  //         { \"type\": \"text\", \"value\": \"Hello, \" },\n  //         { \"type\": \"emphasis\", \"children\": [{ \"type\": \"text\", \"value\": \"World\" }] },\n  //         { \"type\": \"text\", \"value\": \"!\" }\n  //       ]\n  //     }\n  //   ]\n  // }\n}\n\nparseExample().catch(console.error)","lang":"javascript","description":"This quickstart demonstrates how to asynchronously read a Markdown file and parse its content into an mdast syntax tree using the `fromMarkdown` utility.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}