[BACK]Return to mdoc_html.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Annotation of mandoc/mdoc_html.c, Revision 1.71

1.71    ! kristaps    1: /*     $Id: mdoc_html.c,v 1.70 2010/05/30 22:56:02 kristaps Exp $ */
1.1       kristaps    2: /*
                      3:  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
                      4:  *
                      5:  * Permission to use, copy, modify, and distribute this software for any
                      6:  * purpose with or without fee is hereby granted, provided that the above
                      7:  * copyright notice and this permission notice appear in all copies.
                      8:  *
                      9:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     10:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     11:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     12:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     13:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     14:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     15:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     16:  */
1.52      kristaps   17: #ifdef HAVE_CONFIG_H
                     18: #include "config.h"
                     19: #endif
                     20:
1.1       kristaps   21: #include <sys/types.h>
                     22:
                     23: #include <assert.h>
                     24: #include <ctype.h>
                     25: #include <stdio.h>
                     26: #include <stdlib.h>
                     27: #include <string.h>
                     28: #include <unistd.h>
                     29:
1.65      kristaps   30: #include "mandoc.h"
1.23      kristaps   31: #include "out.h"
1.1       kristaps   32: #include "html.h"
                     33: #include "mdoc.h"
1.29      kristaps   34: #include "main.h"
1.1       kristaps   35:
                     36: #define        INDENT           5
                     37: #define        HALFINDENT       3
                     38:
                     39: #define        MDOC_ARGS         const struct mdoc_meta *m, \
                     40:                          const struct mdoc_node *n, \
                     41:                          struct html *h
                     42:
1.52      kristaps   43: #ifndef MIN
                     44: #define        MIN(a,b)        ((/*CONSTCOND*/(a)<(b))?(a):(b))
                     45: #endif
                     46:
1.1       kristaps   47: struct htmlmdoc {
                     48:        int             (*pre)(MDOC_ARGS);
                     49:        void            (*post)(MDOC_ARGS);
                     50: };
                     51:
                     52: static void              print_mdoc(MDOC_ARGS);
                     53: static void              print_mdoc_head(MDOC_ARGS);
                     54: static void              print_mdoc_node(MDOC_ARGS);
                     55: static void              print_mdoc_nodelist(MDOC_ARGS);
                     56:
1.23      kristaps   57: static void              a2width(const char *, struct roffsu *);
                     58: static void              a2offs(const char *, struct roffsu *);
1.27      kristaps   59:
1.1       kristaps   60: static void              mdoc_root_post(MDOC_ARGS);
                     61: static int               mdoc_root_pre(MDOC_ARGS);
                     62:
1.10      kristaps   63: static void              mdoc__x_post(MDOC_ARGS);
                     64: static int               mdoc__x_pre(MDOC_ARGS);
1.1       kristaps   65: static int               mdoc_ad_pre(MDOC_ARGS);
                     66: static int               mdoc_an_pre(MDOC_ARGS);
1.5       kristaps   67: static int               mdoc_ap_pre(MDOC_ARGS);
1.1       kristaps   68: static void              mdoc_aq_post(MDOC_ARGS);
                     69: static int               mdoc_aq_pre(MDOC_ARGS);
                     70: static int               mdoc_ar_pre(MDOC_ARGS);
                     71: static int               mdoc_bd_pre(MDOC_ARGS);
1.5       kristaps   72: static int               mdoc_bf_pre(MDOC_ARGS);
1.1       kristaps   73: static void              mdoc_bl_post(MDOC_ARGS);
                     74: static int               mdoc_bl_pre(MDOC_ARGS);
1.4       kristaps   75: static void              mdoc_bq_post(MDOC_ARGS);
                     76: static int               mdoc_bq_pre(MDOC_ARGS);
1.2       kristaps   77: static void              mdoc_brq_post(MDOC_ARGS);
                     78: static int               mdoc_brq_pre(MDOC_ARGS);
1.6       kristaps   79: static int               mdoc_bt_pre(MDOC_ARGS);
1.4       kristaps   80: static int               mdoc_bx_pre(MDOC_ARGS);
1.1       kristaps   81: static int               mdoc_cd_pre(MDOC_ARGS);
                     82: static int               mdoc_d1_pre(MDOC_ARGS);
                     83: static void              mdoc_dq_post(MDOC_ARGS);
                     84: static int               mdoc_dq_pre(MDOC_ARGS);
                     85: static int               mdoc_dv_pre(MDOC_ARGS);
                     86: static int               mdoc_fa_pre(MDOC_ARGS);
                     87: static int               mdoc_fd_pre(MDOC_ARGS);
                     88: static int               mdoc_fl_pre(MDOC_ARGS);
                     89: static int               mdoc_fn_pre(MDOC_ARGS);
                     90: static int               mdoc_ft_pre(MDOC_ARGS);
                     91: static int               mdoc_em_pre(MDOC_ARGS);
                     92: static int               mdoc_er_pre(MDOC_ARGS);
                     93: static int               mdoc_ev_pre(MDOC_ARGS);
                     94: static int               mdoc_ex_pre(MDOC_ARGS);
1.4       kristaps   95: static void              mdoc_fo_post(MDOC_ARGS);
                     96: static int               mdoc_fo_pre(MDOC_ARGS);
                     97: static int               mdoc_ic_pre(MDOC_ARGS);
                     98: static int               mdoc_in_pre(MDOC_ARGS);
1.66      kristaps   99: static int               mdoc_it_block_pre(MDOC_ARGS, enum mdoc_list,
                    100:                                int, struct roffsu *, struct roffsu *);
                    101: static int               mdoc_it_head_pre(MDOC_ARGS, enum mdoc_list,
1.27      kristaps  102:                                struct roffsu *);
1.70      kristaps  103: static int               mdoc_it_body_pre(MDOC_ARGS, enum mdoc_list,
                    104:                                struct roffsu *);
1.1       kristaps  105: static int               mdoc_it_pre(MDOC_ARGS);
1.6       kristaps  106: static int               mdoc_lb_pre(MDOC_ARGS);
                    107: static int               mdoc_li_pre(MDOC_ARGS);
1.2       kristaps  108: static int               mdoc_lk_pre(MDOC_ARGS);
                    109: static int               mdoc_mt_pre(MDOC_ARGS);
1.5       kristaps  110: static int               mdoc_ms_pre(MDOC_ARGS);
1.1       kristaps  111: static int               mdoc_nd_pre(MDOC_ARGS);
                    112: static int               mdoc_nm_pre(MDOC_ARGS);
                    113: static int               mdoc_ns_pre(MDOC_ARGS);
                    114: static void              mdoc_op_post(MDOC_ARGS);
                    115: static int               mdoc_op_pre(MDOC_ARGS);
                    116: static int               mdoc_pa_pre(MDOC_ARGS);
1.5       kristaps  117: static void              mdoc_pf_post(MDOC_ARGS);
                    118: static int               mdoc_pf_pre(MDOC_ARGS);
1.1       kristaps  119: static void              mdoc_pq_post(MDOC_ARGS);
                    120: static int               mdoc_pq_pre(MDOC_ARGS);
1.5       kristaps  121: static int               mdoc_rs_pre(MDOC_ARGS);
1.4       kristaps  122: static int               mdoc_rv_pre(MDOC_ARGS);
1.1       kristaps  123: static int               mdoc_sh_pre(MDOC_ARGS);
                    124: static int               mdoc_sp_pre(MDOC_ARGS);
                    125: static void              mdoc_sq_post(MDOC_ARGS);
                    126: static int               mdoc_sq_pre(MDOC_ARGS);
                    127: static int               mdoc_ss_pre(MDOC_ARGS);
                    128: static int               mdoc_sx_pre(MDOC_ARGS);
1.6       kristaps  129: static int               mdoc_sy_pre(MDOC_ARGS);
                    130: static int               mdoc_ud_pre(MDOC_ARGS);
