mdast utility to make trees compact: collapse text nodes (when possible) and blockquotes (in commonmark mode).
npm:
npm install mdast-util-compact
var u = require('unist-builder') var compact = require('mdast-util-compact') var 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' } ] }
compact(tree[, commonmark])Walk the tree and collapse nodes. Combines adjacent texts (but not when they represent entities or escapes). If commonmark is true, collapses blockquotes.
Handles positional information properly.
The given tree.
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, organisation, or community you agree to abide by its terms.