64a6f97186
2002-09-05 Jonathan Wakely <jw@kayari.org> * docs/html/Makefile: Use more portable shell wildcard. * docs/html/makedoc.awk: Nest elements correctly for XHTML conversion. * docs/html/configopts.html, docs/html/documentation.html, docs/html/explanations.html, docs/html/install.html, docs/html/17_intro/contribute.html, docs/html/17_intro/howto.html, docs/html/17_intro/license.html, docs/html/18_support/howto.html, docs/html/19_diagnostics/howto.html, docs/html/20_util/howto.html, docs/html/21_strings/howto.html, docs/html/22_locale/codecvt.html, docs/html/22_locale/ctype.html, docs/html/22_locale/howto.html, docs/html/22_locale/locale.html, docs/html/22_locale/messages.html, docs/html/23_containers/howto.html, docs/html/24_iterators/howto.html, docs/html/25_algorithms/howto.html, docs/html/26_numerics/howto.html, docs/html/27_io/howto.html, docs/html/ext/howto.html, docs/html/ext/sgiexts.html, docs/html/faq/index.html: Convert to XHTML. * docs/html/faq/index.txt: Regenerate. From-SVN: r56845
70 lines
1.7 KiB
Awk
70 lines
1.7 KiB
Awk
# Take apart bits of HTML and puts them back together again in new and
|
|
# fascinating ways. Copyright (C) 2002 Free Software Foundation, Inc.
|
|
# Contributed by Phil Edwards <pme@gcc.gnu.org>. Simple two-state automaton
|
|
# inspired by Richard Henderson's gcc/mkmap-symver.awk.
|
|
|
|
# 'file' is the name of the file on stdin
|
|
# 'title' is the text to print at the start of the list
|
|
|
|
BEGIN {
|
|
state = "looking";
|
|
entries = 0;
|
|
printf (" <li>%s\n", title);
|
|
printf (" <ul>\n");
|
|
}
|
|
|
|
# Searching for the little table of contents at the top.
|
|
state == "looking" && /^<h1>Contents/ {
|
|
state = "entries";
|
|
next;
|
|
}
|
|
|
|
# Ignore everything else up to that point.
|
|
state == "looking" {
|
|
next;
|
|
}
|
|
|
|
# An entry in the table of contents. Pull that line apart.
|
|
state == "entries" && /<li>/ {
|
|
extract_info($0);
|
|
next;
|
|
}
|
|
|
|
# End of the list. Don't bother reading the rest of the file. (It could
|
|
# also contain more <li>'s, so that would be incorrect as well as wasteful.)
|
|
state == "entries" && /^<\/ul>/ {
|
|
exit;
|
|
}
|
|
|
|
END {
|
|
for (i = 0; i < entries; i++)
|
|
printf (" %s\n", entry[i]);
|
|
printf (" </ul>\n </li>\n\n");
|
|
}
|
|
|
|
function extract_info(line) {
|
|
# thistarget will be things like "#5" or "elsewhere.html"
|
|
match(line,"href=\".*\"");
|
|
thistarget = substr(line,RSTART+6,RLENGTH-7);
|
|
|
|
# take apart the filename
|
|
split(file,X,"/");
|
|
if (thistarget ~ /^#/) {
|
|
# local name, use directory and filename
|
|
target = file thistarget
|
|
} else {
|
|
# different file, only use directory
|
|
target = X[1] "/" thistarget
|
|
}
|
|
|
|
# visible text
|
|
gsub("</a></li>","",line);
|
|
start = index(line,"\">") + 2;
|
|
thistext = substr(line,start);
|
|
|
|
# Assemble and store the HTML for later output.
|
|
entry[entries++] = "<li><a href=\"" target "\">" thistext "</a></li>"
|
|
}
|
|
|
|
# vim:sw=2
|