1.4       kristaps  131: static int               mdoc_va_pre(MDOC_ARGS);
1.1       kristaps  132: static int               mdoc_vt_pre(MDOC_ARGS);
                    133: static int               mdoc_xr_pre(MDOC_ARGS);
                    134: static int               mdoc_xx_pre(MDOC_ARGS);
                    135:
                    136: static const struct htmlmdoc mdocs[MDOC_MAX] = {
1.5       kristaps  137:        {mdoc_ap_pre, NULL}, /* Ap */
1.1       kristaps  138:        {NULL, NULL}, /* Dd */
                    139:        {NULL, NULL}, /* Dt */
                    140:        {NULL, NULL}, /* Os */
                    141:        {mdoc_sh_pre, NULL }, /* Sh */
                    142:        {mdoc_ss_pre, NULL }, /* Ss */
                    143:        {mdoc_sp_pre, NULL}, /* Pp */
                    144:        {mdoc_d1_pre, NULL}, /* D1 */
                    145:        {mdoc_d1_pre, NULL}, /* Dl */
                    146:        {mdoc_bd_pre, NULL}, /* Bd */
                    147:        {NULL, NULL}, /* Ed */
                    148:        {mdoc_bl_pre, mdoc_bl_post}, /* Bl */
                    149:        {NULL, NULL}, /* El */
                    150:        {mdoc_it_pre, NULL}, /* It */
                    151:        {mdoc_ad_pre, NULL}, /* Ad */
                    152:        {mdoc_an_pre, NULL}, /* An */
                    153:        {mdoc_ar_pre, NULL}, /* Ar */
                    154:        {mdoc_cd_pre, NULL}, /* Cd */
                    155:        {mdoc_fl_pre, NULL}, /* Cm */
                    156:        {mdoc_dv_pre, NULL}, /* Dv */
                    157:        {mdoc_er_pre, NULL}, /* Er */
                    158:        {mdoc_ev_pre, NULL}, /* Ev */
                    159:        {mdoc_ex_pre, NULL}, /* Ex */
                    160:        {mdoc_fa_pre, NULL}, /* Fa */
                    161:        {mdoc_fd_pre, NULL}, /* Fd */
                    162:        {mdoc_fl_pre, NULL}, /* Fl */
                    163:        {mdoc_fn_pre, NULL}, /* Fn */
                    164:        {mdoc_ft_pre, NULL}, /* Ft */
1.4       kristaps  165:        {mdoc_ic_pre, NULL}, /* Ic */
                    166:        {mdoc_in_pre, NULL}, /* In */
1.6       kristaps  167:        {mdoc_li_pre, NULL}, /* Li */
1.1       kristaps  168:        {mdoc_nd_pre, NULL}, /* Nd */
                    169:        {mdoc_nm_pre, NULL}, /* Nm */
                    170:        {mdoc_op_pre, mdoc_op_post}, /* Op */
                    171:        {NULL, NULL}, /* Ot */
                    172:        {mdoc_pa_pre, NULL}, /* Pa */
1.4       kristaps  173:        {mdoc_rv_pre, NULL}, /* Rv */
1.1       kristaps  174:        {NULL, NULL}, /* St */
1.4       kristaps  175:        {mdoc_va_pre, NULL}, /* Va */
1.1       kristaps  176:        {mdoc_vt_pre, NULL}, /* Vt */
                    177:        {mdoc_xr_pre, NULL}, /* Xr */
1.10      kristaps  178:        {mdoc__x_pre, mdoc__x_post}, /* %A */
                    179:        {mdoc__x_pre, mdoc__x_post}, /* %B */
                    180:        {mdoc__x_pre, mdoc__x_post}, /* %D */
                    181:        {mdoc__x_pre, mdoc__x_post}, /* %I */
                    182:        {mdoc__x_pre, mdoc__x_post}, /* %J */
                    183:        {mdoc__x_pre, mdoc__x_post}, /* %N */
                    184:        {mdoc__x_pre, mdoc__x_post}, /* %O */
                    185:        {mdoc__x_pre, mdoc__x_post}, /* %P */
                    186:        {mdoc__x_pre, mdoc__x_post}, /* %R */
                    187:        {mdoc__x_pre, mdoc__x_post}, /* %T */
                    188:        {mdoc__x_pre, mdoc__x_post}, /* %V */
1.1       kristaps  189:        {NULL, NULL}, /* Ac */
                    190:        {mdoc_aq_pre, mdoc_aq_post}, /* Ao */
                    191:        {mdoc_aq_pre, mdoc_aq_post}, /* Aq */
                    192:        {NULL, NULL}, /* At */
                    193:        {NULL, NULL}, /* Bc */
1.5       kristaps  194:        {mdoc_bf_pre, NULL}, /* Bf */
1.4       kristaps  195:        {mdoc_bq_pre, mdoc_bq_post}, /* Bo */
                    196:        {mdoc_bq_pre, mdoc_bq_post}, /* Bq */
1.1       kristaps  197:        {mdoc_xx_pre, NULL}, /* Bsx */
1.4       kristaps  198:        {mdoc_bx_pre, NULL}, /* Bx */
1.1       kristaps  199:        {NULL, NULL}, /* Db */
                    200:        {NULL, NULL}, /* Dc */
1.4       kristaps  201:        {mdoc_dq_pre, mdoc_dq_post}, /* Do */
1.1       kristaps  202:        {mdoc_dq_pre, mdoc_dq_post}, /* Dq */
1.55      kristaps  203:        {NULL, NULL}, /* Ec */ /* FIXME: no space */
1.1       kristaps  204:        {NULL, NULL}, /* Ef */
                    205:        {mdoc_em_pre, NULL}, /* Em */
                    206:        {NULL, NULL}, /* Eo */
                    207:        {mdoc_xx_pre, NULL}, /* Fx */
1.5       kristaps  208:        {mdoc_ms_pre, NULL}, /* Ms */ /* FIXME: convert to symbol? */
1.1       kristaps  209:        {NULL, NULL}, /* No */
                    210:        {mdoc_ns_pre, NULL}, /* Ns */
                    211:        {mdoc_xx_pre, NULL}, /* Nx */
                    212:        {mdoc_xx_pre, NULL}, /* Ox */
                    213:        {NULL, NULL}, /* Pc */
1.5       kristaps  214:        {mdoc_pf_pre, mdoc_pf_post}, /* Pf */
1.1       kristaps  215:        {mdoc_pq_pre, mdoc_pq_post}, /* Po */
                    216:        {mdoc_pq_pre, mdoc_pq_post}, /* Pq */
                    217:        {NULL, NULL}, /* Qc */
1.4       kristaps  218:        {mdoc_sq_pre, mdoc_sq_post}, /* Ql */
1.5       kristaps  219:        {mdoc_dq_pre, mdoc_dq_post}, /* Qo */
                    220:        {mdoc_dq_pre, mdoc_dq_post}, /* Qq */
1.1       kristaps  221:        {NULL, NULL}, /* Re */
1.5       kristaps  222:        {mdoc_rs_pre, NULL}, /* Rs */
1.1       kristaps  223:        {NULL, NULL}, /* Sc */
                    224:        {mdoc_sq_pre, mdoc_sq_post}, /* So */
                    225:        {mdoc_sq_pre, mdoc_sq_post}, /* Sq */
1.6       kristaps  226:        {NULL, NULL}, /* Sm */ /* FIXME - no idea. */
1.1       kristaps  227:        {mdoc_sx_pre, NULL}, /* Sx */
1.6       kristaps  228:        {mdoc_sy_pre, NULL}, /* Sy */
1.1       kristaps  229:        {NULL, NULL}, /* Tn */
                    230:        {mdoc_xx_pre, NULL}, /* Ux */
                    231:        {NULL, NULL}, /* Xc */
                    232:        {NULL, NULL}, /* Xo */
1.4       kristaps  233:        {mdoc_fo_pre, mdoc_fo_post}, /* Fo */
1.1       kristaps  234:        {NULL, NULL}, /* Fc */
1.4       kristaps  235:        {mdoc_op_pre, mdoc_op_post}, /* Oo */
1.1       kristaps  236:        {NULL, NULL}, /* Oc */
                    237:        {NULL, NULL}, /* Bk */
                    238:        {NULL, NULL}, /* Ek */
1.6       kristaps  239:        {mdoc_bt_pre, NULL}, /* Bt */
1.1       kristaps  240:        {NULL, NULL}, /* Hf */
                    241:        {NULL, NULL}, /* Fr */
1.6       kristaps  242:        {mdoc_ud_pre, NULL}, /* Ud */
                    243:        {mdoc_lb_pre, NULL}, /* Lb */
1.1       kristaps  244:        {mdoc_sp_pre, NULL}, /* Lp */
1.2       kristaps  245:        {mdoc_lk_pre, NULL}, /* Lk */
                    246:        {mdoc_mt_pre, NULL}, /* Mt */
                    247:        {mdoc_brq_pre, mdoc_brq_post}, /* Brq */
                    248:        {mdoc_brq_pre, mdoc_brq_post}, /* Bro */
1.1       kristaps  249:        {NULL, NULL}, /* Brc */
1.10      kristaps  250:        {mdoc__x_pre, mdoc__x_post}, /* %C */
1.2       kristaps  251:        {NULL, NULL}, /* Es */  /* TODO */
                    252:        {NULL, NULL}, /* En */  /* TODO */
1.1       kristaps  253:        {mdoc_xx_pre, NULL}, /* Dx */
1.10      kristaps  254:        {mdoc__x_pre, mdoc__x_post}, /* %Q */
1.1       kristaps  255:        {mdoc_sp_pre, NULL}, /* br */
                    256:        {mdoc_sp_pre, NULL}, /* sp */
1.37      kristaps  257:        {mdoc__x_pre, mdoc__x_post}, /* %U */
1.71    ! kristaps  258:        {NULL, NULL}, /* Ta */
1.1       kristaps  259: };
                    260:
                    261:
                    262: void
                    263: html_mdoc(void *arg, const struct mdoc *m)
                    264: {
                    265:        struct html     *h;
                    266:        struct tag      *t;
                    267:
                    268:        h = (struct html *)arg;
                    269:
1.53      kristaps  270:        print_gen_decls(h);
1.1       kristaps  271:        t = print_otag(h, TAG_HTML, 0, NULL);
                    272:        print_mdoc(mdoc_meta(m), mdoc_node(m), h);
                    273:        print_tagq(h, t);
                    274:
                    275:        printf("\n");
                    276: }
                    277:
                    278:
1.23      kristaps  279: /*
                    280:  * Calculate the scaling unit passed in a `-width' argument.  This uses
                    281:  * either a native scaling unit (e.g., 1i, 2m) or the string length of
                    282:  * the value.
                    283:  */
                    284: static void
                    285: a2width(const char *p, struct roffsu *su)
1.1       kristaps  286: {
                    287:
1.32      kristaps  288:        if ( ! a2roffsu(p, su, SCALE_MAX)) {
                    289:                su->unit = SCALE_EM;
                    290:                su->scale = (int)strlen(p);
                    291:        }
1.1       kristaps  292: }
                    293:
                    294:
1.23      kristaps  295: /*
                    296:  * Calculate the scaling unit passed in an `-offset' argument.  This
                    297:  * uses either a native scaling unit (e.g., 1i, 2m), one of a set of
                    298:  * predefined strings (indent, etc.), or the string length of the value.
                    299:  */
                    300: static void
                    301: a2offs(const char *p, struct roffsu *su)
