File: gruik2devhelp.awk

package info (click to toggle)
gtk+2.0 2.24.31-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 127,432 kB
  • ctags: 74,609
  • sloc: ansic: 573,219; makefile: 5,155; sh: 4,417; xml: 1,193; python: 891; perl: 749; awk: 72; cpp: 34
file content (29 lines) | stat: -rw-r--r-- 1,173 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /usr/bin/awk -f

BEGIN { print "<?xml version=\"1.0\"?>";
        level=1 }

title == 1 { print "<book title=\"" gensub("^>(.*)</TITLE$","\\1",1) "\" name =\"" name "\" link=\"index.html\">";
             print "<chapters>";
             title=0 }
/^><TITLE/ { title=1 }

/^><DD$/ { level++ }
/^><\/DD$/ { level-- }

intext == 0 && href != "" && /^>([^<>]*)<.*$/  { n=n gensub("^>(.*)<.*$", "\\1",1); }
intext == 1 && href != "" && /^([^<>]*)$/  { n=n $0 " "; }
intext == 0 && href != "" && /^>([^<>]*)$/  { n=n gensub("^>(.*)$", "\\1",1) " "; intext=1 }
intext == 1 && href != "" && /^([^<>]*)<.*$/  { n=n gensub("^([^<>]*)<.*$", "\\1",1); intext=0 }
href != "" && /<\/A$/ { for (i=level; i<lastlevel+1; i++) print "</sub>";
                        print "<sub name=\"" n "\" link=\"" href "\">";
                        href = "";
                        lastlevel = level }
ending != 1 && /^HREF=".*"$/ { href=gensub("^HREF=\"(.*)\"$","\\1",1);
                               n = "";
                               intext = 0 }
/^CLASS="NAVFOOTER"$/ { ending = 1 }

END { for (i=0; i<lastlevel; i++) print "</sub>";
      print "</chapters>";
      print "</book>" }