Registry / serialization / mdast-squeeze-paragraphs

mdast-squeeze-paragraphs

JSON →
library6.0.0jsnpmunverified

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-paragraphs
INSTALL
IMPORT
SIG · MDAST-SQUEEZE-PARA
M
mdast-squeeze-paragraphs
serializationjavascriptv6.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

squeezeParagraphs
import { squeezeParagraphs } from 'mdast-squeeze-paragraphs'
const squeezeParagraphs = require('mdast-squeeze-paragraphs')
This package is ESM-only since v5.0.0 and requires Node.js 16+ since v6.0.0. CommonJS `require` is not supported. There is no default export.
squeezeParagraphs
import { squeezeParagraphs } from 'https://esm.sh/mdast-squeeze-paragraphs@6'
For Deno or browser environments, import directly from `esm.sh` specifying the major version.
Wildcard import
import * as mod from 'mdast-squeeze-paragraphs'
import mod from 'mdast-squeeze-paragraphs'
While valid ESM, you would then access the function as `mod.squeezeParagraphs`. There is no default export, so `import mod` will fail.

Demonstrates how to import and use `squeezeParagraphs` to remove empty paragraphs from an mdast tree created with `unist-builder`.

import {squeezeParagraphs} from 'mdast-squeeze-paragraphs'; import {u} from 'unist-builder'; const tree = u('root', [ u('paragraph', []), u('paragraph', [u('text', 'Alpha')]), u('paragraph', [u('text', ' ')]) ]); squeezeParagraphs(tree); console.dir(tree, {depth: null}); // Expected output: // { type: 'root', // children: // [ { type: 'paragraph', // children: [ { type: 'text', value: 'Alpha' } ] } ] }
Debug
Known issues
breakingVersion 6.0.0 changes Node.js compatibility, now requiring Node.js 16 or later.
fix
Ensure your Node.js environment is updated to version 16 or higher to use `mdast-squeeze-paragraphs@6`.
affects: >=6.0.0
breakingThe package transitioned to ESM-only starting from version 5.0.0, removing CommonJS support.
fix
Migrate your import statements from CommonJS `require()` to ESM `import` syntax. Configure your project to support ESM.
affects: >=5.0.0
breakingVersion 6.0.0 introduced the use of an `export` map, which might affect module resolution in some environments or older tooling.
fix
Ensure your build tooling and Node.js version are recent enough to correctly resolve packages using `export` maps. Avoid using private APIs.
affects: >=6.0.0
breakingThe `squeezeParagraphs` function in version 6.0.0 now explicitly returns `undefined`.
fix
Update any code that expects a return value from `squeezeParagraphs` to account for `undefined`. The function modifies the tree in place.
affects: >=6.0.0
breakingVersion 6.0.0 updates its dependency on `@types/mdast`, which might require you to update your own `@types/mdast` version if you encounter type conflicts.
fix
Update your project's `@types/mdast` dependency to a compatible version (e.g., `^4.0.0`) if necessary.
affects: >=6.0.0
breakingVersion 4.0.0 updated `unist-util-remove`, which could potentially introduce breaking changes if your project or its dependents rely on specific internal types or behaviors of `unist-util-remove`.
fix
Review `unist-util-remove` changelogs for breaking changes if encountering issues after upgrading `mdast-squeeze-paragraphs` to v4.0.0, especially in TypeScript projects.
affects: >=4.0.0 <5.0.0
gotchaThe maintainers advise against direct use of `mdast-squeeze-paragraphs` in most application code, recommending higher-level plugins like `remark-squeeze-paragraphs` or manual tree cleaning instead.
fix
Consider if `remark-squeeze-paragraphs` or a custom tree transformation better suits your needs before integrating this low-level utility directly.
affects: always
Errors
Common errors & fixes
TypeError: require is not a function
Attempting to use CommonJS `require()` with an ESM-only package.
fix
Convert your import statements to ESM `import { squeezeParagraphs } from 'mdast-squeeze-paragraphs';` and ensure your project is configured for ESM.
Error: 'mdast-squeeze-paragraphs' requires Node.js 16 or later.
Running the package on an unsupported Node.js version (older than 16).
fix
Upgrade your Node.js environment to version 16 or higher to meet the package's minimum requirement.
TypeError: (0 , mdast_squeeze_paragraphs_1.squeezeParagraphs) is not a function
Incorrect module resolution or transpilation in TypeScript projects targeting CommonJS that try to import an ESM package.
fix
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.
TypeError: squeezeParagraphs is not a function (when using a wildcard or default import)
Attempting to call `mod.squeezeParagraphs` after `import mod from 'mdast-squeeze-paragraphs'` or when `squeezeParagraphs` is not correctly destructured.
fix
Ensure you are using a named import correctly: `import { squeezeParagraphs } from 'mdast-squeeze-paragraphs';`.
Upgrade
Version history
6.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources