在Jekyll的markdown代码块中转义双大括号 [英] Escaping double curly braces inside a markdown code block in Jekyll

查看:504
本文介绍了在Jekyll的markdown代码块中转义双大括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jekyll创建一个文档站点,我试图在其中记录一些包含类似于把手的语法的代码.例如{{foo}}.问题在于Jekyll使用液体标签,而无论我做什么,液体处理器都会撕碎我的双头冰壶.

I'm using Jekyll to create a documentation site wherein I am trying to document some code that contains handlebars-like syntax. For example {{foo}}. The problem is that Jekyll uses liquid tags and no matter what I do, my double curlies are getting ripped out by the liquid processor.

顺便说一句,我正在使用kramdown作为降价处理器.

By the way, I'm using kramdown as the markdown processor.

这是我尝试过的事情:

{% highlight html linenos %}
  Hello, my name is {{name}}.
{% endhighlight %}

此代码完全删除了{{name}}部分,因为它认为这是对液体变量的引用.

This one removes the {{name}} section completely because it thinks it's a reference to a liquid variable.

我也尝试过:

{% highlight html linenos %}
  Hello, my name is \{\{name\}\}.
{% endhighlight %}

在这种情况下,我试图转义花括号,但结果是斜线显示在页面中.

In this case, I'm trying to escape the curly braces but the result is that the slashes get rendered into the page.

我什至尝试过:

{% highlight html linenos %}
  Hello, my name is <span>{</span>{name}}.
{% endhighlight %}

诚然,这是一个非常愚蠢的.在这种情况下,因为我已将语法指定为html(需要将其指定),所以span标签将呈现到页面中.

Admittedly this one was pretty dumb. In this case, because I've specified the syntax as html (which it needs to be), the span tag gets rendered into the page.

那么我该如何解决这个问题?

So how in the world can I resolve this?

推荐答案

您正在寻找{% raw %}标记.

{% raw %}
Hello, my name is {{name}}.
{% endraw %}

这篇关于在Jekyll的markdown代码块中转义双大括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