{"id":11282,"library":"mdast-squeeze-paragraphs","title":"mdast Paragraph Squeezer","description":"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.","status":"active","version":"6.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/syntax-tree/mdast-squeeze-paragraphs","tags":["javascript","unist","mdast","mdast-util","util","utility","squeeze","remove","empty","typescript"],"install":[{"cmd":"npm install mdast-squeeze-paragraphs","lang":"bash","label":"npm"},{"cmd":"yarn add mdast-squeeze-paragraphs","lang":"bash","label":"yarn"},{"cmd":"pnpm add mdast-squeeze-paragraphs","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"const squeezeParagraphs = require('mdast-squeeze-paragraphs')","symbol":"squeezeParagraphs","correct":"import { squeezeParagraphs } from 'mdast-squeeze-paragraphs'"},{"note":"For Deno or browser environments, import directly from `esm.sh` specifying the major version.","symbol":"squeezeParagraphs","correct":"import { squeezeParagraphs } from 'https://esm.sh/mdast-squeeze-paragraphs@6'"},{"note":"While valid ESM, you would then access the function as `mod.squeezeParagraphs`. There is no default export, so `import mod` will fail.","wrong":"import mod from 'mdast-squeeze-paragraphs'","symbol":"Wildcard import","correct":"import * as mod from 'mdast-squeeze-paragraphs'"}],"quickstart":{"code":"import {squeezeParagraphs} from 'mdast-squeeze-paragraphs';\nimport {u} from 'unist-builder';\n\nconst tree = u('root', [\n  u('paragraph', []),\n  u('paragraph', [u('text', 'Alpha')]),\n  u('paragraph', [u('text', ' ')])\n]);\n\nsqueezeParagraphs(tree);\n\nconsole.dir(tree, {depth: null});\n// Expected output:\n// { type: 'root',\n//   children:\n//    [ { type: 'paragraph',\n//        children: [ { type: 'text', value: 'Alpha' } ] } ] }","lang":"typescript","description":"Demonstrates how to import and use `squeezeParagraphs` to remove empty paragraphs from an mdast tree created with `unist-builder`."},"warnings":[{"fix":"Ensure your Node.js environment is updated to version 16 or higher to use `mdast-squeeze-paragraphs@6`.","message":"Version 6.0.0 changes Node.js compatibility, now requiring Node.js 16 or later.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Migrate your import statements from CommonJS `require()` to ESM `import` syntax. Configure your project to support ESM.","message":"The package transitioned to ESM-only starting from version 5.0.0, removing CommonJS support.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Ensure your build tooling and Node.js version are recent enough to correctly resolve packages using `export` maps. Avoid using private APIs.","message":"Version 6.0.0 introduced the use of an `export` map, which might affect module resolution in some environments or older tooling.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Update any code that expects a return value from `squeezeParagraphs` to account for `undefined`. The function modifies the tree in place.","message":"The `squeezeParagraphs` function in version 6.0.0 now explicitly returns `undefined`.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Update your project's `@types/mdast` dependency to a compatible version (e.g., `^4.0.0`) if necessary.","message":"Version 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.","severity":"breaking","affected_versions":">=6.0.0"},{"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.","message":"Version 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`.","severity":"breaking","affected_versions":">=4.0.0 <5.0.0"},{"fix":"Consider if `remark-squeeze-paragraphs` or a custom tree transformation better suits your needs before integrating this low-level utility directly.","message":"The 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.","severity":"gotcha","affected_versions":"always"}],"env_vars":null,"search_vec":"'6.0.0':54 'abstract':26 'author':117 'charact':41 'clean':95 'contain':36 'control':129 'current':50 'cycl':62 'design':17 'develop':84 'differenti':75 'direct':91 'drop':67 'ecosystem':15 'elimin':33 'empti':20,147 'encourag':92 'fine':127 'fine-grain':126 'focus':10 'grain':128 'higher':103 'higher-level':102 'identifi':31 'instead':110 'intend':115 'javascript':137 'key':74 'level':104,136 'low':135 'lts':61 'maintain':81 'major':65 'markdown':25 'mdast':1,5,24,120,139,141 'mdast-squeeze-paragraph':4 'mdast-util':140 'need':125 'never':87 'new':64 'node.js':60,71 'non':39 'non-whitespac':38 'notabl':77 'often':42 'packag':90,112 'paragraph':2,7,21,34,108 'plugin':109,123 'previous':46 'primarili':114 'probabl':86 'recommend':78 'releas':55 'remark':106 'remark-squeeze-paragraph':105 'remov':19,146 'result':44 'sanit':132 'specif':16 'squeez':6,107,145 'squeezer':3 'stabl':51 'support':68 'syntax':27 'tie':58 'transform':48 'tree':28,29,47,97,131 'typescript':148 'typic':57 'unifi':14 'unist':138 'unmaintain':70 'use':88,100 'user':93 'util':11,121,142,143,144 'version':52,66,72 'whitespac':40 'within':12","created_at":"2026-04-19T13:37:11.183735+00:00","updated_at":"2026-04-19T13:37:11.183735+00:00","problems":[{"fix":"Convert your import statements to ESM `import { squeezeParagraphs } from 'mdast-squeeze-paragraphs';` and ensure your project is configured for ESM.","cause":"Attempting to use CommonJS `require()` with an ESM-only package.","error":"TypeError: require is not a function"},{"fix":"Upgrade your Node.js environment to version 16 or higher to meet the package's minimum requirement.","cause":"Running the package on an unsupported Node.js version (older than 16).","error":"Error: 'mdast-squeeze-paragraphs' requires Node.js 16 or later."},{"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.","cause":"Incorrect module resolution or transpilation in TypeScript projects targeting CommonJS that try to import an ESM package.","error":"TypeError: (0 , mdast_squeeze_paragraphs_1.squeezeParagraphs) is not a function"},{"fix":"Ensure you are using a named import correctly: `import { squeezeParagraphs } from 'mdast-squeeze-paragraphs';`.","cause":"Attempting to call `mod.squeezeParagraphs` after `import mod from 'mdast-squeeze-paragraphs'` or when `squeezeParagraphs` is not correctly destructured.","error":"TypeError: squeezeParagraphs is not a function (when using a wildcard or default import)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/syntax-tree/mdast-squeeze-paragraphs","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/mdast-squeeze-paragraphs","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","web-framework","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}