We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f918a06 commit cbf947dCopy full SHA for cbf947d
index.js
@@ -3,7 +3,16 @@
3
4
module.exports = function (ast) {
5
ast.children = ast.children.filter(function (node) {
6
- return !(node.type == 'paragraph' && !node.children.length);
+ if (node.type == 'paragraph') {
7
+ // Remove empty text nodes.
8
+ node.children = node.children.filter(function (node) {
9
+ return node.type != 'text' || !/^\s*$/.test(node.value);
10
+ });
11
+
12
+ return node.children.length;
13
+ }
14
15
+ return true;
16
});
17
18
return ast;
test/input.json
@@ -20,7 +20,12 @@
20
},
21
{
22
"type": "paragraph",
23
- "children": []
+ "children": [
24
+ {
25
+ "type": "text",
26
+ "value": "\n"
27
28
+ ]
29
30
31
0 commit comments