如何在(内联)代码突出显示中使用Jekyll代码?

如何在(内联)代码突出显示中使用Jekyll代码?,jekyll,liquid,Jekyll,Liquid,例如,如何在代码高亮显示中使用{post.date | date:“%H:%M%p-%-d%b%y”} 到目前为止,我找到的唯一方法是使用{%raw%}{{post.date | date:“%H:%M%p-%-d%b%y”}{%endraw%}。但是,它会将代码段显示为未格式化的文本,而不是正确的内联代码高亮显示 如果我使用 `{{ post.date | date: "%H:%M %p - %-d %b %y" }}` 然后代码被呈现,而不是显示为代码。这就是我如何做的 现场查看: {%

例如,如何在代码高亮显示中使用
{post.date | date:“%H:%M%p-%-d%b%y”}

到目前为止,我找到的唯一方法是使用
{%raw%}{{post.date | date:“%H:%M%p-%-d%b%y”}{%endraw%}
。但是,它会将代码段显示为未格式化的文本,而不是正确的内联代码高亮显示

如果我使用

`{{ post.date | date: "%H:%M %p - %-d %b %y" }}`
然后代码被呈现,而不是显示为代码。

这就是我如何做的

现场查看:

{%highlight html%}
{%raw%}
{site.data.projects%中的项目为%s}
{%if project.publish==true%}

{{project.category}
{{project.description}}

{%endif%} {%endfor%} {%endraw%} {%endhighlight%}
您可以通过组合{%highlight%}和{%raw%}轻松实现这一点 比如说

{% highlight ruby %}
{% raw %}
        ---
        limit: 100
        ---

        {% for post in site.posts limit: page.limit %}

            {
              "title": "{{ post.title }}",
              "date"     : "{{ post.date | date: "%B %d, %Y" }}",

              "excerpt" : "{{ post.excerpt }}",
              {% if post.categories %} "categories"  : [
                {% for category in post.categories %} "{{ category }}"
                {% if forloop.last %}{% else %},{% endif %}
                {% endfor %}
                ],
              {% endif %}
              {% if post.categories == nil %} "categories"  : [],  {% endif %}
              "url": "{{ post.url }}",
              {% if post.tags %} "tags"  : [
                {% for tag in post.tags %} "{{ tag }}"
                {% if forloop.last %}{% else %},{% endif %}
                {% endfor %}
                ]
              {% endif %}
              {% if post.tags == nil %} "tags"  : []  {% endif %}

            }

            {% unless forloop.last %},{% endunless %}

        {% endfor %}
{% endraw %}
{% endhighlight %} 

这适用于块代码高亮显示。但是,如何突出显示以其他方式呈现的Jekyll内联代码?为什么接受这种方式?这看起来像块突出显示。这会为我抛出一个未知的标记错误(尽管它仍然有效)。我最后只使用了{%highlight%}
{% highlight html %}
{% raw %}
  {% include google_analytics.html %}
{% endraw %}
{% endhighlight %}
{% highlight ruby %}
{% raw %}
        ---
        limit: 100
        ---

        {% for post in site.posts limit: page.limit %}

            {
              "title": "{{ post.title }}",
              "date"     : "{{ post.date | date: "%B %d, %Y" }}",

              "excerpt" : "{{ post.excerpt }}",
              {% if post.categories %} "categories"  : [
                {% for category in post.categories %} "{{ category }}"
                {% if forloop.last %}{% else %},{% endif %}
                {% endfor %}
                ],
              {% endif %}
              {% if post.categories == nil %} "categories"  : [],  {% endif %}
              "url": "{{ post.url }}",
              {% if post.tags %} "tags"  : [
                {% for tag in post.tags %} "{{ tag }}"
                {% if forloop.last %}{% else %},{% endif %}
                {% endfor %}
                ]
              {% endif %}
              {% if post.tags == nil %} "tags"  : []  {% endif %}

            }

            {% unless forloop.last %},{% endunless %}

        {% endfor %}
{% endraw %}
{% endhighlight %}