【问题标题】:Markdown not interpreted by Ruby redcarpet correctlyRuby redcarpet 未正确解释 Markdown
【发布时间】:2015-09-23 08:13:24
【问题描述】:

我的slate 项目有以下降价:

---
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 构建它,结果是一样的。

不过,如果我把这个标记放在其他解释器上,比如http://stackedit.io,那就没问题了。

所以我怀疑我的降价解释器 (Ruby 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

谁能说出可能的原因是什么?或者如何恢复?

【问题讨论】:

  • 你使用的是什么操作系统?
  • 我无法在我的计算机上使用相同的 Gemfile 重现此问题。您是否以某种方式更改了slate 引擎?通常代码 sn-ps 在另一列中显示为slate
  • 你的 markdown 对我来说编译得很好。我只需要评论therubyracer gem,因为它给我带来了一些悬而未决的问题(并安装nodejs 包)。
  • @AlexeyShein 我在 Win7 x64 上。我很确定 markdown 语法是正确的,因为其他解释器运行良好。我只是想得到一些提示,至少,关于可能的原因在哪里?日志文件,或重新安装哪个 gem,等等。

标签: ruby rubygems redcarpet slate


【解决方案1】:

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


更新 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

【讨论】:

    猜你喜欢
    • 2010-09-27
    • 2021-10-06
    • 2013-03-19
    • 1970-01-01
    • 2019-11-04
    • 2014-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多