Remove linebreaks from rendered post content
This commit is contained in:
parent
fa10cd95c0
commit
8c5df16d67
2 changed files with 5 additions and 1 deletions
|
@ -16,6 +16,10 @@ const markdownLite = new MarkdownIt({ linkify: true, breaks: true })
|
||||||
{ attrs: { target: "_blank", rel: "noopener" } },
|
{ attrs: { target: "_blank", rel: "noopener" } },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Remove \n from output
|
||||||
|
markdownLite.renderer.rules.hardbreak = () => "<br>"
|
||||||
|
markdownLite.renderer.rules.softbreak = () => "<br>"
|
||||||
|
|
||||||
export function renderMarkdown(text: string): string {
|
export function renderMarkdown(text: string): string {
|
||||||
return markdown.render(text)
|
return markdown.render(text)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@ describe("Render markdown", () => {
|
||||||
it("Render markdown lite", () => {
|
it("Render markdown lite", () => {
|
||||||
const text = "test **bold** ~~strike~~ with `code`, <span>html</span> and https://example.com\nand a new line"
|
const text = "test **bold** ~~strike~~ with `code`, <span>html</span> and https://example.com\nand a new line"
|
||||||
const html = renderMarkdownLite(text)
|
const html = renderMarkdownLite(text)
|
||||||
expect(html).to.equal('test <strong>bold</strong> ~~strike~~ with <code>code</code>, <span>html</span> and <a href="https://example.com" target="_blank" rel="noopener">https://example.com</a><br>\nand a new line')
|
expect(html).to.equal('test <strong>bold</strong> ~~strike~~ with <code>code</code>, <span>html</span> and <a href="https://example.com" target="_blank" rel="noopener">https://example.com</a><br>and a new line')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue