2016-10-16 51 views
0

我正在使用Jekyll頁面,該頁面顯示其標記語法突出顯示代碼的項目列表。我有一個數據文件,這樣Jekyll語法突出顯示數據變量

# 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 %}

items輸出我得到的是:output image

<em>This is italicized</em>, and so is <em>this</em>. <strong>This is bold</strong>, and so is <strong>this</strong>. &amp; Use <strong><em>italics and bold together</em></strong> if you <strong><em>have to</em></strong>. <code class="highlighter-rouge">html &lt;script&gt;alert() some content&lt;/script&gt; &lt;p&gt;paragraph&lt;/p&gt;</code> 

任何幫助嗎?

回答

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> 
    ```