简体   繁体   中英

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

在此处输入图像描述

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

Actually, the error was that I should not use {% raw %} and {% endraw %} when using the {% highlight %} tag.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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