如何将扩展传递给Redcarpet Nanoc过滤器

时间:2011-12-24 16:16:47

标签: ruby nanoc redcarpet

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

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魔法。任何帮助表示赞赏。

2 个答案:

答案 0 :(得分:3)

Nanoc 3.3 supports Redcarpet 2,设置组合现在为filter :redcarpet, :options => {:fenced_code_blocks => true}

答案 1 :(得分:1)

使用Redcarpet 1.x你可以使用:options => [ :foo, :bar, :baz ]传递选项,但似乎只有Redcarpet 2.x支持受防护的代码块,而nanoc还不支持Redcarpet 2.x。

遗憾的是,我不能测试Redcarpet 2和nanoc集成,因为Redcarpet 2会导致Ruby在这里发生段错误...

丹尼斯

相关问题