Print this page
9718 update mandoc to 1.14.4
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/mandoc/mdoc_html.c
+++ new/usr/src/cmd/mandoc/mdoc_html.c
1 -/* $Id: mdoc_html.c,v 1.294 2017/07/15 17:57:51 schwarze Exp $ */
1 +/* $Id: mdoc_html.c,v 1.310 2018/07/27 17:49:31 schwarze Exp $ */
2 2 /*
3 3 * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
4 - * Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze <schwarze@openbsd.org>
4 + * Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
5 5 *
6 6 * Permission to use, copy, modify, and distribute this software for any
7 7 * purpose with or without fee is hereby granted, provided that the above
8 8 * copyright notice and this permission notice appear in all copies.
9 9 *
10 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 17 */
18 18 #include "config.h"
19 19
20 20 #include <sys/types.h>
21 21
22 22 #include <assert.h>
23 23 #include <ctype.h>
24 24 #include <stdio.h>
25 25 #include <stdlib.h>
26 26 #include <string.h>
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
27 27 #include <unistd.h>
28 28
29 29 #include "mandoc_aux.h"
30 30 #include "mandoc.h"
31 31 #include "roff.h"
32 32 #include "mdoc.h"
33 33 #include "out.h"
34 34 #include "html.h"
35 35 #include "main.h"
36 36
37 -#define INDENT 5
38 -
39 37 #define MDOC_ARGS const struct roff_meta *meta, \
40 38 struct roff_node *n, \
41 39 struct html *h
42 40
43 41 #ifndef MIN
44 42 #define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b))
45 43 #endif
46 44
47 45 struct htmlmdoc {
48 46 int (*pre)(MDOC_ARGS);
49 47 void (*post)(MDOC_ARGS);
50 48 };
51 49
52 50 static char *cond_id(const struct roff_node *);
53 -static void print_mdoc_head(MDOC_ARGS);
51 +static void print_mdoc_head(const struct roff_meta *,
52 + struct html *);
54 53 static void print_mdoc_node(MDOC_ARGS);
55 54 static void print_mdoc_nodelist(MDOC_ARGS);
56 55 static void synopsis_pre(struct html *,
57 56 const struct roff_node *);
58 57
59 -static void mdoc_root_post(MDOC_ARGS);
60 -static int mdoc_root_pre(MDOC_ARGS);
58 +static void mdoc_root_post(const struct roff_meta *,
59 + struct html *);
60 +static int mdoc_root_pre(const struct roff_meta *,
61 + struct html *);
61 62
62 63 static void mdoc__x_post(MDOC_ARGS);
63 64 static int mdoc__x_pre(MDOC_ARGS);
64 65 static int mdoc_ad_pre(MDOC_ARGS);
65 66 static int mdoc_an_pre(MDOC_ARGS);
66 67 static int mdoc_ap_pre(MDOC_ARGS);
67 68 static int mdoc_ar_pre(MDOC_ARGS);
68 69 static int mdoc_bd_pre(MDOC_ARGS);
69 70 static int mdoc_bf_pre(MDOC_ARGS);
70 71 static void mdoc_bk_post(MDOC_ARGS);
71 72 static int mdoc_bk_pre(MDOC_ARGS);
72 73 static int mdoc_bl_pre(MDOC_ARGS);
73 74 static int mdoc_cd_pre(MDOC_ARGS);
74 75 static int mdoc_cm_pre(MDOC_ARGS);
75 76 static int mdoc_d1_pre(MDOC_ARGS);
76 77 static int mdoc_dv_pre(MDOC_ARGS);
77 78 static int mdoc_fa_pre(MDOC_ARGS);
78 79 static int mdoc_fd_pre(MDOC_ARGS);
79 80 static int mdoc_fl_pre(MDOC_ARGS);
80 81 static int mdoc_fn_pre(MDOC_ARGS);
81 82 static int mdoc_ft_pre(MDOC_ARGS);
82 83 static int mdoc_em_pre(MDOC_ARGS);
83 84 static void mdoc_eo_post(MDOC_ARGS);
84 85 static int mdoc_eo_pre(MDOC_ARGS);
85 86 static int mdoc_er_pre(MDOC_ARGS);
86 87 static int mdoc_ev_pre(MDOC_ARGS);
87 88 static int mdoc_ex_pre(MDOC_ARGS);
88 89 static void mdoc_fo_post(MDOC_ARGS);
89 90 static int mdoc_fo_pre(MDOC_ARGS);
90 91 static int mdoc_ic_pre(MDOC_ARGS);
91 92 static int mdoc_igndelim_pre(MDOC_ARGS);
92 93 static int mdoc_in_pre(MDOC_ARGS);
93 94 static int mdoc_it_pre(MDOC_ARGS);
94 95 static int mdoc_lb_pre(MDOC_ARGS);
95 96 static int mdoc_li_pre(MDOC_ARGS);
96 97 static int mdoc_lk_pre(MDOC_ARGS);
97 98 static int mdoc_mt_pre(MDOC_ARGS);
98 99 static int mdoc_ms_pre(MDOC_ARGS);
99 100 static int mdoc_nd_pre(MDOC_ARGS);
100 101 static int mdoc_nm_pre(MDOC_ARGS);
101 102 static int mdoc_no_pre(MDOC_ARGS);
102 103 static int mdoc_ns_pre(MDOC_ARGS);
103 104 static int mdoc_pa_pre(MDOC_ARGS);
104 105 static void mdoc_pf_post(MDOC_ARGS);
105 106 static int mdoc_pp_pre(MDOC_ARGS);
106 107 static void mdoc_quote_post(MDOC_ARGS);
107 108 static int mdoc_quote_pre(MDOC_ARGS);
108 109 static int mdoc_rs_pre(MDOC_ARGS);
109 110 static int mdoc_sh_pre(MDOC_ARGS);
110 111 static int mdoc_skip_pre(MDOC_ARGS);
111 112 static int mdoc_sm_pre(MDOC_ARGS);
112 113 static int mdoc_ss_pre(MDOC_ARGS);
113 114 static int mdoc_st_pre(MDOC_ARGS);
114 115 static int mdoc_sx_pre(MDOC_ARGS);
115 116 static int mdoc_sy_pre(MDOC_ARGS);
116 117 static int mdoc_va_pre(MDOC_ARGS);
117 118 static int mdoc_vt_pre(MDOC_ARGS);
118 119 static int mdoc_xr_pre(MDOC_ARGS);
119 120 static int mdoc_xx_pre(MDOC_ARGS);
120 121
121 122 static const struct htmlmdoc __mdocs[MDOC_MAX - MDOC_Dd] = {
122 123 {NULL, NULL}, /* Dd */
123 124 {NULL, NULL}, /* Dt */
124 125 {NULL, NULL}, /* Os */
125 126 {mdoc_sh_pre, NULL }, /* Sh */
126 127 {mdoc_ss_pre, NULL }, /* Ss */
127 128 {mdoc_pp_pre, NULL}, /* Pp */
128 129 {mdoc_d1_pre, NULL}, /* D1 */
129 130 {mdoc_d1_pre, NULL}, /* Dl */
130 131 {mdoc_bd_pre, NULL}, /* Bd */
131 132 {NULL, NULL}, /* Ed */
132 133 {mdoc_bl_pre, NULL}, /* Bl */
133 134 {NULL, NULL}, /* El */
134 135 {mdoc_it_pre, NULL}, /* It */
135 136 {mdoc_ad_pre, NULL}, /* Ad */
136 137 {mdoc_an_pre, NULL}, /* An */
137 138 {mdoc_ap_pre, NULL}, /* Ap */
138 139 {mdoc_ar_pre, NULL}, /* Ar */
139 140 {mdoc_cd_pre, NULL}, /* Cd */
140 141 {mdoc_cm_pre, NULL}, /* Cm */
141 142 {mdoc_dv_pre, NULL}, /* Dv */
142 143 {mdoc_er_pre, NULL}, /* Er */
143 144 {mdoc_ev_pre, NULL}, /* Ev */
144 145 {mdoc_ex_pre, NULL}, /* Ex */
145 146 {mdoc_fa_pre, NULL}, /* Fa */
146 147 {mdoc_fd_pre, NULL}, /* Fd */
147 148 {mdoc_fl_pre, NULL}, /* Fl */
148 149 {mdoc_fn_pre, NULL}, /* Fn */
149 150 {mdoc_ft_pre, NULL}, /* Ft */
150 151 {mdoc_ic_pre, NULL}, /* Ic */
151 152 {mdoc_in_pre, NULL}, /* In */
152 153 {mdoc_li_pre, NULL}, /* Li */
153 154 {mdoc_nd_pre, NULL}, /* Nd */
154 155 {mdoc_nm_pre, NULL}, /* Nm */
155 156 {mdoc_quote_pre, mdoc_quote_post}, /* Op */
156 157 {mdoc_ft_pre, NULL}, /* Ot */
157 158 {mdoc_pa_pre, NULL}, /* Pa */
158 159 {mdoc_ex_pre, NULL}, /* Rv */
159 160 {mdoc_st_pre, NULL}, /* St */
160 161 {mdoc_va_pre, NULL}, /* Va */
161 162 {mdoc_vt_pre, NULL}, /* Vt */
162 163 {mdoc_xr_pre, NULL}, /* Xr */
163 164 {mdoc__x_pre, mdoc__x_post}, /* %A */
164 165 {mdoc__x_pre, mdoc__x_post}, /* %B */
165 166 {mdoc__x_pre, mdoc__x_post}, /* %D */
166 167 {mdoc__x_pre, mdoc__x_post}, /* %I */
167 168 {mdoc__x_pre, mdoc__x_post}, /* %J */
168 169 {mdoc__x_pre, mdoc__x_post}, /* %N */
169 170 {mdoc__x_pre, mdoc__x_post}, /* %O */
170 171 {mdoc__x_pre, mdoc__x_post}, /* %P */
171 172 {mdoc__x_pre, mdoc__x_post}, /* %R */
172 173 {mdoc__x_pre, mdoc__x_post}, /* %T */
173 174 {mdoc__x_pre, mdoc__x_post}, /* %V */
174 175 {NULL, NULL}, /* Ac */
175 176 {mdoc_quote_pre, mdoc_quote_post}, /* Ao */
176 177 {mdoc_quote_pre, mdoc_quote_post}, /* Aq */
177 178 {mdoc_xx_pre, NULL}, /* At */
178 179 {NULL, NULL}, /* Bc */
179 180 {mdoc_bf_pre, NULL}, /* Bf */
180 181 {mdoc_quote_pre, mdoc_quote_post}, /* Bo */
181 182 {mdoc_quote_pre, mdoc_quote_post}, /* Bq */
182 183 {mdoc_xx_pre, NULL}, /* Bsx */
183 184 {mdoc_xx_pre, NULL}, /* Bx */
184 185 {mdoc_skip_pre, NULL}, /* Db */
185 186 {NULL, NULL}, /* Dc */
186 187 {mdoc_quote_pre, mdoc_quote_post}, /* Do */
187 188 {mdoc_quote_pre, mdoc_quote_post}, /* Dq */
188 189 {NULL, NULL}, /* Ec */ /* FIXME: no space */
189 190 {NULL, NULL}, /* Ef */
190 191 {mdoc_em_pre, NULL}, /* Em */
191 192 {mdoc_eo_pre, mdoc_eo_post}, /* Eo */
192 193 {mdoc_xx_pre, NULL}, /* Fx */
193 194 {mdoc_ms_pre, NULL}, /* Ms */
194 195 {mdoc_no_pre, NULL}, /* No */
195 196 {mdoc_ns_pre, NULL}, /* Ns */
196 197 {mdoc_xx_pre, NULL}, /* Nx */
197 198 {mdoc_xx_pre, NULL}, /* Ox */
198 199 {NULL, NULL}, /* Pc */
199 200 {mdoc_igndelim_pre, mdoc_pf_post}, /* Pf */
200 201 {mdoc_quote_pre, mdoc_quote_post}, /* Po */
201 202 {mdoc_quote_pre, mdoc_quote_post}, /* Pq */
202 203 {NULL, NULL}, /* Qc */
203 204 {mdoc_quote_pre, mdoc_quote_post}, /* Ql */
204 205 {mdoc_quote_pre, mdoc_quote_post}, /* Qo */
205 206 {mdoc_quote_pre, mdoc_quote_post}, /* Qq */
206 207 {NULL, NULL}, /* Re */
207 208 {mdoc_rs_pre, NULL}, /* Rs */
208 209 {NULL, NULL}, /* Sc */
209 210 {mdoc_quote_pre, mdoc_quote_post}, /* So */
210 211 {mdoc_quote_pre, mdoc_quote_post}, /* Sq */
211 212 {mdoc_sm_pre, NULL}, /* Sm */
212 213 {mdoc_sx_pre, NULL}, /* Sx */
213 214 {mdoc_sy_pre, NULL}, /* Sy */
214 215 {NULL, NULL}, /* Tn */
215 216 {mdoc_xx_pre, NULL}, /* Ux */
216 217 {NULL, NULL}, /* Xc */
217 218 {NULL, NULL}, /* Xo */
218 219 {mdoc_fo_pre, mdoc_fo_post}, /* Fo */
219 220 {NULL, NULL}, /* Fc */
220 221 {mdoc_quote_pre, mdoc_quote_post}, /* Oo */
221 222 {NULL, NULL}, /* Oc */
222 223 {mdoc_bk_pre, mdoc_bk_post}, /* Bk */
223 224 {NULL, NULL}, /* Ek */
224 225 {NULL, NULL}, /* Bt */
225 226 {NULL, NULL}, /* Hf */
226 227 {mdoc_em_pre, NULL}, /* Fr */
227 228 {NULL, NULL}, /* Ud */
228 229 {mdoc_lb_pre, NULL}, /* Lb */
229 230 {mdoc_pp_pre, NULL}, /* Lp */
230 231 {mdoc_lk_pre, NULL}, /* Lk */
231 232 {mdoc_mt_pre, NULL}, /* Mt */
232 233 {mdoc_quote_pre, mdoc_quote_post}, /* Brq */
233 234 {mdoc_quote_pre, mdoc_quote_post}, /* Bro */
234 235 {NULL, NULL}, /* Brc */
235 236 {mdoc__x_pre, mdoc__x_post}, /* %C */
236 237 {mdoc_skip_pre, NULL}, /* Es */
237 238 {mdoc_quote_pre, mdoc_quote_post}, /* En */
238 239 {mdoc_xx_pre, NULL}, /* Dx */
239 240 {mdoc__x_pre, mdoc__x_post}, /* %Q */
240 241 {mdoc__x_pre, mdoc__x_post}, /* %U */
241 242 {NULL, NULL}, /* Ta */
242 243 };
243 244 static const struct htmlmdoc *const mdocs = __mdocs - MDOC_Dd;
244 245
245 246
246 247 /*
247 248 * See the same function in mdoc_term.c for documentation.
248 249 */
249 250 static void
250 251 synopsis_pre(struct html *h, const struct roff_node *n)
251 252 {
252 253
253 254 if (NULL == n->prev || ! (NODE_SYNPRETTY & n->flags))
254 255 return;
255 256
256 257 if (n->prev->tok == n->tok &&
257 258 MDOC_Fo != n->tok &&
258 259 MDOC_Ft != n->tok &&
259 260 MDOC_Fn != n->tok) {
260 261 print_otag(h, TAG_BR, "");
261 262 return;
262 263 }
263 264
264 265 switch (n->prev->tok) {
265 266 case MDOC_Fd:
266 267 case MDOC_Fn:
267 268 case MDOC_Fo:
268 269 case MDOC_In:
269 270 case MDOC_Vt:
270 271 print_paragraph(h);
271 272 break;
272 273 case MDOC_Ft:
273 274 if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {
274 275 print_paragraph(h);
275 276 break;
276 277 }
↓ open down ↓ |
206 lines elided |
↑ open up ↑ |
277 278 /* FALLTHROUGH */
278 279 default:
279 280 print_otag(h, TAG_BR, "");
280 281 break;
281 282 }
282 283 }
283 284
284 285 void
285 286 html_mdoc(void *arg, const struct roff_man *mdoc)
286 287 {
287 - struct html *h;
288 - struct tag *t;
288 + struct html *h;
289 + struct roff_node *n;
290 + struct tag *t;
289 291
290 292 h = (struct html *)arg;
293 + n = mdoc->first->child;
291 294
292 295 if ((h->oflags & HTML_FRAGMENT) == 0) {
293 296 print_gen_decls(h);
294 297 print_otag(h, TAG_HTML, "");
298 + if (n->type == ROFFT_COMMENT)
299 + print_gen_comment(h, n);
295 300 t = print_otag(h, TAG_HEAD, "");
296 - print_mdoc_head(&mdoc->meta, mdoc->first->child, h);
301 + print_mdoc_head(&mdoc->meta, h);
297 302 print_tagq(h, t);
298 303 print_otag(h, TAG_BODY, "");
299 304 }
300 305
301 - mdoc_root_pre(&mdoc->meta, mdoc->first->child, h);
306 + mdoc_root_pre(&mdoc->meta, h);
302 307 t = print_otag(h, TAG_DIV, "c", "manual-text");
303 - print_mdoc_nodelist(&mdoc->meta, mdoc->first->child, h);
308 + print_mdoc_nodelist(&mdoc->meta, n, h);
304 309 print_tagq(h, t);
305 - mdoc_root_post(&mdoc->meta, mdoc->first->child, h);
310 + mdoc_root_post(&mdoc->meta, h);
306 311 print_tagq(h, NULL);
307 312 }
308 313
309 314 static void
310 -print_mdoc_head(MDOC_ARGS)
315 +print_mdoc_head(const struct roff_meta *meta, struct html *h)
311 316 {
312 317 char *cp;
313 318
314 319 print_gen_head(h);
315 320
316 321 if (meta->arch != NULL && meta->msec != NULL)
317 322 mandoc_asprintf(&cp, "%s(%s) (%s)", meta->title,
318 323 meta->msec, meta->arch);
319 324 else if (meta->msec != NULL)
320 325 mandoc_asprintf(&cp, "%s(%s)", meta->title, meta->msec);
321 326 else if (meta->arch != NULL)
322 327 mandoc_asprintf(&cp, "%s (%s)", meta->title, meta->arch);
323 328 else
324 329 cp = mandoc_strdup(meta->title);
325 330
326 331 print_otag(h, TAG_TITLE, "");
327 332 print_text(h, cp);
328 333 free(cp);
329 334 }
330 335
331 336 static void
332 337 print_mdoc_nodelist(MDOC_ARGS)
333 338 {
334 339
335 340 while (n != NULL) {
336 341 print_mdoc_node(meta, n, h);
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
337 342 n = n->next;
338 343 }
339 344 }
340 345
341 346 static void
342 347 print_mdoc_node(MDOC_ARGS)
343 348 {
344 349 int child;
345 350 struct tag *t;
346 351
347 - if (n->flags & NODE_NOPRT)
352 + if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT)
348 353 return;
349 354
350 355 child = 1;
351 356 t = h->tag;
352 357 n->flags &= ~NODE_ENDED;
353 358
354 359 switch (n->type) {
355 360 case ROFFT_TEXT:
356 361 /* No tables in this mode... */
357 362 assert(NULL == h->tblt);
358 363
359 364 /*
360 365 * Make sure that if we're in a literal mode already
361 366 * (i.e., within a <PRE>) don't print the newline.
362 367 */
363 368 if (*n->string == ' ' && n->flags & NODE_LINE &&
364 369 (h->flags & (HTML_LITERAL | HTML_NONEWLINE)) == 0)
365 370 print_otag(h, TAG_BR, "");
366 371 if (NODE_DELIMC & n->flags)
367 372 h->flags |= HTML_NOSPACE;
368 373 print_text(h, n->string);
369 374 if (NODE_DELIMO & n->flags)
370 375 h->flags |= HTML_NOSPACE;
371 376 return;
372 377 case ROFFT_EQN:
373 378 print_eqn(h, n->eqn);
374 379 break;
375 380 case ROFFT_TBL:
376 381 /*
377 382 * This will take care of initialising all of the table
378 383 * state data for the first table, then tearing it down
379 384 * for the last one.
380 385 */
381 386 print_tbl(h, n->span);
382 387 return;
383 388 default:
384 389 /*
385 390 * Close out the current table, if it's open, and unset
386 391 * the "meta" table state. This will be reopened on the
387 392 * next table element.
388 393 */
389 394 if (h->tblt != NULL) {
390 395 print_tblclose(h);
391 396 t = h->tag;
392 397 }
393 398 assert(h->tblt == NULL);
394 399 if (n->tok < ROFF_MAX) {
395 400 roff_html_pre(h, n);
396 401 child = 0;
397 402 break;
398 403 }
399 404 assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);
400 405 if (mdocs[n->tok].pre != NULL &&
401 406 (n->end == ENDBODY_NOT || n->child != NULL))
402 407 child = (*mdocs[n->tok].pre)(meta, n, h);
403 408 break;
404 409 }
405 410
406 411 if (h->flags & HTML_KEEP && n->flags & NODE_LINE) {
407 412 h->flags &= ~HTML_KEEP;
408 413 h->flags |= HTML_PREKEEP;
409 414 }
410 415
411 416 if (child && n->child)
412 417 print_mdoc_nodelist(meta, n->child, h);
413 418
414 419 print_stagq(h, t);
415 420
416 421 switch (n->type) {
417 422 case ROFFT_EQN:
418 423 break;
419 424 default:
420 425 if (n->tok < ROFF_MAX ||
421 426 mdocs[n->tok].post == NULL ||
↓ open down ↓ |
64 lines elided |
↑ open up ↑ |
422 427 n->flags & NODE_ENDED)
423 428 break;
424 429 (*mdocs[n->tok].post)(meta, n, h);
425 430 if (n->end != ENDBODY_NOT)
426 431 n->body->flags |= NODE_ENDED;
427 432 break;
428 433 }
429 434 }
430 435
431 436 static void
432 -mdoc_root_post(MDOC_ARGS)
437 +mdoc_root_post(const struct roff_meta *meta, struct html *h)
433 438 {
434 439 struct tag *t, *tt;
435 440
436 441 t = print_otag(h, TAG_TABLE, "c", "foot");
437 442 tt = print_otag(h, TAG_TR, "");
438 443
439 444 print_otag(h, TAG_TD, "c", "foot-date");
440 445 print_text(h, meta->date);
441 446 print_stagq(h, tt);
442 447
443 448 print_otag(h, TAG_TD, "c", "foot-os");
444 449 print_text(h, meta->os);
445 450 print_tagq(h, t);
446 451 }
447 452
448 453 static int
449 -mdoc_root_pre(MDOC_ARGS)
454 +mdoc_root_pre(const struct roff_meta *meta, struct html *h)
450 455 {
451 456 struct tag *t, *tt;
452 457 char *volume, *title;
453 458
454 459 if (NULL == meta->arch)
455 460 volume = mandoc_strdup(meta->vol);
456 461 else
457 462 mandoc_asprintf(&volume, "%s (%s)",
458 463 meta->vol, meta->arch);
459 464
460 465 if (NULL == meta->msec)
461 466 title = mandoc_strdup(meta->title);
462 467 else
463 468 mandoc_asprintf(&title, "%s(%s)",
464 469 meta->title, meta->msec);
465 470
466 471 t = print_otag(h, TAG_TABLE, "c", "head");
467 472 tt = print_otag(h, TAG_TR, "");
468 473
469 474 print_otag(h, TAG_TD, "c", "head-ltitle");
470 475 print_text(h, title);
471 476 print_stagq(h, tt);
472 477
473 478 print_otag(h, TAG_TD, "c", "head-vol");
474 479 print_text(h, volume);
475 480 print_stagq(h, tt);
476 481
477 482 print_otag(h, TAG_TD, "c", "head-rtitle");
478 483 print_text(h, title);
479 484 print_tagq(h, t);
480 485
481 486 free(title);
482 487 free(volume);
483 488 return 1;
484 489 }
485 490
486 491 static char *
487 492 cond_id(const struct roff_node *n)
↓ open down ↓ |
28 lines elided |
↑ open up ↑ |
488 493 {
489 494 if (n->child != NULL &&
490 495 n->child->type == ROFFT_TEXT &&
491 496 (n->prev == NULL ||
492 497 (n->prev->type == ROFFT_TEXT &&
493 498 strcmp(n->prev->string, "|") == 0)) &&
494 499 (n->parent->tok == MDOC_It ||
495 500 (n->parent->tok == MDOC_Xo &&
496 501 n->parent->parent->prev == NULL &&
497 502 n->parent->parent->parent->tok == MDOC_It)))
498 - return html_make_id(n);
503 + return html_make_id(n, 1);
499 504 return NULL;
500 505 }
501 506
502 507 static int
503 508 mdoc_sh_pre(MDOC_ARGS)
504 509 {
505 510 char *id;
506 511
507 512 switch (n->type) {
508 513 case ROFFT_HEAD:
509 - id = html_make_id(n);
514 + id = html_make_id(n, 1);
510 515 print_otag(h, TAG_H1, "cTi", "Sh", id);
511 516 if (id != NULL)
512 - print_otag(h, TAG_A, "chR", "selflink", id);
513 - free(id);
517 + print_otag(h, TAG_A, "chR", "permalink", id);
514 518 break;
515 519 case ROFFT_BODY:
516 520 if (n->sec == SEC_AUTHORS)
517 521 h->flags &= ~(HTML_SPLIT|HTML_NOSPLIT);
518 522 break;
519 523 default:
520 524 break;
521 525 }
522 526 return 1;
523 527 }
524 528
525 529 static int
526 530 mdoc_ss_pre(MDOC_ARGS)
527 531 {
528 532 char *id;
529 533
530 534 if (n->type != ROFFT_HEAD)
531 535 return 1;
532 536
533 - id = html_make_id(n);
537 + id = html_make_id(n, 1);
534 538 print_otag(h, TAG_H2, "cTi", "Ss", id);
535 539 if (id != NULL)
536 - print_otag(h, TAG_A, "chR", "selflink", id);
537 - free(id);
540 + print_otag(h, TAG_A, "chR", "permalink", id);
538 541 return 1;
539 542 }
540 543
541 544 static int
542 545 mdoc_fl_pre(MDOC_ARGS)
543 546 {
544 547 char *id;
545 548
546 549 if ((id = cond_id(n)) != NULL)
547 - print_otag(h, TAG_A, "chR", "selflink", id);
548 - print_otag(h, TAG_B, "cTi", "Fl", id);
549 - free(id);
550 + print_otag(h, TAG_A, "chR", "permalink", id);
551 + print_otag(h, TAG_CODE, "cTi", "Fl", id);
550 552
551 553 print_text(h, "\\-");
552 554 if (!(n->child == NULL &&
553 555 (n->next == NULL ||
554 556 n->next->type == ROFFT_TEXT ||
555 557 n->next->flags & NODE_LINE)))
556 558 h->flags |= HTML_NOSPACE;
557 559
558 560 return 1;
559 561 }
560 562
561 563 static int
562 564 mdoc_cm_pre(MDOC_ARGS)
563 565 {
564 566 char *id;
565 567
566 568 if ((id = cond_id(n)) != NULL)
567 - print_otag(h, TAG_A, "chR", "selflink", id);
568 - print_otag(h, TAG_B, "cTi", "Cm", id);
569 - free(id);
569 + print_otag(h, TAG_A, "chR", "permalink", id);
570 + print_otag(h, TAG_CODE, "cTi", "Cm", id);
570 571 return 1;
571 572 }
572 573
573 574 static int
574 575 mdoc_nd_pre(MDOC_ARGS)
575 576 {
576 577 if (n->type != ROFFT_BODY)
577 578 return 1;
578 579
579 - /* XXX: this tag in theory can contain block elements. */
580 -
581 580 print_text(h, "\\(em");
582 - print_otag(h, TAG_SPAN, "cT", "Nd");
581 + /* Cannot use TAG_SPAN because it may contain blocks. */
582 + print_otag(h, TAG_DIV, "cT", "Nd");
583 583 return 1;
584 584 }
585 585
586 586 static int
587 587 mdoc_nm_pre(MDOC_ARGS)
588 588 {
589 589 switch (n->type) {
590 590 case ROFFT_HEAD:
591 591 print_otag(h, TAG_TD, "");
592 592 /* FALLTHROUGH */
593 593 case ROFFT_ELEM:
594 - print_otag(h, TAG_B, "cT", "Nm");
594 + print_otag(h, TAG_CODE, "cT", "Nm");
595 595 return 1;
596 596 case ROFFT_BODY:
597 597 print_otag(h, TAG_TD, "");
598 598 return 1;
599 599 default:
600 600 break;
601 601 }
602 602 synopsis_pre(h, n);
603 603 print_otag(h, TAG_TABLE, "c", "Nm");
604 604 print_otag(h, TAG_TR, "");
605 605 return 1;
606 606 }
607 607
608 608 static int
609 609 mdoc_xr_pre(MDOC_ARGS)
610 610 {
611 611 if (NULL == n->child)
612 612 return 0;
613 613
614 614 if (h->base_man)
615 615 print_otag(h, TAG_A, "cThM", "Xr",
616 616 n->child->string, n->child->next == NULL ?
617 617 NULL : n->child->next->string);
618 618 else
619 619 print_otag(h, TAG_A, "cT", "Xr");
620 620
621 621 n = n->child;
622 622 print_text(h, n->string);
623 623
624 624 if (NULL == (n = n->next))
625 625 return 0;
626 626
627 627 h->flags |= HTML_NOSPACE;
628 628 print_text(h, "(");
629 629 h->flags |= HTML_NOSPACE;
630 630 print_text(h, n->string);
631 631 h->flags |= HTML_NOSPACE;
632 632 print_text(h, ")");
633 633 return 0;
634 634 }
635 635
636 636 static int
637 637 mdoc_ns_pre(MDOC_ARGS)
638 638 {
639 639
640 640 if ( ! (NODE_LINE & n->flags))
641 641 h->flags |= HTML_NOSPACE;
642 642 return 1;
643 643 }
644 644
645 645 static int
646 646 mdoc_ar_pre(MDOC_ARGS)
647 647 {
648 648 print_otag(h, TAG_VAR, "cT", "Ar");
649 649 return 1;
650 650 }
651 651
652 652 static int
653 653 mdoc_xx_pre(MDOC_ARGS)
↓ open down ↓ |
49 lines elided |
↑ open up ↑ |
654 654 {
655 655 print_otag(h, TAG_SPAN, "c", "Ux");
656 656 return 1;
657 657 }
658 658
659 659 static int
660 660 mdoc_it_pre(MDOC_ARGS)
661 661 {
662 662 const struct roff_node *bl;
663 663 struct tag *t;
664 - const char *cattr;
665 664 enum mdoc_list type;
666 665
667 666 bl = n->parent;
668 667 while (bl->tok != MDOC_Bl)
669 668 bl = bl->parent;
670 669 type = bl->norm->Bl.type;
671 670
672 671 switch (type) {
673 672 case LIST_bullet:
674 - cattr = "It-bullet";
675 - break;
676 673 case LIST_dash:
677 674 case LIST_hyphen:
678 - cattr = "It-dash";
679 - break;
680 675 case LIST_item:
681 - cattr = "It-item";
682 - break;
683 676 case LIST_enum:
684 - cattr = "It-enum";
685 - break;
686 - case LIST_diag:
687 - cattr = "It-diag";
688 - break;
689 - case LIST_hang:
690 - cattr = "It-hang";
691 - break;
692 - case LIST_inset:
693 - cattr = "It-inset";
694 - break;
695 - case LIST_ohang:
696 - cattr = "It-ohang";
697 - break;
698 - case LIST_tag:
699 - cattr = "It-tag";
700 - break;
701 - case LIST_column:
702 - cattr = "It-column";
703 - break;
704 - default:
705 - break;
706 - }
707 -
708 - switch (type) {
709 - case LIST_bullet:
710 - case LIST_dash:
711 - case LIST_hyphen:
712 - case LIST_item:
713 - case LIST_enum:
714 677 switch (n->type) {
715 678 case ROFFT_HEAD:
716 679 return 0;
717 680 case ROFFT_BODY:
718 - print_otag(h, TAG_LI, "c", cattr);
681 + print_otag(h, TAG_LI, "");
719 682 break;
720 683 default:
721 684 break;
722 685 }
723 686 break;
724 687 case LIST_diag:
725 688 case LIST_hang:
726 689 case LIST_inset:
727 690 case LIST_ohang:
728 691 switch (n->type) {
729 692 case ROFFT_HEAD:
730 - print_otag(h, TAG_DT, "c", cattr);
731 - if (type == LIST_diag)
732 - print_otag(h, TAG_B, "c", cattr);
693 + print_otag(h, TAG_DT, "");
733 694 break;
734 695 case ROFFT_BODY:
735 - print_otag(h, TAG_DD, "csw*+l", cattr,
736 - bl->norm->Bl.width);
696 + print_otag(h, TAG_DD, "");
737 697 break;
738 698 default:
739 699 break;
740 700 }
741 701 break;
742 702 case LIST_tag:
743 703 switch (n->type) {
744 704 case ROFFT_HEAD:
745 705 if (h->style != NULL && !bl->norm->Bl.comp &&
746 706 (n->parent->prev == NULL ||
747 707 n->parent->prev->body == NULL ||
748 708 n->parent->prev->body->child != NULL)) {
749 - t = print_otag(h, TAG_DT, "csw*+-l",
750 - cattr, bl->norm->Bl.width);
709 + t = print_otag(h, TAG_DT, "");
751 710 print_text(h, "\\ ");
752 711 print_tagq(h, t);
753 - t = print_otag(h, TAG_DD, "c", cattr);
712 + t = print_otag(h, TAG_DD, "");
754 713 print_text(h, "\\ ");
755 714 print_tagq(h, t);
756 715 }
757 - print_otag(h, TAG_DT, "csw*+-l", cattr,
758 - bl->norm->Bl.width);
716 + print_otag(h, TAG_DT, "");
759 717 break;
760 718 case ROFFT_BODY:
761 719 if (n->child == NULL) {
762 - print_otag(h, TAG_DD, "css?", cattr,
763 - "width", "auto");
720 + print_otag(h, TAG_DD, "s", "width", "auto");
764 721 print_text(h, "\\ ");
765 722 } else
766 - print_otag(h, TAG_DD, "c", cattr);
723 + print_otag(h, TAG_DD, "");
767 724 break;
768 725 default:
769 726 break;
770 727 }
771 728 break;
772 729 case LIST_column:
773 730 switch (n->type) {
774 731 case ROFFT_HEAD:
775 732 break;
776 733 case ROFFT_BODY:
777 - print_otag(h, TAG_TD, "c", cattr);
734 + print_otag(h, TAG_TD, "");
778 735 break;
779 736 default:
780 - print_otag(h, TAG_TR, "c", cattr);
737 + print_otag(h, TAG_TR, "");
781 738 }
782 739 default:
783 740 break;
784 741 }
785 742
786 743 return 1;
787 744 }
788 745
789 746 static int
790 747 mdoc_bl_pre(MDOC_ARGS)
791 748 {
792 - char cattr[21];
793 - struct tag *t;
749 + char cattr[28];
794 750 struct mdoc_bl *bl;
795 - size_t i;
796 751 enum htmltag elemtype;
797 752
798 - bl = &n->norm->Bl;
799 -
800 753 switch (n->type) {
801 754 case ROFFT_BODY:
802 755 return 1;
803 -
804 756 case ROFFT_HEAD:
805 - if (bl->type != LIST_column || bl->ncols == 0)
806 - return 0;
807 -
808 - /*
809 - * For each column, print out the <COL> tag with our
810 - * suggested width. The last column gets min-width, as
811 - * in terminal mode it auto-sizes to the width of the
812 - * screen and we want to preserve that behaviour.
813 - */
814 -
815 - t = print_otag(h, TAG_COLGROUP, "");
816 - for (i = 0; i < bl->ncols - 1; i++)
817 - print_otag(h, TAG_COL, "sw+w", bl->cols[i]);
818 - print_otag(h, TAG_COL, "swW", bl->cols[i]);
819 - print_tagq(h, t);
820 757 return 0;
821 -
822 758 default:
823 759 break;
824 760 }
825 761
762 + bl = &n->norm->Bl;
826 763 switch (bl->type) {
827 764 case LIST_bullet:
828 765 elemtype = TAG_UL;
829 766 (void)strlcpy(cattr, "Bl-bullet", sizeof(cattr));
830 767 break;
831 768 case LIST_dash:
832 769 case LIST_hyphen:
833 770 elemtype = TAG_UL;
834 771 (void)strlcpy(cattr, "Bl-dash", sizeof(cattr));
835 772 break;
836 773 case LIST_item:
837 774 elemtype = TAG_UL;
838 775 (void)strlcpy(cattr, "Bl-item", sizeof(cattr));
839 776 break;
840 777 case LIST_enum:
841 778 elemtype = TAG_OL;
842 779 (void)strlcpy(cattr, "Bl-enum", sizeof(cattr));
843 780 break;
844 781 case LIST_diag:
845 782 elemtype = TAG_DL;
846 783 (void)strlcpy(cattr, "Bl-diag", sizeof(cattr));
847 784 break;
848 785 case LIST_hang:
849 786 elemtype = TAG_DL;
850 787 (void)strlcpy(cattr, "Bl-hang", sizeof(cattr));
851 788 break;
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
852 789 case LIST_inset:
853 790 elemtype = TAG_DL;
854 791 (void)strlcpy(cattr, "Bl-inset", sizeof(cattr));
855 792 break;
856 793 case LIST_ohang:
857 794 elemtype = TAG_DL;
858 795 (void)strlcpy(cattr, "Bl-ohang", sizeof(cattr));
859 796 break;
860 797 case LIST_tag:
861 798 if (bl->offs)
862 - print_otag(h, TAG_DIV, "cswl", "Bl-tag", bl->offs);
863 - print_otag(h, TAG_DL, "csw*+l", bl->comp ?
864 - "Bl-tag Bl-compact" : "Bl-tag", bl->width);
799 + print_otag(h, TAG_DIV, "c", "Bd-indent");
800 + print_otag(h, TAG_DL, "c", bl->comp ?
801 + "Bl-tag Bl-compact" : "Bl-tag");
865 802 return 1;
866 803 case LIST_column:
867 804 elemtype = TAG_TABLE;
868 805 (void)strlcpy(cattr, "Bl-column", sizeof(cattr));
869 806 break;
870 807 default:
871 808 abort();
872 809 }
810 + if (bl->offs != NULL)
811 + (void)strlcat(cattr, " Bd-indent", sizeof(cattr));
873 812 if (bl->comp)
874 813 (void)strlcat(cattr, " Bl-compact", sizeof(cattr));
875 - print_otag(h, elemtype, "cswl", cattr, bl->offs);
814 + print_otag(h, elemtype, "c", cattr);
876 815 return 1;
877 816 }
878 817
879 818 static int
880 819 mdoc_ex_pre(MDOC_ARGS)
881 820 {
882 821 if (n->prev)
883 822 print_otag(h, TAG_BR, "");
884 823 return 1;
885 824 }
886 825
887 826 static int
888 827 mdoc_st_pre(MDOC_ARGS)
889 828 {
890 829 print_otag(h, TAG_SPAN, "cT", "St");
891 830 return 1;
892 831 }
893 832
894 833 static int
895 834 mdoc_em_pre(MDOC_ARGS)
896 835 {
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
897 836 print_otag(h, TAG_I, "cT", "Em");
898 837 return 1;
899 838 }
900 839
901 840 static int
902 841 mdoc_d1_pre(MDOC_ARGS)
903 842 {
904 843 if (n->type != ROFFT_BLOCK)
905 844 return 1;
906 845
907 - print_otag(h, TAG_DIV, "c", "D1");
846 + print_otag(h, TAG_DIV, "c", "Bd Bd-indent");
908 847
909 848 if (n->tok == MDOC_Dl)
910 849 print_otag(h, TAG_CODE, "c", "Li");
911 850
912 851 return 1;
913 852 }
914 853
915 854 static int
916 855 mdoc_sx_pre(MDOC_ARGS)
917 856 {
918 857 char *id;
919 858
920 - id = html_make_id(n);
859 + id = html_make_id(n, 0);
921 860 print_otag(h, TAG_A, "cThR", "Sx", id);
922 861 free(id);
923 862 return 1;
924 863 }
925 864
926 865 static int
927 866 mdoc_bd_pre(MDOC_ARGS)
928 867 {
929 - int comp, offs, sv;
868 + int comp, sv;
930 869 struct roff_node *nn;
931 870
932 871 if (n->type == ROFFT_HEAD)
933 872 return 0;
934 873
935 874 if (n->type == ROFFT_BLOCK) {
936 875 comp = n->norm->Bd.comp;
937 876 for (nn = n; nn && ! comp; nn = nn->parent) {
938 877 if (nn->type != ROFFT_BLOCK)
939 878 continue;
940 879 if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
941 880 comp = 1;
942 881 if (nn->prev)
943 882 break;
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
944 883 }
945 884 if ( ! comp)
946 885 print_paragraph(h);
947 886 return 1;
948 887 }
949 888
950 889 /* Handle the -offset argument. */
951 890
952 891 if (n->norm->Bd.offs == NULL ||
953 892 ! strcmp(n->norm->Bd.offs, "left"))
954 - offs = 0;
955 - else if ( ! strcmp(n->norm->Bd.offs, "indent"))
956 - offs = INDENT;
957 - else if ( ! strcmp(n->norm->Bd.offs, "indent-two"))
958 - offs = INDENT * 2;
893 + print_otag(h, TAG_DIV, "c", "Bd");
959 894 else
960 - offs = -1;
895 + print_otag(h, TAG_DIV, "c", "Bd Bd-indent");
961 896
962 - if (offs == -1)
963 - print_otag(h, TAG_DIV, "cswl", "Bd", n->norm->Bd.offs);
964 - else
965 - print_otag(h, TAG_DIV, "cshl", "Bd", offs);
966 -
967 897 if (n->norm->Bd.type != DISP_unfilled &&
968 898 n->norm->Bd.type != DISP_literal)
969 899 return 1;
970 900
971 901 print_otag(h, TAG_PRE, "c", "Li");
972 902
973 903 /* This can be recursive: save & set our literal state. */
974 904
975 905 sv = h->flags & HTML_LITERAL;
976 906 h->flags |= HTML_LITERAL;
977 907
978 908 for (nn = n->child; nn; nn = nn->next) {
979 909 print_mdoc_node(meta, nn, h);
980 910 /*
981 911 * If the printed node flushes its own line, then we
982 912 * needn't do it here as well. This is hacky, but the
983 913 * notion of selective eoln whitespace is pretty dumb
984 914 * anyway, so don't sweat it.
985 915 */
986 916 switch (nn->tok) {
987 917 case ROFF_br:
988 918 case ROFF_sp:
989 919 case MDOC_Sm:
990 920 case MDOC_Bl:
991 921 case MDOC_D1:
992 922 case MDOC_Dl:
993 923 case MDOC_Lp:
994 924 case MDOC_Pp:
995 925 continue;
996 926 default:
997 927 break;
998 928 }
999 929 if (h->flags & HTML_NONEWLINE ||
1000 930 (nn->next && ! (nn->next->flags & NODE_LINE)))
1001 931 continue;
1002 932 else if (nn->next)
1003 933 print_text(h, "\n");
1004 934
1005 935 h->flags |= HTML_NOSPACE;
1006 936 }
↓ open down ↓ |
30 lines elided |
↑ open up ↑ |
1007 937
1008 938 if (0 == sv)
1009 939 h->flags &= ~HTML_LITERAL;
1010 940
1011 941 return 0;
1012 942 }
1013 943
1014 944 static int
1015 945 mdoc_pa_pre(MDOC_ARGS)
1016 946 {
1017 - print_otag(h, TAG_I, "cT", "Pa");
947 + print_otag(h, TAG_SPAN, "cT", "Pa");
1018 948 return 1;
1019 949 }
1020 950
1021 951 static int
1022 952 mdoc_ad_pre(MDOC_ARGS)
1023 953 {
1024 - print_otag(h, TAG_I, "c", "Ad");
954 + print_otag(h, TAG_SPAN, "c", "Ad");
1025 955 return 1;
1026 956 }
1027 957
1028 958 static int
1029 959 mdoc_an_pre(MDOC_ARGS)
1030 960 {
1031 961 if (n->norm->An.auth == AUTH_split) {
1032 962 h->flags &= ~HTML_NOSPLIT;
1033 963 h->flags |= HTML_SPLIT;
1034 964 return 0;
1035 965 }
1036 966 if (n->norm->An.auth == AUTH_nosplit) {
1037 967 h->flags &= ~HTML_SPLIT;
1038 968 h->flags |= HTML_NOSPLIT;
1039 969 return 0;
1040 970 }
1041 971
1042 972 if (h->flags & HTML_SPLIT)
1043 973 print_otag(h, TAG_BR, "");
1044 974
1045 975 if (n->sec == SEC_AUTHORS && ! (h->flags & HTML_NOSPLIT))
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
1046 976 h->flags |= HTML_SPLIT;
1047 977
1048 978 print_otag(h, TAG_SPAN, "cT", "An");
1049 979 return 1;
1050 980 }
1051 981
1052 982 static int
1053 983 mdoc_cd_pre(MDOC_ARGS)
1054 984 {
1055 985 synopsis_pre(h, n);
1056 - print_otag(h, TAG_B, "cT", "Cd");
986 + print_otag(h, TAG_CODE, "cT", "Cd");
1057 987 return 1;
1058 988 }
1059 989
1060 990 static int
1061 991 mdoc_dv_pre(MDOC_ARGS)
1062 992 {
1063 993 char *id;
1064 994
1065 995 if ((id = cond_id(n)) != NULL)
1066 - print_otag(h, TAG_A, "chR", "selflink", id);
996 + print_otag(h, TAG_A, "chR", "permalink", id);
1067 997 print_otag(h, TAG_CODE, "cTi", "Dv", id);
1068 - free(id);
1069 998 return 1;
1070 999 }
1071 1000
1072 1001 static int
1073 1002 mdoc_ev_pre(MDOC_ARGS)
1074 1003 {
1075 1004 char *id;
1076 1005
1077 1006 if ((id = cond_id(n)) != NULL)
1078 - print_otag(h, TAG_A, "chR", "selflink", id);
1007 + print_otag(h, TAG_A, "chR", "permalink", id);
1079 1008 print_otag(h, TAG_CODE, "cTi", "Ev", id);
1080 - free(id);
1081 1009 return 1;
1082 1010 }
1083 1011
1084 1012 static int
1085 1013 mdoc_er_pre(MDOC_ARGS)
1086 1014 {
1087 1015 char *id;
1088 1016
1089 1017 id = n->sec == SEC_ERRORS &&
1090 1018 (n->parent->tok == MDOC_It ||
1091 1019 (n->parent->tok == MDOC_Bq &&
1092 1020 n->parent->parent->parent->tok == MDOC_It)) ?
1093 - html_make_id(n) : NULL;
1021 + html_make_id(n, 1) : NULL;
1094 1022
1095 1023 if (id != NULL)
1096 - print_otag(h, TAG_A, "chR", "selflink", id);
1024 + print_otag(h, TAG_A, "chR", "permalink", id);
1097 1025 print_otag(h, TAG_CODE, "cTi", "Er", id);
1098 - free(id);
1099 1026 return 1;
1100 1027 }
1101 1028
1102 1029 static int
1103 1030 mdoc_fa_pre(MDOC_ARGS)
1104 1031 {
1105 1032 const struct roff_node *nn;
1106 1033 struct tag *t;
1107 1034
1108 1035 if (n->parent->tok != MDOC_Fo) {
1109 1036 print_otag(h, TAG_VAR, "cT", "Fa");
1110 1037 return 1;
1111 1038 }
1112 1039
1113 1040 for (nn = n->child; nn; nn = nn->next) {
1114 1041 t = print_otag(h, TAG_VAR, "cT", "Fa");
1115 1042 print_text(h, nn->string);
1116 1043 print_tagq(h, t);
1117 1044 if (nn->next) {
1118 1045 h->flags |= HTML_NOSPACE;
1119 1046 print_text(h, ",");
1120 1047 }
1121 1048 }
1122 1049
1123 1050 if (n->child && n->next && n->next->tok == MDOC_Fa) {
1124 1051 h->flags |= HTML_NOSPACE;
1125 1052 print_text(h, ",");
1126 1053 }
1127 1054
1128 1055 return 0;
1129 1056 }
1130 1057
1131 1058 static int
1132 1059 mdoc_fd_pre(MDOC_ARGS)
1133 1060 {
1134 1061 struct tag *t;
↓ open down ↓ |
26 lines elided |
↑ open up ↑ |
1135 1062 char *buf, *cp;
1136 1063
1137 1064 synopsis_pre(h, n);
1138 1065
1139 1066 if (NULL == (n = n->child))
1140 1067 return 0;
1141 1068
1142 1069 assert(n->type == ROFFT_TEXT);
1143 1070
1144 1071 if (strcmp(n->string, "#include")) {
1145 - print_otag(h, TAG_B, "cT", "Fd");
1072 + print_otag(h, TAG_CODE, "cT", "Fd");
1146 1073 return 1;
1147 1074 }
1148 1075
1149 - print_otag(h, TAG_B, "cT", "In");
1076 + print_otag(h, TAG_CODE, "cT", "In");
1150 1077 print_text(h, n->string);
1151 1078
1152 1079 if (NULL != (n = n->next)) {
1153 1080 assert(n->type == ROFFT_TEXT);
1154 1081
1155 1082 if (h->base_includes) {
1156 1083 cp = n->string;
1157 1084 if (*cp == '<' || *cp == '"')
1158 1085 cp++;
1159 1086 buf = mandoc_strdup(cp);
1160 1087 cp = strchr(buf, '\0') - 1;
1161 1088 if (cp >= buf && (*cp == '>' || *cp == '"'))
1162 1089 *cp = '\0';
1163 1090 t = print_otag(h, TAG_A, "cThI", "In", buf);
1164 1091 free(buf);
1165 1092 } else
1166 1093 t = print_otag(h, TAG_A, "cT", "In");
1167 1094
1168 1095 print_text(h, n->string);
1169 1096 print_tagq(h, t);
1170 1097
1171 1098 n = n->next;
1172 1099 }
1173 1100
1174 1101 for ( ; n; n = n->next) {
1175 1102 assert(n->type == ROFFT_TEXT);
1176 1103 print_text(h, n->string);
1177 1104 }
1178 1105
1179 1106 return 0;
1180 1107 }
1181 1108
1182 1109 static int
1183 1110 mdoc_vt_pre(MDOC_ARGS)
1184 1111 {
1185 1112 if (n->type == ROFFT_BLOCK) {
1186 1113 synopsis_pre(h, n);
1187 1114 return 1;
1188 1115 } else if (n->type == ROFFT_ELEM) {
1189 1116 synopsis_pre(h, n);
1190 1117 } else if (n->type == ROFFT_HEAD)
1191 1118 return 0;
1192 1119
1193 1120 print_otag(h, TAG_VAR, "cT", "Vt");
1194 1121 return 1;
1195 1122 }
1196 1123
1197 1124 static int
1198 1125 mdoc_ft_pre(MDOC_ARGS)
1199 1126 {
1200 1127 synopsis_pre(h, n);
1201 1128 print_otag(h, TAG_VAR, "cT", "Ft");
1202 1129 return 1;
1203 1130 }
1204 1131
1205 1132 static int
1206 1133 mdoc_fn_pre(MDOC_ARGS)
1207 1134 {
1208 1135 struct tag *t;
1209 1136 char nbuf[BUFSIZ];
1210 1137 const char *sp, *ep;
1211 1138 int sz, pretty;
1212 1139
1213 1140 pretty = NODE_SYNPRETTY & n->flags;
1214 1141 synopsis_pre(h, n);
1215 1142
1216 1143 /* Split apart into type and name. */
1217 1144 assert(n->child->string);
1218 1145 sp = n->child->string;
1219 1146
1220 1147 ep = strchr(sp, ' ');
1221 1148 if (NULL != ep) {
1222 1149 t = print_otag(h, TAG_VAR, "cT", "Ft");
1223 1150
1224 1151 while (ep) {
↓ open down ↓ |
65 lines elided |
↑ open up ↑ |
1225 1152 sz = MIN((int)(ep - sp), BUFSIZ - 1);
1226 1153 (void)memcpy(nbuf, sp, (size_t)sz);
1227 1154 nbuf[sz] = '\0';
1228 1155 print_text(h, nbuf);
1229 1156 sp = ++ep;
1230 1157 ep = strchr(sp, ' ');
1231 1158 }
1232 1159 print_tagq(h, t);
1233 1160 }
1234 1161
1235 - t = print_otag(h, TAG_B, "cT", "Fn");
1162 + t = print_otag(h, TAG_CODE, "cT", "Fn");
1236 1163
1237 1164 if (sp)
1238 1165 print_text(h, sp);
1239 1166
1240 1167 print_tagq(h, t);
1241 1168
1242 1169 h->flags |= HTML_NOSPACE;
1243 1170 print_text(h, "(");
1244 1171 h->flags |= HTML_NOSPACE;
1245 1172
1246 1173 for (n = n->child->next; n; n = n->next) {
1247 1174 if (NODE_SYNPRETTY & n->flags)
1248 - t = print_otag(h, TAG_VAR, "cTss?", "Fa",
1175 + t = print_otag(h, TAG_VAR, "cTs", "Fa",
1249 1176 "white-space", "nowrap");
1250 1177 else
1251 1178 t = print_otag(h, TAG_VAR, "cT", "Fa");
1252 1179 print_text(h, n->string);
1253 1180 print_tagq(h, t);
1254 1181 if (n->next) {
1255 1182 h->flags |= HTML_NOSPACE;
1256 1183 print_text(h, ",");
1257 1184 }
1258 1185 }
1259 1186
1260 1187 h->flags |= HTML_NOSPACE;
1261 1188 print_text(h, ")");
1262 1189
1263 1190 if (pretty) {
1264 1191 h->flags |= HTML_NOSPACE;
1265 1192 print_text(h, ";");
1266 1193 }
1267 1194
1268 1195 return 0;
1269 1196 }
1270 1197
1271 1198 static int
1272 1199 mdoc_sm_pre(MDOC_ARGS)
1273 1200 {
1274 1201
1275 1202 if (NULL == n->child)
1276 1203 h->flags ^= HTML_NONOSPACE;
1277 1204 else if (0 == strcmp("on", n->child->string))
1278 1205 h->flags &= ~HTML_NONOSPACE;
1279 1206 else
1280 1207 h->flags |= HTML_NONOSPACE;
1281 1208
1282 1209 if ( ! (HTML_NONOSPACE & h->flags))
1283 1210 h->flags &= ~HTML_NOSPACE;
1284 1211
1285 1212 return 0;
1286 1213 }
1287 1214
1288 1215 static int
1289 1216 mdoc_skip_pre(MDOC_ARGS)
1290 1217 {
1291 1218
1292 1219 return 0;
1293 1220 }
1294 1221
1295 1222 static int
1296 1223 mdoc_pp_pre(MDOC_ARGS)
1297 1224 {
1298 1225
1299 1226 print_paragraph(h);
1300 1227 return 0;
1301 1228 }
1302 1229
1303 1230 static int
1304 1231 mdoc_lk_pre(MDOC_ARGS)
1305 1232 {
1306 1233 const struct roff_node *link, *descr, *punct;
1307 1234 struct tag *t;
1308 1235
1309 1236 if ((link = n->child) == NULL)
1310 1237 return 0;
1311 1238
1312 1239 /* Find beginning of trailing punctuation. */
1313 1240 punct = n->last;
1314 1241 while (punct != link && punct->flags & NODE_DELIMC)
1315 1242 punct = punct->prev;
1316 1243 punct = punct->next;
1317 1244
1318 1245 /* Link target and link text. */
1319 1246 descr = link->next;
1320 1247 if (descr == punct)
1321 1248 descr = link; /* no text */
1322 1249 t = print_otag(h, TAG_A, "cTh", "Lk", link->string);
1323 1250 do {
1324 1251 if (descr->flags & (NODE_DELIMC | NODE_DELIMO))
1325 1252 h->flags |= HTML_NOSPACE;
1326 1253 print_text(h, descr->string);
1327 1254 descr = descr->next;
1328 1255 } while (descr != punct);
1329 1256 print_tagq(h, t);
1330 1257
1331 1258 /* Trailing punctuation. */
1332 1259 while (punct != NULL) {
1333 1260 h->flags |= HTML_NOSPACE;
1334 1261 print_text(h, punct->string);
1335 1262 punct = punct->next;
1336 1263 }
1337 1264 return 0;
1338 1265 }
1339 1266
1340 1267 static int
1341 1268 mdoc_mt_pre(MDOC_ARGS)
1342 1269 {
1343 1270 struct tag *t;
1344 1271 char *cp;
1345 1272
1346 1273 for (n = n->child; n; n = n->next) {
1347 1274 assert(n->type == ROFFT_TEXT);
1348 1275
1349 1276 mandoc_asprintf(&cp, "mailto:%s", n->string);
1350 1277 t = print_otag(h, TAG_A, "cTh", "Mt", cp);
1351 1278 print_text(h, n->string);
1352 1279 print_tagq(h, t);
1353 1280 free(cp);
1354 1281 }
1355 1282
1356 1283 return 0;
1357 1284 }
1358 1285
1359 1286 static int
1360 1287 mdoc_fo_pre(MDOC_ARGS)
1361 1288 {
1362 1289 struct tag *t;
1363 1290
1364 1291 if (n->type == ROFFT_BODY) {
1365 1292 h->flags |= HTML_NOSPACE;
1366 1293 print_text(h, "(");
1367 1294 h->flags |= HTML_NOSPACE;
↓ open down ↓ |
109 lines elided |
↑ open up ↑ |
1368 1295 return 1;
1369 1296 } else if (n->type == ROFFT_BLOCK) {
1370 1297 synopsis_pre(h, n);
1371 1298 return 1;
1372 1299 }
1373 1300
1374 1301 if (n->child == NULL)
1375 1302 return 0;
1376 1303
1377 1304 assert(n->child->string);
1378 - t = print_otag(h, TAG_B, "cT", "Fn");
1305 + t = print_otag(h, TAG_CODE, "cT", "Fn");
1379 1306 print_text(h, n->child->string);
1380 1307 print_tagq(h, t);
1381 1308 return 0;
1382 1309 }
1383 1310
1384 1311 static void
1385 1312 mdoc_fo_post(MDOC_ARGS)
1386 1313 {
1387 1314
1388 1315 if (n->type != ROFFT_BODY)
1389 1316 return;
1390 1317 h->flags |= HTML_NOSPACE;
1391 1318 print_text(h, ")");
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
1392 1319 h->flags |= HTML_NOSPACE;
1393 1320 print_text(h, ";");
1394 1321 }
1395 1322
1396 1323 static int
1397 1324 mdoc_in_pre(MDOC_ARGS)
1398 1325 {
1399 1326 struct tag *t;
1400 1327
1401 1328 synopsis_pre(h, n);
1402 - print_otag(h, TAG_B, "cT", "In");
1329 + print_otag(h, TAG_CODE, "cT", "In");
1403 1330
1404 1331 /*
1405 1332 * The first argument of the `In' gets special treatment as
1406 1333 * being a linked value. Subsequent values are printed
1407 1334 * afterward. groff does similarly. This also handles the case
1408 1335 * of no children.
1409 1336 */
1410 1337
1411 1338 if (NODE_SYNPRETTY & n->flags && NODE_LINE & n->flags)
1412 1339 print_text(h, "#include");
1413 1340
1414 1341 print_text(h, "<");
1415 1342 h->flags |= HTML_NOSPACE;
1416 1343
1417 1344 if (NULL != (n = n->child)) {
1418 1345 assert(n->type == ROFFT_TEXT);
1419 1346
1420 1347 if (h->base_includes)
1421 1348 t = print_otag(h, TAG_A, "cThI", "In", n->string);
1422 1349 else
1423 1350 t = print_otag(h, TAG_A, "cT", "In");
1424 1351 print_text(h, n->string);
1425 1352 print_tagq(h, t);
1426 1353
1427 1354 n = n->next;
1428 1355 }
1429 1356
1430 1357 h->flags |= HTML_NOSPACE;
1431 1358 print_text(h, ">");
1432 1359
1433 1360 for ( ; n; n = n->next) {
1434 1361 assert(n->type == ROFFT_TEXT);
1435 1362 print_text(h, n->string);
1436 1363 }
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
1437 1364
1438 1365 return 0;
1439 1366 }
1440 1367
1441 1368 static int
1442 1369 mdoc_ic_pre(MDOC_ARGS)
1443 1370 {
1444 1371 char *id;
1445 1372
1446 1373 if ((id = cond_id(n)) != NULL)
1447 - print_otag(h, TAG_A, "chR", "selflink", id);
1448 - print_otag(h, TAG_B, "cTi", "Ic", id);
1449 - free(id);
1374 + print_otag(h, TAG_A, "chR", "permalink", id);
1375 + print_otag(h, TAG_CODE, "cTi", "Ic", id);
1450 1376 return 1;
1451 1377 }
1452 1378
1453 1379 static int
1454 1380 mdoc_va_pre(MDOC_ARGS)
1455 1381 {
1456 1382 print_otag(h, TAG_VAR, "cT", "Va");
1457 1383 return 1;
1458 1384 }
1459 1385
1460 1386 static int
1461 1387 mdoc_ap_pre(MDOC_ARGS)
1462 1388 {
1463 1389
1464 1390 h->flags |= HTML_NOSPACE;
1465 1391 print_text(h, "\\(aq");
1466 1392 h->flags |= HTML_NOSPACE;
1467 1393 return 1;
1468 1394 }
1469 1395
1470 1396 static int
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
1471 1397 mdoc_bf_pre(MDOC_ARGS)
1472 1398 {
1473 1399 const char *cattr;
1474 1400
1475 1401 if (n->type == ROFFT_HEAD)
1476 1402 return 0;
1477 1403 else if (n->type != ROFFT_BODY)
1478 1404 return 1;
1479 1405
1480 1406 if (FONT_Em == n->norm->Bf.font)
1481 - cattr = "Em";
1407 + cattr = "Bf Em";
1482 1408 else if (FONT_Sy == n->norm->Bf.font)
1483 - cattr = "Sy";
1409 + cattr = "Bf Sy";
1484 1410 else if (FONT_Li == n->norm->Bf.font)
1485 - cattr = "Li";
1411 + cattr = "Bf Li";
1486 1412 else
1487 - cattr = "No";
1413 + cattr = "Bf No";
1488 1414
1489 - /*
1490 - * We want this to be inline-formatted, but needs to be div to
1491 - * accept block children.
1492 - */
1493 -
1494 - print_otag(h, TAG_DIV, "css?hl", cattr, "display", "inline", 1);
1415 + /* Cannot use TAG_SPAN because it may contain blocks. */
1416 + print_otag(h, TAG_DIV, "c", cattr);
1495 1417 return 1;
1496 1418 }
1497 1419
1498 1420 static int
1499 1421 mdoc_ms_pre(MDOC_ARGS)
1500 1422 {
1501 1423 char *id;
1502 1424
1503 1425 if ((id = cond_id(n)) != NULL)
1504 - print_otag(h, TAG_A, "chR", "selflink", id);
1505 - print_otag(h, TAG_B, "cTi", "Ms", id);
1506 - free(id);
1426 + print_otag(h, TAG_A, "chR", "permalink", id);
1427 + print_otag(h, TAG_SPAN, "cTi", "Ms", id);
1507 1428 return 1;
1508 1429 }
1509 1430
1510 1431 static int
1511 1432 mdoc_igndelim_pre(MDOC_ARGS)
1512 1433 {
1513 1434
1514 1435 h->flags |= HTML_IGNDELIM;
1515 1436 return 1;
1516 1437 }
1517 1438
1518 1439 static void
1519 1440 mdoc_pf_post(MDOC_ARGS)
1520 1441 {
1521 1442
1522 1443 if ( ! (n->next == NULL || n->next->flags & NODE_LINE))
1523 1444 h->flags |= HTML_NOSPACE;
1524 1445 }
1525 1446
1526 1447 static int
1527 1448 mdoc_rs_pre(MDOC_ARGS)
1528 1449 {
1529 1450 if (n->type != ROFFT_BLOCK)
1530 1451 return 1;
1531 1452
1532 1453 if (n->prev && SEC_SEE_ALSO == n->sec)
1533 1454 print_paragraph(h);
1534 1455
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
1535 1456 print_otag(h, TAG_CITE, "cT", "Rs");
1536 1457 return 1;
1537 1458 }
1538 1459
1539 1460 static int
1540 1461 mdoc_no_pre(MDOC_ARGS)
1541 1462 {
1542 1463 char *id;
1543 1464
1544 1465 if ((id = cond_id(n)) != NULL)
1545 - print_otag(h, TAG_A, "chR", "selflink", id);
1466 + print_otag(h, TAG_A, "chR", "permalink", id);
1546 1467 print_otag(h, TAG_SPAN, "ci", "No", id);
1547 - free(id);
1548 1468 return 1;
1549 1469 }
1550 1470
1551 1471 static int
1552 1472 mdoc_li_pre(MDOC_ARGS)
1553 1473 {
1554 1474 char *id;
1555 1475
1556 1476 if ((id = cond_id(n)) != NULL)
1557 - print_otag(h, TAG_A, "chR", "selflink", id);
1477 + print_otag(h, TAG_A, "chR", "permalink", id);
1558 1478 print_otag(h, TAG_CODE, "ci", "Li", id);
1559 - free(id);
1560 1479 return 1;
1561 1480 }
1562 1481
1563 1482 static int
1564 1483 mdoc_sy_pre(MDOC_ARGS)
1565 1484 {
1566 1485 print_otag(h, TAG_B, "cT", "Sy");
1567 1486 return 1;
1568 1487 }
1569 1488
1570 1489 static int
1571 1490 mdoc_lb_pre(MDOC_ARGS)
1572 1491 {
1573 1492 if (SEC_LIBRARY == n->sec && NODE_LINE & n->flags && n->prev)
1574 1493 print_otag(h, TAG_BR, "");
1575 1494
1576 1495 print_otag(h, TAG_SPAN, "cT", "Lb");
1577 1496 return 1;
1578 1497 }
1579 1498
1580 1499 static int
1581 1500 mdoc__x_pre(MDOC_ARGS)
1582 1501 {
1583 1502 const char *cattr;
1584 1503 enum htmltag t;
1585 1504
1586 1505 t = TAG_SPAN;
1587 1506
1588 1507 switch (n->tok) {
1589 1508 case MDOC__A:
1590 1509 cattr = "RsA";
1591 1510 if (n->prev && MDOC__A == n->prev->tok)
1592 1511 if (NULL == n->next || MDOC__A != n->next->tok)
1593 1512 print_text(h, "and");
1594 1513 break;
1595 1514 case MDOC__B:
1596 1515 t = TAG_I;
1597 1516 cattr = "RsB";
1598 1517 break;
1599 1518 case MDOC__C:
1600 1519 cattr = "RsC";
1601 1520 break;
1602 1521 case MDOC__D:
1603 1522 cattr = "RsD";
1604 1523 break;
1605 1524 case MDOC__I:
1606 1525 t = TAG_I;
1607 1526 cattr = "RsI";
1608 1527 break;
1609 1528 case MDOC__J:
1610 1529 t = TAG_I;
1611 1530 cattr = "RsJ";
1612 1531 break;
1613 1532 case MDOC__N:
1614 1533 cattr = "RsN";
1615 1534 break;
1616 1535 case MDOC__O:
1617 1536 cattr = "RsO";
1618 1537 break;
1619 1538 case MDOC__P:
1620 1539 cattr = "RsP";
1621 1540 break;
1622 1541 case MDOC__Q:
1623 1542 cattr = "RsQ";
1624 1543 break;
1625 1544 case MDOC__R:
1626 1545 cattr = "RsR";
1627 1546 break;
1628 1547 case MDOC__T:
1629 1548 cattr = "RsT";
1630 1549 break;
1631 1550 case MDOC__U:
1632 1551 print_otag(h, TAG_A, "ch", "RsU", n->child->string);
1633 1552 return 1;
1634 1553 case MDOC__V:
1635 1554 cattr = "RsV";
1636 1555 break;
1637 1556 default:
1638 1557 abort();
1639 1558 }
1640 1559
1641 1560 print_otag(h, t, "c", cattr);
1642 1561 return 1;
1643 1562 }
1644 1563
1645 1564 static void
1646 1565 mdoc__x_post(MDOC_ARGS)
1647 1566 {
1648 1567
1649 1568 if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok)
1650 1569 if (NULL == n->next->next || MDOC__A != n->next->next->tok)
1651 1570 if (NULL == n->prev || MDOC__A != n->prev->tok)
1652 1571 return;
1653 1572
1654 1573 /* TODO: %U */
1655 1574
1656 1575 if (NULL == n->parent || MDOC_Rs != n->parent->tok)
1657 1576 return;
1658 1577
1659 1578 h->flags |= HTML_NOSPACE;
1660 1579 print_text(h, n->next ? "," : ".");
1661 1580 }
1662 1581
1663 1582 static int
1664 1583 mdoc_bk_pre(MDOC_ARGS)
1665 1584 {
1666 1585
1667 1586 switch (n->type) {
1668 1587 case ROFFT_BLOCK:
1669 1588 break;
1670 1589 case ROFFT_HEAD:
1671 1590 return 0;
1672 1591 case ROFFT_BODY:
1673 1592 if (n->parent->args != NULL || n->prev->child == NULL)
1674 1593 h->flags |= HTML_PREKEEP;
1675 1594 break;
1676 1595 default:
1677 1596 abort();
1678 1597 }
1679 1598
1680 1599 return 1;
1681 1600 }
1682 1601
1683 1602 static void
1684 1603 mdoc_bk_post(MDOC_ARGS)
1685 1604 {
1686 1605
1687 1606 if (n->type == ROFFT_BODY)
1688 1607 h->flags &= ~(HTML_KEEP | HTML_PREKEEP);
1689 1608 }
1690 1609
1691 1610 static int
1692 1611 mdoc_quote_pre(MDOC_ARGS)
1693 1612 {
1694 1613 if (n->type != ROFFT_BODY)
1695 1614 return 1;
1696 1615
1697 1616 switch (n->tok) {
1698 1617 case MDOC_Ao:
1699 1618 case MDOC_Aq:
1700 1619 print_text(h, n->child != NULL && n->child->next == NULL &&
1701 1620 n->child->tok == MDOC_Mt ? "<" : "\\(la");
1702 1621 break;
1703 1622 case MDOC_Bro:
1704 1623 case MDOC_Brq:
↓ open down ↓ |
135 lines elided |
↑ open up ↑ |
1705 1624 print_text(h, "\\(lC");
1706 1625 break;
1707 1626 case MDOC_Bo:
1708 1627 case MDOC_Bq:
1709 1628 print_text(h, "\\(lB");
1710 1629 break;
1711 1630 case MDOC_Oo:
1712 1631 case MDOC_Op:
1713 1632 print_text(h, "\\(lB");
1714 1633 h->flags |= HTML_NOSPACE;
1715 - print_otag(h, TAG_SPAN, "c", "Op");
1634 + /* Cannot use TAG_SPAN because it may contain blocks. */
1635 + print_otag(h, TAG_IDIV, "c", "Op");
1716 1636 break;
1717 1637 case MDOC_En:
1718 1638 if (NULL == n->norm->Es ||
1719 1639 NULL == n->norm->Es->child)
1720 1640 return 1;
1721 1641 print_text(h, n->norm->Es->child->string);
1722 1642 break;
1723 1643 case MDOC_Do:
1724 1644 case MDOC_Dq:
1725 1645 case MDOC_Qo:
1726 1646 case MDOC_Qq:
1727 1647 print_text(h, "\\(lq");
1728 1648 break;
1729 1649 case MDOC_Po:
1730 1650 case MDOC_Pq:
1731 1651 print_text(h, "(");
1732 1652 break;
1733 1653 case MDOC_Ql:
1734 1654 print_text(h, "\\(oq");
1735 1655 h->flags |= HTML_NOSPACE;
1736 1656 print_otag(h, TAG_CODE, "c", "Li");
1737 1657 break;
1738 1658 case MDOC_So:
1739 1659 case MDOC_Sq:
1740 1660 print_text(h, "\\(oq");
1741 1661 break;
1742 1662 default:
1743 1663 abort();
1744 1664 }
1745 1665
1746 1666 h->flags |= HTML_NOSPACE;
1747 1667 return 1;
1748 1668 }
1749 1669
1750 1670 static void
1751 1671 mdoc_quote_post(MDOC_ARGS)
1752 1672 {
1753 1673
1754 1674 if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM)
1755 1675 return;
1756 1676
1757 1677 h->flags |= HTML_NOSPACE;
1758 1678
1759 1679 switch (n->tok) {
1760 1680 case MDOC_Ao:
1761 1681 case MDOC_Aq:
1762 1682 print_text(h, n->child != NULL && n->child->next == NULL &&
1763 1683 n->child->tok == MDOC_Mt ? ">" : "\\(ra");
1764 1684 break;
1765 1685 case MDOC_Bro:
1766 1686 case MDOC_Brq:
1767 1687 print_text(h, "\\(rC");
1768 1688 break;
1769 1689 case MDOC_Oo:
1770 1690 case MDOC_Op:
1771 1691 case MDOC_Bo:
1772 1692 case MDOC_Bq:
1773 1693 print_text(h, "\\(rB");
1774 1694 break;
1775 1695 case MDOC_En:
1776 1696 if (n->norm->Es == NULL ||
1777 1697 n->norm->Es->child == NULL ||
1778 1698 n->norm->Es->child->next == NULL)
1779 1699 h->flags &= ~HTML_NOSPACE;
1780 1700 else
1781 1701 print_text(h, n->norm->Es->child->next->string);
1782 1702 break;
1783 1703 case MDOC_Qo:
1784 1704 case MDOC_Qq:
1785 1705 case MDOC_Do:
1786 1706 case MDOC_Dq:
1787 1707 print_text(h, "\\(rq");
1788 1708 break;
1789 1709 case MDOC_Po:
1790 1710 case MDOC_Pq:
1791 1711 print_text(h, ")");
1792 1712 break;
1793 1713 case MDOC_Ql:
1794 1714 case MDOC_So:
1795 1715 case MDOC_Sq:
1796 1716 print_text(h, "\\(cq");
1797 1717 break;
1798 1718 default:
1799 1719 abort();
1800 1720 }
1801 1721 }
1802 1722
1803 1723 static int
1804 1724 mdoc_eo_pre(MDOC_ARGS)
1805 1725 {
1806 1726
1807 1727 if (n->type != ROFFT_BODY)
1808 1728 return 1;
1809 1729
1810 1730 if (n->end == ENDBODY_NOT &&
1811 1731 n->parent->head->child == NULL &&
1812 1732 n->child != NULL &&
1813 1733 n->child->end != ENDBODY_NOT)
1814 1734 print_text(h, "\\&");
1815 1735 else if (n->end != ENDBODY_NOT ? n->child != NULL :
1816 1736 n->parent->head->child != NULL && (n->child != NULL ||
1817 1737 (n->parent->tail != NULL && n->parent->tail->child != NULL)))
1818 1738 h->flags |= HTML_NOSPACE;
1819 1739 return 1;
1820 1740 }
1821 1741
1822 1742 static void
1823 1743 mdoc_eo_post(MDOC_ARGS)
1824 1744 {
1825 1745 int body, tail;
1826 1746
1827 1747 if (n->type != ROFFT_BODY)
1828 1748 return;
1829 1749
1830 1750 if (n->end != ENDBODY_NOT) {
1831 1751 h->flags &= ~HTML_NOSPACE;
1832 1752 return;
1833 1753 }
1834 1754
1835 1755 body = n->child != NULL || n->parent->head->child != NULL;
1836 1756 tail = n->parent->tail != NULL && n->parent->tail->child != NULL;
1837 1757
1838 1758 if (body && tail)
1839 1759 h->flags |= HTML_NOSPACE;
1840 1760 else if ( ! tail)
1841 1761 h->flags &= ~HTML_NOSPACE;
1842 1762 }
↓ open down ↓ |
117 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX