diff options
Diffstat (limited to 'mdoc2man.awk')
-rw-r--r-- | mdoc2man.awk | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/mdoc2man.awk b/mdoc2man.awk index 856e2d7c5..9135af07e 100644 --- a/mdoc2man.awk +++ b/mdoc2man.awk | |||
@@ -76,19 +76,19 @@ function add(str) { | |||
76 | skip=1 | 76 | skip=1 |
77 | ext=1 | 77 | ext=1 |
78 | if(length(line)&&!(match(line," $")||prenl)) | 78 | if(length(line)&&!(match(line," $")||prenl)) |
79 | add(OFS) | 79 | add(OFS) |
80 | } else if(match(words[w],"^Xc$")) { | 80 | } else if(match(words[w],"^Xc$")) { |
81 | skip=1 | 81 | skip=1 |
82 | ext=0 | 82 | ext=0 |
83 | if(!extopt) | 83 | if(!extopt) |
84 | prenl++ | 84 | prenl++ |
85 | w=nwords | 85 | w=nwords |
86 | } else if(match(words[w],"^Bd$")) { | 86 | } else if(match(words[w],"^Bd$")) { |
87 | skip=1 | 87 | skip=1 |
88 | if(match(words[w+1],"-literal")) { | 88 | if(match(words[w+1],"-literal")) { |
89 | literal=1 | 89 | literal=1 |
90 | prenl++ | 90 | prenl++ |
91 | w=nwords | 91 | w=nwords |
92 | } | 92 | } |
93 | } else if(match(words[w],"^Ed$")) { | 93 | } else if(match(words[w],"^Ed$")) { |
94 | skip=1 | 94 | skip=1 |
@@ -96,7 +96,7 @@ function add(str) { | |||
96 | } else if(match(words[w],"^Ns$")) { | 96 | } else if(match(words[w],"^Ns$")) { |
97 | skip=1 | 97 | skip=1 |
98 | if(!nospace) | 98 | if(!nospace) |
99 | nospace=1 | 99 | nospace=1 |
100 | sub(" $","",line) | 100 | sub(" $","",line) |
101 | } else if(match(words[w],"^No$")) { | 101 | } else if(match(words[w],"^No$")) { |
102 | skip=1 | 102 | skip=1 |
@@ -107,20 +107,20 @@ function add(str) { | |||
107 | add("``") | 107 | add("``") |
108 | add(words[++w]) | 108 | add(words[++w]) |
109 | while(w<nwords&&!match(words[w+1],"^[\\.,]")) | 109 | while(w<nwords&&!match(words[w+1],"^[\\.,]")) |
110 | add(OFS words[++w]) | 110 | add(OFS words[++w]) |
111 | add("''") | 111 | add("''") |
112 | if(!nospace&&match(words[w+1],"^[\\.,]")) | 112 | if(!nospace&&match(words[w+1],"^[\\.,]")) |
113 | nospace=1 | 113 | nospace=1 |
114 | } else if(match(words[w],"^Sq|Ql$")) { | 114 | } else if(match(words[w],"^Sq|Ql$")) { |
115 | skip=1 | 115 | skip=1 |
116 | add("`" words[++w] "'") | 116 | add("`" words[++w] "'") |
117 | if(!nospace&&match(words[w+1],"^[\\.,]")) | 117 | if(!nospace&&match(words[w+1],"^[\\.,]")) |
118 | nospace=1 | 118 | nospace=1 |
119 | } else if(match(words[w],"^Oo$")) { | 119 | } else if(match(words[w],"^Oo$")) { |
120 | skip=1 | 120 | skip=1 |
121 | extopt=1 | 121 | extopt=1 |
122 | if(!nospace) | 122 | if(!nospace) |
123 | nospace=1 | 123 | nospace=1 |
124 | add("[") | 124 | add("[") |
125 | } else if(match(words[w],"^Oc$")) { | 125 | } else if(match(words[w],"^Oc$")) { |
126 | skip=1 | 126 | skip=1 |
@@ -129,9 +129,9 @@ function add(str) { | |||
129 | } | 129 | } |
130 | if(!skip) { | 130 | if(!skip) { |
131 | if(!nospace&&length(line)&&!(match(line," $")||prenl)) | 131 | if(!nospace&&length(line)&&!(match(line," $")||prenl)) |
132 | add(OFS) | 132 | add(OFS) |
133 | if(nospace==1) | 133 | if(nospace==1) |
134 | nospace=0 | 134 | nospace=0 |
135 | } | 135 | } |
136 | if(match(words[w],"^Dd$")) { | 136 | if(match(words[w],"^Dd$")) { |
137 | date=wtail() | 137 | date=wtail() |
@@ -158,69 +158,69 @@ function add(str) { | |||
158 | } else if(match(words[w],"^Re$")) { | 158 | } else if(match(words[w],"^Re$")) { |
159 | prenl++ | 159 | prenl++ |
160 | for(i=nrefauthors-1;i>0;i--) { | 160 | for(i=nrefauthors-1;i>0;i--) { |
161 | add(refauthors[i]) | 161 | add(refauthors[i]) |
162 | if(i>1) | 162 | if(i>1) |
163 | add(", ") | 163 | add(", ") |
164 | } | 164 | } |
165 | if(nrefauthors>1) | 165 | if(nrefauthors>1) |
166 | add(" and ") | 166 | add(" and ") |
167 | add(refauthors[0] ", \\fI" reftitle "\\fP") | 167 | add(refauthors[0] ", \\fI" reftitle "\\fP") |
168 | if(length(refissue)) | 168 | if(length(refissue)) |
169 | add(", " refissue) | 169 | add(", " refissue) |
170 | if(length(refdate)) | 170 | if(length(refdate)) |
171 | add(", " refdate) | 171 | add(", " refdate) |
172 | if(length(refopt)) | 172 | if(length(refopt)) |
173 | add(", " refopt) | 173 | add(", " refopt) |
174 | add(".") | 174 | add(".") |
175 | reference=0 | 175 | reference=0 |
176 | } else if(reference) { | 176 | } else if(reference) { |
177 | if(match(words[w],"^%A$")) { refauthors[nrefauthors++]=wtail() } | 177 | if(match(words[w],"^%A$")) { refauthors[nrefauthors++]=wtail() } |
178 | if(match(words[w],"^%T$")) { | 178 | if(match(words[w],"^%T$")) { |
179 | reftitle=wtail() | 179 | reftitle=wtail() |
180 | sub("^\"","",reftitle) | 180 | sub("^\"","",reftitle) |
181 | sub("\"$","",reftitle) | 181 | sub("\"$","",reftitle) |
182 | } | 182 | } |
183 | if(match(words[w],"^%N$")) { refissue=wtail() } | 183 | if(match(words[w],"^%N$")) { refissue=wtail() } |
184 | if(match(words[w],"^%D$")) { refdate=wtail() } | 184 | if(match(words[w],"^%D$")) { refdate=wtail() } |
185 | if(match(words[w],"^%O$")) { refopt=wtail() } | 185 | if(match(words[w],"^%O$")) { refopt=wtail() } |
186 | } else if(match(words[w],"^Nm$")) { | 186 | } else if(match(words[w],"^Nm$")) { |
187 | if(synopsis) { | 187 | if(synopsis) { |
188 | add(".br") | 188 | add(".br") |
189 | prenl++ | 189 | prenl++ |
190 | } | 190 | } |
191 | n=words[++w] | 191 | n=words[++w] |
192 | if(!length(name)) | 192 | if(!length(name)) |
193 | name=n | 193 | name=n |
194 | if(!length(n)) | 194 | if(!length(n)) |
195 | n=name | 195 | n=name |
196 | add("\\fB" n "\\fP") | 196 | add("\\fB" n "\\fP") |
197 | if(!nospace&&match(words[w+1],"^[\\.,]")) | 197 | if(!nospace&&match(words[w+1],"^[\\.,]")) |
198 | nospace=1 | 198 | nospace=1 |
199 | } else if(match(words[w],"^Nd$")) { | 199 | } else if(match(words[w],"^Nd$")) { |
200 | add("\\- " wtail()) | 200 | add("\\- " wtail()) |
201 | } else if(match(words[w],"^Fl$")) { | 201 | } else if(match(words[w],"^Fl$")) { |
202 | add("\\fB\\-" words[++w] "\\fP") | 202 | add("\\fB\\-" words[++w] "\\fP") |
203 | if(!nospace&&match(words[w+1],"^[\\.,]")) | 203 | if(!nospace&&match(words[w+1],"^[\\.,]")) |
204 | nospace=1 | 204 | nospace=1 |
205 | } else if(match(words[w],"^Ar$")) { | 205 | } else if(match(words[w],"^Ar$")) { |
206 | add("\\fI") | 206 | add("\\fI") |
207 | if(w==nwords) | 207 | if(w==nwords) |
208 | add("file ...\\fP") | 208 | add("file ...\\fP") |
209 | else { | 209 | else { |
210 | add(words[++w] "\\fP") | 210 | add(words[++w] "\\fP") |
211 | while(match(words[w+1],"^\\|$")) | 211 | while(match(words[w+1],"^\\|$")) |
212 | add(OFS words[++w] " \\fI" words[++w] "\\fP") | 212 | add(OFS words[++w] " \\fI" words[++w] "\\fP") |
213 | } | 213 | } |
214 | if(!nospace&&match(words[w+1],"^[\\.,]")) | 214 | if(!nospace&&match(words[w+1],"^[\\.,]")) |
215 | nospace=1 | 215 | nospace=1 |
216 | } else if(match(words[w],"^Cm$")) { | 216 | } else if(match(words[w],"^Cm$")) { |
217 | add("\\fB" words[++w] "\\fP") | 217 | add("\\fB" words[++w] "\\fP") |
218 | while(w<nwords&&match(words[w+1],"^[\\.,:;)]")) | 218 | while(w<nwords&&match(words[w+1],"^[\\.,:;)]")) |
219 | add(words[++w]) | 219 | add(words[++w]) |
220 | } else if(match(words[w],"^Op$")) { | 220 | } else if(match(words[w],"^Op$")) { |
221 | option=1 | 221 | option=1 |
222 | if(!nospace) | 222 | if(!nospace) |
223 | nospace=1 | 223 | nospace=1 |
224 | add("[") | 224 | add("[") |
225 | } else if(match(words[w],"^Pp$")) { | 225 | } else if(match(words[w],"^Pp$")) { |
226 | prenl++ | 226 | prenl++ |
@@ -232,10 +232,10 @@ function add(str) { | |||
232 | add("\\fI") | 232 | add("\\fI") |
233 | w++ | 233 | w++ |
234 | if(match(words[w],"^\\.")) | 234 | if(match(words[w],"^\\.")) |
235 | add("\\&") | 235 | add("\\&") |
236 | add(words[w] "\\fP") | 236 | add(words[w] "\\fP") |
237 | while(w<nwords&&match(words[w+1],"^[\\.,:;)]")) | 237 | while(w<nwords&&match(words[w+1],"^[\\.,:;)]")) |
238 | add(words[++w]) | 238 | add(words[++w]) |
239 | } else if(match(words[w],"^Dv$")) { | 239 | } else if(match(words[w],"^Dv$")) { |
240 | add(".BR") | 240 | add(".BR") |
241 | } else if(match(words[w],"^Em|Ev$")) { | 241 | } else if(match(words[w],"^Em|Ev$")) { |
@@ -254,69 +254,69 @@ function add(str) { | |||
254 | plain=1 | 254 | plain=1 |
255 | add("\\fB") | 255 | add("\\fB") |
256 | while(w<nwords) { | 256 | while(w<nwords) { |
257 | w++ | 257 | w++ |
258 | if(match(words[w],"^Op$")) { | 258 | if(match(words[w],"^Op$")) { |
259 | w++ | 259 | w++ |
260 | add("[") | 260 | add("[") |
261 | words[nwords]=words[nwords] "]" | 261 | words[nwords]=words[nwords] "]" |
262 | } | 262 | } |
263 | if(match(words[w],"^Ar$")) { | 263 | if(match(words[w],"^Ar$")) { |
264 | add("\\fI" words[++w] "\\fP") | 264 | add("\\fI" words[++w] "\\fP") |
265 | } else if(match(words[w],"^[\\.,]")) { | 265 | } else if(match(words[w],"^[\\.,]")) { |
266 | sub(" $","",line) | 266 | sub(" $","",line) |
267 | if(plain) { | 267 | if(plain) { |
268 | add("\\fP") | 268 | add("\\fP") |
269 | plain=0 | 269 | plain=0 |
270 | } | 270 | } |
271 | add(words[w]) | 271 | add(words[w]) |
272 | } else { | 272 | } else { |
273 | if(!plain) { | 273 | if(!plain) { |
274 | add("\\fB") | 274 | add("\\fB") |
275 | plain=1 | 275 | plain=1 |
276 | } | 276 | } |
277 | add(words[w]) | 277 | add(words[w]) |
278 | } | 278 | } |
279 | if(!nospace) | 279 | if(!nospace) |
280 | add(OFS) | 280 | add(OFS) |
281 | } | 281 | } |
282 | sub(" $","",line) | 282 | sub(" $","",line) |
283 | if(plain) | 283 | if(plain) |
284 | add("\\fP") | 284 | add("\\fP") |
285 | } else if(match(words[w],"^Bl$")) { | 285 | } else if(match(words[w],"^Bl$")) { |
286 | oldoptlist=optlist | 286 | oldoptlist=optlist |
287 | if(match(words[w+1],"-bullet")) | 287 | if(match(words[w+1],"-bullet")) |
288 | optlist=1 | 288 | optlist=1 |
289 | else if(match(words[w+1],"-enum")) { | 289 | else if(match(words[w+1],"-enum")) { |
290 | optlist=2 | 290 | optlist=2 |
291 | enum=0 | 291 | enum=0 |
292 | } else if(match(words[w+1],"-tag")) | 292 | } else if(match(words[w+1],"-tag")) |
293 | optlist=3 | 293 | optlist=3 |
294 | else if(match(words[w+1],"-item")) | 294 | else if(match(words[w+1],"-item")) |
295 | optlist=4 | 295 | optlist=4 |
296 | else if(match(words[w+1],"-bullet")) | 296 | else if(match(words[w+1],"-bullet")) |
297 | optlist=1 | 297 | optlist=1 |
298 | w=nwords | 298 | w=nwords |
299 | } else if(match(words[w],"^El$")) { | 299 | } else if(match(words[w],"^El$")) { |
300 | optlist=oldoptlist | 300 | optlist=oldoptlist |
301 | } else if(match(words[w],"^It$")&&optlist) { | 301 | } else if(match(words[w],"^It$")&&optlist) { |
302 | if(optlist==1) | 302 | if(optlist==1) |
303 | add(".IP \\(bu") | 303 | add(".IP \\(bu") |
304 | else if(optlist==2) | 304 | else if(optlist==2) |
305 | add(".IP " ++enum ".") | 305 | add(".IP " ++enum ".") |
306 | else if(optlist==3) { | 306 | else if(optlist==3) { |
307 | add(".TP") | 307 | add(".TP") |
308 | prenl++ | 308 | prenl++ |
309 | if(match(words[w+1],"^Pa|Ev$")) { | 309 | if(match(words[w+1],"^Pa|Ev$")) { |
310 | add(".B") | 310 | add(".B") |
311 | w++ | 311 | w++ |
312 | } | 312 | } |
313 | } else if(optlist==4) | 313 | } else if(optlist==4) |
314 | add(".IP") | 314 | add(".IP") |
315 | } else if(match(words[w],"^Sm$")) { | 315 | } else if(match(words[w],"^Sm$")) { |
316 | if(match(words[w+1],"off")) | 316 | if(match(words[w+1],"off")) |
317 | nospace=2 | 317 | nospace=2 |
318 | else if(match(words[w+1],"on")) | 318 | else if(match(words[w+1],"on")) |
319 | nospace=0 | 319 | nospace=0 |
320 | w++ | 320 | w++ |
321 | } else if(!skip) { | 321 | } else if(!skip) { |
322 | add(words[w]) | 322 | add(words[w]) |