{"id":29125779,"url":"https://github.com/syntax-tree/mdast-util-compact","last_synced_at":"2025-06-29T22:03:41.706Z","repository":{"id":57293475,"uuid":"63488730","full_name":"syntax-tree/mdast-util-compact","owner":"syntax-tree","description":"utility to make an mdast tree compact","archived":false,"fork":false,"pushed_at":"2023-07-07T15:47:19.000Z","size":109,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-21T22:53:20.311Z","etag":null,"topics":["compact","mdast","mdast-util","syntax-tree","unist","util"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syntax-tree.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"unifiedjs","open_collective":"unified"}},"created_at":"2016-07-16T15:17:09.000Z","updated_at":"2024-04-28T09:55:45.000Z","dependencies_parsed_at":"2024-05-01T10:56:56.269Z","dependency_job_id":null,"html_url":"https://github.com/syntax-tree/mdast-util-compact","commit_stats":{"total_commits":95,"total_committers":3,"mean_commits":"31.666666666666668","dds":0.03157894736842104,"last_synced_commit":"3b343e394218d1691c5780862ce62efa02c555fb"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/syntax-tree/mdast-util-compact","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fmdast-util-compact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fmdast-util-compact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fmdast-util-compact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fmdast-util-compact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syntax-tree","download_url":"https://codeload.github.com/syntax-tree/mdast-util-compact/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fmdast-util-compact/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262331877,"owners_count":23294931,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compact","mdast","mdast-util","syntax-tree","unist","util"],"created_at":"2025-06-29T22:03:40.983Z","updated_at":"2025-06-29T22:03:41.680Z","avatar_url":"https://github.com/syntax-tree.png","language":"JavaScript","readme":"# mdast-util-compact\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[mdast][] utility to make trees compact by collapsing adjacent text nodes and\nblockquotes.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`compact(tree)`](#compacttree)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Security](#security)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package is a utility that lets you make a tree, after changes, more similar\nto how it would be parsed.\n\n## When should I use this?\n\nProbably never!\nYou should try and keep your trees clean yourself.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install mdast-util-compact\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {compact} from 'https://esm.sh/mdast-util-compact@5'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {compact} from 'https://esm.sh/mdast-util-compact@5?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {u} from 'unist-builder'\nimport {compact} from 'mdast-util-compact'\n\nconst tree = u('strong', [u('text', 'alpha'), u('text', ' '), u('text', 'bravo')])\n\ncompact(tree)\n\nconsole.log(tree)\n```\n\nYields:\n\n```js\n{\n  type: 'strong',\n  children: [ { type: 'text', value: 'alpha bravo' } ]\n}\n```\n\n## API\n\nThis package exports the identifier [`compact`][api-compact].\nThere is no default export.\n\n### `compact(tree)`\n\nMake an mdast tree compact by merging adjacent text nodes and block quotes.\n\n###### Parameters\n\n*   `tree` ([`Node`][node])\n    — tree to change\n\n###### Returns\n\nNothing (`undefined`).\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports no additional types.\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `mdast-util-compact@^5`,\ncompatible with Node.js 16.\n\n## Security\n\nUse of `mdast-util-compact` does not involve **[hast][]** or user content so\nthere are no openings for [cross-site scripting (XSS)][xss] attacks.\n\n## Related\n\n*   [`mdast-squeeze-paragraphs`](https://github.com/syntax-tree/mdast-squeeze-paragraphs)\n    — remove empty paragraphs\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for\nways to get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/syntax-tree/mdast-util-compact/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/mdast-util-compact/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-compact.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/mdast-util-compact\n\n[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-compact.svg\n\n[downloads]: https://www.npmjs.com/package/mdast-util-compact\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size\u0026query=$.size.compressedSize\u0026url=https://deno.bundlejs.com/?q=mdast-util-compact\n\n[size]: https://bundlejs.com/?q=mdast-util-compact\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[health]: https://github.com/syntax-tree/.github\n\n[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[mdast]: https://github.com/syntax-tree/mdast\n\n[node]: https://github.com/syntax-tree/mdast#node\n\n[hast]: https://github.com/syntax-tree/hast\n\n[api-compact]: #compacttree\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fmdast-util-compact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Fmdast-util-compact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fmdast-util-compact/lists"}