1.1       kristaps  302: {
                    303:
1.31      kristaps  304:        /* FIXME: "right"? */
                    305:
1.1       kristaps  306:        if (0 == strcmp(p, "left"))
1.23      kristaps  307:                SCALE_HS_INIT(su, 0);
                    308:        else if (0 == strcmp(p, "indent"))
                    309:                SCALE_HS_INIT(su, INDENT);
                    310:        else if (0 == strcmp(p, "indent-two"))
                    311:                SCALE_HS_INIT(su, INDENT * 2);
1.32      kristaps  312:        else if ( ! a2roffsu(p, su, SCALE_MAX)) {
1.24      kristaps  313:                su->unit = SCALE_EM;
                    314:                su->scale = (int)strlen(p);
                    315:        }
1.1       kristaps  316: }
                    317:
                    318:
                    319: static void
                    320: print_mdoc(MDOC_ARGS)
                    321: {
                    322:        struct tag      *t;
                    323:        struct htmlpair  tag;
                    324:
                    325:        t = print_otag(h, TAG_HEAD, 0, NULL);
                    326:        print_mdoc_head(m, n, h);
                    327:        print_tagq(h, t);
                    328:
                    329:        t = print_otag(h, TAG_BODY, 0, NULL);
                    330:
                    331:        tag.key = ATTR_CLASS;
                    332:        tag.val = "body";
                    333:        print_otag(h, TAG_DIV, 1, &tag);
                    334:
                    335:        print_mdoc_nodelist(m, n, h);
                    336:        print_tagq(h, t);
                    337: }
                    338:
                    339:
                    340: /* ARGSUSED */
                    341: static void
                    342: print_mdoc_head(MDOC_ARGS)
                    343: {
                    344:
                    345:        print_gen_head(h);
1.20      kristaps  346:        bufinit(h);
1.63      kristaps  347:        buffmt(h, "%s(%s)", m->title, m->msec);
1.1       kristaps  348:
                    349:        if (m->arch) {
1.20      kristaps  350:                bufcat(h, " (");
                    351:                bufcat(h, m->arch);
                    352:                bufcat(h, ")");
1.1       kristaps  353:        }
                    354:
                    355:        print_otag(h, TAG_TITLE, 0, NULL);
1.20      kristaps  356:        print_text(h, h->buf);
1.1       kristaps  357: }
                    358:
                    359:
                    360: static void
                    361: print_mdoc_nodelist(MDOC_ARGS)
                    362: {
                    363:
                    364:        print_mdoc_node(m, n, h);
                    365:        if (n->next)
                    366:                print_mdoc_nodelist(m, n->next, h);
                    367: }
                    368:
                    369:
                    370: static void
                    371: print_mdoc_node(MDOC_ARGS)
                    372: {
                    373:        int              child;
                    374:        struct tag      *t;
                    375:
                    376:        child = 1;
1.39      kristaps  377:        t = h->tags.head;
1.1       kristaps  378:
1.16      kristaps  379:        bufinit(h);
1.1       kristaps  380:        switch (n->type) {
                    381:        case (MDOC_ROOT):
                    382:                child = mdoc_root_pre(m, n, h);
                    383:                break;
                    384:        case (MDOC_TEXT):
                    385:                print_text(h, n->string);
1.48      kristaps  386:                return;
1.1       kristaps  387:        default:
                    388:                if (mdocs[n->tok].pre)
                    389:                        child = (*mdocs[n->tok].pre)(m, n, h);
                    390:                break;
                    391:        }
                    392:
                    393:        if (child && n->child)
                    394:                print_mdoc_nodelist(m, n->child, h);
                    395:
                    396:        print_stagq(h, t);
                    397:
1.16      kristaps  398:        bufinit(h);
1.1       kristaps  399:        switch (n->type) {
                    400:        case (MDOC_ROOT):
                    401:                mdoc_root_post(m, n, h);
                    402:                break;
                    403:        default:
                    404:                if (mdocs[n->tok].post)
                    405:                        (*mdocs[n->tok].post)(m, n, h);
                    406:                break;
                    407:        }
                    408: }
                    409:
                    410:
                    411: /* ARGSUSED */
                    412: static void
                    413: mdoc_root_post(MDOC_ARGS)
                    414: {
1.40      kristaps  415:        struct htmlpair  tag[3];
1.1       kristaps  416:        struct tag      *t, *tt;
1.36      kristaps  417:        char             b[DATESIZ];
                    418:
                    419:        time2a(m->date, b, DATESIZ);
1.1       kristaps  420:
1.23      kristaps  421:        /*
                    422:         * XXX: this should use divs, but in Firefox, divs with nested
                    423:         * divs for some reason puke when trying to put a border line
                    424:         * below.  So I use tables, instead.
                    425:         */
                    426:
                    427:        PAIR_CLASS_INIT(&tag[0], "footer");
                    428:        bufcat_style(h, "width", "100%");
                    429:        PAIR_STYLE_INIT(&tag[1], h);
1.40      kristaps  430:        PAIR_SUMMARY_INIT(&tag[2], "footer");
                    431:
                    432:        t = print_otag(h, TAG_TABLE, 3, tag);
1.1       kristaps  433:        tt = print_otag(h, TAG_TR, 0, NULL);
                    434:
1.23      kristaps  435:        bufinit(h);
                    436:        bufcat_style(h, "width", "50%");
                    437:        PAIR_STYLE_INIT(&tag[0], h);
1.1       kristaps  438:        print_otag(h, TAG_TD, 1, tag);
                    439:        print_text(h, b);
                    440:        print_stagq(h, tt);
                    441:
1.23      kristaps  442:        bufinit(h);
                    443:        bufcat_style(h, "width", "50%");
                    444:        bufcat_style(h, "text-align", "right");
                    445:        PAIR_STYLE_INIT(&tag[0], h);
1.1       kristaps  446:        print_otag(h, TAG_TD, 1, tag);
                    447:        print_text(h, m->os);
                    448:        print_tagq(h, t);
                    449: }
                    450:
                    451:
                    452: /* ARGSUSED */
                    453: static int
                    454: mdoc_root_pre(MDOC_ARGS)
                    455: {
1.40      kristaps  456:        struct htmlpair  tag[3];
1.1       kristaps  457:        struct tag      *t, *tt;
                    458:        char             b[BUFSIZ], title[BUFSIZ];
                    459:
                    460:        (void)strlcpy(b, m->vol, BUFSIZ);
                    461:
                    462:        if (m->arch) {
                    463:                (void)strlcat(b, " (", BUFSIZ);
                    464:                (void)strlcat(b, m->arch, BUFSIZ);
                    465:                (void)strlcat(b, ")", BUFSIZ);
                    466:        }
                    467:
                    468:        (void)snprintf(title, BUFSIZ - 1,
1.63      kristaps  469:                        "%s(%s)", m->title, m->msec);
1.1       kristaps  470:
1.23      kristaps  471:        /* XXX: see note in mdoc_root_post() about divs. */
                    472:
                    473:        PAIR_CLASS_INIT(&tag[0], "header");
                    474:        bufcat_style(h, "width", "100%");
                    475:        PAIR_STYLE_INIT(&tag[1], h);
1.40      kristaps  476:        PAIR_SUMMARY_INIT(&tag[2], "header");
                    477:
                    478:        t = print_otag(h, TAG_TABLE, 3, tag);
                    479:
1.1       kristaps  480:        tt = print_otag(h, TAG_TR, 0, NULL);
                    481:
1.23      kristaps  482:        bufinit(h);
                    483:        bufcat_style(h, "width", "10%");
                    484:        PAIR_STYLE_INIT(&tag[0], h);
1.1       kristaps  485:        print_otag(h, TAG_TD, 1, tag);
1.2       kristaps  486:        print_text(h, title);
1.1       kristaps  487:        print_stagq(h, tt);
                    488:
1.23      kristaps  489:        bufinit(h);
                    490:        bufcat_style(h, "text-align", "center");
                    491:        bufcat_style(h, "white-space", "nowrap");
                    492:        bufcat_style(h, "width", "80%");
                    493:        PAIR_STYLE_INIT(&tag[0], h);
1.1       kristaps  494:        print_otag(h, TAG_TD, 1, tag);
1.2       kristaps  495:        print_text(h, b);
1.1       kristaps  496:        print_stagq(h, tt);
                    497:
1.23      kristaps  498:        bufinit(h);
                    499:        bufcat_style(h, "text-align", "right");
                    500:        bufcat_style(h, "width", "10%");
                    501:        PAIR_STYLE_INIT(&tag[0], h);
1.1       kristaps  502:        print_otag(h, TAG_TD, 1, tag);
1.2       kristaps  503:        print_text(h, title);
1.1       kristaps  504:        print_tagq(h, t);
                    505:        return(1);
                    506: }
                    507:
                    508:
                    509: /* ARGSUSED */
                    510: static int
                    511: mdoc_sh_pre(MDOC_ARGS)
                    512: {
                    513:        struct htmlpair          tag[2];
                    514:        const struct mdoc_node  *nn;
1.41      kristaps  515:        char                     buf[BUFSIZ];
1.23      kristaps  516:        struct roffsu            su;
1.21      kristaps  517:
                    518:        if (MDOC_BODY == n->type) {
1.23      kristaps  519:                SCALE_HS_INIT(&su, INDENT);
                    520:                bufcat_su(h, "margin-left", &su);
                    521:                PAIR_CLASS_INIT(&tag[0], "sec-body");
                    522:                PAIR_STYLE_INIT(&tag[1], h);
1.21      kristaps  523:                print_otag(h, TAG_DIV, 2, tag);
1.1       kristaps  524:                return(1);
                    525:        } else if (MDOC_BLOCK == n->type) {
1.23      kristaps  526:                PAIR_CLASS_INIT(&tag[0], "sec-block");
1.1       kristaps  527:                if (n->prev && NULL == n->prev->body->child) {
                    528:                        print_otag(h, TAG_DIV, 1, tag);
                    529:                        return(1);
                    530:                }
1.23      kristaps  531:
                    532:                SCALE_VS_INIT(&su, 1);
                    533:                bufcat_su(h, "margin-top", &su);
1.1       kristaps  534:                if (NULL == n->next)
1.23      kristaps  535:                        bufcat_su(h, "margin-bottom", &su);
1.1       kristaps  536:
1.23      kristaps  537:                PAIR_STYLE_INIT(&tag[1], h);
1.1       kristaps  538:                print_otag(h, TAG_DIV, 2, tag);
                    539:                return(1);
                    540:        }
                    541:
1.42      kristaps  542:        buf[0] = '\0';
1.21      kristaps  543:        for (nn = n->child; nn; nn = nn->next) {
1.41      kristaps  544:                html_idcat(buf, nn->string, BUFSIZ);
1.21      kristaps  545:                if (nn->next)
1.42      kristaps  546:                        html_idcat(buf, " ", BUFSIZ);
1.21      kristaps  547:        }
                    548:
1.57      kristaps  549:        PAIR_CLASS_INIT(&tag[0], "sec-head");
                    550:        PAIR_ID_INIT(&tag[1], buf);
1.22      kristaps  551:
1.1       kristaps  552:        print_otag(h, TAG_DIV, 2, tag);
                    553:        return(1);
                    554: }
                    555:
                    556:
                    557: /* ARGSUSED */
                    558: static int
                    559: mdoc_ss_pre(MDOC_ARGS)
                    560: {
1.21      kristaps  561:        struct htmlpair          tag[3];
1.1       kristaps  562:        const struct mdoc_node  *nn;
1.41      kristaps  563:        char                     buf[BUFSIZ];
1.23      kristaps  564:        struct roffsu            su;
1.1       kristaps  565:
1.23      kristaps  566:        SCALE_VS_INIT(&su, 1);
1.1       kristaps  567:
                    568:        if (MDOC_BODY == n->type) {
1.23      kristaps  569:                PAIR_CLASS_INIT(&tag[0], "ssec-body");
1.1       kristaps  570:                if (n->parent->next && n->child) {
1.23      kristaps  571:                        bufcat_su(h, "margin-bottom", &su);
                    572:                        PAIR_STYLE_INIT(&tag[1], h);
                    573:                        print_otag(h, TAG_DIV, 2, tag);
                    574:                } else
                    575:                        print_otag(h, TAG_DIV, 1, tag);
1.1       kristaps  576:                return(1);
                    577:        } else if (MDOC_BLOCK == n->type) {
1.23      kristaps  578:                PAIR_CLASS_INIT(&tag[0], "ssec-block");
1.1       kristaps  579:                if (n->prev) {
1.23      kristaps  580:                        bufcat_su(h, "margin-top", &su);
                    581:                        PAIR_STYLE_INIT(&tag[1], h);
                    582:                        print_otag(h, TAG_DIV, 2, tag);
                    583:                } else
                    584:                        print_otag(h, TAG_DIV, 1, tag);
1.1       kristaps  585:                return(1);
                    586:        }
                    587:
1.23      kristaps  588:        /* TODO: see note in mdoc_sh_pre() about duplicates. */
                    589:
1.42      kristaps  590:        buf[0] = '\0';
1.21      kristaps  591:        for (nn = n->child; nn; nn = nn->next) {
1.41      kristaps  592:                html_idcat(buf, nn->string, BUFSIZ);
1.21      kristaps  593:                if (nn->next)
1.42      kristaps  594:                        html_idcat(buf, " ", BUFSIZ);
1.21      kristaps  595:        }
                    596:
1.23      kristaps  597:        SCALE_HS_INIT(&su, INDENT - HALFINDENT);
                    598:        su.scale = -su.scale;
                    599:        bufcat_su(h, "margin-left", &su);
1.22      kristaps  600:
1.23      kristaps  601:        PAIR_CLASS_INIT(&tag[0], "ssec-head");
                    602:        PAIR_STYLE_INIT(&tag[1], h);
1.57      kristaps  603:        PAIR_ID_INIT(&tag[2], buf);
                    604:
1.21      kristaps  605:        print_otag(h, TAG_DIV, 3, tag);
1.1       kristaps  606:        return(1);
                    607: }
                    608:
                    609:
                    610: /* ARGSUSED */
                    611: static int
                    612: mdoc_fl_pre(MDOC_ARGS)
                    613: {
                    614:        struct htmlpair  tag;
                    615:
1.51      kristaps  616:        PAIR_CLASS_INIT(&tag, "flag");
                    617:        print_otag(h, TAG_SPAN, 1, &tag);
                    618:
1.50      kristaps  619:        /* `Cm' has no leading hyphen. */
                    620:
1.51      kristaps  621:        if (MDOC_Cm == n->tok)
1.50      kristaps  622:                return(1);
                    623:
                    624:        print_text(h, "\\-");
                    625:
                    626:        if (n->child)
1.58      kristaps  627:                h->flags |= HTML_NOSPACE;
                    628:        else if (n->next && n->next->line == n->line)
1.1       kristaps  629:                h->flags |= HTML_NOSPACE;
1.50      kristaps  630:
1.1       kristaps  631:        return(1);
                    632: }
                    633:
                    634:
                    635: /* ARGSUSED */
                    636: static int
                    637: mdoc_nd_pre(MDOC_ARGS)
                    638: {
                    639:        struct htmlpair  tag;
                    640:
                    641:        if (MDOC_BODY != n->type)
                    642:                return(1);
                    643:
1.24      kristaps  644:        /* XXX: this tag in theory can contain block elements. */
                    645:
1.1       kristaps  646:        print_text(h, "\\(em");
1.23      kristaps  647:        PAIR_CLASS_INIT(&tag, "desc-body");
1.1       kristaps  648:        print_otag(h, TAG_SPAN, 1, &tag);
                    649:        return(1);
                    650: }
                    651:
                    652:
                    653: /* ARGSUSED */
                    654: static int
                    655: mdoc_op_pre(MDOC_ARGS)
                    656: {
                    657:        struct htmlpair  tag;
                    658:
                    659:        if (MDOC_BODY != n->type)
                    660:                return(1);
                    661:
1.24      kristaps  662:        /* XXX: this tag in theory can contain block elements. */
                    663:
1.1       kristaps  664:        print_text(h, "\\(lB");
                    665:        h->flags |= HTML_NOSPACE;
1.23      kristaps  666:        PAIR_CLASS_INIT(&tag, "opt");
1.1       kristaps  667:        print_otag(h, TAG_SPAN, 1, &tag);
                    668:        return(1);
                    669: }
                    670:
                    671:
                    672: /* ARGSUSED */
                    673: static void
                    674: mdoc_op_post(MDOC_ARGS)
                    675: {
                    676:
                    677:        if (MDOC_BODY != n->type)
                    678:                return;
                    679:        h->flags |= HTML_NOSPACE;
                    680:        print_text(h, "\\(rB");
                    681: }
                    682:
                    683:
                    684: static int
                    685: mdoc_nm_pre(MDOC_ARGS)
                    686: {
                    687:        struct htmlpair tag;
                    688:
1.65      kristaps  689:        if (NULL == n->child && NULL == m->name)
                    690:                return(1);
                    691:
1.62      kristaps  692:        if (SEC_SYNOPSIS == n->sec &&
                    693:                        n->prev && MDOC_LINE & n->flags) {
1.47      kristaps  694:                bufcat_style(h, "clear", "both");
                    695:                PAIR_STYLE_INIT(&tag, h);
                    696:                print_otag(h, TAG_BR, 1, &tag);
                    697:        }
1.1       kristaps  698:
1.23      kristaps  699:        PAIR_CLASS_INIT(&tag, "name");
1.1       kristaps  700:        print_otag(h, TAG_SPAN, 1, &tag);
                    701:        if (NULL == n->child)
                    702:                print_text(h, m->name);
                    703:
                    704:        return(1);
                    705: }
                    706:
                    707:
                    708: /* ARGSUSED */
                    709: static int
                    710: mdoc_xr_pre(MDOC_ARGS)
                    711: {
                    712:        struct htmlpair          tag[2];
                    713:        const struct mdoc_node  *nn;
1.56      kristaps  714:
                    715:        if (NULL == n->child)
                    716:                return(0);
1.17      kristaps  717:
1.23      kristaps  718:        PAIR_CLASS_INIT(&tag[0], "link-man");
1.1       kristaps  719:
1.17      kristaps  720:        if (h->base_man) {
1.23      kristaps  721:                buffmt_man(h, n->child->string,
                    722:                                n->child->next ?
1.17      kristaps  723:                                n->child->next->string : NULL);
1.57      kristaps  724:                PAIR_HREF_INIT(&tag[1], h->buf);
1.23      kristaps  725:                print_otag(h, TAG_A, 2, tag);
                    726:        } else
                    727:                print_otag(h, TAG_A, 1, tag);
1.1       kristaps  728:
                    729:        nn = n->child;
                    730:        print_text(h, nn->string);
1.16      kristaps  731:
1.1       kristaps  732:        if (NULL == (nn = nn->next))
                    733:                return(0);
                    734:
                    735:        h->flags |= HTML_NOSPACE;
                    736:        print_text(h, "(");
                    737:        h->flags |= HTML_NOSPACE;
                    738:        print_text(h, nn->string);
                    739:        h->flags |= HTML_NOSPACE;
                    740:        print_text(h, ")");
                    741:        return(0);
                    742: }
                    743:
                    744:
                    745: /* ARGSUSED */
                    746: static int
                    747: mdoc_ns_pre(MDOC_ARGS)
                    748: {
                    749:
                    750:        h->flags |= HTML_NOSPACE;
                    751:        return(1);
                    752: }
                    753:
                    754:
                    755: /* ARGSUSED */
                    756: static int
                    757: mdoc_ar_pre(MDOC_ARGS)
                    758: {
                    759:        struct htmlpair tag;
                    760:
1.23      kristaps  761:        PAIR_CLASS_INIT(&tag, "arg");
1.1       kristaps  762:        print_otag(h, TAG_SPAN, 1, &tag);
                    763:        return(1);
                    764: }
                    765:
                    766:
                    767: /* ARGSUSED */
                    768: static int
                    769: mdoc_xx_pre(MDOC_ARGS)
                    770: {
                    771:        const char      *pp;
                    772:        struct htmlpair  tag;
                    773:
                    774:        switch (n->tok) {
                    775:        case (MDOC_Bsx):
                    776:                pp = "BSDI BSD/OS";
                    777:                break;
                    778:        case (MDOC_Dx):
1.45      kristaps  779:                pp = "DragonFly";
1.1       kristaps  780:                break;
                    781:        case (MDOC_Fx):
                    782:                pp = "FreeBSD";
                    783:                break;
                    784:        case (MDOC_Nx):
                    785:                pp = "NetBSD";
                    786:                break;
                    787:        case (MDOC_Ox):
                    788:                pp = "OpenBSD";
                    789:                break;
                    790:        case (MDOC_Ux):
                    791:                pp = "UNIX";
                    792:                break;
                    793:        default:
                    794:                return(1);
                    795:        }
                    796:
1.23      kristaps  797:        PAIR_CLASS_INIT(&tag, "unix");
1.1       kristaps  798:        print_otag(h, TAG_SPAN, 1, &tag);
                    799:        print_text(h, pp);
                    800:        return(1);
                    801: }
                    802:
                    803:
                    804: /* ARGSUSED */
                    805: static int
