Skip to content

Commit

Permalink
fix: remove unnessesary line breaks (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed May 27, 2021
1 parent f75419f commit 6879e45
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/core/parser/markdown/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ function parseAsJSON(node: Node, parent: DocusMarkdownNode[]) {

if (node.tagName === 'prose-li') {
// unwrap unwanted paragraphs around `<li>` children
let hasPreviousParagraph = false
node.children = (node.children as Node[]).flatMap(child => {
if (child.tagName === 'prose-paragraph') {
return [
...(child.children as Node[]),
{
if (hasPreviousParagraph) {
// Insert line break before new paragraph
;(child.children as Node[]).unshift({
type: 'element',
tagName: 'br',
properties: {}
}
]
})
}

hasPreviousParagraph = true
return child.children
}
return child
})
Expand Down

1 comment on commit 6879e45

@vercel
Copy link

@vercel vercel bot commented on 6879e45 May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.