我正在使用一个Jekyll页面,该页面显示了带有 markdownified-syntax highlight 代码的项目列表。我有一个包含这样内容的数据文件
# myitems.yaml
id: 'someID'
updated: 'someDate'
items:
- item:
id: "0001"
content: "
*This is italicized*, and so is _this_.
**This is bold**, and so is __this__. &
Use ***italics and bold together*** if you ___have to___.
``` html
<script>alert() some content</script>
<p>paragraph</p>
```"
- item:
id: "0002"
content: "some more content"
所以items[].content
有降价+一些代码要突出显示语法。
我在我的items.html
中使用液体
<ul>
{% for item in site.data.myitems.items %}
<li id="{{item.id}}">
<div>{{ item.content | strip | markdownify}}</div>
</li>
{% endfor %}
</ul>
我使用胭脂语法高亮显示。 markdown被正确解析为html,但html语法高亮显示在items.html
部分不起作用。语法高亮显示在帖子正文中正常工作,但不在{% include items.html %}
<em>This is italicized</em>, and so is <em>this</em>. <strong>This is bold</strong>, and so is <strong>this</strong>. & Use <strong><em>italics and bold together</em></strong> if you <strong><em>have to</em></strong>. <code class="highlighter-rouge">html <script>alert() some content</script> <p>paragraph</p></code>
请帮忙吗?
答案 0 :(得分:1)
通过使用管道而不是常规字符串引号来解决。
-item:
id:"0001"
content: |
*This is italicized*, and so is _this_.
**This is bold**, and so is __this__. &
Use ***italics and bold together*** if you ___have to___.
``` html
<script>alert() some content</script>
<p>paragraph</p>
```