#!/usr/bin/perl

use HTML::Scrubber;
use Encode;
use Markdown;

sub readfile {
	my $file=shift;
	local $/=undef;
	open (IN, "<:utf8", $file);
	my $ret=<IN>;
	close IN;
	return $ret;
}

sub htmlize {
	my $type=shift;
	my $content=shift;
	
	$content=Encode::encode_utf8($content);
	$content=Markdown::Markdown($content);
	$content=Encode::decode_utf8($content); # comment me out and it goes away..
	sanitize($content);
	#$mommy=~s/(.*)/$1/; # uncomment me and it goes away..
	return;
}

sub sanitize {
	HTML::Scrubber->new(
		# change "img" to "xxx" and it goes away..
		allow => ['img'],
		default => [undef, {title => 1 }],
	)->scrub(shift);
	return;
}

print "a\n";
htmlize(".mdwn", readfile("a")); # comment me out and it goes away..
print "b\n";
htmlize(".mdwn", readfile("b"));
