fix: Trailing slash on exported markdown files

closes #6672
This commit is contained in:
Tom Moor
2024-03-21 20:40:36 -04:00
parent 1f7620c6f5
commit a648625700
2 changed files with 19 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
import MarkdownHelper from "./MarkdownHelper";
describe("#MarkdownHelper", () => {
it("should serialize title and text", () => {
expect(MarkdownHelper.toMarkdown({ title: "Title", text: "Test" })).toEqual(
"# Title\n\nTest"
);
});
it("should trim backslashes", () => {
expect(
MarkdownHelper.toMarkdown({
title: "Title",
text: "One\n\\\nTest\n\\",
})
).toEqual("# Title\n\nOne\n\nTest");
});
});

View File

@@ -13,7 +13,7 @@ export default class MarkdownHelper {
*/
static toMarkdown(document: DocumentInterface) {
const text = document.text
.replace(/\n\\\n/g, "\n\n")
.replace(/\n\\(\n|$)/g, "\n\n")
.replace(/“/g, '"')
.replace(/”/g, '"')
.replace(//g, "'")