[l2h] setting ALT attribute in converted images

Stephen Gildea gildea@stop.mail-abuse.org
Wed, 10 Apr 2002 12:53:41 EDT


I would like to be able to control the ALT attribute in the IMG tag
of automatically-generated images.  (I can already do this for
explicit images with \htmladdimg.)  The following patch to
latex2html 2002 (1.63) extends the \htmlimage command to accept an
"alt" parameter, for example, \htmlimage{alt=some text}

--- latext2html-2002/latex2html.pin	Sun Mar 31 00:15:01 2002
+++ latex2html.pin	Sun Apr  7 14:57:00 2002
@@ -4262,6 +4262,11 @@ sub extract_parameters {
     $contents =~ s/$htmlimage_rx/$_ = $2;''/ego;
     $contents =~ s/$htmlimage_pr_rx/$_ .= $2;''/ego;
 
+    # If the document specifies the ALT tag explicitly
+    # with \htmlimage{alt=some text} then use it.
+    s/alt=([^,]+)/$alt="ALT=\"$1\"";''/ie;
+
+    if (!$alt) {
     #...catching all the code for the ALT text.
     local($keep_gt)=1;
     $alt = &flatten_math($contents); undef $keep_gt;
@@ -4283,6 +4288,7 @@ sub extract_parameters {
 	$alt =~ s/(^\s*|\s*$)//mg;
 	$alt = "ALT=\"$alt\"" if ($alt);
     } else { $alt = 'ALT="image"' }
+    }
 
     $psimage++ if ($contents =~ /\.ps/);
 #    $contents =~ s/\s//g;	# Remove spaces   Why ?