[l2h] [patch] $HTML_VERSION fixes

Phil Lanch phil at subtle.clara.co.uk
Wed Mar 12 11:42:40 CET 2003


this is a rather dull patch to do with $HTML_VERSION (more interesting
patches will follow).

On Mon, Mar 10, 2003 at 07:42:54PM +1100, Ross Moore wrote:
[about why no-one is using HTML versions 1, 2.1, 2.2 or 3.1 now]

ok, and it's not important how obsolete HTML versions are handled.  my
point was specifically that the the html*.pl files for 2.1, 2.2 and 3.1
are never (in the Perl sense) required, because those numbers aren't
matched by this regex (probably deliberately) -

|     if ($HTML_VERSION =~ /(2.0|3.0|3.2|4.0|4.1)/) {
| 	# Require the version specific file 
|	...
|     } else {
| 	print "\n You specified an invalid version: $HTML_VERSION\n"
|	    ...
|     # Require all necessary version specific files
| 	foreach ( sort <$LATEX2HTMLVERSIONS${dd}html[1-9].[0-9].pl> ) {
  	                                                 ^
- but nor by this fileglob, because it has a . where it needs a _ and so
doesn't match any files.  this patch just tries to fix the fileglob.

|	    ...
| 	};
|     }

> >    _if_ i have all that right, then the best course of action would be
> >    to stop the code rounding 4.01 to 4.0, and delete html4_1.pl.
> 
> For compatibility with any existing documents or scripts calling
> LaTeX2HTML, it would be best to catch  4_1 and make it  4.01
> where needed, as well as stopping the rounding.

that's what this patch does.  thanks for the point about catching 4.1 -
i hadn't thought of that.  i've also given 4.01 a "Transitional" DOCTYPE
(like 4.0 already has).  and added 4.01 to the POD's list of available
versions.

i moved the definitions of $TeXname et al., which depend on
$HTML_VERSION, to *after* $HTML_VERSION has been parsed; because they
could be defined incorrectly e.g. if $HTML_VERSION were "math,3.0".

finally, i turned some string comparisons with $HTML_VERSION into
numeric comparisons, like most of them already were.

applies from inside the top directory of latex2html with `patch -p1'.
also, please `rm versions/html4_1.pl' (i left that out of the patch to
keep it fairly short).

i hope you find this useful - or can tell me where i've got it wrong.

diff -u -N -r latex2html-rel-2002-2-1/Changes latex2html-2002-2-1-hv/Changes
--- latex2html-rel-2002-2-1/Changes	Sat Apr 10 06:15:08 1999
+++ latex2html-2002-2-1-hv/Changes	Wed Mar 12 06:12:28 2003
@@ -84,6 +84,7 @@
 #  bv = Boris Veytsman <boris at plmsc.psu.edu>
 #  kr = Keith Refson <Keith.Refson at earth.ox.ac.uk>
 #  uw = Uli Wortmann <uli12 at bonk.ethz.ch>
+#  pl = Phil Lanch <phil at subtle.clara.co.uk>
 #
 #
 #------------------- Test Suite Manifest ----------------------------------
