Skip to content

Remove extra blank lines between list items in markdown export #1885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/core/src/api/exporters/markdown/markdownExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export function cleanHTMLToMarkdown(cleanHTMLString: string) {
})
.processSync(cleanHTMLString);

return markdownString.value as string;
let result = markdownString.value as string;

// Remove extra blank lines between list items
result = result.replace(/\n\n(?=\d+\.|-|\*)/g, "\n");

return result;
}

export async function blocksToMarkdown<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ exports[`Test ServerBlockNoteEditor > converts to and from markdown (blocksToMar
"## **Heading&#x20;***~~2~~*

Paragraph

* list item

![Example](exampleURL)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
## **Heading&#x20;***~~2~~*

Paragraph

*
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
* Bullet List Item 1

* Bullet List Item 2

1. Numbered List Item 1

2. Numbered List Item 2

* [ ] Check List Item 1
* [x] Check List Item 2
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
* Bullet List Item 1

* Bullet List Item 2

1. Numbered List Item 1
Expand Down
Loading