#!/usr/local/bin/perl
# Convert html to xhtml - html2xhtml.pl
#
# Usage : html2xhtml.pl htmlfile.html > xhtmlfile.html
#
# Author : Kyo Nagashima
# E-Mail : kyo@hail2u.net
# URL : http://hail2u.net/
#
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
use strict;
die "Usage: html2xhtml.pl htmlfile.html > xhtmlfile.html\n" unless @ARGV == 1;
use Jcode;
my $j = new Jcode;
my $html = &header;
while (<>) {
$_ = $j->set(\$_)->utf8;
$_ =~ s/^/;
$_ =~ s/<(br|hr|img|link|input|col|base|meta|area|param)(.*?)>/<$1$2 \/>/g;
$_ =~ s/<(a|map)( |.*?)name="(.*?)"( |>)/<$1$2id="$3"$4/;
$html .= $_;
}
print STDOUT $j->set(\$html)->sjis;
exit;
sub header {
my $header = <<"_HEADER_";
_HEADER_
return $header;
}