Commits

Anonymous committed a5b8f81

List are now indexed as well. Since the is no <LH> in HTML3.2 I just index them by
sequence number. This of course makes links to them position-dependent. Oh well ...
Headings are indexed the old way again. Appending a sequence number would make them
just as position-dependent as links to lists.
It is recommented to create bookmarks to Headings but not to list.
Tables and figures could be indexed based on their captions, if they have one.

  • Participants
  • Parent commits 4aebdfe

Comments (0)

Files changed (1)

adrian/website/HTMLindex.pl

 
 sub main {
     my (@cmd_line) = ($0, @ARGV);
-    my(@index, $index_number);
+    my(@index, $list_index);
+    $list_index = 1;
     my($modifiers) = "(not?|m?any|all|much|little)";
     my($word_ends) = "(ed|ing|sion|tion|ould|ate|ize)";
     my($words) = "(are|on|from|with|we)";
 	    .. m|<HR>|) {
 	    next;
 	}
-	if (m|<P><A HREF=\"\#index\">Goto</A> Index</P>|) {
+	if (m|<P><A HREF=\"\#index\"(\s+NAME[^>]*)?>Goto</A> Index</P>|) {
 	    next;
 	}
 	if (m|(<H[1-6][^>]*>)(.*)(</H[1-6]>)|i) {
 	    # Remove HTML-markup (needs more work to handle HTML ATTRIBUTES).
 	    $_ = $heading;
 	    $_ =~ s/<[^>]+>//g;
-	    # Match a word in Heading somewhat meaningful as a link-label.
+	    # Match a work in Heading somewhat meaningful as a hyper-link.
 	    m|$data_pat|i;
 	    $data = $1;
-	    # Build unique link-target by appending the index-number to the link-label.
-	    $name = $data . $index_number++;
+	    # Build unique link-target by using first letter of each word in HEADING.
+	    $name = $_;
+	    $name =~ s/(\w)\w*/$1/g;
+	    $name =~ s/\W+//g;
 	    # Incorporate the link-target into the current line, which is a HEADING.
 	    # Create an index-line, containing a hyper-link to this HEADING.
 	    $index = $_;
 	    $_ .= "\n<P><A HREF=\"\#index\">Goto</A> Index</P>\n";
 	    s|$data\b|<A NAME="$name">$data</A>|;
 	}
+	if (/(<(D|O|U)L>)/i) {
+	    my($list_tag) = $1;
+	    s|$list_tag|<P><A HREF=\"\#index\" NAME="list$list_index">Goto</A> Index</P>\n$list_tag|;
+	    push @index, "<A HREF=\"\#list$list_index\">List</A> $list_index";
+	    $list_index++;
+	}
 	if (m|<ADDRESS>|i) {
 	    print "<P>This <A NAME=\"index\">index</A> was generated by @cmd_line</P>\n<UL>\n";
 	    print "<LI><P><A HREF=\"#\">Goto</A> Top</P></LI>\n";