简体   繁体   English

Pipe “|” 和括号“[”被转换为“\|” 和 Jekyll 代码块 markdown 上的“\[”

[英]Pipe “|” and brackets “[” being converted to “\|” and “\[” on Jekyll code block markdown

I want to display a block of code on a jekyll blog post.我想在 jekyll 博客文章中显示一段代码。 I'm using the following syntax:我正在使用以下语法:

{% highlight javascript %}
{% raw %}<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', '{{ site.google_analytics }}');
</script>{% endraw %}
{% endhighlight %}

However, on the resulting page the '||但是,在结果页面上的 '|| []' caracters are converted to '\|| []' 字符转换为 '\|| \[]'. \[]'。 Here is the rendered output showing that这是呈现的 output 显示

在此处输入图像描述

How do I avoid this?我该如何避免这种情况? Preferrably there should be a solution that didn't involve editing the code snippet itself.最好应该有一个不涉及编辑代码片段本身的解决方案。

Please do note that I'm already enclosing the code snippet with {% raw %} and {% endraw %} .请注意,我已经用{% raw %}{% endraw %}附上了代码片段。

Actually, the error was that I should not use {% raw %} and {% endraw %} when using the {% highlight %} tag.实际上,错误是我在使用{% highlight %}标签时不应该使用{% raw %}{% endraw %}

This is the correct code:这是正确的代码:

{% highlight javascript %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', '{{ site.google_analytics }}');
</script>
{% endhighlight %}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM