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

mdast-squeeze-paragraphs

Build Coverage Downloads Size Sponsors Backers Chat

mdast utility to remove empty paragraphs from a tree.

Paragraphs are considered empty if they do not contain non-whitespace characters.

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-squeeze-paragraphs

Use

import {u} from 'unist-builder'
import {squeezeParagraphs} from 'mdast-squeeze-paragraphs'

const tree = u('root', [
  u('paragraph', []),
  u('paragraph', [u('text', 'Alpha')]),
  u('paragraph', [u('text', ' ')])
])

squeezeParagraphs(tree)

console.dir(tree, {depth: null})

Yields:

{ type: 'root',
  children:
   [ { type: 'paragraph',
       children: [ { type: 'text', value: 'Alpha' } ] } ] }

API

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

squeezeParagraphs(tree)

Modifies tree in-place. Returns tree.

Security

Use of mdast-squeeze-paragraphs 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 © Eugene Sharygin

Current Tags

  • 5.2.0                                ...           latest (5 years ago)

15 Versions

  • 5.2.0                                ...           5 years ago
  • 5.1.0                                ...           5 years ago
  • 5.0.0                                ...           5 years ago
  • 4.0.0                                ...           6 years ago
  • 3.0.5                                ...           7 years ago
  • 3.0.4                                ...           7 years ago
  • 3.0.3                                ...           8 years ago
  • 3.0.2                                ...           9 years ago
  • 3.0.1                                ...           10 years ago
  • 3.0.0                                ...           10 years ago
  • 1.1.0                                ...           11 years ago
  • 2.1.1                                ...           11 years ago
  • 2.1.0                                ...           11 years ago
  • 2.0.0                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 15
Dependencies (2)
Dev Dependencies (12)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |