【问题标题】:Jekyll: Highlighting code snippets using markdown syntaxJekyll:使用 markdown 语法高亮代码片段
【发布时间】:2013-11-30 16:29:50
【问题描述】:

Jekyll docs 状态代码高亮是使用 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
```

但是,结果看起来并不应有的样子。

【问题讨论】:

  • 我不完全确定这是 Github 上的缓存问题还是缺少配置设置,但我将 markdown: redcarpet 添加到 _config.yml,现在代码示例使用 markdown 语法呈现。

标签: markdown jekyll github-flavored-markdown


【解决方案1】:

我必须将以下内容添加到我的 _config.yml 中才能使我的 GitHub Pages 语法高亮工作:

markdown: redcarpet
extensions: [fenced_code_blocks]

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

【讨论】:

  • 这适用于 Jekyll 3 吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-11-09
  • 1970-01-01
  • 2016-06-09
  • 2019-06-13
  • 2021-12-19
  • 1970-01-01
相关资源
最近更新 更多