1 | ;
|
2 |
|
3 | var remove = require('unist-util-remove');
|
4 |
|
5 |
|
6 | module.exports = function (ast) {
|
7 | return remove(ast, { cascade: false }, isEmptyParagraph);
|
8 | };
|
9 |
|
10 |
|
11 | // Whether paragraph is empty or composed only of whitespace.
|
12 | function isEmptyParagraph (node) {
|
13 | return node.type == 'paragraph' && node.children.every(function (node) {
|
14 | return node.type == 'text' && /^\s*$/.test(node.value);
|
15 | });
|
16 | }
|