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

Annotation of mandoc/mdoc_html.c, Revision 1.70

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

CVSweb