微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

忽略 markdown-it 中指定的 HTML 块?

如何解决忽略 markdown-it 中指定的 HTML 块?

我有以下降价:

> Acronis True Image does not allow to clone a single partition; only cloning of an entire disk is possible
> [Acronis True Image: how to clone a disk | KNowledge Base](https://kb.acronis.com/content/56634)

But you can use <a href="https://px.a8.net/svt/ejp?a8mat=3H7MDC+20NGN6+49QG+5YJRM" rel="nofollow">this</a><img border="0" width="1" height="1" src="https://www11.a8.net/0.gif?a8mat=3H7MDC+20NGN6+49QG+5YJRM" alt="">. 

markdown-it 渲染成这样:

<blockquote>
<p>Acronis True Image does not allow to clone a single partition; only cloning of an entire disk is possible    
<a href="https://kb.acronis.com/content/56634">Acronis True Image: how to clone a disk | KNowledge Base</a></p> 
</blockquote>
<p>But you can use &lt;a href=&quot;https://px.a8.net/svt/ejp?a8mat=3H7MDC+20NGN6+49QG+5YJRM&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;&lt;img border=&quot;0&quot; width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://www11.a8.net/0.gif?a8mat=3H7MDC+20NGN6+49QG+5YJRM&quot; alt=&quot;&quot;&gt;.</p>

但实际上我想把它渲染成这样:

<blockquote>
<p>Acronis True Image does not allow to clone a single partition; only cloning of an entire disk is possible    
<a href="https://kb.acronis.com/content/56634">Acronis True Image: how to clone a disk | KNowledge Base</a></p> 
</blockquote>
<p>But you can use <a href="https://px.a8.net/svt/ejp?a8mat=3H7MDC+20NGN6+49QG+5YJRM" rel="nofollow">this</a><img border="0" width="1" height="1" src="https://www11.a8.net/0.gif?a8mat=3H7MDC+20NGN6+49QG+5YJRM" alt="">.</p>

我该怎么做?

解决方法

您需要启用 html 选项:

var md = require('markdown-it')({
  html: true,});

作为 documentedhtml 在默认情况下是禁用的,这解释了它被转义的原因。

选项:

  • html - false。设置 true 以启用源代码中的 HTML 标记。当心!那不安全!您可能需要外部消毒剂来保护 XSS 的输出。最好通过插件扩展功能,而不是 启用 HTML。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。