【问题标题】:How To Syntax Highlight Jekyll Markup in Jekyll Page如何在 Jekyll 页面中使用语法高亮 Jekyll 标记
【发布时间】:2012-07-24 02:37:57
【问题描述】:

我正在尝试使用由 kramdown 解析的 Markdown 写一篇基于 Jekyll 的帖子,讲述我如何在 Jekyll 的液体模板引擎中实现某些目标。但是,当页面生成时,Jekyll 似乎会感到困惑,如果我打算渲染它的实际降价,或者它是否应该显示为代码。

因此,我怎样才能使以下 sn-p 在我的帖子中显示为突出显示的代码部分?

{% for post in paginator.posts %}
   <div class="author">{{ post.date | date_to_string }}</div>
   <h3><a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></h3>
   <div class="content">
       {{ post.content | split:"<!--break-->" | first }}
   </div>
   <b><a href="{{ BASE_PATH }}{{ post.url }}">continue reading >></a></b>
   <hr/>
{% endfor %}

【问题讨论】:

    标签: markdown jekyll liquid


    【解决方案1】:

    假设你有 Liquid 的词法分析器:

    {% highlight liquid %}
    {% raw %}
    {% for post in paginator.posts %}
       <div class="author">{{ post.date | date_to_string }}</div>
       <h3><a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></h3>
       <div class="content">
           {{ post.content | split:"<!--break-->" | first }}
       </div>
       <b><a href="{{ BASE_PATH }}{{ post.url }}">continue reading >></a></b>
       <hr/>
    {% endfor %}
    {% endraw %}
    {% endhighlight %}
    

    【讨论】:

    • 谢谢你,成功了。虽然我必须使用{% highlight html %},但它不会将liquid 识别为有效的突出显示语言
    • 改用“django”,因为Django templates' syntax 更接近 Liquid。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-30
    • 2018-02-07
    • 1970-01-01
    相关资源
    最近更新 更多