See this old thread: 
https://lists.gnu.org/archive/html/bug-texinfo/2016-02/msg00056.html

Attached is a simple patch to generate better-structured html.

It wraps all nodes (anything processed by _convert_heading_command) in a <div> 
block.
It uses id="xx" instead of <a name="xx">.  When I could, I attached the id to 
existing
elements (or the new <div> block); otherwise I replaced the <a> by a <span>.

If people are concerned about breaking things, I suggested adding --html4 and 
--html5
as new output options.  Only --html5 would create the new-style output.
The existing --html flag would be an alias to --html4.  After a release or two 
we could
change the default so --html is a default for --html5.
--
        --Per Bothner
[email protected]   http://per.bothner.com/
Index: tp/Texinfo/Convert/HTML.pm
===================================================================
--- tp/Texinfo/Convert/HTML.pm	(revision 8445)
+++ tp/Texinfo/Convert/HTML.pm	(working copy)
@@ -1563,7 +1563,7 @@
   my $id = $self->command_id($command);
   if (defined($id) and $id ne '' and !@{$self->{'multiple_pass'}}
       and !$self->in_string()) {
-    return "<a name=\"$id\"></a>";
+    return "<span id=\"$id\"></span>";
   }
   return '';
 }
@@ -2308,8 +2308,10 @@
   }
 
   my $element_id = $self->command_id($command);
-  $result .= "<a name=\"$element_id\"></a>\n" 
+  $result .= "<div cmdname=\"$cmdname\"";
+  $result .= " id=\"$element_id\"" 
     if (defined($element_id) and $element_id ne '');
+  $result .= ">\n";
 
   print STDERR "Process $command "
         .Texinfo::Structuring::_print_root_command_texi($command)."\n"
@@ -2392,6 +2394,7 @@
       }
     }
   }
+  $result .= "</div>\n";
   return $result;
 }
 
@@ -2819,7 +2822,7 @@
   my $id = $self->command_id($command);
   my $label;
   if (defined($id) and $id ne '') {
-    $label = "<a name=\"$id\"></a>";
+    $label = "<span is=\"$id\"></span>";
   } else {
     $label = '';
   }
@@ -3070,7 +3073,7 @@
       }
       my $index_id = $self->command_id ($command);
       if (defined($index_id) and $index_id ne '') {
-        $result .= "\n<a name=\"$index_id\"></a>\n";
+        $result .= "\n<span id=\"$index_id\"></span>\n";
       }
     
       return '<dt>' .$result. '</dt>' . "\n";
@@ -3377,7 +3380,7 @@
   if (defined($index_id) and $index_id ne '' 
       and !@{$self->{'multiple_pass'}} 
       and !$self->in_string()) {
-    my $result = "<a name=\"$index_id\"></a>";
+    my $result = "<span id=\"$index_id\"></span>";
     $result .= "\n" unless ($self->in_preformatted());
     return $result;
   }
@@ -3536,8 +3539,8 @@
        $entries_text .= "</td></tr>\n";
     }
     # a letter and associated indice entries
-    $result .= '<tr><th>' . 
-    "<a name=\"$letter_id{$letter}\">".$self->protect_text($letter).'</a>'
+    $result .= '<tr>' . 
+    "<th id=\"$letter_id{$letter}\">".$self->protect_text($letter)
         .  "</th><td></td><td></td></tr>\n" . $entries_text .
        "<tr><td colspan=\"4\"> ".$self->get_conf('DEFAULT_RULE')."</td></tr>\n";
 
@@ -3566,7 +3569,7 @@
     if ($special_element) {
       my $id = $self->command_id($special_element);
       if ($id ne '') {
-        $result .= "<a name=\"$id\"></a>\n";
+        $result .= "<span id=\"$id\"></span>\n";
       }
       $heading = $self->command_text($special_element);
     } else {
@@ -4054,7 +4057,7 @@
   my $index_label = '';
   my $index_id = $self->command_id($command);
   if (defined($index_id) and $index_id ne '' and !@{$self->{'multiple_pass'}}) {
-    $index_label = "<a name=\"$index_id\"></a>";
+    $index_label = " id=\"$index_id\"";
   }
   my $arguments
     = Texinfo::Common::definition_arguments_content($command);
@@ -4233,7 +4236,7 @@
       }
     }
 
-    return '<dt>'.$index_label.$self->convert_tree({'type' => '_code',
+    return "<dt$index_label>".$self->convert_tree({'type' => '_code',
                              'contents' => [$tree]}) . "</dt>\n";
   } else {
     my $category_prepared = '';
@@ -4271,9 +4274,8 @@
     $type_name .= ' <strong>' . $name . '</strong>' if ($name ne '');
     $type_name .= $arguments_text;
 
-    return "<tr><td align=\"left\">" . $type_name .
-       "</td><td align=\"right\">" . $category_prepared . 
-       $index_label . "</td></tr>\n";
+    return "<tr$index_label><td align=\"left\">" . $type_name .
+       "</td><td align=\"right\">" . $category_prepared . "</td></tr>\n";
   }
 }
 
@@ -4430,7 +4432,7 @@
     $special_element = $element->{'extra'}->{'special_element'};
     my $id = $self->command_id($element);
     if ($id ne '') {
-      $result .= "<a name=\"$id\"></a>\n";
+      $result .= "<span id=\"$id\"></span>\n";
     }
     if ($self->get_conf('HEADERS') 
         # first in page

Reply via email to