diff --git a/src/utils/markdown.ts b/src/utils/markdown.ts index f471cb8..37b6fc5 100644 --- a/src/utils/markdown.ts +++ b/src/utils/markdown.ts @@ -16,6 +16,10 @@ const markdownLite = new MarkdownIt({ linkify: true, breaks: true }) { attrs: { target: "_blank", rel: "noopener" } }, ) +// Remove \n from output +markdownLite.renderer.rules.hardbreak = () => "
" +markdownLite.renderer.rules.softbreak = () => "
" + export function renderMarkdown(text: string): string { return markdown.render(text) } diff --git a/tests/unit/markdown.spec.ts b/tests/unit/markdown.spec.ts index bfce0fe..4866fcd 100644 --- a/tests/unit/markdown.spec.ts +++ b/tests/unit/markdown.spec.ts @@ -5,6 +5,6 @@ describe("Render markdown", () => { it("Render markdown lite", () => { const text = "test **bold** ~~strike~~ with `code`, html and https://example.com\nand a new line" const html = renderMarkdownLite(text) - expect(html).to.equal('test bold ~~strike~~ with code, <span>html</span> and https://example.com
\nand a new line') + expect(html).to.equal('test bold ~~strike~~ with code, <span>html</span> and https://example.com
and a new line') }) })