This package provides a highly specialized utility within the HAST (HTML Abstract Syntax Tree) ecosystem, designed to determine if a given node or string constitutes "inter-element whitespace" as defined by HTML specifications. Currently at stable version 3.0.0, the package adheres to the unified collective's release cadence, which typically involves major version bumps for breaking changes and Node.js compatibility updates. Its key differentiator is its precise adherence to HTML's definition of inter-element whitespace, making it crucial for tools that need to correctly manipulate or process HTML ASTs while preserving semantic meaning. It is ESM-only and ships with TypeScript types.
npm install hast-util-whitespaceVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use the `whitespace` function to identify inter-element whitespace in both HAST text nodes and raw strings, showcasing various input types.
Upgrade your Node.js environment to version 16 or newer. If this is not possible, you must remain on `hast-util-whitespace@^2`.
Ensure you are importing only the public `whitespace` function. Avoid direct imports from subpaths or undocumented files within the package.
Ensure that the `thing` argument passed to `whitespace` is either a string or a `hast` Node (typically a `Text` node). Review any code that might pass `null`, `undefined`, or other non-string/non-node values.
Refactor your codebase to use ECMAScript Modules (ESM) `import` statements. If your project is strictly CommonJS, you must remain on `hast-util-whitespace@^1`.
Familiarize yourself with the HTML specification's definition of 'inter-element whitespace' to ensure this utility aligns with your intended use case. For general whitespace checks, you might need custom logic or other utilities.
Ensure your project is configured for ESM by setting `"type": "module"` in your `package.json` or by using `.mjs` file extensions. Also, make sure your Node.js version meets the package requirements (16+ for v3).
Switch to using `import` statements for `hast-util-whitespace`: `import { whitespace } from 'hast-util-whitespace';`. Ensure your project supports ESM.Verify that the value you are passing to `whitespace` is either a string or a HAST `Text` node. Version 3.0.0 introduced stricter validation.
Ensure you are running Node.js 16+ for `hast-util-whitespace@3`. Also, confirm that you are using the correct named import `{ whitespace }` as there is no default export.No dependency data recorded yet.