1 # Take apart bits of HTML and puts them back together again in new and
2 # fascinating ways. Copyright (C) 2002 Free Software Foundation, Inc.
3 # Contributed by Phil Edwards <pme@gcc.gnu.org>. Simple two-state automaton
4 # inspired by Richard Henderson's gcc/mkmap-symver.awk.
6 # 'file' is the name of the file on stdin
7 # 'title' is the text to print at the start of the list
12 printf (" <li>%s\n", title
);
16 # Searching for the little table of contents at the top.
17 state ==
"looking" && /^
<h1
>Contents
/ {
22 # Ignore everything else up to that point.
27 # An entry in the table of contents. Pull that line apart.
28 state ==
"entries" && /<li
>/ {
33 # End of the list. Don't bother reading the rest of the file. (It could
34 # also contain more <li>'s, so that would be incorrect as well as wasteful.)
35 state ==
"entries" && /^
<\
/ul
>/ {
40 for (i =
0; i
< entries
; i
++)
41 printf (" %s\n", entry
[i
]);
42 printf (" </ul>\n </li>\n\n");
45 function extract_info
(line
) {
46 # thistarget will be things like "#5" or "elsewhere.html"
47 match(line
,"href=\".*\"");
48 thistarget =
substr(line
,RSTART+6,RLENGTH-7);
50 # take apart the filename
52 if (thistarget ~
/^
#/) {
53 # local name, use directory and filename
54 target = file thistarget
56 # different file, only use directory
57 target = X
[1] "/" thistarget
61 gsub("</a></li>","",line
);
62 start =
index(line
,"\">") + 2;
63 thistext =
substr(line
,start
);
65 # Assemble and store the HTML for later output.
66 entry
[entries
++] =
"<li><a href=\"" target
"\">" thistext
"</a></li>"