mdast-squeeze-paragraphs
Advanced tools
Comparing version 3.0.0 to 3.0.1
18
index.js
'use strict'; | ||
var remove = require('unist-util-remove'); | ||
module.exports = function (ast) { | ||
ast.children = ast.children.filter(function (node) { | ||
return node.type != 'paragraph' || node.children.some(function (node) { | ||
return node.type != 'text' || !/^\s*$/.test(node.value); | ||
}); | ||
return remove(ast, { cascade: false }, isEmptyParagraph); | ||
}; | ||
// Whether paragraph is empty or composed only of whitespace. | ||
function isEmptyParagraph (node) { | ||
return node.type == 'paragraph' && node.children.every(function (node) { | ||
return node.type == 'text' && /^\s*$/.test(node.value); | ||
}); | ||
return ast; | ||
}; | ||
} |
{ | ||
"name": "mdast-squeeze-paragraphs", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Remove empty paragraphs from mdast tree", | ||
@@ -31,6 +31,9 @@ "author": "Eugene Sharygin <eush77@gmail.com>", | ||
], | ||
"dependencies": {}, | ||
"dependencies": { | ||
"unist-util-remove": "^0.2.0" | ||
}, | ||
"devDependencies": { | ||
"tape": "^4.0.0" | ||
"tape": "^4.0.0", | ||
"unist-builder": "^1.0.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
4160
11
0
1
2
+ Addedunist-util-remove@^0.2.0
+ Addedunist-util-is@1.0.0(transitive)
+ Addedunist-util-remove@0.2.1(transitive)