About
Random notes: A pile of assorted scribblings, snippets and ramblings (mostly about programming and the software that makes my life easier).

Rhesa Rozendaal
Subscribe
Subscribe to a syndicated feed of my weblog.
Categories
Archive
February
Sun Mon Tue Wed Thu Fri Sat
     
8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      
Links

2010. 11. 29

Tidyhtml 0.01


Initial version

I’ve just written a tiny blosxom plugin that cleans up your html. It uses the 1.07_01 dev version of HTML::Tidy, which in turn uses libtidy.

Since this is the first ever version, I’m just going to paste it here. I’ll build a proper release later on.

# Blosxom Plugin: tidyhtml
# Author(s): Rhesa Rozendaal  
# Version: 0.01
# URL: http://oss.rhesa.com/blog/text/blosxom/plugins/tidyhtml

package tidyhtml;
use strict;

# --- Configurable variables -----

my $tidy_config = {
    tidy_mark     => 'no',
    wrap          => '120',
    indent        => 'auto',
    output_xhtml  => 'yes',
    char_encoding => 'utf8',
    doctype       => 'strict',
    add_xml_decl  => 'yes',
    alt_text      => 'photo',
};

# --------------------------------

use HTML::Tidy;

sub last {
    # only operate on html content types.
    return unless $blosxom::header->{-type} =~ /html/;

    $blosxom::output = HTML::Tidy->new( $tidy_config )
                                 ->clean( $blosxom::output );
    return;
}

sub start { 1 }

1;


New version of “tidyhtml”


Slightly cleaned up, and made sure we’re outputting proper utf-8.

Grab tidyhtml 0.03 here and enjoy :-)