diff -u -N -r latex2html-rel-2002-2-1/latex2html.pin latex2html-2002-2-1-hv/latex2html.pin
--- latex2html-rel-2002-2-1/latex2html.pin	Fri Aug 23 06:15:01 2002
+++ latex2html-2002-2-1-hv/latex2html.pin	Wed Mar 12 10:04:36 2003
@@ -3203,7 +3203,7 @@
 sub special_env {
     # Modifies $contents in its caller
     local($next)='';
-    local ($allow) = $HTML_VERSION ge '3.0' ?
+    local ($allow) = $HTML_VERSION >= 3.0 ?
 	 "[^#\$%&~\\\\{}]|\\limits" : "[^^#\$%&~_\\\\{}]";
     #JKR: Use italics instead of bold #HWS: Generalize to include more symbols.
 #    $contents =~ s/^\$(\s*($html_specials_inv_rx|$allow)*\s*)\$(.)?/
@@ -7127,7 +7127,7 @@
 	, "  Jens Lippmann, Marek Rouchal, Martin Wilck and others"
 	    . " -->\n<HTML>\n<HEAD>\n<TITLE>".$title."</TITLE>"
 	, &meta_information($title)
-	,  ($CHARSET && $HTML_VERSION ge "2.1" ? 
+	,  ($CHARSET && $HTML_VERSION >= 2.1 ? 
 	      "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=$this_charset\">" 
 	      : "" )
 	, $LATEX2HTML_META
@@ -9475,7 +9475,7 @@
 sub revert_to_raw_tex {
     local($_) = @_;
     local($character_map) = "";
-    if ( $CHARSET && $HTML_VERSION ge "2.1" ) {
+    if ( $CHARSET && $HTML_VERSION >= 2.1 ) {
 	$character_map = $CHARSET;
 	$character_map =~ tr/-/_/; }
     while (s/$O\s*\d+\s*$C/\{/o) { s/$&/\}/;}
@@ -10333,7 +10333,7 @@
     my($character_map,$enc);
     local ($this);
 
-    if ( $CHARSET && $HTML_VERSION ge "2.1" ) {
+    if ( $CHARSET && $HTML_VERSION >= 2.1 ) {
 	# see if it is a character in the charset
 	$character_map = ((($charset =~ /utf/)&&!$NO_UTF)?
 			  'iso_10646' : $CHARSET );
@@ -15525,12 +15525,6 @@
 	. "\n<META HTTP-EQUIV=\"Content-Style-Type\" CONTENT=\"text/css\">"
 	      unless ($LATEX2HTML_META);
 
-    $TeXname = (($HTML_VERSION ge "3.0")? "T<SMALL>E</SMALL>X" : "TeX");
-    $Laname = (($HTML_VERSION ge "3.0")? "L<SUP><SMALL>A</SMALL></SUP>" : "La");
-    $MFname = (($HTML_VERSION ge "3.0")? "M<SMALL>ETAFONT</SMALL>" : "Metafont");
-    $Xyname = (($HTML_VERSION ge "3.0")? "X<SUB><BIG>Y</BIG></SUB>" : "Xy");
-    $AmSname = (($HTML_VERSION ge "3.0")? "A<SUB><BIG>M</BIG></SUB>S" : "AmS");
-
     $EQN_TAGS = "R" unless ($EQN_TAGS);
     $EQNO_START = "(";
     $EQNO_END   = ")";
@@ -15599,10 +15593,17 @@
     foreach ( @HTML_VERSION ) {
 	if (/^[\d\.]+$/) {
 	    # Make sure $HTML_VERSION is in the right range and in the right format.
+	    #PL: The right format is with either 1 or 2 digits after the decimal
+	    #    point.  (Algorithm: Format it with exactly 2 digits after the
+	    #    point; then, if it ends with `0', remove the trailing `0'.)
 	    $HTML_VERSION = 0.0 + $_;
 	    $HTML_VERSION = 2 if ( $HTML_VERSION < 2 );
 	    $HTML_VERSION = 9 if ( $HTML_VERSION > 9 );
-	    $HTML_VERSION = sprintf("%3.1f",$HTML_VERSION);
+	    $HTML_VERSION = sprintf("%.2f",$HTML_VERSION);
+	    $HTML_VERSION =~ s/0$//;
+	    # For compatibility with earlier versions of LaTeX2HTML,
+	    # in which one had to ask for 4.1 in order to get 4.01:
+	    $HTML_VERSION = 4.01 if $HTML_VERSION == 4.1;
 	} else {
 	    $HTML_OPTIONS .= "$_,";
 	}
@@ -15616,18 +15617,18 @@
     &do_require_extension('latin1');
     $charset = $CHARSET = $PREV_CHARSET = '';
 
-    if ($HTML_VERSION =~ /(2.0|3.0|3.2|4.0|4.1)/) {
+    if ($HTML_VERSION =~ /^(2\.0|3\.0|3\.2|4\.01?)$/) {
 	# 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/ };
+	     if (!(-f $_)) {  s/(\d)\.(\d\d?\.pl)$/$1_$2/ };
+	     if (!(-f $_)) {  s/(\d)_(\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.0")? " Transitional" : "");
+	    .(($HTML_VERSION =~ /^4\.01?$/)? " Transitional" : "");
 
 	if ($HTML_OPTIONS) {
 	    local($ext);
@@ -15649,11 +15650,13 @@
 	    . "  i18n  table  math  frame  latin1  unicode  etc.\n";
 
     # Require all necessary version specific files
-	foreach ( sort <$LATEX2HTMLVERSIONS${dd}html[1-9].[0-9].pl> ) {
-	    last if ( $_ gt "$LATEX2HTMLVERSIONS${dd}html$HTML_VERSION.pl" );
+	foreach ( sort <$LATEX2HTMLVERSIONS${dd}html[1-9]_[0-9]*.pl> ) {
+	    my ($version) = /([1-9]_[0-9][1-9]?)\.pl$/;
+	    $version =~ s/_/./;
+	    last if ( $version > $HTML_VERSION );
 	    do { print "\nloading $_" if ($DEBUG);
 		 require $_; } unless (
-		($NO_SIMPLE_MATH)&&($_ eq "$LATEX2HTMLVERSIONS${dd}html3.1.pl"));
+		($NO_SIMPLE_MATH)&&($_ eq "$LATEX2HTMLVERSIONS${dd}html3_1.pl"));
 	};
 	$STRICT_HTML = 0;
     }
@@ -15664,6 +15667,12 @@
      , '10pt' , 1 , '11pt' , 1 , '12pt' , 1
      , %styles_loaded );
 
+    $TeXname = (($HTML_VERSION >= 3.0)? "T<SMALL>E</SMALL>X" : "TeX");
+    $Laname = (($HTML_VERSION >= 3.0)? "L<SUP><SMALL>A</SMALL></SUP>" : "La");
+    $MFname = (($HTML_VERSION >= 3.0)? "M<SMALL>ETAFONT</SMALL>" : "Metafont");
+    $Xyname = (($HTML_VERSION >= 3.0)? "X<SUB><BIG>Y</BIG></SUB>" : "Xy");
+    $AmSname = (($HTML_VERSION >= 3.0)? "A<SUB><BIG>M</BIG></SUB>S" : "AmS");
+
 
     %declarations =
     ('em' , '<EM></EM>',
@@ -17329,8 +17338,8 @@
 =item B<-html_version> I<list>
 
 Which HTML version should be generated. Currently available are:
-C<2.0>, C<3.0>, C<3.2>, C<4.0>. Some additional options that may be
-added are: C<math> (parse mathematics), C<i18n> (?), 
+C<2.0>, C<3.0>, C<3.2>, C<4.0>, C<4.01>. Some additional options that
+may be added are: C<math> (parse mathematics), C<i18n> (?), 
 C<table> (generate tables), C<frame> (generate frames),
 C<latin1>...C<latin9> (use ISO-Latin-x encoding),
 C<unicode> (generate unicode characters). Separate the options with ',',

-- 
Phil Lanch
D95B33E3
D78D 598D A663 5CF3 2AB2  4593 C989 94B7 D95B 33E3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://tug.org/pipermail/latex2html/attachments/20030312/da065ae8/attachment.bin


More information about the latex2html mailing list