Question

I'm trying to filter content in Nanoc 3 using their :redcarpet filter. My code looks like the following (from the Rules file):

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

I want to pass the option :fenced_code_blocks to the redcarpet extension so that I can highlight syntax. I can't find an example of how to do this. https://github.com/tanoku/redcarpet describes how to do this when using redcarpet. Nanoc's documentation suggests that I can pass options, http://nanoc.stoneship.org/docs/api/3.2/Nanoc3/Filters/Redcarpet.html but nothing I tried worked.

Here's some things that don't work:

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 }

A lot of this doesn't look like proper ruby, and it's just stabs in the dark. I don't actually know what kind of DSL magic goes on in the Rules file. Any help is appreciated.

Was it helpful?

Solution

Using Redcarpet 1.x you can pass options using :options => [ :foo, :bar, :baz ] but it seems that only Redcarpet 2.x supports fenced code blocks, and nanoc does not yet support Redcarpet 2.x.

I can unfortunately not test Redcarpet 2 and the nanoc integration, because Redcarpet 2 causes Ruby to segfault here...

Denis

OTHER TIPS

Nanoc 3.3 supports Redcarpet 2 and the setting combination is now filter :redcarpet, :options => {:fenced_code_blocks => true}.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top