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