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

Annotation of mandoc/mdoc_html.c, Revision 1.90

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

CVSweb