{"id":11289,"library":"mdast-util-phrasing","title":"mdast Phrasing Content Utility","description":"mdast-util-phrasing is a specialized utility within the unified (syntax-tree) ecosystem designed to accurately identify if a given mdast (Markdown Abstract Syntax Tree) node constitutes \"phrasing content.\" This includes elements like text, emphasis, strong, links, and code spans, but notably excludes `html` nodes due to their dual nature as both phrasing and flow content. The package is currently stable at version 4.1.0 and is actively maintained by the unified collective, with major releases typically aligning with Node.js LTS version updates or significant architectural shifts, such as the transition to ESM-only in version 3.0.0. Its core functionality relies on `unist-util-is` for robust node testing, making it a foundational tool for building other mdast utilities that need to differentiate between inline and block-level content in Markdown.","status":"active","version":"4.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/syntax-tree/mdast-util-phrasing","tags":["javascript","unist","mdast","mdast=util","util","utility","markdown","phrasing","typescript"],"install":[{"cmd":"npm install mdast-util-phrasing","lang":"bash","label":"npm"},{"cmd":"yarn add mdast-util-phrasing","lang":"bash","label":"yarn"},{"cmd":"pnpm add mdast-util-phrasing","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used internally for core node type checking functionality.","package":"unist-util-is","optional":false}],"imports":[{"note":"Package is ESM-only since v3.0.0; CommonJS `require` is not supported. There is no default export.","wrong":"const phrasing = require('mdast-util-phrasing')","symbol":"phrasing","correct":"import { phrasing } from 'mdast-util-phrasing'"},{"note":"The package does not have a default export; `phrasing` must be imported as a named export.","wrong":"import phrasing from 'mdast-util-phrasing'","symbol":"phrasing","correct":"import { phrasing } from 'mdast-util-phrasing'"},{"note":"This package ships its own types but works with `mdast` nodes. For `Node` types, import from the `mdast` package.","symbol":"Node","correct":"import type { Node } from 'mdast'"}],"quickstart":{"code":"import { phrasing } from 'mdast-util-phrasing';\nimport { paragraph, strong, text } from 'mdast-builder';\n\n// Example 1: A paragraph is not phrasing content\nconst paragraphNode = paragraph([text('Alpha')]);\nconsole.log(`Is paragraph node phrasing content? ${phrasing(paragraphNode)}`);\n\n// Example 2: A strong node (inline) is phrasing content\nconst strongNode = strong([text('Delta')]);\nconsole.log(`Is strong node phrasing content? ${phrasing(strongNode)}`);\n\n// Example 3: An HTML node is explicitly excluded and returns false\nconst htmlNode = { type: 'html', value: '<span>Hello</span>' };\nconsole.log(`Is HTML node phrasing content? ${phrasing(htmlNode)}`);\n\n// Output:\n// Is paragraph node phrasing content? false\n// Is strong node phrasing content? true\n// Is HTML node phrasing content? false","lang":"typescript","description":"Demonstrates how to import and use the `phrasing` function to determine if an mdast node is phrasing content, showing examples for paragraph, strong, and HTML nodes."},"warnings":[{"fix":"Upgrade your Node.js environment to version 16 or later. If using a bundler, ensure it supports `export` maps.","message":"Version 4.0.0 changed to require Node.js 16 or newer and utilizes an `export` map. Older Node.js versions are no longer supported.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Migrate your codebase to use ECMAScript Modules (ESM) `import` syntax. Ensure your `package.json` has `\"type\": \"module\"` or use `.mjs` file extensions.","message":"Version 3.0.0 switched the package to be ESM-only. CommonJS `require()` statements will no longer work.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Update `mdast-util-phrasing` and its peer dependencies (like `@types/mdast`) to the latest compatible versions to ensure correct type resolution.","message":"Version 2.0.0 updated its dependency on `unist-util-is` which could be a breaking change, particularly for TypeScript users relying on specific type definitions from `unist-util-is`.","severity":"breaking","affected_versions":">=2.0.0 <3.0.0"},{"fix":"If you need to classify `html` nodes, you will need to implement a custom check or use `hast-util-phrasing` for hast trees.","message":"The `phrasing` function explicitly excludes `html` nodes from its check, returning `false` for them. This is because HTML can represent both phrasing and flow content, and the utility takes a conservative approach.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change your import statement to `import { phrasing } from 'mdast-util-phrasing'` and ensure your environment supports ESM (e.g., `type: \"module\"` in `package.json` for Node.js).","cause":"Attempting to use `require()` to import `mdast-util-phrasing` after version 3.0.0, which is an ESM-only package.","error":"ERR_REQUIRE_ESM"},{"fix":"Use a named import: `import { phrasing } from 'mdast-util-phrasing';`","cause":"Incorrectly importing `phrasing` as a default export, when it is a named export.","error":"TypeError: mdast_util_phrasing_1.phrasing is not a function"},{"fix":"Ensure your Node.js version is 16 or newer. Update `@types/mdast` and `mdast-util-phrasing` to their latest compatible versions.","cause":"This TypeScript error often occurs due to mismatched `@types/mdast` versions or using an unsupported Node.js version (pre-16) with `mdast-util-phrasing@4+`.","error":"Module '\"mdast-util-phrasing\"' has no exported member 'phrasing'."}],"ecosystem":"npm"}