Don't add target and rel attrs to links in post content

This commit is contained in:
silverpill 2022-10-09 13:08:48 +00:00
parent f975167ea7
commit 023bdb2a5f
2 changed files with 2 additions and 6 deletions

View file

@ -19,10 +19,6 @@ const markdownLite = new MarkdownIt({ linkify: true, breaks: true })
"strikethrough", "strikethrough",
"image", "image",
]) ])
.use(
MarkdownItLinkAttrs,
{ attrs: { target: "_blank", rel: "noopener" } },
)
// Remove \n from output // Remove \n from output
markdownLite.renderer.rules.hardbreak = () => "<br>" markdownLite.renderer.rules.hardbreak = () => "<br>"

View file

@ -9,11 +9,11 @@ describe("Render markdown", () => {
it("Render markdown lite", () => { it("Render markdown lite", () => {
const html = renderMarkdownLite(text) const html = renderMarkdownLite(text)
expect(html).to.equal('<p># heading</p><p>test <strong>bold</strong> test <em>italic</em> test ~~strike~~ with <code>code</code>, &lt;span&gt;html&lt;/span&gt; and <a href="https://example.com" target="_blank" rel="noopener">https://example.com</a><br>new line</p><p>two new lines and a list:<br>- item 1<br>- item 2</p><p>code block:</p><pre><code>let test\ntest = 1\n</code></pre>') expect(html).to.equal('<p># heading</p><p>test <strong>bold</strong> test <em>italic</em> test ~~strike~~ with <code>code</code>, &lt;span&gt;html&lt;/span&gt; and <a href="https://example.com">https://example.com</a><br>new line</p><p>two new lines and a list:<br>- item 1<br>- item 2</p><p>code block:</p><pre><code>let test\ntest = 1\n</code></pre>')
}) })
it("Render markdown lite inline", () => { it("Render markdown lite inline", () => {
const html = renderMarkdownLiteInline(text) const html = renderMarkdownLiteInline(text)
expect(html).to.equal('# heading<br><br>test <strong>bold</strong> test <em>italic</em> test ~~strike~~ with <code>code</code>, &lt;span&gt;html&lt;/span&gt; and <a href="https://example.com" target="_blank" rel="noopener">https://example.com</a><br>new line<br><br>two new lines and a list:<br>- item 1<br>- item 2<br><br>code block:<br><code>let test test = 1</code>') expect(html).to.equal('# heading<br><br>test <strong>bold</strong> test <em>italic</em> test ~~strike~~ with <code>code</code>, &lt;span&gt;html&lt;/span&gt; and <a href="https://example.com">https://example.com</a><br>new line<br><br>two new lines and a list:<br>- item 1<br>- item 2<br><br>code block:<br><code>let test test = 1</code>')
}) })
}) })