UNPKG

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