2

我正在尝试使用他们的:redcarpet过滤器过滤 Nanoc 3 中的内容。我的代码如下所示(来自规则文件):

compile '/posts/*/' do
    filter :redcarpet
    layout 'default'
end

我想将选项传递:fenced_code_blocks给 redcarpet 扩展,以便我可以突出显示语法。我找不到如何执行此操作的示例。https://github.com/tanoku/redcarpet描述了使用 redcarpet 时如何执行此操作。Nanoc 的文档表明我可以通过选项http://nanoc.stoneship.org/docs/api/3.2/Nanoc3/Filters/Redcarpet.html但我没有尝试过。

以下是一些不起作用的事情:

filter :redcarpet, :fenced_code_blocks => true
filter :redcarpet, :options => [:fenced_code_blocks]
filter :redcarpet, { :options => [:fenced_code_blocks] }
filter :redcarpet, { :options => { :fenced_code_blocks => true } }
filter :redcarpet, { :options => [{ :fenced_code_blocks => true }] }
filter :redcarpet, { :fenced_code_blocks => true }

其中很多看起来不像是真正的红宝石,而且只是在黑暗中刺伤。我实际上不知道规则文件中发生了什么样的 DSL 魔法。任何帮助表示赞赏。

4

2 回答 2

3

Nanoc 3.3 支持 Redcarpet 2并且设置组合现在是filter :redcarpet, :options => {:fenced_code_blocks => true}.

于 2012-04-11T07:06:24.760 回答
1

使用 Redcarpet 1.x,您可以使用传递选项,:options => [ :foo, :bar, :baz ]但似乎只有 Redcarpet 2.x 支持围栏代码块,并且 nanoc 尚不支持 Redcarpet 2.x。

不幸的是,我不能测试 Redcarpet 2 和 nanoc 集成,因为 Redcarpet 2 导致 Ruby 在这里出现段错误......

丹尼斯

于 2011-12-25T11:04:36.617 回答