1.4       kristaps  806: mdoc_bx_pre(MDOC_ARGS)
                    807: {
                    808:        const struct mdoc_node  *nn;
                    809:        struct htmlpair          tag;
                    810:
1.23      kristaps  811:        PAIR_CLASS_INIT(&tag, "unix");
1.4       kristaps  812:        print_otag(h, TAG_SPAN, 1, &tag);
                    813:
                    814:        for (nn = n->child; nn; nn = nn->next)
                    815:                print_mdoc_node(m, nn, h);
                    816:
                    817:        if (n->child)
                    818:                h->flags |= HTML_NOSPACE;
                    819:
                    820:        print_text(h, "BSD");
                    821:        return(0);
                    822: }
                    823:
                    824:
                    825: /* ARGSUSED */
                    826: static int
1.66      kristaps  827: mdoc_it_block_pre(MDOC_ARGS, enum mdoc_list type, int comp,
1.27      kristaps  828:                struct roffsu *offs, struct roffsu *width)
1.1       kristaps  829: {
1.14      kristaps  830:        struct htmlpair          tag;
                    831:        const struct mdoc_node  *nn;
1.23      kristaps  832:        struct roffsu            su;
                    833:
                    834:        nn = n->parent->parent;
                    835:        assert(nn->args);
                    836:
1.24      kristaps  837:        /* XXX: see notes in mdoc_it_pre(). */
                    838:
1.66      kristaps  839:        if (LIST_column == type) {
1.24      kristaps  840:                /* Don't width-pad on the left. */
                    841:                SCALE_HS_INIT(width, 0);
                    842:                /* Also disallow non-compact. */
                    843:                comp = 1;
                    844:        }
1.66      kristaps  845:        if (LIST_diag == type)
1.24      kristaps  846:                /* Mandate non-compact with empty prior. */
1.23      kristaps  847:                if (n->prev && NULL == n->prev->body->child)
                    848:                        comp = 1;
                    849:
1.24      kristaps  850:        bufcat_style(h, "clear", "both");
1.23      kristaps  851:        if (offs->scale > 0)
                    852:                bufcat_su(h, "margin-left", offs);
                    853:        if (width->scale > 0)
                    854:                bufcat_su(h, "padding-left", width);
1.1       kristaps  855:
1.23      kristaps  856:        PAIR_STYLE_INIT(&tag, h);
                    857:
1.24      kristaps  858:        /* Mandate compact following `Ss' and `Sh' starts. */
                    859:
1.23      kristaps  860:        for (nn = n; nn && ! comp; nn = nn->parent) {
                    861:                if (MDOC_BLOCK != nn->type)
                    862:                        continue;
                    863:                if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
                    864:                        comp = 1;
                    865:                if (nn->prev)
                    866:                        break;
1.1       kristaps  867:        }
                    868:
1.23      kristaps  869:        if ( ! comp) {
                    870:                SCALE_VS_INIT(&su, 1);
                    871:                bufcat_su(h, "padding-top", &su);
1.1       kristaps  872:        }
                    873:
1.23      kristaps  874:        PAIR_STYLE_INIT(&tag, h);
1.1       kristaps  875:        print_otag(h, TAG_DIV, 1, &tag);
                    876:        return(1);
                    877: }
                    878:
                    879:
1.25      kristaps  880: /* ARGSUSED */
1.1       kristaps  881: static int
1.70      kristaps  882: mdoc_it_body_pre(MDOC_ARGS, enum mdoc_list type, struct roffsu *width)
1.1       kristaps  883: {
1.23      kristaps  884:        struct htmlpair  tag;
                    885:        struct roffsu    su;
                    886:
                    887:        switch (type) {
1.66      kristaps  888:        case (LIST_item):
1.23      kristaps  889:                /* FALLTHROUGH */
1.66      kristaps  890:        case (LIST_ohang):
1.23      kristaps  891:                /* FALLTHROUGH */
1.66      kristaps  892:        case (LIST_column):
1.70      kristaps  893:                bufcat_su(h, "min-width", width);
                    894:                bufcat_style(h, "clear", "none");
                    895:                if (n->next)
                    896:                        bufcat_style(h, "float", "left");
                    897:                PAIR_STYLE_INIT(&tag, h);
                    898:                print_otag(h, TAG_DIV, 1, &tag);
1.23      kristaps  899:                break;
                    900:        default:
1.24      kristaps  901:                /*
                    902:                 * XXX: this tricks CSS into aligning the bodies with
                    903:                 * the right-padding in the head.
                    904:                 */
1.23      kristaps  905:                SCALE_HS_INIT(&su, 2);
                    906:                bufcat_su(h, "margin-left", &su);
                    907:                PAIR_STYLE_INIT(&tag, h);
                    908:                print_otag(h, TAG_DIV, 1, &tag);
                    909:                break;
                    910:        }
1.1       kristaps  911:
                    912:        return(1);
                    913: }
                    914:
                    915:
1.25      kristaps  916: /* ARGSUSED */
1.1       kristaps  917: static int
1.66      kristaps  918: mdoc_it_head_pre(MDOC_ARGS, enum mdoc_list type, struct roffsu *width)
1.1       kristaps  919: {
                    920:        struct htmlpair  tag;
                    921:        struct ord      *ord;
                    922:        char             nbuf[BUFSIZ];
                    923:
1.23      kristaps  924:        switch (type) {
1.66      kristaps  925:        case (LIST_item):
1.46      kristaps  926:                return(0);
1.66      kristaps  927:        case (LIST_ohang):
1.46      kristaps  928:                print_otag(h, TAG_DIV, 0, &tag);
                    929:                return(1);
1.66      kristaps  930:        case (LIST_column):
1.1       kristaps  931:                break;
                    932:        default:
1.23      kristaps  933:                bufcat_su(h, "min-width", width);
                    934:                SCALE_INVERT(width);
                    935:                bufcat_su(h, "margin-left", width);
1.2       kristaps  936:                if (n->next && n->next->child)
1.23      kristaps  937:                        bufcat_style(h, "float", "left");
1.24      kristaps  938:
                    939:                /* XXX: buffer if we run into body. */
1.23      kristaps  940:                SCALE_HS_INIT(width, 1);
                    941:                bufcat_su(h, "margin-right", width);
                    942:                PAIR_STYLE_INIT(&tag, h);
1.1       kristaps  943:                print_otag(h, TAG_DIV, 1, &tag);
                    944:                break;
                    945:        }
                    946:
1.23      kristaps  947:        switch (type) {
1.66      kristaps  948:        case (LIST_diag):
1.23      kristaps  949:                PAIR_CLASS_INIT(&tag, "diag");
1.1       kristaps  950:                print_otag(h, TAG_SPAN, 1, &tag);
                    951:                break;
1.66      kristaps  952:        case (LIST_enum):
1.39      kristaps  953:                ord = h->ords.head;
1.1       kristaps  954:                assert(ord);
                    955:                nbuf[BUFSIZ - 1] = 0;
                    956:                (void)snprintf(nbuf, BUFSIZ - 1, "%d.", ord->pos++);
                    957:                print_text(h, nbuf);
                    958:                return(0);
1.66      kristaps  959:        case (LIST_dash):
1.1       kristaps  960:                print_text(h, "\\(en");
                    961:                return(0);
1.66      kristaps  962:        case (LIST_hyphen):
1.4       kristaps  963:                print_text(h, "\\(hy");
1.1       kristaps  964:                return(0);
1.66      kristaps  965:        case (LIST_bullet):
1.1       kristaps  966:                print_text(h, "\\(bu");
                    967:                return(0);
                    968:        default:
                    969:                break;
                    970:        }
                    971:
                    972:        return(1);
                    973: }
                    974:
                    975:
                    976: static int
