Skip to content

Commit 57b0d05

Browse files
committed
Fix bug where white space only paragraphs showed
1 parent 993a5cb commit 57b0d05

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib/util/wrap.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,28 @@ function wrap(nodes) {
2424

2525
queue.push(node)
2626
} else {
27-
if (queue !== undefined) {
28-
result.push({type: 'paragraph', children: queue})
29-
queue = undefined
30-
}
31-
27+
flush()
3228
result.push(node)
3329
}
3430
}
3531

36-
if (queue !== undefined) {
37-
result.push({type: 'paragraph', children: queue})
38-
}
32+
flush()
3933

4034
return result
35+
36+
function flush() {
37+
if (queue !== undefined) {
38+
if (
39+
queue.length !== 1 ||
40+
queue[0].type !== 'text' ||
41+
(queue[0].value !== ' ' && queue[0].value !== '\n')
42+
) {
43+
result.push({type: 'paragraph', children: queue})
44+
}
45+
}
46+
47+
queue = undefined
48+
}
4149
}
4250

4351
/* Check if there are non-inline MDAST nodes returned.

0 commit comments

Comments
 (0)