[l2h] Doesn't recognise HTML version 4.01 though version script exists for it

Stuart Rossiter monsieurrigsby at googlemail.com
Thu Dec 10 13:56:31 CET 2009


Nasser,

 Thanks. Yes, it appears that Ubuntu (up to and including Karmic) has
a slightly out of date 2002-2-1 version of latex2html, despite Debian
having it in for ages. (The upcoming Lucid release does have the
latest version: http://packages.ubuntu.com/lucid/latex2html).

Upgraded and the issue still persists. I fixed it manually by changes
to the code as below (haven't coded in Perl for ages, so did it in a
very basic kind of way). I would include a diff file but appears we
can't use attachments here...

    # Collect HTML options and figure out HTML version
    $HTML_OPTIONS = '' unless ($HTML_OPTIONS);
    $HTML_VERSION =~ s/^html|\s+//g;
    local(@HTML_VERSION) = split(/,/, $HTML_VERSION);
    foreach ( @HTML_VERSION ) {
	if (/^[\d\.]+$/) {
	    # Make sure $HTML_VERSION is in the right range and in the right format.
	    $HTML_VERSION = 0.0 + $_;
	    $HTML_VERSION = 2 if ( $HTML_VERSION < 2 );
	    $HTML_VERSION = 9 if ( $HTML_VERSION > 9 );
            if ($HTML_VERSION != 4.01) {
	        $HTML_VERSION = sprintf("%3.1f",$HTML_VERSION);
            }
	} else {
	    $HTML_OPTIONS .= "$_,";
	}
    }
    $HTML_OPTIONS =~ s/\W$//;  # remove any trailing punctuation

    print "...producing markup for HTML version $HTML_VERSION  ";
    print ($HTML_OPTIONS ? "with $HTML_OPTIONS extensions\n\n\n" : "\n\n\n");

    # load the character defs for latin-1, but don't set the charset yet
    &do_require_extension('latin1');
    $charset = $CHARSET = $PREV_CHARSET = '';

    if ($HTML_VERSION =~ /(2.0|3.0|3.2|4.01|4.0|4.1)/) {
	# Require the version specific file
	do { $_ = "$LATEX2HTMLVERSIONS${dd}html$1.pl";
	     if (!(-f $_)) {  s/(\d).(\d+\.pl)$/$1_$2/ };
	     if (!(-f $_)) {  s/(\d)_(\d+\.pl)$/$1-$2/ };
	     require $_ || die "\n*** Could not load $_ ***\n";
	     print "\nHTML version: loading $_\n";
	} unless ($HTML_VERSION =~ /2.0/);
	$DOCTYPE = "-//".(($HTML_VERSION eq "2.0")? "IETF" : "W3C")
	    . "//DTD HTML $HTML_VERSION"
	    .(($HTML_VERSION eq "3.2")? " Final" : "")
	    .(($HTML_VERSION eq "4.01")? " Transitional" : "")
	    .(($HTML_VERSION eq "4.0")? " Transitional" : "");

Basically:
-- only do the sprintf if not 4.01 (needed to make 4.0 stay as 4.0 and not 4)
-- add 4.01 to the if clause (think needs to be before 4.0 since
matches 4.0 otherwise)
-- change regular expressions afterwards from \d.pl to \d+\.pl (can be
two digits after decimal point)
-- add line so that 4.01 also Transitional in the DOCTYPE

Hope that may be of use/interest to other users.

Stuart


More information about the latex2html mailing list