1.23      kristaps  977: mdoc_it_pre(MDOC_ARGS)
1.1       kristaps  978: {
1.66      kristaps  979:        int                      i, wp, comp;
1.1       kristaps  980:        const struct mdoc_node  *bl, *nn;
1.23      kristaps  981:        struct roffsu            width, offs;
1.66      kristaps  982:        enum mdoc_list           type;
1.23      kristaps  983:
1.24      kristaps  984:        /*
                    985:         * XXX: be very careful in changing anything, here.  Lists in
                    986:         * mandoc have many peculiarities; furthermore, they don't
                    987:         * translate well into HTML and require a bit of mangling.
                    988:         */
1.1       kristaps  989:
                    990:        bl = n->parent->parent;
1.23      kristaps  991:        if (MDOC_BLOCK != n->type)
1.1       kristaps  992:                bl = bl->parent;
                    993:
1.66      kristaps  994:        type = bl->data.list;
1.1       kristaps  995:
1.23      kristaps  996:        /* Set default width and offset. */
1.1       kristaps  997:
1.24      kristaps  998:        SCALE_HS_INIT(&offs, 0);
                    999:
1.1       kristaps 1000:        switch (type) {
1.66      kristaps 1001:        case (LIST_enum):
1.1       kristaps 1002:                /* FALLTHROUGH */
1.66      kristaps 1003:        case (LIST_dash):
1.1       kristaps 1004:                /* FALLTHROUGH */
1.66      kristaps 1005:        case (LIST_hyphen):
1.1       kristaps 1006:                /* FALLTHROUGH */
1.66      kristaps 1007:        case (LIST_bullet):
1.23      kristaps 1008:                SCALE_HS_INIT(&width, 2);
1.1       kristaps 1009:                break;
1.23      kristaps 1010:        default:
                   1011:                SCALE_HS_INIT(&width, INDENT);
                   1012:                break;
                   1013:        }
                   1014:
                   1015:        /* Get width, offset, and compact arguments. */
                   1016:
                   1017:        for (wp = -1, comp = i = 0; i < (int)bl->args->argc; i++)
                   1018:                switch (bl->args->argv[i].arg) {
1.24      kristaps 1019:                case (MDOC_Column):
                   1020:                        wp = i; /* Save for later. */
                   1021:                        break;
1.23      kristaps 1022:                case (MDOC_Width):
                   1023:                        a2width(bl->args->argv[i].value[0], &width);
                   1024:                        break;
                   1025:                case (MDOC_Offset):
                   1026:                        a2offs(bl->args->argv[i].value[0], &offs);
                   1027:                        break;
                   1028:                case (MDOC_Compact):
                   1029:                        comp = 1;
                   1030:                        break;
                   1031:                default:
                   1032:                        break;
                   1033:                }
                   1034:
                   1035:        /* Override width in some cases. */
                   1036:
                   1037:        switch (type) {
1.66      kristaps 1038:        case (LIST_ohang):
1.46      kristaps 1039:                /* FALLTHROUGH */
1.66      kristaps 1040:        case (LIST_item):
1.33      kristaps 1041:                /* FALLTHROUGH */
1.66      kristaps 1042:        case (LIST_inset):
1.1       kristaps 1043:                /* FALLTHROUGH */
1.66      kristaps 1044:        case (LIST_diag):
1.23      kristaps 1045:                SCALE_HS_INIT(&width, 0);
1.1       kristaps 1046:                break;
                   1047:        default:
1.23      kristaps 1048:                if (0 == width.scale)
                   1049:                        SCALE_HS_INIT(&width, INDENT);
1.1       kristaps 1050:                break;
                   1051:        }
                   1052:
1.70      kristaps 1053:        if (LIST_column == type && MDOC_BODY == n->type) {
1.23      kristaps 1054:                nn = n->parent->child;
1.70      kristaps 1055:                for (i = 0; nn && nn != n; nn = nn->next)
                   1056:                        if (MDOC_BODY == nn->type)
                   1057:                                i++;
1.24      kristaps 1058:                if (i < (int)bl->args->argv[wp].sz)
1.23      kristaps 1059:                        a2width(bl->args->argv[wp].value[i], &width);
1.1       kristaps 1060:        }
                   1061:
1.70      kristaps 1062:        if (MDOC_HEAD == n->type)
                   1063:                return(mdoc_it_head_pre(m, n, h, type, &width));
                   1064:        else if (MDOC_BODY == n->type)
                   1065:                return(mdoc_it_body_pre(m, n, h, type, &width));
                   1066:
                   1067:        return(mdoc_it_block_pre(m, n, h, type, comp, &offs, &width));
1.1       kristaps 1068: }
                   1069:
                   1070:
                   1071: /* ARGSUSED */
                   1072: static int
                   1073: mdoc_bl_pre(MDOC_ARGS)
                   1074: {
                   1075:        struct ord      *ord;
                   1076:
1.59      kristaps 1077:        if (MDOC_HEAD == n->type)
                   1078:                return(0);
1.1       kristaps 1079:        if (MDOC_BLOCK != n->type)
                   1080:                return(1);
1.67      kristaps 1081:        if (LIST_enum != n->data.list)
1.1       kristaps 1082:                return(1);
                   1083:
                   1084:        ord = malloc(sizeof(struct ord));
1.43      kristaps 1085:        if (NULL == ord) {
1.44      kristaps 1086:                perror(NULL);
1.43      kristaps 1087:                exit(EXIT_FAILURE);
                   1088:        }
1.1       kristaps 1089:        ord->cookie = n;
                   1090:        ord->pos = 1;
1.39      kristaps 1091:        ord->next = h->ords.head;
                   1092:        h->ords.head = ord;
1.1       kristaps 1093:        return(1);
                   1094: }
                   1095:
                   1096:
                   1097: /* ARGSUSED */
                   1098: static void
                   1099: mdoc_bl_post(MDOC_ARGS)
                   1100: {
                   1101:        struct ord      *ord;
                   1102:
                   1103:        if (MDOC_BLOCK != n->type)
                   1104:                return;
1.67      kristaps 1105:        if (LIST_enum != n->data.list)
1.1       kristaps 1106:                return;
                   1107:
1.39      kristaps 1108:        ord = h->ords.head;
1.1       kristaps 1109:        assert(ord);
1.39      kristaps 1110:        h->ords.head = ord->next;
1.1       kristaps 1111:        free(ord);
                   1112: }
                   1113:
                   1114:
                   1115: /* ARGSUSED */
                   1116: static int
                   1117: mdoc_ex_pre(MDOC_ARGS)
                   1118: {
                   1119:        const struct mdoc_node  *nn;
                   1120:        struct tag              *t;
                   1121:        struct htmlpair          tag;
                   1122:
1.23      kristaps 1123:        PAIR_CLASS_INIT(&tag, "utility");
                   1124:
1.1       kristaps 1125:        print_text(h, "The");
                   1126:        for (nn = n->child; nn; nn = nn->next) {
                   1127:                t = print_otag(h, TAG_SPAN, 1, &tag);
                   1128:                print_text(h, nn->string);
                   1129:                print_tagq(h, t);
                   1130:
                   1131:                h->flags |= HTML_NOSPACE;
                   1132:
                   1133:                if (nn->next && NULL == nn->next->next)
                   1134:                        print_text(h, ", and");
                   1135:                else if (nn->next)
                   1136:                        print_text(h, ",");
                   1137:                else
                   1138:                        h->flags &= ~HTML_NOSPACE;
                   1139:        }
                   1140:
1.65      kristaps 1141:        if (n->child && n->child->next)
1.1       kristaps 1142:                print_text(h, "utilities exit");
                   1143:        else
                   1144:                print_text(h, "utility exits");
                   1145:
                   1146:                print_text(h, "0 on success, and >0 if an error occurs.");
                   1147:        return(0);
                   1148: }
                   1149:
                   1150:
                   1151: /* ARGSUSED */
                   1152: static int
                   1153: mdoc_dq_pre(MDOC_ARGS)
                   1154: {
                   1155:
                   1156:        if (MDOC_BODY != n->type)
                   1157:                return(1);
                   1158:        print_text(h, "\\(lq");
                   1159:        h->flags |= HTML_NOSPACE;
                   1160:        return(1);
                   1161: }
                   1162:
                   1163:
                   1164: /* ARGSUSED */
                   1165: static void
                   1166: mdoc_dq_post(MDOC_ARGS)
                   1167: {
                   1168:
                   1169:        if (MDOC_BODY != n->type)
                   1170:                return;
                   1171:        h->flags |= HTML_NOSPACE;
                   1172:        print_text(h, "\\(rq");
                   1173: }
                   1174:
                   1175:
                   1176: /* ARGSUSED */
                   1177: static int
                   1178: mdoc_pq_pre(MDOC_ARGS)
                   1179: {
                   1180:
                   1181:        if (MDOC_BODY != n->type)
                   1182:                return(1);
                   1183:        print_text(h, "\\&(");
                   1184:        h->flags |= HTML_NOSPACE;
                   1185:        return(1);
                   1186: }
                   1187:
                   1188:
                   1189: /* ARGSUSED */
                   1190: static void
                   1191: mdoc_pq_post(MDOC_ARGS)
                   1192: {
                   1193:
                   1194:        if (MDOC_BODY != n->type)
                   1195:                return;
                   1196:        print_text(h, ")");
                   1197: }
                   1198:
                   1199:
                   1200: /* ARGSUSED */
                   1201: static int
                   1202: mdoc_sq_pre(MDOC_ARGS)
                   1203: {
                   1204:
                   1205:        if (MDOC_BODY != n->type)
                   1206:                return(1);
                   1207:        print_text(h, "\\(oq");
                   1208:        h->flags |= HTML_NOSPACE;
                   1209:        return(1);
                   1210: }
                   1211:
                   1212:
                   1213: /* ARGSUSED */
                   1214: static void
                   1215: mdoc_sq_post(MDOC_ARGS)
                   1216: {
                   1217:
                   1218:        if (MDOC_BODY != n->type)
                   1219:                return;
                   1220:        h->flags |= HTML_NOSPACE;
                   1221:        print_text(h, "\\(aq");
                   1222: }
                   1223:
                   1224:
                   1225: /* ARGSUSED */
                   1226: static int
                   1227: mdoc_em_pre(MDOC_ARGS)
                   1228: {
                   1229:        struct htmlpair tag;
                   1230:
1.23      kristaps 1231:        PAIR_CLASS_INIT(&tag, "emph");
1.1       kristaps 1232:        print_otag(h, TAG_SPAN, 1, &tag);
                   1233:        return(1);
                   1234: }
                   1235:
                   1236:
                   1237: /* ARGSUSED */
                   1238: static int
                   1239: mdoc_d1_pre(MDOC_ARGS)
                   1240: {
1.23      kristaps 1241:        struct htmlpair  tag[2];
                   1242:        struct roffsu    su;
1.1       kristaps 1243:
                   1244:        if (MDOC_BLOCK != n->type)
                   1245:                return(1);
                   1246:
1.35      kristaps 1247:        /* FIXME: D1 shouldn't be literal. */
                   1248:
1.64      kristaps 1249:        SCALE_VS_INIT(&su, INDENT - 1);
1.23      kristaps 1250:        bufcat_su(h, "margin-left", &su);
                   1251:        PAIR_CLASS_INIT(&tag[0], "lit");
                   1252:        PAIR_STYLE_INIT(&tag[1], h);
1.1       kristaps 1253:        print_otag(h, TAG_DIV, 2, tag);
                   1254:        return(1);
                   1255: }
                   1256:
                   1257:
                   1258: /* ARGSUSED */
                   1259: static int
                   1260: mdoc_sx_pre(MDOC_ARGS)
                   1261: {
1.18      kristaps 1262:        struct htmlpair          tag[2];
1.1       kristaps 1263:        const struct mdoc_node  *nn;
1.35      kristaps 1264:        char                     buf[BUFSIZ];
1.1       kristaps 1265:
1.41      kristaps 1266:        strlcpy(buf, "#", BUFSIZ);
1.1       kristaps 1267:        for (nn = n->child; nn; nn = nn->next) {
1.41      kristaps 1268:                html_idcat(buf, nn->string, BUFSIZ);
1.1       kristaps 1269:                if (nn->next)
1.42      kristaps 1270:                        html_idcat(buf, " ", BUFSIZ);
1.1       kristaps 1271:        }
                   1272:
1.23      kristaps 1273:        PAIR_CLASS_INIT(&tag[0], "link-sec");
1.57      kristaps 1274:        PAIR_HREF_INIT(&tag[1], buf);
1.1       kristaps 1275:
1.18      kristaps 1276:        print_otag(h, TAG_A, 2, tag);
1.1       kristaps 1277:        return(1);
                   1278: }
                   1279:
                   1280:
                   1281: /* ARGSUSED */
                   1282: static int
                   1283: mdoc_aq_pre(MDOC_ARGS)
                   1284: {
                   1285:
                   1286:        if (MDOC_BODY != n->type)
                   1287:                return(1);
                   1288:        print_text(h, "\\(la");
                   1289:        h->flags |= HTML_NOSPACE;
                   1290:        return(1);
                   1291: }
                   1292:
                   1293:
                   1294: /* ARGSUSED */
                   1295: static void
                   1296: mdoc_aq_post(MDOC_ARGS)
                   1297: {
                   1298:
                   1299:        if (MDOC_BODY != n->type)
                   1300:                return;
                   1301:        h->flags |= HTML_NOSPACE;
                   1302:        print_text(h, "\\(ra");
                   1303: }
                   1304:
                   1305:
                   1306: /* ARGSUSED */
                   1307: static int
                   1308: mdoc_bd_pre(MDOC_ARGS)
                   1309: {
                   1310:        struct htmlpair          tag[2];
1.23      kristaps 1311:        int                      type, comp, i;
1.14      kristaps 1312:        const struct mdoc_node  *bl, *nn;
1.23      kristaps 1313:        struct roffsu            su;
1.1       kristaps 1314:
                   1315:        if (MDOC_BLOCK == n->type)
                   1316:                bl = n;
                   1317:        else if (MDOC_HEAD == n->type)
                   1318:                return(0);
                   1319:        else
                   1320:                bl = n->parent;
                   1321:
1.24      kristaps 1322:        SCALE_VS_INIT(&su, 0);
                   1323:
1.23      kristaps 1324:        type = comp = 0;
1.1       kristaps 1325:        for (i = 0; i < (int)bl->args->argc; i++)
                   1326:                switch (bl->args->argv[i].arg) {
                   1327:                case (MDOC_Offset):
1.23      kristaps 1328:                        a2offs(bl->args->argv[i].value[0], &su);
1.1       kristaps 1329:                        break;
                   1330:                case (MDOC_Compact):
1.23      kristaps 1331:                        comp = 1;
1.1       kristaps 1332:                        break;
1.30      kristaps 1333:                case (MDOC_Centred):
                   1334:                        /* FALLTHROUGH */
1.1       kristaps 1335:                case (MDOC_Ragged):
                   1336:                        /* FALLTHROUGH */
                   1337:                case (MDOC_Filled):
                   1338:                        /* FALLTHROUGH */
                   1339:                case (MDOC_Unfilled):
                   1340:                        /* FALLTHROUGH */
                   1341:                case (MDOC_Literal):
1.23      kristaps 1342:                        type = bl->args->argv[i].arg;
1.1       kristaps 1343:                        break;
1.30      kristaps 1344:                default:
                   1345:                        break;
1.1       kristaps 1346:                }
                   1347:
1.31      kristaps 1348:        /* FIXME: -centered, etc. formatting. */
1.60      kristaps 1349:        /* FIXME: does not respect -offset ??? */
1.31      kristaps 1350:
1.1       kristaps 1351:        if (MDOC_BLOCK == n->type) {
1.24      kristaps 1352:                bufcat_su(h, "margin-left", &su);
1.23      kristaps 1353:                for (nn = n; nn && ! comp; nn = nn->parent) {
                   1354:                        if (MDOC_BLOCK != nn->type)
                   1355:                                continue;
                   1356:                        if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
                   1357:                                comp = 1;
                   1358:                        if (nn->prev)
                   1359:                                break;
                   1360:                }
                   1361:                if (comp) {
1.64      kristaps 1362:                        PAIR_STYLE_INIT(&tag[0], h);
                   1363:                        print_otag(h, TAG_DIV, 1, tag);
1.23      kristaps 1364:                        return(1);
1.14      kristaps 1365:                }
1.23      kristaps 1366:                SCALE_VS_INIT(&su, 1);
                   1367:                bufcat_su(h, "margin-top", &su);
                   1368:                PAIR_STYLE_INIT(&tag[0], h);
1.1       kristaps 1369:                print_otag(h, TAG_DIV, 1, tag);
                   1370:                return(1);
                   1371:        }
                   1372:
1.23      kristaps 1373:        if (MDOC_Unfilled != type && MDOC_Literal != type)
1.1       kristaps 1374:                return(1);
                   1375:
1.23      kristaps 1376:        PAIR_CLASS_INIT(&tag[0], "lit");
                   1377:        bufcat_style(h, "white-space", "pre");
                   1378:        PAIR_STYLE_INIT(&tag[1], h);
1.1       kristaps 1379:        print_otag(h, TAG_DIV, 2, tag);
                   1380:
1.14      kristaps 1381:        for (nn = n->child; nn; nn = nn->next) {
1.23      kristaps 1382:                h->flags |= HTML_NOSPACE;
1.14      kristaps 1383:                print_mdoc_node(m, nn, h);
                   1384:                if (NULL == nn->next)
                   1385:                        continue;
                   1386:                if (nn->prev && nn->prev->line < nn->line)
1.1       kristaps 1387:                        print_text(h, "\n");
1.23      kristaps 1388:                else if (NULL == nn->prev)
                   1389:                        print_text(h, "\n");
1.1       kristaps 1390:        }
                   1391:
                   1392:        return(0);
                   1393: }
                   1394:
                   1395:
                   1396: /* ARGSUSED */
                   1397: static int
                   1398: mdoc_pa_pre(MDOC_ARGS)
                   1399: {
                   1400:        struct htmlpair tag;
                   1401:
1.23      kristaps 1402:        PAIR_CLASS_INIT(&tag, "file");
1.1       kristaps 1403:        print_otag(h, TAG_SPAN, 1, &tag);
                   1404:        return(1);
                   1405: }
                   1406:
                   1407:
                   1408: /* ARGSUSED */
                   1409: static int
                   1410: mdoc_ad_pre(MDOC_ARGS)
                   1411: {
                   1412:        struct htmlpair tag;
                   1413:
1.23      kristaps 1414:        PAIR_CLASS_INIT(&tag, "addr");
1.1       kristaps 1415:        print_otag(h, TAG_SPAN, 1, &tag);
                   1416:        return(1);
                   1417: }
                   1418:
                   1419:
                   1420: /* ARGSUSED */
                   1421: static int
                   1422: mdoc_an_pre(MDOC_ARGS)
                   1423: {
                   1424:        struct htmlpair tag;
                   1425:
1.19      kristaps 1426:        /* TODO: -split and -nosplit (see termp_an_pre()). */
                   1427:
1.23      kristaps 1428:        PAIR_CLASS_INIT(&tag, "author");
1.1       kristaps 1429:        print_otag(h, TAG_SPAN, 1, &tag);
                   1430:        return(1);
                   1431: }
                   1432:
                   1433:
                   1434: /* ARGSUSED */
                   1435: static int
                   1436: mdoc_cd_pre(MDOC_ARGS)
                   1437: {
                   1438:        struct htmlpair tag;
                   1439:
1.28      kristaps 1440:        print_otag(h, TAG_DIV, 0, NULL);
1.23      kristaps 1441:        PAIR_CLASS_INIT(&tag, "config");
1.1       kristaps 1442:        print_otag(h, TAG_SPAN, 1, &tag);
                   1443:        return(1);
                   1444: }
                   1445:
                   1446:
                   1447: /* ARGSUSED */
                   1448: static int
                   1449: mdoc_dv_pre(MDOC_ARGS)
                   1450: {
                   1451:        struct htmlpair tag;
                   1452:
1.23      kristaps 1453:        PAIR_CLASS_INIT(&tag, "define");
1.1       kristaps 1454:        print_otag(h, TAG_SPAN, 1, &tag);
                   1455:        return(1);
                   1456: }
                   1457:
                   1458:
                   1459: /* ARGSUSED */
                   1460: static int
                   1461: mdoc_ev_pre(MDOC_ARGS)
                   1462: {
                   1463:        struct htmlpair tag;
                   1464:
1.23      kristaps 1465:        PAIR_CLASS_INIT(&tag, "env");
1.1       kristaps 1466:        print_otag(h, TAG_SPAN, 1, &tag);
                   1467:        return(1);
                   1468: }
                   1469:
                   1470:
                   1471: /* ARGSUSED */
                   1472: static int
                   1473: mdoc_er_pre(MDOC_ARGS)
                   1474: {
                   1475:        struct htmlpair tag;
                   1476:
1.23      kristaps 1477:        PAIR_CLASS_INIT(&tag, "errno");
1.1       kristaps 1478:        print_otag(h, TAG_SPAN, 1, &tag);
                   1479:        return(1);
                   1480: }
                   1481:
                   1482:
                   1483: /* ARGSUSED */
                   1484: static int
                   1485: mdoc_fa_pre(MDOC_ARGS)
                   1486: {
                   1487:        const struct mdoc_node  *nn;
                   1488:        struct htmlpair          tag;
                   1489:        struct tag              *t;
                   1490:
1.23      kristaps 1491:        PAIR_CLASS_INIT(&tag, "farg");
1.1       kristaps 1492:        if (n->parent->tok != MDOC_Fo) {
                   1493:                print_otag(h, TAG_SPAN, 1, &tag);
                   1494:                return(1);
                   1495:        }
                   1496:
                   1497:        for (nn = n->child; nn; nn = nn->next) {
                   1498:                t = print_otag(h, TAG_SPAN, 1, &tag);
                   1499:                print_text(h, nn->string);
                   1500:                print_tagq(h, t);
                   1501:                if (nn->next)
                   1502:                        print_text(h, ",");
                   1503:        }
                   1504:
                   1505:        if (n->child && n->next && n->next->tok == MDOC_Fa)
                   1506:                print_text(h, ",");
                   1507:
                   1508:        return(0);
                   1509: }
                   1510:
                   1511:
                   1512: /* ARGSUSED */
                   1513: static int
                   1514: mdoc_fd_pre(MDOC_ARGS)
                   1515: {
1.23      kristaps 1516:        struct htmlpair  tag;
                   1517:        struct roffsu    su;
1.1       kristaps 1518:
1.62      kristaps 1519:        if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
1.1       kristaps 1520:                if (n->next && MDOC_Fd != n->next->tok) {
1.23      kristaps 1521:                        SCALE_VS_INIT(&su, 1);
                   1522:                        bufcat_su(h, "margin-bottom", &su);
                   1523:                        PAIR_STYLE_INIT(&tag, h);
1.1       kristaps 1524:                        print_otag(h, TAG_DIV, 1, &tag);
                   1525:                } else
                   1526:                        print_otag(h, TAG_DIV, 0, NULL);
                   1527:        }
                   1528:
