pse*_*ble 3 javascript markdown jstransform pug
说到点子上了
有没有办法让 Pug 将嵌入的 HTML 作为实际 HTML 的一部分包含在 Markdown 文件中,而不仅仅是纯文本?
细节
我有一个使用jstransformer-markdown-it过滤器的 Pug 模板。输入 Markdown 文件已嵌入 HTML。那个 Markdown 文件看起来像这样 ( video.md)
# Watch this video!
This video demonstrates *the power of something something*.
<iframe width="560" height="315" src="https://www.youtube.com/..." frameborder="0" allowfullscreen></iframe>
More Markdown here.
----------------
Run Code Online (Sandbox Code Playgroud)
加载此 Markdown 文件的模板如下所示 ( entry.pug)
html
include head.pug
body
header Article
div(id="main")
article
include:markdown-it video.md
Run Code Online (Sandbox Code Playgroud)
然后像这样 ( index.js)通过 Express 提供。
const express = require('express');
const app = express();
app.set('view engine', 'pug');
app.get('/', (req, res) => {
res.render('entry');
}
app.listen(3000);
Run Code Online (Sandbox Code Playgroud)
在浏览器中加载此内容时,文件中的大部分 Markdown 已成功转换为 HTML。然而,嵌入的标记(iframe在这种情况下)是作为纯文本插入的。
有没有办法让 Pug 将嵌入的 HTML 作为实际 HTML 的一部分包含在 Markdown 文件中,而不仅仅是文本?
有一种方法,但它没有记录! https://github.com/pugjs/pug/issues/2200
改变 include:markdown-it(html)
您还可以安装 markdown-it 插件,并将它们包含在例如 include:markdown-it(plugins=['markdown-it-decorate'])
我还没有找到默认打开插件的方法,所以你需要把它们放在每个 pug 包含中。