骨のダイスを転がそう

2009|01|02|03|04|05|06|07|10|12|
2010|01|02|03|04|05|06|07|08|09|10|11|
2011|02|03|05|06|07|08|09|10|11|12|
2012|01|02|04|05|09|10|11|12|
2013|01|02|04|
2014|11|
2015|01|04|05|
2016|06|07|08|09|11|
2017|01|02|03|04|
2018|03|

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

フィルタの中に、共有ライブラリのパスを書かせる、というのはちょっとダサいな……。