Socket
Socket
Sign inDemoInstall

mdast-util-compact

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-compact

Make an mdast tree compact


Version published
Weekly downloads
656K
increased by1.9%
Maintainers
2
Weekly downloads
 
Created
Source

mdast-util-compact

Build Coverage Downloads Size Sponsors Backers Chat

mdast utility to make trees compact: collapse text nodes (when possible) and blockquotes (in commonmark mode).

Install

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])

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.

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.

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, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 10 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc