1 # table-of-contents extractor
2 # Copyright (C) 1999 Sandy Harris.
4 # This program is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License as published by the
6 # Free Software Foundation; either version 2 of the License, or (at your
7 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # RCSID $Id: contents.awk,v 1.1 2001/01/29 01:18:07 sandy Exp $
16 # initialise indent counter
18 # define variables for section breaks
19 b0 = "==================================================="
20 b1 = "---------------------------------------------------"
21 b2 = "\t------------------------------------------"
22 # TURN OFF HTML formatting
28 print "Section headings printed, indentation shows structure"
33 print "HTML file: " "<a href=\"" FILENAME "\">" FILENAME "</a>"
37 # actual printing is done by tagged() function
38 # which adds tag if last line was <a name=...>
42 gsub(/.*<h1>/, "", text)
43 gsub(/<\/h1>/, "", text)
49 gsub(/.*<h2>/, "", text)
50 gsub(/<\/h2>/, "", text)
56 gsub(/.*<h3>/, "", text)
57 gsub(/<\/h3>/, "", text)
63 gsub(/.*<h4>/, "", text)
64 gsub(/<\/h4>/, "", text)
67 # if current line is not header
68 # and we have stored tag from <a name=..> line
69 # make link to that tag
72 print "[ <a href=\"" FILENAME "#" name "\">" name "</a>" " ]"
75 # for <a name=whatever> lines
76 # save name in a variable
77 # not printed until we see next line
80 # strip anything before or after name tag
81 gsub(/.*<a name=/, "", name)
83 # strip quotes off name
90 print "Docs & script by Sandy Harris"
96 function tagged(text) { # print header with tag if available
97 if( length(name) ) # > 0 if previous line was a name
98 print tabs "<a href=\"" FILENAME "#" name "\">" text "</a>"
105 print "Linux FreeSWAN HTML documents"
106 print "Automatically generated Table of Contents"
107 print "Bug reports to the mailing list: linux-ipsec@clinet.fi"