Jekyll:使用Markdown语法突出显示代码片段

4

Jekyll 文档中指出,代码高亮是通过使用 Liquid 标签实现的,具体如下:

{% highlight ruby %}
def show
  @widget = Widget(params[:id])
  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @widget }
  end
end
{% endhighlight %}

然而,我更喜欢使用Markdown语法:

```ruby
def foo
  puts 'foo'
end
```

我自己尝试了以下方法:

``` ini
; Disables the splash screen, if it has been compiled into the launcher.
RunLocally=true
```

然而,结果并不如预期那样。

在此输入图片描述


1
我不确定是Github上的缓存问题还是缺少配置设置,但我将markdown: redcarpet添加到_config.yml中,现在代码示例使用markdown语法呈现。 - orschiro
1个回答

10
我不得不将以下内容添加到我的_config.yml文件中,以使我的GitHub Pages语法高亮工作:
markdown: redcarpet
extensions: [fenced_code_blocks]

我不知道为什么GitHub Pages需要fenced_code_blocks,因为在Jekyll中它应该默认就启用了。


这适用于Jekyll 3吗? - ManuelSchneid3r

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接