MultiMarkdown Filter for nanoc
I recently dropped blog posts rendered via MultiMarkdown. I used MMD to support citations, but this is not a book, this is a website!
So I retired my MultiMarkdown processor for nanoc, the static site generator that I use.
If you need something like it for your project, here it is:
require "systemu"
class MultiMarkdownFilter < Nanoc::Filter
identifier :mmd
type :text
def run(content, args = {})
output = ''
stderr = ''
status = systemu(
[ 'multimarkdown' ],
'stdin' => content,
'stdout' => output,
'stderr' => stderr)
unless status.success?
$stderr.puts stderr
raise RuntimeError, "MultiMarkdown filter failed with status #{status}"
end
output.force_encoding('UTF-8')
end
end
It requires a local installation of the MultiMarkdown binaries. This is not part of any Ruby gem that I’m aware of, so you need to install it separately, e.g. via brew install multimarkdown.
Use it in your Rules file:
compile '/posts/**/*' do
filter :erb
filter :mmd # <----
layout '/default*'
end