JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 742534
  • Score
    100M100P100Q204118F
  • License MIT

Make an MDAST tree compact

Package Exports

  • mdast-util-compact

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mdast-util-compact) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

mdast-util-compact Build Status Coverage Status

Make an MDAST tree compact: collapse text nodes (when possible), and blockquotes (in commonmark mode).

Installation

npm:

npm install mdast-util-compact

Usage

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' } ] }

API

compact(tree[, commonmark])

Visit the tree and collapse nodes. Combines adjacent text nodes (but not when they represent entities or escapes). If commonmark is true, collapses blockquote nodes.

Handles positional information properly.

Returns

The given tree.

License

MIT © Titus Wormer