我怎样才能让Nanoc以多种方式编译同一个项目?

Nat*_*ong 2 nanoc

我想让Nanoc以多种格式编译单个项目 - 特别是将Markdown文件编译为HTML和PDF.据我所知,单个项目只能匹配单个编译规则.

硬链接(ln somefile.md newfile.md)允许我编译同一个文件,好像它是两个不同的文件,但这是一种尴尬的解决方案.

有一个更好的方法吗?

Den*_*yne 6

You can use item representations in order to achieve that. You can compile a single item into multiple output items (representations). Here’s an example:

compile '/stuff/' do
  filter :markdown
end

compile '/stuff/', :rep => :pdf do
  filter :markdown
  filter :pdf
end
Run Code Online (Sandbox Code Playgroud)

The only thing remaining is to provide routing rules that write the two item representations to their right location (also using :rep => ...).