骨のダイスを転がそう
2011-08-30
_ [Ruby] nanoc で出力時に、tidy を通す
require 'tidy'
module Nanoc3::Filters
class Tidy < Nanoc3::Filter
def run(content, params={})
::Tidy.path = '/usr/lib/libtidy.so'
::Tidy.open(:wrap => 0, :tidy_mark => false) do |tidy|
tidy.options.indent = true
tidy.options.char_encoding = "raw"
tidy.clean(content)
end
end
end
Nanoc3::Filter.register '::Nanoc3::Filters::Tidy', :tidy
end
というのを、 ./lib に入れておいて Rules で
compile '*' do
if item[:extension] == "html"
filter :tidy
end
end
フィルタの中に、共有ライブラリのパスを書かせる、というのはちょっとダサいな……。
[ツッコミを入れる]