4 sed 's/&/\&/g;s/</\</g;s/>/\>/g' |
awk '
7 print "<html><head><title>" $0 "</title></head><body><pre>"
10 while (getline == 1) {
15 print "<a name=\"Contents\" href=\"#Contents\">Contents</a>"
17 while (getline == 1) {
21 if (id ~ /^([1-9A-Z]|Index|Foreword|Introduction|Bibliography)/) {
22 if (match($0, /<[a-zA-Z0-9_]*\.h>/)) {
23 h=substr($0,RSTART,RLENGTH)
28 id = substr(id,1,length(id)-1)
29 s = "<a href=\"#" id "\">" $0
45 !seenindex && /^ *([1-9A-Z]\.|Annex|Index|Foreword|Introduction|Bibliography)/ {
49 if (($0 ~ /^ [1-9]\./ || id ~ /^([A-Z]|[1-9A-Z]\.[1-9][0-9.]*|Index|Foreword|Introduction|Bibliography)$/) &&
50 (NF==1 || $2 ~ /^[A-Zv]/) &&
51 ($0 !~ /^ *[0-9.]+[^0-9]$/)) {
53 id = substr(id,1,length(id)-1)
54 print "<a name=\"" id "\" href=\"#" id "\"><b>" $0 "</b></a>"
62 p = substr($2,1,length($2)-1)
63 print "[<a name=\"p" p "\" href=\"#p" p "\">page " p "</a>] (<a href=\"#Contents\">Contents</a>)"
67 /^ *(Syntax|Semantics|Description|Constraints|Synopsis|Returns)$/ {
76 r = "[ (][A-Z1-9][0-9.]*"
78 r = "[ (][A-Z1-9]\\.[0-9.]*[0-9]"
80 p = p substr(s,1,RSTART)
81 m = substr(s,RSTART+1,RLENGTH-1)
82 if (m ~ /\.0$/ || m ~ /[4-9][0-9]/ || m ~ /[0-3][0-9][0-9]/ || substr(s,RSTART+RLENGTH,1) ~ /[a-zA-Z\-]/)
85 p = p "<a href=\"#" m "\">" m "</a>"
86 s = substr(s,RSTART+RLENGTH)
90 while (match(s, /[Aa]nnex [A-Z]/)) {
91 p = p substr(s,1,RSTART-1)
92 m = substr(s,RSTART,RLENGTH)
93 p = p "<a href=\"#" substr(m,RLENGTH,1) "\">" m "</a>"
94 s = substr(s,RSTART+RLENGTH)
98 while (match(s, /<[a-zA-Z0-9_]*\.h>/)) {
99 p = p substr(s,1,RSTART-1)
100 m = substr(s,RSTART,RLENGTH)
102 p = p "<a href=\"#" header[m] "\">" m "</a>"
105 s = substr(s,RSTART+RLENGTH)
109 while (match(s, note "\\)")) {
110 if (note==1 && s !~ /\.1\)/)
112 p = p substr(s,1,RSTART-1)
113 p = p "<sup><a href=\"#note" note "\"><b>" note ")</b></a></sup>"
115 s = substr(s,RSTART+RLENGTH)
118 if (s ~ /^ *[1-9][0-9]*\) /) {
120 sub(/[0-9]+/,"<sup><a name=\"note&\" href=\"#note&\"><b>&)</b></a></sup>",s)
125 END { print "</pre></body></html>" }'