当使用Jekyll GitHub Pages中的Redcarpet时,表格无法呈现?

35

默认情况下,使用maruku引擎,编写表格如下:

surround text, etc.

| Tables        | Are           | Cool  |
| ------------- |:-------------:| -----:|
| col 3 is      | right-aligned | $1600 |
| col 2 is      | centered      |   $12 |
| zebra stripes | are neat      |    $1 |

surround text...

如果我使用kramdown而不是redcarpet,这个表格会正确呈现。

但当我切换到redcarpet(在_config.yml中添加markdown: redcarpet),这张表格不再呈现,无论是在本地主机还是GitHub Pages上。

我做错了什么吗?


不,这个话题与Jekyll无关,但是它确实给了我一些提示。 - neizod
5个回答

64

仅在_config.yml中添加markdown: redcarpet是不够的,还需要添加extensions部分,例如:

markdown: redcarpet
redcarpet:
  extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "tables", "with_toc_data"]

1
这是来自Jekyll文档的内容: http://jekyllrb.com/docs/configuration/#redcarpet 这些是Redcarpet扩展, 来自Readme: http://git.io/Xk0CQQ - agustibr

6
对于这个问题,似乎关键的扩展是“表格”。
但是,如果您想使用更多Github风格的标记,则可以在http://sholsinger.com/2014/03/jekyll-github-flavored-markdown上找到更多选项。
结合neizod的答案,我最终使用了。
markdown: redcarpet
redcarpet:
  extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "tables", "strikethrough", "superscript", "with_toc_data"]

2
redcarpet 的 markdown 引擎已不再受 GitHub Pages 支持,可能随时停止工作。
一个非常简单的解决方案是,在网站的 _config.yml 文件中删除 markdown 设置,并在标题/文本和表格之间添加额外的一行。
你可以从 GitHub 帮助中心 获取更多信息,此解决方案取自此问题

0

对于仍然遇到此问题的任何人,以下是如何解决的示例。

如果您的 Markdown 如下所示:

# My Favorite Books 
| Title | Description |
| ----- | ----------- |
| Attack Surface | A sci-fi book by Cory Doctorow showing how currently available tech can be used to oppress | 

在github.org上它可以正常渲染,但在github pages上无法渲染。

解决方案是在您的表格上方添加一个空行,如下所示:

# My Favorite Books 

| Title | Description |
| ----- | ----------- |
| Attack Surface | A sci-fi book by Cory Doctorow showing how currently available tech can be used to oppress | 

感谢LTChen的答案,让我找到了正确的方向。

0

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