{"library":"mdast-util-to-nlcst","title":"mdast to nlcst Transformer","description":"mdast-util-to-nlcst is a utility in the unifiedjs ecosystem that transforms an mdast (markdown abstract syntax tree) into an nlcst (natural language concrete syntax tree). Currently at stable version 7.0.1, the package follows a semver release cadence with notable breaking changes often accompanying major version bumps. Its core function is to allow inspection of the natural language content within markdown documents by providing a structured NLCST representation. Unlike other utilities like `mdast-util-to-hast` which converts markdown to HTML, this package focuses specifically on language processing. It is frequently used in conjunction with natural language parsers like `parse-english` or `parse-latin` and is wrapped by the `remark-retext` plugin for a higher-level abstraction. A key limitation is that it does not provide functionality to apply changes from the NLCST back into the original mdast tree.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install mdast-util-to-nlcst"],"cli":null},"imports":["import { toNlcst } from 'mdast-util-to-nlcst'","import type { Options } from 'mdast-util-to-nlcst'","import { ParseEnglish } from 'parse-english'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { fromMarkdown } from 'mdast-util-from-markdown'\nimport { toNlcst } from 'mdast-util-to-nlcst'\nimport { ParseEnglish } from 'parse-english'\nimport { read } from 'to-vfile'\nimport { inspect } from 'unist-util-inspect'\nimport { VFile } from 'vfile'\n\nasync function processMarkdown() {\n  // Simulate reading a markdown file\n  const markdownContent = 'Some *foo*sball.\\n\\nA second sentence.'\n  const file = new VFile({\n    path: 'example.md',\n    value: markdownContent\n  })\n\n  // Convert markdown string to mdast tree\n  const mdast = fromMarkdown(file.value.toString(), { \n    // Extensions might be needed for full markdown features, but not for basic text.\n  })\n\n  // Ensure the mdast tree has positional information, which `fromMarkdown` usually provides.\n  // The `file` object is crucial here as `toNlcst` expects it.\n  const nlcst = toNlcst(mdast, file, ParseEnglish)\n\n  // Inspect the resulting nlcst tree\n  console.log(inspect(nlcst))\n}\n\nprocessMarkdown().catch(console.error)\n","lang":"typescript","description":"Demonstrates converting markdown content from a VFile into an mdast tree, then transforming it into an nlcst tree using `ParseEnglish`, and inspecting the resulting natural language AST.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}