简体   繁体   English

Jekyll代码以Markdown突出显示

[英]Jekyll code highlighting with markdown

I want to highlight some code in Jeckyll. 我想在Jeckyll中突出显示一些代码。 With liquid tags it works and with kramdown it doesn't: 使用液体标签可以使用,而使用kramdown则不能:

# This is highlighted
{% highlight C %}
void foo(){
}
{% endhighlight %}

# These aren't
~~~ C
void foo(){
}
~~~

``` C
void foo(){
}
```

The relevant parts of my _config.yml : 我的_config.yml的相关部分:

markdown: kramdown
kramdown:
  input: GFM

Does Jekyll not support markdown code blocks? Jekyll是否不支持降价代码块? If I stick this in github pages, will it work there? 如果我将其粘贴在github页面中,它将在那工作吗?

GitHub Pages uses Pygments as the default syntax highlighter and the Liquid tag that wraps your code generates a lot of additional markup in the resulting HTML to make the code look pretty. GitHub Pages使用Pygments作为默认的语法突出显示工具,包装代码的Liquid标签在生成的HTML中会产生很多额外的标记,以使代码看起来更漂亮。

The back-tick and tilde Markdown notation simply wrap your code in <pre><code class="language-c"> tags. 反勾号和波浪号Markdown表示法只是将您的代码包装在<pre><code class="language-c">标记中。 If you want to use Markdown and have the resulting HTML be syntax highlighted you can add a client-side solution to your HTML templates, such as Highlight.js . 如果要使用Markdown并突出显示结果HTML语法,则可以向HTML模板(例如Highlight.js)添加客户端解决方案。

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

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