1.23      kristaps 1529:        PAIR_CLASS_INIT(&tag, "macro");
1.1       kristaps 1530:        print_otag(h, TAG_SPAN, 1, &tag);
                   1531:        return(1);
                   1532: }
                   1533:
                   1534:
                   1535: /* ARGSUSED */
                   1536: static int
                   1537: mdoc_vt_pre(MDOC_ARGS)
                   1538: {
1.23      kristaps 1539:        struct htmlpair  tag;
                   1540:        struct roffsu    su;
1.1       kristaps 1541:
1.57      kristaps 1542:        if (SEC_SYNOPSIS == n->sec && MDOC_BLOCK == n->type) {
                   1543:                if (n->next && MDOC_Vt != n->next->tok) {
1.23      kristaps 1544:                        SCALE_VS_INIT(&su, 1);
1.57      kristaps 1545:                        bufcat_su(h, "margin-bottom", &su);
1.23      kristaps 1546:                        PAIR_STYLE_INIT(&tag, h);
1.1       kristaps 1547:                        print_otag(h, TAG_DIV, 1, &tag);
                   1548:                } else
                   1549:                        print_otag(h, TAG_DIV, 0, NULL);
1.57      kristaps 1550:
1.54      kristaps 1551:                return(1);
                   1552:        } else if (MDOC_HEAD == n->type)
                   1553:                return(0);
1.1       kristaps 1554:
1.23      kristaps 1555:        PAIR_CLASS_INIT(&tag, "type");
1.1       kristaps 1556:        print_otag(h, TAG_SPAN, 1, &tag);
                   1557:        return(1);
                   1558: }
                   1559:
1.2       kristaps 1560:
1.1       kristaps 1561: /* ARGSUSED */
                   1562: static int
                   1563: mdoc_ft_pre(MDOC_ARGS)
                   1564: {
1.23      kristaps 1565:        struct htmlpair  tag;
1.1       kristaps 1566:
1.62      kristaps 1567:        if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
1.57      kristaps 1568:                print_otag(h, TAG_DIV, 0, NULL);
1.1       kristaps 1569:
1.23      kristaps 1570:        PAIR_CLASS_INIT(&tag, "ftype");
1.1       kristaps 1571:        print_otag(h, TAG_SPAN, 1, &tag);
                   1572:        return(1);
                   1573: }
                   1574:
                   1575:
                   1576: /* ARGSUSED */
                   1577: static int
                   1578: mdoc_fn_pre(MDOC_ARGS)
                   1579: {
                   1580:        struct tag              *t;
1.15      kristaps 1581:        struct htmlpair          tag[2];
1.1       kristaps 1582:        const struct mdoc_node  *nn;
1.7       kristaps 1583:        char                     nbuf[BUFSIZ];
                   1584:        const char              *sp, *ep;
1.15      kristaps 1585:        int                      sz, i;
1.23      kristaps 1586:        struct roffsu            su;
1.1       kristaps 1587:
1.62      kristaps 1588:        if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
1.23      kristaps 1589:                SCALE_HS_INIT(&su, INDENT);
                   1590:                bufcat_su(h, "margin-left", &su);
                   1591:                su.scale = -su.scale;
                   1592:                bufcat_su(h, "text-indent", &su);
                   1593:                if (n->next) {
                   1594:                        SCALE_VS_INIT(&su, 1);
                   1595:                        bufcat_su(h, "margin-bottom", &su);
                   1596:                }
                   1597:                PAIR_STYLE_INIT(&tag[0], h);
1.15      kristaps 1598:                print_otag(h, TAG_DIV, 1, tag);
1.1       kristaps 1599:        }
                   1600:
1.7       kristaps 1601:        /* Split apart into type and name. */
                   1602:        assert(n->child->string);
                   1603:        sp = n->child->string;
1.19      kristaps 1604:
1.26      kristaps 1605:        ep = strchr(sp, ' ');
                   1606:        if (NULL != ep) {
1.23      kristaps 1607:                PAIR_CLASS_INIT(&tag[0], "ftype");
1.19      kristaps 1608:                t = print_otag(h, TAG_SPAN, 1, tag);
                   1609:
                   1610:                while (ep) {
                   1611:                        sz = MIN((int)(ep - sp), BUFSIZ - 1);
                   1612:                        (void)memcpy(nbuf, sp, (size_t)sz);
                   1613:                        nbuf[sz] = '\0';
                   1614:                        print_text(h, nbuf);
                   1615:                        sp = ++ep;
                   1616:                        ep = strchr(sp, ' ');
                   1617:                }
                   1618:                print_tagq(h, t);
1.7       kristaps 1619:        }
1.1       kristaps 1620:
1.23      kristaps 1621:        PAIR_CLASS_INIT(&tag[0], "fname");
1.57      kristaps 1622:
                   1623:        /*
                   1624:         * FIXME: only refer to IDs that we know exist.
                   1625:         */
                   1626:
                   1627: #if 0
                   1628:        if (SEC_SYNOPSIS == n->sec) {
                   1629:                nbuf[0] = '\0';
                   1630:                html_idcat(nbuf, sp, BUFSIZ);
                   1631:                PAIR_ID_INIT(&tag[1], nbuf);
                   1632:        } else {
                   1633:                strlcpy(nbuf, "#", BUFSIZ);
                   1634:                html_idcat(nbuf, sp, BUFSIZ);
                   1635:                PAIR_HREF_INIT(&tag[1], nbuf);
                   1636:        }
                   1637: #endif
                   1638:
