mdast-util-compact
mdast utility to make a tree compact
Last updated 5 years ago by wooorm .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mdast-util-compact 
SYNC missed versions from official npm registry.

mdast-util-compact

Build Coverage Downloads Size Sponsors Backers Chat

mdast utility to make trees compact: collapse adjacent text nodes and blockquotes.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install mdast-util-compact

Use

import {u} from 'unist-builder'
import {compact} from 'mdast-util-compact'

const tree = u('strong', [u('text', 'alpha'), u('text', ' '), u('text', 'bravo')])

compact(tree)

console.log(tree)

Yields:

{
  type: 'strong',
  children: [ { type: 'text', value: 'alpha bravo' } ]
}

API

This package exports the following identifiers: compact. There is no default export.

compact(tree)

Walk the tree and collapse nodes. Combines adjacent texts and collapses blockquotes.

Handles positional information properly.

Returns

The given tree.

Security

Use of mdast-util-compact does not involve hast or user content so there are no openings for cross-site scripting (XSS) attacks.

Related

Contribute

See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Current Tags

  • 4.1.0                                ...           latest (5 years ago)

10 Versions

  • 4.1.0                                ...           5 years ago
  • 4.0.0                                ...           5 years ago
  • 3.0.0                                ...           6 years ago
  • 2.0.1                                ...           6 years ago
  • 2.0.0                                ...           6 years ago
  • 1.0.4                                ...           6 years ago
  • 1.0.3                                ...           7 years ago
  • 1.0.2                                ...           8 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (2)
Downloads
Today 0
This Week 2
This Month 3
Last Day 1
Last Week 1
Last Month 1
Dependencies (2)
Dev Dependencies (11)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |