2011-07-31 22:51:41 +02:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# coding: utf-8
|
|
|
|
# Copyright muflax <mail@muflax.com>, 2011
|
|
|
|
# License: GNU GPL 3 <http://www.gnu.org/copyleft/gpl.html>
|
|
|
|
|
|
|
|
require 'tidy_ffi'
|
|
|
|
|
2012-02-16 23:17:17 +01:00
|
|
|
class TidyFilter < Nanoc::Filter
|
2011-07-31 22:51:41 +02:00
|
|
|
identifier :tidy
|
|
|
|
def run(content, params={})
|
2012-05-30 06:06:54 +02:00
|
|
|
tidy content
|
2011-07-31 22:51:41 +02:00
|
|
|
end
|
|
|
|
end
|
2012-05-30 06:06:54 +02:00
|
|
|
|
|
|
|
def tidy text
|
|
|
|
TidyFFI::Tidy.new(text,
|
|
|
|
:wrap => 80,
|
|
|
|
:tidy_mark => false,
|
|
|
|
:indent => 1,
|
|
|
|
:char_encoding => "utf8",
|
|
|
|
:hide_comments => true,
|
|
|
|
:show_body_only => "auto"
|
|
|
|
).clean
|
|
|
|
end
|