23 gsub(/ +/, " ", title)
24 gsub(/Committee Draft --/, "", title)
28 ss[sid] = ss[sid] "</pre>\n"
33 seencontents && !seenfore && /^[^@]/ {
40 if (!sub(/ +\. .*/, "", s)) {
48 if (match(s, /<[a-zA-Z0-9_]*\.h>/)) {
49 h = substr($0,RSTART,RLENGTH)
54 s = "<a href=\"#" id "\">" s "</a>\n"
57 n = split(id, a, /\./)
72 ss[sid] = ss[sid] "</ul>\n"
82 ss[sid] = ss[sid] "</pre>\n"
87 ss[sid] = ss[sid] "<h1>" $0 "</h1>\n"
89 ss[sid] = ss[sid] "<pre>\n"
100 slevel = split($2,a,/\./)+1
106 # todo hX, back to top
107 ss[sid] = sprintf("<h%s><a name=\"%s\" href=\"#%s\">%s</a></h%s>\n", slevel, sect, sect, $0, slevel)
109 ss[sid] = ss[sid] "<pre>\n"
114 ss[sid] = ss[sid] "<ul>\n"
118 ss[sid] = ss[sid] "</ul>\n"
122 ss[sid] = ss[sid] "<ol>\n"
126 ss[sid] = ss[sid] "</ol>\n"
131 ss[sid] = ss[sid] "<li>"
143 pre = pre "\n</pre>\n"
145 note[nn] = note[nn] "\n" pre
147 ss[sid] = ss[sid] pre
162 ss[sid] = ss[sid] "<!--page " p " -->\n"
167 ss[sid] = ss[sid] sprintf("<p><a name=\"%sp%s\" href=\"#%sp%s\"><small>%s</small></a>\n", sect, $2, sect, $2, $2)
171 /^ ?(Syntax|Semantics|Description|Constraints|Synopsis|Returns|Recommended practice|Implementation limits|Environmental limits)$/ {
172 ss[sid] = ss[sid] "<p><b>" $0 "</b>\n"
177 ss[sid] = ss[sid] $0 "\n"
185 r = " [A-Z1-9][0-9.]*"
187 r = "[ ([][A-Z1-9]\\.[0-9.]*[0-9]"
190 while (match(s, r)) {
191 p = p substr(s,1,RSTART)
192 m = substr(s,RSTART+1,RLENGTH-1)
193 if (m ~ /\.0$/ || m ~ /[4-9][0-9]/ || m ~ /[0-3][0-9][0-9]/ ||
194 substr(s,RSTART+RLENGTH,1) ~ /[a-zA-Z_\-]/)
197 p = p "<a href=\"#" m "\">" m "</a>"
198 s = substr(s,RSTART+RLENGTH)
202 while (match(s, /[Aa]nnex [A-Z]/)) {
203 p = p substr(s,1,RSTART-1)
204 m = substr(s,RSTART,RLENGTH)
205 p = p "<a href=\"#" substr(m,RLENGTH,1) "\">" m "</a>"
206 s = substr(s,RSTART+RLENGTH)
210 while (match(s, /<[a-zA-Z0-9_]*\.h>/)) {
211 p = p substr(s,1,RSTART-1)
212 m = substr(s,RSTART,RLENGTH)
214 p = p "<a href=\"#" header[m] "\">" m "</a>"
217 s = substr(s,RSTART+RLENGTH)
221 # TODO: false positives..
222 while (match(s, /[a-z]opt[ )"]/))
223 s = substr(s,1,RSTART) "<sub>opt</sub>" substr(s,RSTART+RLENGTH-1)
224 if (match(s, /[a-z]opt$/))
225 s = substr(s,1,RSTART) "<sub>opt</sub>"
227 while (match(s, noteid-1 "\\)")) {
228 p = p substr(s,1,RSTART-1)
229 p = p "<sup><a href=\"#note" noteid-1 "\"><b>" noteid-1 ")</b></a></sup>"
230 s = substr(s,RSTART+RLENGTH)
232 if (!match(s, noteid "\\)"))
234 if (noteid==1 && s !~ /\.1\)/)
236 p = p substr(s,1,RSTART-1)
237 p = p "<sup><a href=\"#note" noteid "\"><b>" noteid ")</b></a></sup>"
238 snote[sid] = snote[sid] " " noteid
240 s = substr(s,RSTART+RLENGTH)
243 sub(/^ *Forward references/, "<p><b>&</b>", s)
245 s = "<b>" s "</b><br>"
251 note[nn] = note[nn] s "\n"
253 ss[sid] = ss[sid] s "\n"
257 ss[sid] = ss[sid] "</pre>"
259 print "<html><head><title>" title "</title></head><body>"
261 for (i = 1; i <= sid; i++) {
263 n = split(snote[i],a)
265 s = "<p><b>Footnotes</b>\n"
266 for (j = 1; j <= n; j++) {
267 s = s "<p><small><a name=\"note" a[j] "\" href=\"#note" a[j] "\">" a[j] ")</a>" note[a[j]+0] "</small>\n"
271 print "<p><small><a href=\"#Contents\">Contents</a></small>"
274 print "</body></html>"