Print this page
Update to 1.12.3.
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/mandoc/man_html.c
+++ new/usr/src/cmd/mandoc/man_html.c
1 -/* $Id: man_html.c,v 1.86 2012/01/03 15:16:24 kristaps Exp $ */
1 +/* $Id: man_html.c,v 1.90 2013/10/17 20:54:58 schwarze Exp $ */
2 2 /*
3 - * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
3 + * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 + * Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
4 5 *
5 6 * Permission to use, copy, modify, and distribute this software for any
6 7 * purpose with or without fee is hereby granted, provided that the above
7 8 * copyright notice and this permission notice appear in all copies.
8 9 *
9 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 17 */
17 18 #ifdef HAVE_CONFIG_H
18 19 #include "config.h"
19 20 #endif
20 21
21 22 #include <sys/types.h>
22 23
23 24 #include <assert.h>
24 25 #include <ctype.h>
25 26 #include <stdio.h>
26 27 #include <stdlib.h>
27 28 #include <string.h>
28 29
29 30 #include "mandoc.h"
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
30 31 #include "out.h"
31 32 #include "html.h"
32 33 #include "man.h"
33 34 #include "main.h"
34 35
35 36 /* TODO: preserve ident widths. */
36 37 /* FIXME: have PD set the default vspace width. */
37 38
38 39 #define INDENT 5
39 40
40 -#define MAN_ARGS const struct man_meta *m, \
41 +#define MAN_ARGS const struct man_meta *man, \
41 42 const struct man_node *n, \
42 43 struct mhtml *mh, \
43 44 struct html *h
44 45
45 46 struct mhtml {
46 47 int fl;
47 48 #define MANH_LITERAL (1 << 0) /* literal context */
48 49 };
49 50
50 51 struct htmlman {
51 52 int (*pre)(MAN_ARGS);
52 53 int (*post)(MAN_ARGS);
53 54 };
54 55
55 56 static void print_bvspace(struct html *,
56 57 const struct man_node *);
57 58 static void print_man(MAN_ARGS);
58 59 static void print_man_head(MAN_ARGS);
59 60 static void print_man_nodelist(MAN_ARGS);
60 61 static void print_man_node(MAN_ARGS);
61 62 static int a2width(const struct man_node *,
62 63 struct roffsu *);
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
63 64 static int man_B_pre(MAN_ARGS);
64 65 static int man_HP_pre(MAN_ARGS);
65 66 static int man_IP_pre(MAN_ARGS);
66 67 static int man_I_pre(MAN_ARGS);
67 68 static int man_OP_pre(MAN_ARGS);
68 69 static int man_PP_pre(MAN_ARGS);
69 70 static int man_RS_pre(MAN_ARGS);
70 71 static int man_SH_pre(MAN_ARGS);
71 72 static int man_SM_pre(MAN_ARGS);
72 73 static int man_SS_pre(MAN_ARGS);
74 +static int man_UR_pre(MAN_ARGS);
73 75 static int man_alt_pre(MAN_ARGS);
74 76 static int man_br_pre(MAN_ARGS);
75 77 static int man_ign_pre(MAN_ARGS);
76 78 static int man_in_pre(MAN_ARGS);
77 79 static int man_literal_pre(MAN_ARGS);
78 80 static void man_root_post(MAN_ARGS);
79 81 static void man_root_pre(MAN_ARGS);
80 82
81 83 static const struct htmlman mans[MAN_MAX] = {
82 84 { man_br_pre, NULL }, /* br */
83 85 { NULL, NULL }, /* TH */
84 86 { man_SH_pre, NULL }, /* SH */
85 87 { man_SS_pre, NULL }, /* SS */
86 88 { man_IP_pre, NULL }, /* TP */
87 89 { man_PP_pre, NULL }, /* LP */
88 90 { man_PP_pre, NULL }, /* PP */
89 91 { man_PP_pre, NULL }, /* P */
90 92 { man_IP_pre, NULL }, /* IP */
91 93 { man_HP_pre, NULL }, /* HP */
92 94 { man_SM_pre, NULL }, /* SM */
93 95 { man_SM_pre, NULL }, /* SB */
94 96 { man_alt_pre, NULL }, /* BI */
95 97 { man_alt_pre, NULL }, /* IB */
96 98 { man_alt_pre, NULL }, /* BR */
97 99 { man_alt_pre, NULL }, /* RB */
98 100 { NULL, NULL }, /* R */
99 101 { man_B_pre, NULL }, /* B */
100 102 { man_I_pre, NULL }, /* I */
101 103 { man_alt_pre, NULL }, /* IR */
102 104 { man_alt_pre, NULL }, /* RI */
103 105 { man_ign_pre, NULL }, /* na */
104 106 { man_br_pre, NULL }, /* sp */
105 107 { man_literal_pre, NULL }, /* nf */
↓ open down ↓ |
23 lines elided |
↑ open up ↑ |
106 108 { man_literal_pre, NULL }, /* fi */
107 109 { NULL, NULL }, /* RE */
108 110 { man_RS_pre, NULL }, /* RS */
109 111 { man_ign_pre, NULL }, /* DT */
110 112 { man_ign_pre, NULL }, /* UC */
111 113 { man_ign_pre, NULL }, /* PD */
112 114 { man_ign_pre, NULL }, /* AT */
113 115 { man_in_pre, NULL }, /* in */
114 116 { man_ign_pre, NULL }, /* ft */
115 117 { man_OP_pre, NULL }, /* OP */
118 + { man_literal_pre, NULL }, /* EX */
119 + { man_literal_pre, NULL }, /* EE */
120 + { man_UR_pre, NULL }, /* UR */
121 + { NULL, NULL }, /* UE */
116 122 };
117 123
118 124 /*
119 125 * Printing leading vertical space before a block.
120 126 * This is used for the paragraph macros.
121 127 * The rules are pretty simple, since there's very little nesting going
122 128 * on here. Basically, if we're the first within another block (SS/SH),
123 129 * then don't emit vertical space. If we are (RS), then do. If not the
124 130 * first, print it.
125 131 */
126 132 static void
127 133 print_bvspace(struct html *h, const struct man_node *n)
128 134 {
129 135
130 136 if (n->body && n->body->child)
131 137 if (MAN_TBL == n->body->child->type)
↓ open down ↓ |
6 lines elided |
↑ open up ↑ |
132 138 return;
133 139
134 140 if (MAN_ROOT == n->parent->type || MAN_RS != n->parent->tok)
135 141 if (NULL == n->prev)
136 142 return;
137 143
138 144 print_otag(h, TAG_P, 0, NULL);
139 145 }
140 146
141 147 void
142 -html_man(void *arg, const struct man *m)
148 +html_man(void *arg, const struct man *man)
143 149 {
144 150 struct mhtml mh;
145 151
146 152 memset(&mh, 0, sizeof(struct mhtml));
147 - print_man(man_meta(m), man_node(m), &mh, (struct html *)arg);
153 + print_man(man_meta(man), man_node(man), &mh, (struct html *)arg);
148 154 putchar('\n');
149 155 }
150 156
151 157 static void
152 158 print_man(MAN_ARGS)
153 159 {
154 160 struct tag *t, *tt;
155 161 struct htmlpair tag;
156 162
157 163 PAIR_CLASS_INIT(&tag, "mandoc");
158 164
159 165 if ( ! (HTML_FRAGMENT & h->oflags)) {
160 166 print_gen_decls(h);
161 167 t = print_otag(h, TAG_HTML, 0, NULL);
162 168 tt = print_otag(h, TAG_HEAD, 0, NULL);
163 - print_man_head(m, n, mh, h);
169 + print_man_head(man, n, mh, h);
164 170 print_tagq(h, tt);
165 171 print_otag(h, TAG_BODY, 0, NULL);
166 172 print_otag(h, TAG_DIV, 1, &tag);
167 173 } else
168 174 t = print_otag(h, TAG_DIV, 1, &tag);
169 175
170 - print_man_nodelist(m, n, mh, h);
176 + print_man_nodelist(man, n, mh, h);
171 177 print_tagq(h, t);
172 178 }
173 179
174 180
175 181 /* ARGSUSED */
176 182 static void
177 183 print_man_head(MAN_ARGS)
178 184 {
179 185
180 186 print_gen_head(h);
181 - assert(m->title);
182 - assert(m->msec);
183 - bufcat_fmt(h, "%s(%s)", m->title, m->msec);
187 + assert(man->title);
188 + assert(man->msec);
189 + bufcat_fmt(h, "%s(%s)", man->title, man->msec);
184 190 print_otag(h, TAG_TITLE, 0, NULL);
185 191 print_text(h, h->buf);
186 192 }
187 193
188 194
189 195 static void
190 196 print_man_nodelist(MAN_ARGS)
191 197 {
192 198
193 - print_man_node(m, n, mh, h);
199 + print_man_node(man, n, mh, h);
194 200 if (n->next)
195 - print_man_nodelist(m, n->next, mh, h);
201 + print_man_nodelist(man, n->next, mh, h);
196 202 }
197 203
198 204
199 205 static void
200 206 print_man_node(MAN_ARGS)
201 207 {
202 208 int child;
203 209 struct tag *t;
204 210
205 211 child = 1;
206 212 t = h->tags.head;
207 213
208 214 switch (n->type) {
209 215 case (MAN_ROOT):
210 - man_root_pre(m, n, mh, h);
216 + man_root_pre(man, n, mh, h);
211 217 break;
212 218 case (MAN_TEXT):
213 219 /*
214 220 * If we have a blank line, output a vertical space.
215 221 * If we have a space as the first character, break
216 222 * before printing the line's data.
217 223 */
218 224 if ('\0' == *n->string) {
219 225 print_otag(h, TAG_P, 0, NULL);
220 226 return;
221 227 }
222 228
223 229 if (' ' == *n->string && MAN_LINE & n->flags)
224 230 print_otag(h, TAG_BR, 0, NULL);
225 231 else if (MANH_LITERAL & mh->fl && n->prev)
226 232 print_otag(h, TAG_BR, 0, NULL);
227 233
228 234 print_text(h, n->string);
229 235 return;
230 236 case (MAN_EQN):
231 237 print_eqn(h, n->eqn);
232 238 break;
233 239 case (MAN_TBL):
234 240 /*
235 241 * This will take care of initialising all of the table
236 242 * state data for the first table, then tearing it down
237 243 * for the last one.
238 244 */
239 245 print_tbl(h, n->span);
240 246 return;
241 247 default:
242 248 /*
243 249 * Close out scope of font prior to opening a macro
244 250 * scope.
245 251 */
246 252 if (HTMLFONT_NONE != h->metac) {
247 253 h->metal = h->metac;
248 254 h->metac = HTMLFONT_NONE;
249 255 }
250 256
↓ open down ↓ |
30 lines elided |
↑ open up ↑ |
251 257 /*
252 258 * Close out the current table, if it's open, and unset
253 259 * the "meta" table state. This will be reopened on the
254 260 * next table element.
255 261 */
256 262 if (h->tblt) {
257 263 print_tblclose(h);
258 264 t = h->tags.head;
259 265 }
260 266 if (mans[n->tok].pre)
261 - child = (*mans[n->tok].pre)(m, n, mh, h);
267 + child = (*mans[n->tok].pre)(man, n, mh, h);
262 268 break;
263 269 }
264 270
265 271 if (child && n->child)
266 - print_man_nodelist(m, n->child, mh, h);
272 + print_man_nodelist(man, n->child, mh, h);
267 273
268 274 /* This will automatically close out any font scope. */
269 275 print_stagq(h, t);
270 276
271 277 switch (n->type) {
272 278 case (MAN_ROOT):
273 - man_root_post(m, n, mh, h);
279 + man_root_post(man, n, mh, h);
274 280 break;
275 281 case (MAN_EQN):
276 282 break;
277 283 default:
278 284 if (mans[n->tok].post)
279 - (*mans[n->tok].post)(m, n, mh, h);
285 + (*mans[n->tok].post)(man, n, mh, h);
280 286 break;
281 287 }
282 288 }
283 289
284 290
285 291 static int
286 292 a2width(const struct man_node *n, struct roffsu *su)
287 293 {
288 294
289 295 if (MAN_TEXT != n->type)
290 296 return(0);
291 297 if (a2roffsu(n->string, su, SCALE_BU))
292 298 return(1);
293 299
294 300 return(0);
295 301 }
296 302
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
297 303
298 304 /* ARGSUSED */
299 305 static void
300 306 man_root_pre(MAN_ARGS)
301 307 {
302 308 struct htmlpair tag[3];
303 309 struct tag *t, *tt;
304 310 char b[BUFSIZ], title[BUFSIZ];
305 311
306 312 b[0] = 0;
307 - if (m->vol)
308 - (void)strlcat(b, m->vol, BUFSIZ);
313 + if (man->vol)
314 + (void)strlcat(b, man->vol, BUFSIZ);
309 315
310 - assert(m->title);
311 - assert(m->msec);
312 - snprintf(title, BUFSIZ - 1, "%s(%s)", m->title, m->msec);
316 + assert(man->title);
317 + assert(man->msec);
318 + snprintf(title, BUFSIZ - 1, "%s(%s)", man->title, man->msec);
313 319
314 320 PAIR_SUMMARY_INIT(&tag[0], "Document Header");
315 321 PAIR_CLASS_INIT(&tag[1], "head");
316 322 PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
317 323 t = print_otag(h, TAG_TABLE, 3, tag);
318 324 PAIR_INIT(&tag[0], ATTR_WIDTH, "30%");
319 325 print_otag(h, TAG_COL, 1, tag);
320 326 print_otag(h, TAG_COL, 1, tag);
321 327 print_otag(h, TAG_COL, 1, tag);
322 328
323 329 print_otag(h, TAG_TBODY, 0, NULL);
324 330
325 331 tt = print_otag(h, TAG_TR, 0, NULL);
326 332
327 333 PAIR_CLASS_INIT(&tag[0], "head-ltitle");
328 334 print_otag(h, TAG_TD, 1, tag);
329 335 print_text(h, title);
330 336 print_stagq(h, tt);
331 337
332 338 PAIR_CLASS_INIT(&tag[0], "head-vol");
333 339 PAIR_INIT(&tag[1], ATTR_ALIGN, "center");
334 340 print_otag(h, TAG_TD, 2, tag);
335 341 print_text(h, b);
336 342 print_stagq(h, tt);
337 343
338 344 PAIR_CLASS_INIT(&tag[0], "head-rtitle");
339 345 PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
340 346 print_otag(h, TAG_TD, 2, tag);
341 347 print_text(h, title);
342 348 print_tagq(h, t);
343 349 }
344 350
345 351
346 352 /* ARGSUSED */
347 353 static void
348 354 man_root_post(MAN_ARGS)
349 355 {
350 356 struct htmlpair tag[3];
351 357 struct tag *t, *tt;
352 358
353 359 PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
354 360 PAIR_CLASS_INIT(&tag[1], "foot");
355 361 PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
↓ open down ↓ |
33 lines elided |
↑ open up ↑ |
356 362 t = print_otag(h, TAG_TABLE, 3, tag);
357 363 PAIR_INIT(&tag[0], ATTR_WIDTH, "50%");
358 364 print_otag(h, TAG_COL, 1, tag);
359 365 print_otag(h, TAG_COL, 1, tag);
360 366
361 367 tt = print_otag(h, TAG_TR, 0, NULL);
362 368
363 369 PAIR_CLASS_INIT(&tag[0], "foot-date");
364 370 print_otag(h, TAG_TD, 1, tag);
365 371
366 - assert(m->date);
367 - print_text(h, m->date);
372 + assert(man->date);
373 + print_text(h, man->date);
368 374 print_stagq(h, tt);
369 375
370 376 PAIR_CLASS_INIT(&tag[0], "foot-os");
371 377 PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
372 378 print_otag(h, TAG_TD, 2, tag);
373 379
374 - if (m->source)
375 - print_text(h, m->source);
380 + if (man->source)
381 + print_text(h, man->source);
376 382 print_tagq(h, t);
377 383 }
378 384
379 385
380 386 /* ARGSUSED */
381 387 static int
382 388 man_br_pre(MAN_ARGS)
383 389 {
384 390 struct roffsu su;
385 391 struct htmlpair tag;
386 392
387 393 SCALE_VS_INIT(&su, 1);
388 394
389 395 if (MAN_sp == n->tok) {
390 396 if (NULL != (n = n->child))
391 397 if ( ! a2roffsu(n->string, &su, SCALE_VS))
392 398 SCALE_VS_INIT(&su, atoi(n->string));
393 399 } else
394 400 su.scale = 0;
395 401
396 402 bufinit(h);
397 403 bufcat_su(h, "height", &su);
398 404 PAIR_STYLE_INIT(&tag, h);
399 405 print_otag(h, TAG_DIV, 1, &tag);
400 406
401 407 /* So the div isn't empty: */
402 408 print_text(h, "\\~");
403 409
404 410 return(0);
405 411 }
406 412
407 413 /* ARGSUSED */
408 414 static int
409 415 man_SH_pre(MAN_ARGS)
410 416 {
411 417 struct htmlpair tag;
412 418
413 419 if (MAN_BLOCK == n->type) {
414 420 mh->fl &= ~MANH_LITERAL;
415 421 PAIR_CLASS_INIT(&tag, "section");
416 422 print_otag(h, TAG_DIV, 1, &tag);
417 423 return(1);
418 424 } else if (MAN_BODY == n->type)
419 425 return(1);
420 426
421 427 print_otag(h, TAG_H1, 0, NULL);
422 428 return(1);
423 429 }
424 430
425 431 /* ARGSUSED */
426 432 static int
427 433 man_alt_pre(MAN_ARGS)
428 434 {
429 435 const struct man_node *nn;
430 436 int i, savelit;
431 437 enum htmltag fp;
432 438 struct tag *t;
433 439
434 440 if ((savelit = mh->fl & MANH_LITERAL))
435 441 print_otag(h, TAG_BR, 0, NULL);
436 442
437 443 mh->fl &= ~MANH_LITERAL;
438 444
439 445 for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
440 446 t = NULL;
441 447 switch (n->tok) {
442 448 case (MAN_BI):
443 449 fp = i % 2 ? TAG_I : TAG_B;
444 450 break;
445 451 case (MAN_IB):
446 452 fp = i % 2 ? TAG_B : TAG_I;
447 453 break;
448 454 case (MAN_RI):
449 455 fp = i % 2 ? TAG_I : TAG_MAX;
450 456 break;
451 457 case (MAN_IR):
452 458 fp = i % 2 ? TAG_MAX : TAG_I;
453 459 break;
454 460 case (MAN_BR):
455 461 fp = i % 2 ? TAG_MAX : TAG_B;
456 462 break;
457 463 case (MAN_RB):
458 464 fp = i % 2 ? TAG_B : TAG_MAX;
459 465 break;
460 466 default:
↓ open down ↓ |
75 lines elided |
↑ open up ↑ |
461 467 abort();
462 468 /* NOTREACHED */
463 469 }
464 470
465 471 if (i)
466 472 h->flags |= HTML_NOSPACE;
467 473
468 474 if (TAG_MAX != fp)
469 475 t = print_otag(h, fp, 0, NULL);
470 476
471 - print_man_node(m, nn, mh, h);
477 + print_man_node(man, nn, mh, h);
472 478
473 479 if (t)
474 480 print_tagq(h, t);
475 481 }
476 482
477 483 if (savelit)
478 484 mh->fl |= MANH_LITERAL;
479 485
480 486 return(0);
481 487 }
482 488
483 489 /* ARGSUSED */
484 490 static int
485 491 man_SM_pre(MAN_ARGS)
486 492 {
487 493
488 494 print_otag(h, TAG_SMALL, 0, NULL);
489 495 if (MAN_SB == n->tok)
490 496 print_otag(h, TAG_B, 0, NULL);
491 497 return(1);
492 498 }
493 499
494 500 /* ARGSUSED */
495 501 static int
496 502 man_SS_pre(MAN_ARGS)
497 503 {
498 504 struct htmlpair tag;
499 505
500 506 if (MAN_BLOCK == n->type) {
501 507 mh->fl &= ~MANH_LITERAL;
502 508 PAIR_CLASS_INIT(&tag, "subsection");
503 509 print_otag(h, TAG_DIV, 1, &tag);
504 510 return(1);
505 511 } else if (MAN_BODY == n->type)
506 512 return(1);
507 513
508 514 print_otag(h, TAG_H2, 0, NULL);
509 515 return(1);
510 516 }
511 517
512 518 /* ARGSUSED */
513 519 static int
514 520 man_PP_pre(MAN_ARGS)
515 521 {
516 522
517 523 if (MAN_HEAD == n->type)
518 524 return(0);
519 525 else if (MAN_BLOCK == n->type)
520 526 print_bvspace(h, n);
521 527
522 528 return(1);
523 529 }
524 530
525 531 /* ARGSUSED */
526 532 static int
527 533 man_IP_pre(MAN_ARGS)
528 534 {
529 535 const struct man_node *nn;
530 536
531 537 if (MAN_BODY == n->type) {
532 538 print_otag(h, TAG_DD, 0, NULL);
533 539 return(1);
534 540 } else if (MAN_HEAD != n->type) {
535 541 print_otag(h, TAG_DL, 0, NULL);
↓ open down ↓ |
54 lines elided |
↑ open up ↑ |
536 542 return(1);
537 543 }
538 544
539 545 /* FIXME: width specification. */
540 546
541 547 print_otag(h, TAG_DT, 0, NULL);
542 548
543 549 /* For IP, only print the first header element. */
544 550
545 551 if (MAN_IP == n->tok && n->child)
546 - print_man_node(m, n->child, mh, h);
552 + print_man_node(man, n->child, mh, h);
547 553
548 554 /* For TP, only print next-line header elements. */
549 555
550 556 if (MAN_TP == n->tok)
551 557 for (nn = n->child; nn; nn = nn->next)
552 558 if (nn->line > n->line)
553 - print_man_node(m, nn, mh, h);
559 + print_man_node(man, nn, mh, h);
554 560
555 561 return(0);
556 562 }
557 563
558 564 /* ARGSUSED */
559 565 static int
560 566 man_HP_pre(MAN_ARGS)
561 567 {
562 568 struct htmlpair tag;
563 569 struct roffsu su;
564 570 const struct man_node *np;
565 571
566 572 if (MAN_HEAD == n->type)
567 573 return(0);
568 574 else if (MAN_BLOCK != n->type)
569 575 return(1);
570 576
571 577 np = n->head->child;
572 578
573 579 if (NULL == np || ! a2width(np, &su))
574 580 SCALE_HS_INIT(&su, INDENT);
575 581
576 582 bufinit(h);
577 583
578 584 print_bvspace(h, n);
579 585 bufcat_su(h, "margin-left", &su);
580 586 su.scale = -su.scale;
581 587 bufcat_su(h, "text-indent", &su);
582 588 PAIR_STYLE_INIT(&tag, h);
583 589 print_otag(h, TAG_P, 1, &tag);
584 590 return(1);
585 591 }
586 592
587 593 /* ARGSUSED */
588 594 static int
589 595 man_OP_pre(MAN_ARGS)
590 596 {
591 597 struct tag *tt;
592 598 struct htmlpair tag;
593 599
594 600 print_text(h, "[");
595 601 h->flags |= HTML_NOSPACE;
596 602 PAIR_CLASS_INIT(&tag, "opt");
597 603 tt = print_otag(h, TAG_SPAN, 1, &tag);
598 604
599 605 if (NULL != (n = n->child)) {
600 606 print_otag(h, TAG_B, 0, NULL);
601 607 print_text(h, n->string);
602 608 }
603 609
604 610 print_stagq(h, tt);
605 611
606 612 if (NULL != n && NULL != n->next) {
607 613 print_otag(h, TAG_I, 0, NULL);
608 614 print_text(h, n->next->string);
609 615 }
610 616
611 617 print_stagq(h, tt);
612 618 h->flags |= HTML_NOSPACE;
613 619 print_text(h, "]");
614 620 return(0);
615 621 }
616 622
617 623
618 624 /* ARGSUSED */
619 625 static int
620 626 man_B_pre(MAN_ARGS)
621 627 {
622 628
623 629 print_otag(h, TAG_B, 0, NULL);
624 630 return(1);
625 631 }
626 632
627 633 /* ARGSUSED */
628 634 static int
629 635 man_I_pre(MAN_ARGS)
630 636 {
↓ open down ↓ |
67 lines elided |
↑ open up ↑ |
631 637
632 638 print_otag(h, TAG_I, 0, NULL);
633 639 return(1);
634 640 }
635 641
636 642 /* ARGSUSED */
637 643 static int
638 644 man_literal_pre(MAN_ARGS)
639 645 {
640 646
641 - if (MAN_nf != n->tok) {
647 + if (MAN_fi == n->tok || MAN_EE == n->tok) {
642 648 print_otag(h, TAG_BR, 0, NULL);
643 649 mh->fl &= ~MANH_LITERAL;
644 650 } else
645 651 mh->fl |= MANH_LITERAL;
646 652
647 653 return(0);
648 654 }
649 655
650 656 /* ARGSUSED */
651 657 static int
652 658 man_in_pre(MAN_ARGS)
653 659 {
654 660
655 661 print_otag(h, TAG_BR, 0, NULL);
656 662 return(0);
657 663 }
658 664
659 665 /* ARGSUSED */
660 666 static int
661 667 man_ign_pre(MAN_ARGS)
662 668 {
663 669
664 670 return(0);
665 671 }
666 672
667 673 /* ARGSUSED */
668 674 static int
669 675 man_RS_pre(MAN_ARGS)
670 676 {
671 677 struct htmlpair tag;
672 678 struct roffsu su;
673 679
674 680 if (MAN_HEAD == n->type)
675 681 return(0);
676 682 else if (MAN_BODY == n->type)
677 683 return(1);
↓ open down ↓ |
26 lines elided |
↑ open up ↑ |
678 684
679 685 SCALE_HS_INIT(&su, INDENT);
680 686 if (n->head->child)
681 687 a2width(n->head->child, &su);
682 688
683 689 bufinit(h);
684 690 bufcat_su(h, "margin-left", &su);
685 691 PAIR_STYLE_INIT(&tag, h);
686 692 print_otag(h, TAG_DIV, 1, &tag);
687 693 return(1);
694 +}
695 +
696 +/* ARGSUSED */
697 +static int
698 +man_UR_pre(MAN_ARGS)
699 +{
700 + struct htmlpair tag[2];
701 +
702 + n = n->child;
703 + assert(MAN_HEAD == n->type);
704 + if (n->nchild) {
705 + assert(MAN_TEXT == n->child->type);
706 + PAIR_CLASS_INIT(&tag[0], "link-ext");
707 + PAIR_HREF_INIT(&tag[1], n->child->string);
708 + print_otag(h, TAG_A, 2, tag);
709 + }
710 +
711 + assert(MAN_BODY == n->next->type);
712 + if (n->next->nchild)
713 + n = n->next;
714 +
715 + print_man_nodelist(man, n->child, mh, h);
716 +
717 + return(0);
688 718 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX