mdast-squeeze-paragraphs is a focused utility within the unified ecosystem, specifically designed to remove empty paragraphs from an mdast (Markdown Abstract Syntax Tree) tree. It identifies and eliminates paragraphs that contain no non-whitespace characters, often a result of previous tree transformations. The current stable version is 6.0.0. Releases are typically tied to Node.js LTS cycles, with new major versions dropping support for unmaintained Node.js versions. A key differentiator and notable recommendation from its maintainers is that developers should 'probably never!' use this package directly, encouraging users to clean their trees themselves or use the higher-level `remark-squeeze-paragraphs` plugin instead. This package is primarily intended for authors of other mdast utilities or plugins who need fine-grained control over tree sanitation at a low level.
npm install mdast-squeeze-paragraphsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use `squeezeParagraphs` to remove empty paragraphs from an mdast tree created with `unist-builder`.
Ensure your Node.js environment is updated to version 16 or higher to use `mdast-squeeze-paragraphs@6`.
Migrate your import statements from CommonJS `require()` to ESM `import` syntax. Configure your project to support ESM.
Ensure your build tooling and Node.js version are recent enough to correctly resolve packages using `export` maps. Avoid using private APIs.
Update any code that expects a return value from `squeezeParagraphs` to account for `undefined`. The function modifies the tree in place.
Update your project's `@types/mdast` dependency to a compatible version (e.g., `^4.0.0`) if necessary.
Review `unist-util-remove` changelogs for breaking changes if encountering issues after upgrading `mdast-squeeze-paragraphs` to v4.0.0, especially in TypeScript projects.
Consider if `remark-squeeze-paragraphs` or a custom tree transformation better suits your needs before integrating this low-level utility directly.
Convert your import statements to ESM `import { squeezeParagraphs } from 'mdast-squeeze-paragraphs';` and ensure your project is configured for ESM.Upgrade your Node.js environment to version 16 or higher to meet the package's minimum requirement.
Set your TypeScript `tsconfig.json` `compilerOptions.module` to `ESNext` or `NodeNext` and `compilerOptions.moduleResolution` to `NodeNext` for better ESM interoperability. Alternatively, use dynamic `import()` for ESM packages in CJS projects.
Ensure you are using a named import correctly: `import { squeezeParagraphs } from 'mdast-squeeze-paragraphs';`.No dependency data recorded yet.