Jekyll在Github上的页面:在Markdown中添加脚注的任何方式?

Bro*_*and 58 jekyll github-pages

我最近转而在Github Pages上使用Jekyll为我的各种博客,并且喜欢我可以将Markdown推送到Github并且他们处理这些处理.我想继续以这种方式使用它(而不是在本地运行Jekyll,只是将预先生成的站点推送到Github),因为如果我不在自己的机器上,Github UI可以轻松添加和调整帖子.

只有一件事我无法弄清楚:我无法让Markdown脚注工作.我正在使用这种风格:

I bet you'd like more information about this sentence [^1].

[^1]: Well lucky for you, I've included more information in footnote form.
Run Code Online (Sandbox Code Playgroud)

我确实找到一个帖子(某个地方)建议为redcarpet markdown处理器启用脚注扩展,但是这也没有做到:

markdown: redcarpet
redcarpet:
  extensions: ["footnotes"]
Run Code Online (Sandbox Code Playgroud)

有没有办法使用Markdown脚注而不预先生成静态网站,然后再将其推送到Github?

Bri*_*lis 63

我使用kramdown进行markdown解析,它可以很好地处理脚注.

_config.yml文件中更改此行:

markdown: redcarpet
Run Code Online (Sandbox Code Playgroud)

至:

markdown: kramdown
Run Code Online (Sandbox Code Playgroud)

  • @BrockBoland我也非常喜欢你. (18认同)

Yi *_* Ou 17

从Jekyll 3.0.0开始,kramdown是默认的Markdown处理器,因此OP问题中的示例现在开箱即用.模式是:

Some text[^1].

Some other text[^2].

The identifier in the square brackets does not have to be numeric[^my_footnote].

[^1]: Some footnote.
[^2]: Other footnote.
[^my_footnote]: This also works fine.
Run Code Online (Sandbox Code Playgroud)


Mar*_*oma 7

红地毯

当你想使用时,redcarpet现在似乎没有方便的解决方案.尽管Redcarpet 3支持使用您使用的语法的脚注,但它不包含在Jekyll中,因为Redcarpet 3删除了Ruby 1.8兼容性(源代码).

解决方案1:使用分叉的Redcarpet 2

请参阅Jerod Santo的此解决方案:

Gemfile使用以下内容添加一个名为Jekyll文件夹根目录的文件:

source "https://rubygems.org"

gem "jekyll"
gem "redcarpet", github: "triplecanopy/redcarpet"
Run Code Online (Sandbox Code Playgroud)

或者 djui/redcarpet

Theny调整你_config.yml

markdown: redcarpet
redcarpet:
  extensions: [footnotes]
Run Code Online (Sandbox Code Playgroud)

解决方案2:Fork Jekyll并包含Redcarpet 3

我不知道最简单的方法是什么.欢迎评论.

Maruku

似乎支持脚注(来源,来源).