blob: cc1bf9c6e9b518b34e45f6e3305c1fc4d8e22092 (
plain)
- #!/usr/bin/perl
- package IkiWiki::Plugin::htmlpacker;
- # htmlpacker: HTML code cleaner
- #
- # Copyright 2011 Jonas Smedegaard <dr@jones.dk>
- # Based on htmlbalance which is...
- # Copyright 2008 Simon McVittie <http://smcv.pseudorandom.co.uk/>
- # Licensed under the GNU GPL, version 2, or any later version published by the
- # Free Software Foundation
- use warnings;
- use strict;
- use IkiWiki 3.00;
- sub import {
- hook(type => "getsetup", id => "htmlpacker", call => \&getsetup);
- hook(type => "sanitize", id => "htmlpacker", call => \&sanitize);
- }
- sub getsetup () {
- return
- plugin => {
- safe => 1,
- rebuild => undef,
- },
- }
- sub sanitize (@) {
- my %params=@_;
- my $ret = '';
- eval q{use HTML::Packer};
- error $@ if $@;
- my $packer = HTML::Packer->init();
- $ret = $packer->minify( \$params{content}, { html5 => $config{html5} } );
- return $ret;
- }
- 1
|