红色地毯(Ruby redcarpet)未正确解析Markdown

5

我有一个用于我的slate项目的以下markdown:

---
title: API Reference
language_tabs:
  - http
  - javascript
search: true
---
# Getting Started
## Logout
# Call Management
## Call States
```javascript
{
}
```
## Call Notification
## Caller ID Called Number
## Call Information During Call

我使用middleman来服务一个网站:bundle exec middleman server。然而,最后一个子标题没有正确解释为h2标签(截图)。如果我通过rake build构建它,结果是一样的。 但是,如果我将这个markdown放在其他解释器上,比如http://stackedit.io,那就没问题了。 所以我怀疑我的markdown解释器(Ruby redcarpet)有些问题。控制台上没有任何警告/错误消息。我尝试了不同版本的redcarpet。虽然错误不同,但解释后的HTML也是错误的。我想某些Ruby和Redcarpet的组合会使其正常工作?
这是我的config.rb
# Markdown
set :markdown_engine, :redcarpet
set :markdown,
fenced_code_blocks: true,
smartypants: true,
disable_indented_code_blocks: true,
prettify: true,
tables: true,
with_toc_data: true,
no_intra_emphasis: true

有人能告诉我可能的原因是什么吗?或者如何恢复?

在此输入图片描述


你使用的是哪个操作系统? - Alexey Shein
我无法在我的电脑上用相同的Gemfile重现这个问题。你是否以某种方式更改了“Slate”引擎?通常,代码片段会在“Slate”的另一列中显示。 - haradwaith
1
你的Markdown在我这里编译得很好。我只是不得不注释掉therubyracer gem,因为它会导致一些卡顿问题(并安装nodejs包代替)。 - Alexey Shein
@AlexeyShein,我使用的是Win7 x64。我很确信markdown语法是正确的,因为其他解释器都能正常工作。我只是想得到一些提示,至少能知道可能出现问题的地方在哪里?是日志文件,还是需要重新安装宝石包,或者其他什么原因。 - Joy
1个回答

1

更新到最新版本 (3.3.3) 的 RedCarpet 解决了我的问题。


更新1

好吧,它仍然存在问题:我无法在Markdown文件中更改甚至一个字母。否则,生成的HTML标记会再次出现问题...


更新2

问题终于解决了。将RedCarpet切换为kramdown就解决了。

我的config.rb文件:

# set :markdown_engine, :redcarpet
set :markdown_engine, :kramdown
set :markdown,
    fenced_code_blocks: true,
    smartypants: true,
    disable_indented_code_blocks: true,
    prettify: true,
    tables: true,
    with_toc_data: true,
    no_intra_emphasis: true

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