mdast-squeeze-paragraphs
Remove empty paragraphs from mdast syntax trees.
Paragraphs are considered empty if they do not contain non-whitespace
characters.
Installation
npm:
npm install mdast-squeeze-paragraphs
Usage
var u = require('unist-builder')
var squeezeParagraphs = require('mdast-squeeze-paragraphs')
var 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
squeezeParagraphs(tree)
Modifies tree in-place. Returns tree
.
Related
Contribute
See contributing.md
in syntax-tree/mdast
for ways to get
started.
This organisation has a Code of Conduct. By interacting with this
repository, organisation, or community you agree to abide by its terms.
License
MIT © Eugene Sharygin