mdast-squeeze-paragraphs
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -7,5 +7,9 @@ 'use strict'; | ||
ast.children = ast.children.filter(function (node) { | ||
return !(node.type == 'paragraph' && !node.children.length); | ||
return node.type != 'paragraph' || node.children.some(function (node) { | ||
return node.type != 'text' || !/^\s*$/.test(node.value); | ||
}); | ||
}); | ||
return ast; | ||
}; | ||
}; |
{ | ||
"name": "mdast-squeeze-paragraphs", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Remove empty paragraphs left from other mdast transformations", | ||
@@ -35,2 +35,3 @@ "author": "Eugene Sharygin <eush77@gmail.com>", | ||
"devDependencies": { | ||
"clone": "^1.0.2", | ||
"mdast": "^0.26.2", | ||
@@ -37,0 +38,0 @@ "tape": "^4.0.0" |
@@ -5,7 +5,12 @@ [![npm](https://nodei.co/npm/mdast-squeeze-paragraphs.png)](https://npmjs.com/package/mdast-squeeze-paragraphs) | ||
[![Build Status](https://travis-ci.org/eush77/mdast-squeeze-paragraphs.svg)](https://travis-ci.org/eush77/mdast-squeeze-paragraphs) | ||
[![Dependency Status][david-badge]][david] | ||
[![Build Status][travis-badge]][travis] [![Dependency Status][david-badge]][david] | ||
Remove empty paragraphs left from other [mdast](http://mdast.js.org) transformations. | ||
Remove empty paragraphs left from other [mdast] transformations. | ||
Paragraph is considered empty if it is composed from whitespace characters. | ||
[mdast]: https://github.com/wooorm/mdast | ||
[travis]: https://travis-ci.org/eush77/mdast-squeeze-paragraphs | ||
[travis-badge]: https://travis-ci.org/eush77/mdast-squeeze-paragraphs.svg | ||
[david]: https://david-dm.org/eush77/mdast-squeeze-paragraphs | ||
@@ -17,5 +22,8 @@ [david-badge]: https://david-dm.org/eush77/mdast-squeeze-paragraphs.png | ||
```js | ||
> mdastSqueezeParagraphs = require('mdast-squeeze-paragraphs') | ||
> mdast.use(mdastStripBadges) | ||
.process('![](http://img.shields.io/)\n\ntext') | ||
'\n\ntext\n' | ||
> mdast.use(mdastStripBadges) | ||
@@ -29,6 +37,16 @@ .use(mdastSqueezeParagraphs) | ||
#### `mdast.use(mdastSqueezeParagraphs)` | ||
```js | ||
var mdastSqueezeParagraphs = require('mdast-squeeze-paragraphs'); | ||
Remove empty paragraphs from the AST. | ||
mdast.use(mdastSqueezeParagraphs) | ||
``` | ||
Modifies AST in-place. | ||
## CLI | ||
``` | ||
mdast -u mdast-squeeze-paragraphs | ||
``` | ||
## Install | ||
@@ -35,0 +53,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3503
11
58
0
3