1.15      kristaps 1639:        t = print_otag(h, TAG_SPAN, 1, tag);
1.7       kristaps 1640:
                   1641:        if (sp) {
1.57      kristaps 1642:                strlcpy(nbuf, sp, BUFSIZ);
1.7       kristaps 1643:                print_text(h, nbuf);
                   1644:        }
                   1645:
1.1       kristaps 1646:        print_tagq(h, t);
                   1647:
                   1648:        h->flags |= HTML_NOSPACE;
                   1649:        print_text(h, "(");
                   1650:
1.23      kristaps 1651:        bufinit(h);
                   1652:        PAIR_CLASS_INIT(&tag[0], "farg");
                   1653:        bufcat_style(h, "white-space", "nowrap");
                   1654:        PAIR_STYLE_INIT(&tag[1], h);
                   1655:
1.1       kristaps 1656:        for (nn = n->child->next; nn; nn = nn->next) {
1.23      kristaps 1657:                i = 1;
                   1658:                if (SEC_SYNOPSIS == n->sec)
                   1659:                        i = 2;
1.15      kristaps 1660:                t = print_otag(h, TAG_SPAN, i, tag);
1.1       kristaps 1661:                print_text(h, nn->string);
                   1662:                print_tagq(h, t);
                   1663:                if (nn->next)
                   1664:                        print_text(h, ",");
                   1665:        }
                   1666:
                   1667:        print_text(h, ")");
                   1668:        if (SEC_SYNOPSIS == n->sec)
                   1669:                print_text(h, ";");
                   1670:
                   1671:        return(0);
                   1672: }
                   1673:
                   1674:
                   1675: /* ARGSUSED */
                   1676: static int
                   1677: mdoc_sp_pre(MDOC_ARGS)
                   1678: {
1.23      kristaps 1679:        int              len;
                   1680:        struct htmlpair  tag;
                   1681:        struct roffsu    su;
1.1       kristaps 1682:
                   1683:        switch (n->tok) {
                   1684:        case (MDOC_sp):
1.23      kristaps 1685:                /* FIXME: can this have a scaling indicator? */
1.1       kristaps 1686:                len = n->child ? atoi(n->child->string) : 1;
                   1687:                break;
                   1688:        case (MDOC_br):
                   1689:                len = 0;
                   1690:                break;
                   1691:        default:
                   1692:                len = 1;
                   1693:                break;
                   1694:        }
                   1695:
1.23      kristaps 1696:        SCALE_VS_INIT(&su, len);
                   1697:        bufcat_su(h, "height", &su);
                   1698:        PAIR_STYLE_INIT(&tag, h);
1.1       kristaps 1699:        print_otag(h, TAG_DIV, 1, &tag);
1.42      kristaps 1700:        /* So the div isn't empty: */
                   1701:        print_text(h, "\\~");
                   1702:
                   1703:        return(0);
1.1       kristaps 1704:
                   1705: }
1.2       kristaps 1706:
                   1707:
                   1708: /* ARGSUSED */
                   1709: static int
                   1710: mdoc_brq_pre(MDOC_ARGS)
                   1711: {
                   1712:
                   1713:        if (MDOC_BODY != n->type)
                   1714:                return(1);
                   1715:        print_text(h, "\\(lC");
                   1716:        h->flags |= HTML_NOSPACE;
                   1717:        return(1);
                   1718: }
                   1719:
                   1720:
                   1721: /* ARGSUSED */
                   1722: static void
                   1723: mdoc_brq_post(MDOC_ARGS)
                   1724: {
                   1725:
                   1726:        if (MDOC_BODY != n->type)
                   1727:                return;
                   1728:        h->flags |= HTML_NOSPACE;
                   1729:        print_text(h, "\\(rC");
                   1730: }
                   1731:
                   1732:
                   1733: /* ARGSUSED */
                   1734: static int
                   1735: mdoc_lk_pre(MDOC_ARGS)
                   1736: {
                   1737:        const struct mdoc_node  *nn;
                   1738:        struct htmlpair          tag[2];
                   1739:
                   1740:        nn = n->child;
                   1741:
1.23      kristaps 1742:        PAIR_CLASS_INIT(&tag[0], "link-ext");
1.57      kristaps 1743:        PAIR_HREF_INIT(&tag[1], nn->string);
1.2       kristaps 1744:        print_otag(h, TAG_A, 2, tag);
                   1745:
1.38      kristaps 1746:        if (NULL == nn->next)
                   1747:                return(1);
                   1748:
1.2       kristaps 1749:        for (nn = nn->next; nn; nn = nn->next)
                   1750:                print_text(h, nn->string);
                   1751:
                   1752:        return(0);
                   1753: }
                   1754:
                   1755:
                   1756: /* ARGSUSED */
                   1757: static int
                   1758: mdoc_mt_pre(MDOC_ARGS)
                   1759: {
                   1760:        struct htmlpair          tag[2];
                   1761:        struct tag              *t;
                   1762:        const struct mdoc_node  *nn;
                   1763:
1.23      kristaps 1764:        PAIR_CLASS_INIT(&tag[0], "link-mail");
1.2       kristaps 1765:
                   1766:        for (nn = n->child; nn; nn = nn->next) {
1.16      kristaps 1767:                bufinit(h);
                   1768:                bufcat(h, "mailto:");
                   1769:                bufcat(h, nn->string);
1.57      kristaps 1770:                PAIR_HREF_INIT(&tag[1], h->buf);
1.2       kristaps 1771:                t = print_otag(h, TAG_A, 2, tag);
                   1772:                print_text(h, nn->string);
                   1773:                print_tagq(h, t);
                   1774:        }
                   1775:
                   1776:        return(0);
                   1777: }
1.4       kristaps 1778:
                   1779:
                   1780: /* ARGSUSED */
                   1781: static int
                   1782: mdoc_fo_pre(MDOC_ARGS)
                   1783: {
                   1784:        struct htmlpair tag;
1.57      kristaps 1785:        struct roffsu   su;
1.4       kristaps 1786:
                   1787:        if (MDOC_BODY == n->type) {
                   1788:                h->flags |= HTML_NOSPACE;
                   1789:                print_text(h, "(");
                   1790:                h->flags |= HTML_NOSPACE;
                   1791:                return(1);
1.57      kristaps 1792:        } else if (MDOC_BLOCK == n->type && n->next) {
                   1793:                SCALE_VS_INIT(&su, 1);
                   1794:                bufcat_su(h, "margin-bottom", &su);
                   1795:                PAIR_STYLE_INIT(&tag, h);
                   1796:                print_otag(h, TAG_DIV, 1, &tag);
1.4       kristaps 1797:                return(1);
1.57      kristaps 1798:        }
1.4       kristaps 1799:
1.23      kristaps 1800:        PAIR_CLASS_INIT(&tag, "fname");
1.4       kristaps 1801:        print_otag(h, TAG_SPAN, 1, &tag);
                   1802:        return(1);
                   1803: }
                   1804:
                   1805:
                   1806: /* ARGSUSED */
                   1807: static void
                   1808: mdoc_fo_post(MDOC_ARGS)
                   1809: {
                   1810:        if (MDOC_BODY != n->type)
                   1811:                return;
                   1812:        h->flags |= HTML_NOSPACE;
                   1813:        print_text(h, ")");
                   1814:        h->flags |= HTML_NOSPACE;
                   1815:        print_text(h, ";");
                   1816: }
                   1817:
                   1818:
                   1819: /* ARGSUSED */
                   1820: static int
                   1821: mdoc_in_pre(MDOC_ARGS)
                   1822: {
                   1823:        const struct mdoc_node  *nn;
1.23      kristaps 1824:        struct tag              *t;
1.17      kristaps 1825:        struct htmlpair          tag[2];
                   1826:        int                      i;
1.23      kristaps 1827:        struct roffsu            su;
1.4       kristaps 1828:
1.62      kristaps 1829:        if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
1.4       kristaps 1830:                if (n->next && MDOC_In != n->next->tok) {
1.23      kristaps 1831:                        SCALE_VS_INIT(&su, 1);
                   1832:                        bufcat_su(h, "margin-bottom", &su);
                   1833:                        PAIR_STYLE_INIT(&tag[0], h);
1.17      kristaps 1834:                        print_otag(h, TAG_DIV, 1, tag);
1.4       kristaps 1835:                } else
                   1836:                        print_otag(h, TAG_DIV, 0, NULL);
                   1837:        }
                   1838:
1.34      kristaps 1839:        /* FIXME: there's a buffer bug in here somewhere. */
                   1840:
1.23      kristaps 1841:        PAIR_CLASS_INIT(&tag[0], "includes");
1.17      kristaps 1842:        print_otag(h, TAG_SPAN, 1, tag);
1.4       kristaps 1843:
                   1844:        if (SEC_SYNOPSIS == n->sec)
                   1845:                print_text(h, "#include");
                   1846:
                   1847:        print_text(h, "<");
                   1848:        h->flags |= HTML_NOSPACE;
                   1849:
                   1850:        /* XXX -- see warning in termp_in_post(). */
                   1851:
1.17      kristaps 1852:        for (nn = n->child; nn; nn = nn->next) {
1.23      kristaps 1853:                PAIR_CLASS_INIT(&tag[0], "link-includes");
                   1854:                i = 1;
1.41      kristaps 1855:                bufinit(h);
1.17      kristaps 1856:                if (h->base_includes) {
                   1857:                        buffmt_includes(h, nn->string);
1.57      kristaps 1858:                        PAIR_HREF_INIT(&tag[i], h->buf);
                   1859:                        i++;
1.17      kristaps 1860:                }
                   1861:                t = print_otag(h, TAG_A, i, tag);
1.4       kristaps 1862:                print_mdoc_node(m, nn, h);
1.17      kristaps 1863:                print_tagq(h, t);
                   1864:        }
1.4       kristaps 1865:
                   1866:        h->flags |= HTML_NOSPACE;
                   1867:        print_text(h, ">");
                   1868:
                   1869:        return(0);
                   1870: }
                   1871:
                   1872:
                   1873: /* ARGSUSED */
                   1874: static int
                   1875: mdoc_ic_pre(MDOC_ARGS)
                   1876: {
                   1877:        struct htmlpair tag;
                   1878:
1.23      kristaps 1879:        PAIR_CLASS_INIT(&tag, "cmd");
1.4       kristaps 1880:        print_otag(h, TAG_SPAN, 1, &tag);
                   1881:        return(1);
                   1882: }
                   1883:
                   1884:
                   1885: /* ARGSUSED */
                   1886: static int
                   1887: mdoc_rv_pre(MDOC_ARGS)
                   1888: {
                   1889:        const struct mdoc_node  *nn;
                   1890:        struct htmlpair          tag;
                   1891:        struct tag              *t;
                   1892:
                   1893:        print_otag(h, TAG_DIV, 0, NULL);
                   1894:        print_text(h, "The");
                   1895:
                   1896:        for (nn = n->child; nn; nn = nn->next) {
1.23      kristaps 1897:                PAIR_CLASS_INIT(&tag, "fname");
1.4       kristaps 1898:                t = print_otag(h, TAG_SPAN, 1, &tag);
                   1899:                print_text(h, nn->string);
                   1900:                print_tagq(h, t);
                   1901:
                   1902:                h->flags |= HTML_NOSPACE;
                   1903:                if (nn->next && NULL == nn->next->next)
                   1904:                        print_text(h, "(), and");
                   1905:                else if (nn->next)
                   1906:                        print_text(h, "(),");
                   1907:                else
                   1908:                        print_text(h, "()");
                   1909:        }
                   1910:
1.65      kristaps 1911:        if (n->child && n->child->next)
1.4       kristaps 1912:                print_text(h, "functions return");
                   1913:        else
                   1914:                print_text(h, "function returns");
                   1915:
                   1916:                print_text(h, "the value 0 if successful; otherwise the value "
                   1917:                        "-1 is returned and the global variable");
                   1918:
1.23      kristaps 1919:        PAIR_CLASS_INIT(&tag, "var");
1.4       kristaps 1920:        t = print_otag(h, TAG_SPAN, 1, &tag);
                   1921:        print_text(h, "errno");
                   1922:        print_tagq(h, t);
                   1923:                print_text(h, "is set to indicate the error.");
                   1924:        return(0);
                   1925: }
                   1926:
                   1927:
                   1928: /* ARGSUSED */
                   1929: static int
                   1930: mdoc_va_pre(MDOC_ARGS)
                   1931: {
                   1932:        struct htmlpair tag;
                   1933:
1.23      kristaps 1934:        PAIR_CLASS_INIT(&tag, "var");
1.4       kristaps 1935:        print_otag(h, TAG_SPAN, 1, &tag);
                   1936:        return(1);
                   1937: }
                   1938:
                   1939:
                   1940: /* ARGSUSED */
                   1941: static int
                   1942: mdoc_bq_pre(MDOC_ARGS)
                   1943: {
                   1944:
                   1945:        if (MDOC_BODY != n->type)
                   1946:                return(1);
                   1947:        print_text(h, "\\(lB");
                   1948:        h->flags |= HTML_NOSPACE;
                   1949:        return(1);
                   1950: }
                   1951:
                   1952:
                   1953: /* ARGSUSED */
                   1954: static void
                   1955: mdoc_bq_post(MDOC_ARGS)
                   1956: {
                   1957:
                   1958:        if (MDOC_BODY != n->type)
                   1959:                return;
                   1960:        h->flags |= HTML_NOSPACE;
                   1961:        print_text(h, "\\(rB");
                   1962: }
1.5       kristaps 1963:
                   1964:
                   1965: /* ARGSUSED */
                   1966: static int
                   1967: mdoc_ap_pre(MDOC_ARGS)
                   1968: {
                   1969:
                   1970:        h->flags |= HTML_NOSPACE;
                   1971:        print_text(h, "\\(aq");
                   1972:        h->flags |= HTML_NOSPACE;
                   1973:        return(1);
                   1974: }
                   1975:
                   1976:
                   1977: /* ARGSUSED */
                   1978: static int
                   1979: mdoc_bf_pre(MDOC_ARGS)
                   1980: {
1.23      kristaps 1981:        int              i;
                   1982:        struct htmlpair  tag[2];
                   1983:        struct roffsu    su;
1.5       kristaps 1984:
                   1985:        if (MDOC_HEAD == n->type)
                   1986:                return(0);
                   1987:        else if (MDOC_BLOCK != n->type)
                   1988:                return(1);
                   1989:
1.23      kristaps 1990:        PAIR_CLASS_INIT(&tag[0], "lit");
1.5       kristaps 1991:
                   1992:        if (n->head->child) {
                   1993:                if ( ! strcmp("Em", n->head->child->string))
1.23      kristaps 1994:                        PAIR_CLASS_INIT(&tag[0], "emph");
1.5       kristaps 1995:                else if ( ! strcmp("Sy", n->head->child->string))
1.23      kristaps 1996:                        PAIR_CLASS_INIT(&tag[0], "symb");
1.5       kristaps 1997:                else if ( ! strcmp("Li", n->head->child->string))
1.23      kristaps 1998:                        PAIR_CLASS_INIT(&tag[0], "lit");
1.5       kristaps 1999:        } else {
                   2000:                assert(n->args);
                   2001:                for (i = 0; i < (int)n->args->argc; i++)
                   2002:                        switch (n->args->argv[i].arg) {
                   2003:                        case (MDOC_Symbolic):
1.23      kristaps 2004:                                PAIR_CLASS_INIT(&tag[0], "symb");
1.5       kristaps 2005:                                break;
                   2006:                        case (MDOC_Literal):
1.23      kristaps 2007:                                PAIR_CLASS_INIT(&tag[0], "lit");
1.5       kristaps 2008:                                break;
                   2009:                        case (MDOC_Emphasis):
1.23      kristaps 2010:                                PAIR_CLASS_INIT(&tag[0], "emph");
1.5       kristaps 2011:                                break;
                   2012:                        default:
                   2013:                                break;
                   2014:                        }
                   2015:        }
                   2016:
                   2017:        /* FIXME: div's have spaces stripped--we want them. */
                   2018:
1.23      kristaps 2019:        bufcat_style(h, "display", "inline");
                   2020:        SCALE_HS_INIT(&su, 1);
                   2021:        bufcat_su(h, "margin-right", &su);
                   2022:        PAIR_STYLE_INIT(&tag[1], h);
1.5       kristaps 2023:        print_otag(h, TAG_DIV, 2, tag);
                   2024:        return(1);
                   2025: }
                   2026:
                   2027:
                   2028: /* ARGSUSED */
                   2029: static int
                   2030: mdoc_ms_pre(MDOC_ARGS)
                   2031: {
                   2032:        struct htmlpair tag;
                   2033:
1.23      kristaps 2034:        PAIR_CLASS_INIT(&tag, "symb");
1.5       kristaps 2035:        print_otag(h, TAG_SPAN, 1, &tag);
                   2036:        return(1);
                   2037: }
                   2038:
                   2039:
                   2040: /* ARGSUSED */
                   2041: static int
                   2042: mdoc_pf_pre(MDOC_ARGS)
                   2043: {
                   2044:
                   2045:        h->flags |= HTML_IGNDELIM;
                   2046:        return(1);
                   2047: }
                   2048:
                   2049:
                   2050: /* ARGSUSED */
                   2051: static void
                   2052: mdoc_pf_post(MDOC_ARGS)
                   2053: {
                   2054:
                   2055:        h->flags &= ~HTML_IGNDELIM;
                   2056:        h->flags |= HTML_NOSPACE;
                   2057: }
                   2058:
                   2059:
                   2060: /* ARGSUSED */
                   2061: static int
                   2062: mdoc_rs_pre(MDOC_ARGS)
                   2063: {
1.23      kristaps 2064:        struct htmlpair  tag;
                   2065:        struct roffsu    su;
1.5       kristaps 2066:
                   2067:        if (MDOC_BLOCK != n->type)
                   2068:                return(1);
                   2069:
1.8       kristaps 2070:        if (n->prev && SEC_SEE_ALSO == n->sec) {
1.23      kristaps 2071:                SCALE_VS_INIT(&su, 1);
                   2072:                bufcat_su(h, "margin-top", &su);
                   2073:                PAIR_STYLE_INIT(&tag, h);
1.8       kristaps 2074:                print_otag(h, TAG_DIV, 1, &tag);
1.5       kristaps 2075:        }
                   2076:
1.23      kristaps 2077:        PAIR_CLASS_INIT(&tag, "ref");
1.8       kristaps 2078:        print_otag(h, TAG_SPAN, 1, &tag);
1.5       kristaps 2079:        return(1);
                   2080: }
1.6       kristaps 2081:
                   2082:
                   2083:
                   2084: /* ARGSUSED */
                   2085: static int
                   2086: mdoc_li_pre(MDOC_ARGS)
                   2087: {
                   2088:        struct htmlpair tag;
                   2089:
1.23      kristaps 2090:        PAIR_CLASS_INIT(&tag, "lit");
1.6       kristaps 2091:        print_otag(h, TAG_SPAN, 1, &tag);
                   2092:        return(1);
                   2093: }
                   2094:
                   2095:
                   2096: /* ARGSUSED */
                   2097: static int
                   2098: mdoc_sy_pre(MDOC_ARGS)
                   2099: {
                   2100:        struct htmlpair tag;
                   2101:
1.23      kristaps 2102:        PAIR_CLASS_INIT(&tag, "symb");
1.6       kristaps 2103:        print_otag(h, TAG_SPAN, 1, &tag);
                   2104:        return(1);
                   2105: }
                   2106:
                   2107:
                   2108: /* ARGSUSED */
                   2109: static int
                   2110: mdoc_bt_pre(MDOC_ARGS)
                   2111: {
                   2112:
                   2113:        print_text(h, "is currently in beta test.");
                   2114:        return(0);
                   2115: }
                   2116:
                   2117:
                   2118: /* ARGSUSED */
                   2119: static int
                   2120: mdoc_ud_pre(MDOC_ARGS)
                   2121: {
                   2122:
                   2123:        print_text(h, "currently under development.");
                   2124:        return(0);
                   2125: }
                   2126:
                   2127:
                   2128: /* ARGSUSED */
                   2129: static int
                   2130: mdoc_lb_pre(MDOC_ARGS)
                   2131: {
                   2132:        struct htmlpair tag;
                   2133:
1.62      kristaps 2134:        if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags)
1.6       kristaps 2135:                print_otag(h, TAG_DIV, 0, NULL);
1.23      kristaps 2136:        PAIR_CLASS_INIT(&tag, "lib");
1.6       kristaps 2137:        print_otag(h, TAG_SPAN, 1, &tag);
                   2138:        return(1);
                   2139: }
1.10      kristaps 2140:
                   2141:
                   2142: /* ARGSUSED */
                   2143: static int
                   2144: mdoc__x_pre(MDOC_ARGS)
                   2145: {
1.38      kristaps 2146:        struct htmlpair tag[2];
1.37      kristaps 2147:
1.10      kristaps 2148:        switch (n->tok) {
                   2149:        case(MDOC__A):
1.38      kristaps 2150:                PAIR_CLASS_INIT(&tag[0], "ref-auth");
1.10      kristaps 2151:                break;
                   2152:        case(MDOC__B):
1.38      kristaps 2153:                PAIR_CLASS_INIT(&tag[0], "ref-book");
1.10      kristaps 2154:                break;
                   2155:        case(MDOC__C):
1.38      kristaps 2156:                PAIR_CLASS_INIT(&tag[0], "ref-city");
1.10      kristaps 2157:                break;
                   2158:        case(MDOC__D):
1.38      kristaps 2159:                PAIR_CLASS_INIT(&tag[0], "ref-date");
1.10      kristaps 2160:                break;
                   2161:        case(MDOC__I):
1.38      kristaps 2162:                PAIR_CLASS_INIT(&tag[0], "ref-issue");
1.10      kristaps 2163:                break;
                   2164:        case(MDOC__J):
1.38      kristaps 2165:                PAIR_CLASS_INIT(&tag[0], "ref-jrnl");
1.10      kristaps 2166:                break;
                   2167:        case(MDOC__N):
1.38      kristaps 2168:                PAIR_CLASS_INIT(&tag[0], "ref-num");
1.10      kristaps 2169:                break;
                   2170:        case(MDOC__O):
1.38      kristaps 2171:                PAIR_CLASS_INIT(&tag[0], "ref-opt");
1.10      kristaps 2172:                break;
                   2173:        case(MDOC__P):
1.38      kristaps 2174:                PAIR_CLASS_INIT(&tag[0], "ref-page");
1.10      kristaps 2175:                break;
                   2176:        case(MDOC__Q):
1.38      kristaps 2177:                PAIR_CLASS_INIT(&tag[0], "ref-corp");
1.10      kristaps 2178:                break;
                   2179:        case(MDOC__R):
1.38      kristaps 2180:                PAIR_CLASS_INIT(&tag[0], "ref-rep");
1.10      kristaps 2181:                break;
                   2182:        case(MDOC__T):
1.38      kristaps 2183:                PAIR_CLASS_INIT(&tag[0], "ref-title");
1.10      kristaps 2184:                break;
1.38      kristaps 2185:        case(MDOC__U):
                   2186:                PAIR_CLASS_INIT(&tag[0], "link-ref");
                   2187:                break;
1.10      kristaps 2188:        case(MDOC__V):
1.38      kristaps 2189:                PAIR_CLASS_INIT(&tag[0], "ref-vol");
1.10      kristaps 2190:                break;
                   2191:        default:
                   2192:                abort();
                   2193:                /* NOTREACHED */
                   2194:        }
                   2195:
1.38      kristaps 2196:        if (MDOC__U != n->tok) {
                   2197:                print_otag(h, TAG_SPAN, 1, tag);
                   2198:                return(1);
                   2199:        }
                   2200:
                   2201:        PAIR_HREF_INIT(&tag[1], n->child->string);
                   2202:        print_otag(h, TAG_A, 2, tag);
1.10      kristaps 2203:        return(1);
                   2204: }
                   2205:
                   2206:
                   2207: /* ARGSUSED */
                   2208: static void
                   2209: mdoc__x_post(MDOC_ARGS)
                   2210: {
                   2211:
1.61      kristaps 2212:        /* TODO: %U */
                   2213:
1.10      kristaps 2214:        h->flags |= HTML_NOSPACE;
                   2215:        print_text(h, n->next ? "," : ".");
                   2216: }

CVSweb