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

Annotation of mandoc/mdoc_html.c, Revision 1.93

1.93    ! kristaps    1: /*     $Id: mdoc_html.c,v 1.92 2010/07/02 12:54:33 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: {
1.91      kristaps  739:        struct htmlpair  tag;
                    740:        struct roffsu    su;
                    741:        const char      *cp;
                    742:
                    743:        /*
                    744:         * Accomodate for `Nm' being both an element (which may have
                    745:         * NULL children AND no m->name) and a block.
                    746:         */
                    747:
                    748:        cp = NULL;
                    749:
                    750:        if (MDOC_ELEM == n->type) {
                    751:                if (NULL == n->child && NULL == m->name)
                    752:                        return(1);
                    753:                synopsis_pre(h, n);
                    754:                PAIR_CLASS_INIT(&tag, "name");
                    755:                print_otag(h, TAG_SPAN, 1, &tag);
                    756:                if (NULL == n->child)
                    757:                        print_text(h, m->name);
                    758:        } else if (MDOC_BLOCK == n->type) {
                    759:                synopsis_pre(h, n);
                    760:
                    761:                bufcat_style(h, "clear", "both");
                    762:                if (n->head->child || m->name) {
                    763:                        if (n->head->child && MDOC_TEXT ==
                    764:                                        n->head->child->type)
                    765:                                cp = n->head->child->string;
                    766:                        if (NULL == cp || '\0' == *cp)
                    767:                                cp = m->name;
                    768:
                    769:                        SCALE_HS_INIT(&su, (double)strlen(cp));
                    770:                        bufcat_su(h, "padding-left", &su);
                    771:                }
1.1       kristaps  772:
1.91      kristaps  773:                PAIR_STYLE_INIT(&tag, h);
                    774:                print_otag(h, TAG_DIV, 1, &tag);
                    775:        } else if (MDOC_HEAD == n->type) {
                    776:                if (NULL == n->child && NULL == m->name)
                    777:                        return(1);
                    778:
                    779:                if (n->child && MDOC_TEXT == n->child->type)
                    780:                        cp = n->child->string;
                    781:                if (NULL == cp || '\0' == *cp)
                    782:                        cp = m->name;
                    783:
                    784:                SCALE_HS_INIT(&su, (double)strlen(cp));
                    785:
                    786:                bufcat_style(h, "float", "left");
                    787:                bufcat_su(h, "min-width", &su);
                    788:                SCALE_INVERT(&su);
                    789:                bufcat_su(h, "margin-left", &su);
                    790:
                    791:                PAIR_STYLE_INIT(&tag, h);
                    792:                print_otag(h, TAG_DIV, 1, &tag);
1.65      kristaps  793:
1.91      kristaps  794:                if (NULL == n->child)
                    795:                        print_text(h, m->name);
                    796:        } else if (MDOC_BODY == n->type) {
                    797:                SCALE_HS_INIT(&su, 2);
                    798:                bufcat_su(h, "margin-left", &su);
                    799:                PAIR_STYLE_INIT(&tag, h);
                    800:                print_otag(h, TAG_DIV, 1, &tag);
                    801:        }
1.1       kristaps  802:
                    803:        return(1);
                    804: }
                    805:
                    806:
                    807: /* ARGSUSED */
                    808: static int
                    809: mdoc_xr_pre(MDOC_ARGS)
                    810: {
                    811:        struct htmlpair          tag[2];
                    812:        const struct mdoc_node  *nn;
1.56      kristaps  813:
                    814:        if (NULL == n->child)
                    815:                return(0);
1.17      kristaps  816:
1.23      kristaps  817:        PAIR_CLASS_INIT(&tag[0], "link-man");
1.1       kristaps  818:
1.17      kristaps  819:        if (h->base_man) {
1.23      kristaps  820:                buffmt_man(h, n->child->string,
                    821:                                n->child->next ?
1.17      kristaps  822:                                n->child->next->string : NULL);
1.57      kristaps  823:                PAIR_HREF_INIT(&tag[1], h->buf);
1.23      kristaps  824:                print_otag(h, TAG_A, 2, tag);
                    825:        } else
                    826:                print_otag(h, TAG_A, 1, tag);
1.1       kristaps  827:
                    828:        nn = n->child;
                    829:        print_text(h, nn->string);
1.16      kristaps  830:
1.1       kristaps  831:        if (NULL == (nn = nn->next))
                    832:                return(0);
                    833:
                    834:        h->flags |= HTML_NOSPACE;
                    835:        print_text(h, "(");
                    836:        h->flags |= HTML_NOSPACE;
                    837:        print_text(h, nn->string);
                    838:        h->flags |= HTML_NOSPACE;
                    839:        print_text(h, ")");
                    840:        return(0);
                    841: }
                    842:
                    843:
                    844: /* ARGSUSED */
                    845: static int
                    846: mdoc_ns_pre(MDOC_ARGS)
                    847: {
                    848:
                    849:        h->flags |= HTML_NOSPACE;
                    850:        return(1);
                    851: }
                    852:
                    853:
                    854: /* ARGSUSED */
                    855: static int
                    856: mdoc_ar_pre(MDOC_ARGS)
                    857: {
                    858:        struct htmlpair tag;
                    859:
1.23      kristaps  860:        PAIR_CLASS_INIT(&tag, "arg");
1.1       kristaps  861:        print_otag(h, TAG_SPAN, 1, &tag);
                    862:        return(1);
                    863: }
                    864:
                    865:
                    866: /* ARGSUSED */
                    867: static int
                    868: mdoc_xx_pre(MDOC_ARGS)
                    869: {
                    870:        const char      *pp;
                    871:        struct htmlpair  tag;
                    872:
                    873:        switch (n->tok) {
                    874:        case (MDOC_Bsx):
                    875:                pp = "BSDI BSD/OS";
                    876:                break;
                    877:        case (MDOC_Dx):
1.45      kristaps  878:                pp = "DragonFly";
1.1       kristaps  879:                break;
                    880:        case (MDOC_Fx):
                    881:                pp = "FreeBSD";
                    882:                break;
                    883:        case (MDOC_Nx):
                    884:                pp = "NetBSD";
                    885:                break;
                    886:        case (MDOC_Ox):
                    887:                pp = "OpenBSD";
                    888:                break;
                    889:        case (MDOC_Ux):
                    890:                pp = "UNIX";
                    891:                break;
                    892:        default:
                    893:                return(1);
                    894:        }
                    895:
1.23      kristaps  896:        PAIR_CLASS_INIT(&tag, "unix");
1.1       kristaps  897:        print_otag(h, TAG_SPAN, 1, &tag);
                    898:        print_text(h, pp);
                    899:        return(1);
                    900: }
                    901:
                    902:
                    903: /* ARGSUSED */
                    904: static int
1.4       kristaps  905: mdoc_bx_pre(MDOC_ARGS)
                    906: {
                    907:        const struct mdoc_node  *nn;
                    908:        struct htmlpair          tag;
                    909:
1.23      kristaps  910:        PAIR_CLASS_INIT(&tag, "unix");
1.4       kristaps  911:        print_otag(h, TAG_SPAN, 1, &tag);
                    912:
                    913:        for (nn = n->child; nn; nn = nn->next)
                    914:                print_mdoc_node(m, nn, h);
                    915:
                    916:        if (n->child)
                    917:                h->flags |= HTML_NOSPACE;
                    918:
                    919:        print_text(h, "BSD");
                    920:        return(0);
                    921: }
                    922:
                    923:
                    924: /* ARGSUSED */
                    925: static int
1.66      kristaps  926: mdoc_it_block_pre(MDOC_ARGS, enum mdoc_list type, int comp,
1.27      kristaps  927:                struct roffsu *offs, struct roffsu *width)
1.1       kristaps  928: {
1.14      kristaps  929:        struct htmlpair          tag;
                    930:        const struct mdoc_node  *nn;
1.23      kristaps  931:        struct roffsu            su;
                    932:
                    933:        nn = n->parent->parent;
                    934:
1.24      kristaps  935:        /* XXX: see notes in mdoc_it_pre(). */
                    936:
1.66      kristaps  937:        if (LIST_column == type) {
1.24      kristaps  938:                /* Don't width-pad on the left. */
                    939:                SCALE_HS_INIT(width, 0);
                    940:                /* Also disallow non-compact. */
                    941:                comp = 1;
                    942:        }
1.66      kristaps  943:        if (LIST_diag == type)
1.24      kristaps  944:                /* Mandate non-compact with empty prior. */
1.23      kristaps  945:                if (n->prev && NULL == n->prev->body->child)
                    946:                        comp = 1;
                    947:
1.24      kristaps  948:        bufcat_style(h, "clear", "both");
1.23      kristaps  949:        if (offs->scale > 0)
                    950:                bufcat_su(h, "margin-left", offs);
                    951:        if (width->scale > 0)
                    952:                bufcat_su(h, "padding-left", width);
1.1       kristaps  953:
1.23      kristaps  954:        PAIR_STYLE_INIT(&tag, h);
                    955:
1.24      kristaps  956:        /* Mandate compact following `Ss' and `Sh' starts. */
                    957:
1.23      kristaps  958:        for (nn = n; nn && ! comp; nn = nn->parent) {
                    959:                if (MDOC_BLOCK != nn->type)
                    960:                        continue;
                    961:                if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
                    962:                        comp = 1;
                    963:                if (nn->prev)
                    964:                        break;
1.1       kristaps  965:        }
                    966:
1.23      kristaps  967:        if ( ! comp) {
                    968:                SCALE_VS_INIT(&su, 1);
                    969:                bufcat_su(h, "padding-top", &su);
1.1       kristaps  970:        }
                    971:
1.23      kristaps  972:        PAIR_STYLE_INIT(&tag, h);
1.1       kristaps  973:        print_otag(h, TAG_DIV, 1, &tag);
                    974:        return(1);
                    975: }
                    976:
                    977:
1.25      kristaps  978: /* ARGSUSED */
1.1       kristaps  979: static int
1.70      kristaps  980: mdoc_it_body_pre(MDOC_ARGS, enum mdoc_list type, struct roffsu *width)
1.1       kristaps  981: {
1.23      kristaps  982:        struct htmlpair  tag;
                    983:        struct roffsu    su;
                    984:
                    985:        switch (type) {
1.66      kristaps  986:        case (LIST_item):
1.23      kristaps  987:                /* FALLTHROUGH */
1.66      kristaps  988:        case (LIST_ohang):
1.23      kristaps  989:                /* FALLTHROUGH */
1.66      kristaps  990:        case (LIST_column):
1.70      kristaps  991:                bufcat_su(h, "min-width", width);
                    992:                bufcat_style(h, "clear", "none");
                    993:                if (n->next)
                    994:                        bufcat_style(h, "float", "left");
                    995:                PAIR_STYLE_INIT(&tag, h);
                    996:                print_otag(h, TAG_DIV, 1, &tag);
1.23      kristaps  997:                break;
                    998:        default:
1.24      kristaps  999:                /*
                   1000:                 * XXX: this tricks CSS into aligning the bodies with
                   1001:                 * the right-padding in the head.
                   1002:                 */
1.23      kristaps 1003:                SCALE_HS_INIT(&su, 2);
                   1004:                bufcat_su(h, "margin-left", &su);
                   1005:                PAIR_STYLE_INIT(&tag, h);
                   1006:                print_otag(h, TAG_DIV, 1, &tag);
                   1007:                break;
                   1008:        }
1.1       kristaps 1009:
                   1010:        return(1);
                   1011: }
                   1012:
                   1013:
1.25      kristaps 1014: /* ARGSUSED */
1.1       kristaps 1015: static int
1.66      kristaps 1016: mdoc_it_head_pre(MDOC_ARGS, enum mdoc_list type, struct roffsu *width)
1.1       kristaps 1017: {
                   1018:        struct htmlpair  tag;
                   1019:        struct ord      *ord;
                   1020:        char             nbuf[BUFSIZ];
                   1021:
1.23      kristaps 1022:        switch (type) {
1.66      kristaps 1023:        case (LIST_item):
1.46      kristaps 1024:                return(0);
1.66      kristaps 1025:        case (LIST_ohang):
1.46      kristaps 1026:                print_otag(h, TAG_DIV, 0, &tag);
                   1027:                return(1);
1.66      kristaps 1028:        case (LIST_column):
1.1       kristaps 1029:                break;
                   1030:        default:
1.23      kristaps 1031:                bufcat_su(h, "min-width", width);
                   1032:                SCALE_INVERT(width);
                   1033:                bufcat_su(h, "margin-left", width);
1.2       kristaps 1034:                if (n->next && n->next->child)
1.23      kristaps 1035:                        bufcat_style(h, "float", "left");
1.24      kristaps 1036:
                   1037:                /* XXX: buffer if we run into body. */
1.23      kristaps 1038:                SCALE_HS_INIT(width, 1);
                   1039:                bufcat_su(h, "margin-right", width);
                   1040:                PAIR_STYLE_INIT(&tag, h);
1.1       kristaps 1041:                print_otag(h, TAG_DIV, 1, &tag);
                   1042:                break;
                   1043:        }
                   1044:
1.23      kristaps 1045:        switch (type) {
1.66      kristaps 1046:        case (LIST_diag):
1.23      kristaps 1047:                PAIR_CLASS_INIT(&tag, "diag");
1.1       kristaps 1048:                print_otag(h, TAG_SPAN, 1, &tag);
                   1049:                break;
1.66      kristaps 1050:        case (LIST_enum):
1.39      kristaps 1051:                ord = h->ords.head;
1.1       kristaps 1052:                assert(ord);
                   1053:                nbuf[BUFSIZ - 1] = 0;
                   1054:                (void)snprintf(nbuf, BUFSIZ - 1, "%d.", ord->pos++);
                   1055:                print_text(h, nbuf);
                   1056:                return(0);
1.66      kristaps 1057:        case (LIST_dash):
1.1       kristaps 1058:                print_text(h, "\\(en");
                   1059:                return(0);
1.66      kristaps 1060:        case (LIST_hyphen):
1.4       kristaps 1061:                print_text(h, "\\(hy");
1.1       kristaps 1062:                return(0);
1.66      kristaps 1063:        case (LIST_bullet):
1.1       kristaps 1064:                print_text(h, "\\(bu");
                   1065:                return(0);
                   1066:        default:
                   1067:                break;
                   1068:        }
                   1069:
                   1070:        return(1);
                   1071: }
                   1072:
                   1073:
                   1074: static int
1.23      kristaps 1075: mdoc_it_pre(MDOC_ARGS)
1.1       kristaps 1076: {
1.93    ! kristaps 1077:        int                      i, comp;
1.1       kristaps 1078:        const struct mdoc_node  *bl, *nn;
1.23      kristaps 1079:        struct roffsu            width, offs;
1.66      kristaps 1080:        enum mdoc_list           type;
1.23      kristaps 1081:
1.24      kristaps 1082:        /*
                   1083:         * XXX: be very careful in changing anything, here.  Lists in
                   1084:         * mandoc have many peculiarities; furthermore, they don't
                   1085:         * translate well into HTML and require a bit of mangling.
                   1086:         */
1.1       kristaps 1087:
                   1088:        bl = n->parent->parent;
1.23      kristaps 1089:        if (MDOC_BLOCK != n->type)
1.1       kristaps 1090:                bl = bl->parent;
                   1091:
1.83      kristaps 1092:        SCALE_HS_INIT(&offs, 0);
                   1093:
1.90      kristaps 1094:        assert(bl->data.Bl);
                   1095:        type = bl->data.Bl->type;
                   1096:        comp = bl->data.Bl->comp;
1.1       kristaps 1097:
1.90      kristaps 1098:        if (bl->data.Bl->offs)
                   1099:                a2offs(bl->data.Bl->offs, &offs);
1.24      kristaps 1100:
1.1       kristaps 1101:        switch (type) {
1.66      kristaps 1102:        case (LIST_enum):
1.1       kristaps 1103:                /* FALLTHROUGH */
1.66      kristaps 1104:        case (LIST_dash):
1.1       kristaps 1105:                /* FALLTHROUGH */
1.66      kristaps 1106:        case (LIST_hyphen):
1.1       kristaps 1107:                /* FALLTHROUGH */
1.66      kristaps 1108:        case (LIST_bullet):
1.23      kristaps 1109:                SCALE_HS_INIT(&width, 2);
1.1       kristaps 1110:                break;
1.23      kristaps 1111:        default:
                   1112:                SCALE_HS_INIT(&width, INDENT);
                   1113:                break;
                   1114:        }
                   1115:
1.90      kristaps 1116:        if (bl->data.Bl->width)
                   1117:                a2width(bl->data.Bl->width, &width);
1.84      kristaps 1118:
1.23      kristaps 1119:        /* Override width in some cases. */
                   1120:
                   1121:        switch (type) {
1.66      kristaps 1122:        case (LIST_ohang):
1.46      kristaps 1123:                /* FALLTHROUGH */
1.66      kristaps 1124:        case (LIST_item):
1.33      kristaps 1125:                /* FALLTHROUGH */
1.66      kristaps 1126:        case (LIST_inset):
1.1       kristaps 1127:                /* FALLTHROUGH */
1.66      kristaps 1128:        case (LIST_diag):
1.23      kristaps 1129:                SCALE_HS_INIT(&width, 0);
1.1       kristaps 1130:                break;
                   1131:        default:
1.23      kristaps 1132:                if (0 == width.scale)
                   1133:                        SCALE_HS_INIT(&width, INDENT);
1.1       kristaps 1134:                break;
                   1135:        }
                   1136:
1.70      kristaps 1137:        if (LIST_column == type && MDOC_BODY == n->type) {
1.23      kristaps 1138:                nn = n->parent->child;
1.70      kristaps 1139:                for (i = 0; nn && nn != n; nn = nn->next)
                   1140:                        if (MDOC_BODY == nn->type)
                   1141:                                i++;
1.93    ! kristaps 1142:                if (i < (int)bl->data.Bl->ncols)
        !          1143:                        a2width(bl->data.Bl->cols[i], &width);
1.1       kristaps 1144:        }
                   1145:
1.70      kristaps 1146:        if (MDOC_HEAD == n->type)
                   1147:                return(mdoc_it_head_pre(m, n, h, type, &width));
                   1148:        else if (MDOC_BODY == n->type)
                   1149:                return(mdoc_it_body_pre(m, n, h, type, &width));
                   1150:
                   1151:        return(mdoc_it_block_pre(m, n, h, type, comp, &offs, &width));
1.1       kristaps 1152: }
                   1153:
                   1154:
                   1155: /* ARGSUSED */
                   1156: static int
                   1157: mdoc_bl_pre(MDOC_ARGS)
                   1158: {
                   1159:        struct ord      *ord;
                   1160:
1.59      kristaps 1161:        if (MDOC_HEAD == n->type)
                   1162:                return(0);
1.1       kristaps 1163:        if (MDOC_BLOCK != n->type)
                   1164:                return(1);
1.90      kristaps 1165:        assert(n->data.Bl);
                   1166:        if (LIST_enum != n->data.Bl->type)
1.1       kristaps 1167:                return(1);
                   1168:
                   1169:        ord = malloc(sizeof(struct ord));
1.43      kristaps 1170:        if (NULL == ord) {
1.44      kristaps 1171:                perror(NULL);
1.43      kristaps 1172:                exit(EXIT_FAILURE);
                   1173:        }
1.1       kristaps 1174:        ord->cookie = n;
                   1175:        ord->pos = 1;
1.39      kristaps 1176:        ord->next = h->ords.head;
                   1177:        h->ords.head = ord;
1.1       kristaps 1178:        return(1);
                   1179: }
                   1180:
                   1181:
                   1182: /* ARGSUSED */
                   1183: static void
                   1184: mdoc_bl_post(MDOC_ARGS)
                   1185: {
                   1186:        struct ord      *ord;
                   1187:
                   1188:        if (MDOC_BLOCK != n->type)
                   1189:                return;
1.90      kristaps 1190:        if (LIST_enum != n->data.Bl->type)
1.1       kristaps 1191:                return;
                   1192:
1.39      kristaps 1193:        ord = h->ords.head;
1.1       kristaps 1194:        assert(ord);
1.39      kristaps 1195:        h->ords.head = ord->next;
1.1       kristaps 1196:        free(ord);
                   1197: }
                   1198:
                   1199:
                   1200: /* ARGSUSED */
                   1201: static int
                   1202: mdoc_ex_pre(MDOC_ARGS)
                   1203: {
                   1204:        const struct mdoc_node  *nn;
                   1205:        struct tag              *t;
                   1206:        struct htmlpair          tag;
                   1207:
1.23      kristaps 1208:        PAIR_CLASS_INIT(&tag, "utility");
                   1209:
1.1       kristaps 1210:        print_text(h, "The");
                   1211:        for (nn = n->child; nn; nn = nn->next) {
                   1212:                t = print_otag(h, TAG_SPAN, 1, &tag);
                   1213:                print_text(h, nn->string);
                   1214:                print_tagq(h, t);
                   1215:
                   1216:                h->flags |= HTML_NOSPACE;
                   1217:
                   1218:                if (nn->next && NULL == nn->next->next)
                   1219:                        print_text(h, ", and");
                   1220:                else if (nn->next)
                   1221:                        print_text(h, ",");
                   1222:                else
                   1223:                        h->flags &= ~HTML_NOSPACE;
                   1224:        }
                   1225:
1.65      kristaps 1226:        if (n->child && n->child->next)
1.1       kristaps 1227:                print_text(h, "utilities exit");
                   1228:        else
                   1229:                print_text(h, "utility exits");
                   1230:
                   1231:                print_text(h, "0 on success, and >0 if an error occurs.");
                   1232:        return(0);
                   1233: }
                   1234:
                   1235:
                   1236: /* ARGSUSED */
                   1237: static int
                   1238: mdoc_dq_pre(MDOC_ARGS)
                   1239: {
                   1240:
                   1241:        if (MDOC_BODY != n->type)
                   1242:                return(1);
                   1243:        print_text(h, "\\(lq");
                   1244:        h->flags |= HTML_NOSPACE;
                   1245:        return(1);
                   1246: }
                   1247:
                   1248:
                   1249: /* ARGSUSED */
                   1250: static void
                   1251: mdoc_dq_post(MDOC_ARGS)
                   1252: {
                   1253:
                   1254:        if (MDOC_BODY != n->type)
                   1255:                return;
                   1256:        h->flags |= HTML_NOSPACE;
                   1257:        print_text(h, "\\(rq");
                   1258: }
                   1259:
                   1260:
                   1261: /* ARGSUSED */
                   1262: static int
                   1263: mdoc_pq_pre(MDOC_ARGS)
                   1264: {
                   1265:
                   1266:        if (MDOC_BODY != n->type)
                   1267:                return(1);
                   1268:        print_text(h, "\\&(");
                   1269:        h->flags |= HTML_NOSPACE;
                   1270:        return(1);
                   1271: }
                   1272:
                   1273:
                   1274: /* ARGSUSED */
                   1275: static void
                   1276: mdoc_pq_post(MDOC_ARGS)
                   1277: {
                   1278:
                   1279:        if (MDOC_BODY != n->type)
                   1280:                return;
                   1281:        print_text(h, ")");
                   1282: }
                   1283:
                   1284:
                   1285: /* ARGSUSED */
                   1286: static int
                   1287: mdoc_sq_pre(MDOC_ARGS)
                   1288: {
                   1289:
                   1290:        if (MDOC_BODY != n->type)
                   1291:                return(1);
                   1292:        print_text(h, "\\(oq");
                   1293:        h->flags |= HTML_NOSPACE;
                   1294:        return(1);
                   1295: }
                   1296:
                   1297:
                   1298: /* ARGSUSED */
                   1299: static void
                   1300: mdoc_sq_post(MDOC_ARGS)
                   1301: {
                   1302:
                   1303:        if (MDOC_BODY != n->type)
                   1304:                return;
                   1305:        h->flags |= HTML_NOSPACE;
                   1306:        print_text(h, "\\(aq");
                   1307: }
                   1308:
                   1309:
                   1310: /* ARGSUSED */
                   1311: static int
                   1312: mdoc_em_pre(MDOC_ARGS)
                   1313: {
                   1314:        struct htmlpair tag;
                   1315:
1.23      kristaps 1316:        PAIR_CLASS_INIT(&tag, "emph");
1.1       kristaps 1317:        print_otag(h, TAG_SPAN, 1, &tag);
                   1318:        return(1);
                   1319: }
                   1320:
                   1321:
                   1322: /* ARGSUSED */
                   1323: static int
                   1324: mdoc_d1_pre(MDOC_ARGS)
                   1325: {
1.23      kristaps 1326:        struct htmlpair  tag[2];
                   1327:        struct roffsu    su;
1.1       kristaps 1328:
                   1329:        if (MDOC_BLOCK != n->type)
                   1330:                return(1);
                   1331:
1.35      kristaps 1332:        /* FIXME: D1 shouldn't be literal. */
                   1333:
1.77      kristaps 1334:        SCALE_VS_INIT(&su, INDENT - 2);
1.23      kristaps 1335:        bufcat_su(h, "margin-left", &su);
                   1336:        PAIR_CLASS_INIT(&tag[0], "lit");
                   1337:        PAIR_STYLE_INIT(&tag[1], h);
1.1       kristaps 1338:        print_otag(h, TAG_DIV, 2, tag);
                   1339:        return(1);
                   1340: }
                   1341:
                   1342:
                   1343: /* ARGSUSED */
                   1344: static int
                   1345: mdoc_sx_pre(MDOC_ARGS)
                   1346: {
1.18      kristaps 1347:        struct htmlpair          tag[2];
1.1       kristaps 1348:        const struct mdoc_node  *nn;
1.35      kristaps 1349:        char                     buf[BUFSIZ];
1.1       kristaps 1350:
1.41      kristaps 1351:        strlcpy(buf, "#", BUFSIZ);
1.1       kristaps 1352:        for (nn = n->child; nn; nn = nn->next) {
1.41      kristaps 1353:                html_idcat(buf, nn->string, BUFSIZ);
1.1       kristaps 1354:                if (nn->next)
1.42      kristaps 1355:                        html_idcat(buf, " ", BUFSIZ);
1.1       kristaps 1356:        }
                   1357:
1.23      kristaps 1358:        PAIR_CLASS_INIT(&tag[0], "link-sec");
1.57      kristaps 1359:        PAIR_HREF_INIT(&tag[1], buf);
1.1       kristaps 1360:
1.18      kristaps 1361:        print_otag(h, TAG_A, 2, tag);
1.1       kristaps 1362:        return(1);
                   1363: }
                   1364:
                   1365:
                   1366: /* ARGSUSED */
                   1367: static int
                   1368: mdoc_aq_pre(MDOC_ARGS)
                   1369: {
                   1370:
                   1371:        if (MDOC_BODY != n->type)
                   1372:                return(1);
                   1373:        print_text(h, "\\(la");
                   1374:        h->flags |= HTML_NOSPACE;
                   1375:        return(1);
                   1376: }
                   1377:
                   1378:
                   1379: /* ARGSUSED */
                   1380: static void
                   1381: mdoc_aq_post(MDOC_ARGS)
                   1382: {
                   1383:
                   1384:        if (MDOC_BODY != n->type)
                   1385:                return;
                   1386:        h->flags |= HTML_NOSPACE;
                   1387:        print_text(h, "\\(ra");
                   1388: }
                   1389:
                   1390:
                   1391: /* ARGSUSED */
                   1392: static int
                   1393: mdoc_bd_pre(MDOC_ARGS)
                   1394: {
                   1395:        struct htmlpair          tag[2];
1.80      kristaps 1396:        int                      comp;
                   1397:        const struct mdoc_node  *nn;
1.23      kristaps 1398:        struct roffsu            su;
1.1       kristaps 1399:
1.80      kristaps 1400:        if (MDOC_HEAD == n->type)
1.1       kristaps 1401:                return(0);
                   1402:
1.24      kristaps 1403:        SCALE_VS_INIT(&su, 0);
                   1404:
1.90      kristaps 1405:        assert(n->data.Bd);
                   1406:        if (n->data.Bd->offs)
                   1407:                a2offs(n->data.Bd->offs, &su);
1.80      kristaps 1408:
1.90      kristaps 1409:        comp = n->data.Bd->comp;
1.1       kristaps 1410:
1.31      kristaps 1411:        /* FIXME: -centered, etc. formatting. */
1.60      kristaps 1412:        /* FIXME: does not respect -offset ??? */
1.31      kristaps 1413:
1.1       kristaps 1414:        if (MDOC_BLOCK == n->type) {
1.24      kristaps 1415:                bufcat_su(h, "margin-left", &su);
1.23      kristaps 1416:                for (nn = n; nn && ! comp; nn = nn->parent) {
                   1417:                        if (MDOC_BLOCK != nn->type)
                   1418:                                continue;
                   1419:                        if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
                   1420:                                comp = 1;
                   1421:                        if (nn->prev)
                   1422:                                break;
                   1423:                }
                   1424:                if (comp) {
1.64      kristaps 1425:                        PAIR_STYLE_INIT(&tag[0], h);
                   1426:                        print_otag(h, TAG_DIV, 1, tag);
1.23      kristaps 1427:                        return(1);
1.14      kristaps 1428:                }
1.23      kristaps 1429:                SCALE_VS_INIT(&su, 1);
                   1430:                bufcat_su(h, "margin-top", &su);
                   1431:                PAIR_STYLE_INIT(&tag[0], h);
1.1       kristaps 1432:                print_otag(h, TAG_DIV, 1, tag);
                   1433:                return(1);
                   1434:        }
                   1435:
1.90      kristaps 1436:        if (DISP_unfilled != n->data.Bd->type &&
                   1437:                        DISP_literal != n->data.Bd->type)
1.1       kristaps 1438:                return(1);
                   1439:
1.23      kristaps 1440:        PAIR_CLASS_INIT(&tag[0], "lit");
                   1441:        bufcat_style(h, "white-space", "pre");
                   1442:        PAIR_STYLE_INIT(&tag[1], h);
1.1       kristaps 1443:        print_otag(h, TAG_DIV, 2, tag);
                   1444:
1.14      kristaps 1445:        for (nn = n->child; nn; nn = nn->next) {
1.23      kristaps 1446:                h->flags |= HTML_NOSPACE;
1.14      kristaps 1447:                print_mdoc_node(m, nn, h);
                   1448:                if (NULL == nn->next)
                   1449:                        continue;
                   1450:                if (nn->prev && nn->prev->line < nn->line)
1.1       kristaps 1451:                        print_text(h, "\n");
1.23      kristaps 1452:                else if (NULL == nn->prev)
                   1453:                        print_text(h, "\n");
1.1       kristaps 1454:        }
                   1455:
                   1456:        return(0);
                   1457: }
                   1458:
                   1459:
                   1460: /* ARGSUSED */
                   1461: static int
                   1462: mdoc_pa_pre(MDOC_ARGS)
                   1463: {
                   1464:        struct htmlpair tag;
                   1465:
1.23      kristaps 1466:        PAIR_CLASS_INIT(&tag, "file");
1.1       kristaps 1467:        print_otag(h, TAG_SPAN, 1, &tag);
                   1468:        return(1);
                   1469: }
                   1470:
                   1471:
                   1472: /* ARGSUSED */
                   1473: static int
                   1474: mdoc_ad_pre(MDOC_ARGS)
                   1475: {
                   1476:        struct htmlpair tag;
                   1477:
1.23      kristaps 1478:        PAIR_CLASS_INIT(&tag, "addr");
1.1       kristaps 1479:        print_otag(h, TAG_SPAN, 1, &tag);
                   1480:        return(1);
                   1481: }
                   1482:
                   1483:
                   1484: /* ARGSUSED */
                   1485: static int
                   1486: mdoc_an_pre(MDOC_ARGS)
                   1487: {
                   1488:        struct htmlpair tag;
                   1489:
1.19      kristaps 1490:        /* TODO: -split and -nosplit (see termp_an_pre()). */
                   1491:
1.23      kristaps 1492:        PAIR_CLASS_INIT(&tag, "author");
1.1       kristaps 1493:        print_otag(h, TAG_SPAN, 1, &tag);
                   1494:        return(1);
                   1495: }
                   1496:
                   1497:
                   1498: /* ARGSUSED */
                   1499: static int
                   1500: mdoc_cd_pre(MDOC_ARGS)
                   1501: {
                   1502:        struct htmlpair tag;
                   1503:
1.78      kristaps 1504:        synopsis_pre(h, n);
1.23      kristaps 1505:        PAIR_CLASS_INIT(&tag, "config");
1.1       kristaps 1506:        print_otag(h, TAG_SPAN, 1, &tag);
                   1507:        return(1);
                   1508: }
                   1509:
                   1510:
                   1511: /* ARGSUSED */
                   1512: static int
                   1513: mdoc_dv_pre(MDOC_ARGS)
                   1514: {
                   1515:        struct htmlpair tag;
                   1516:
1.23      kristaps 1517:        PAIR_CLASS_INIT(&tag, "define");
1.1       kristaps 1518:        print_otag(h, TAG_SPAN, 1, &tag);
                   1519:        return(1);
                   1520: }
                   1521:
                   1522:
                   1523: /* ARGSUSED */
                   1524: static int
                   1525: mdoc_ev_pre(MDOC_ARGS)
                   1526: {
                   1527:        struct htmlpair tag;
                   1528:
1.23      kristaps 1529:        PAIR_CLASS_INIT(&tag, "env");
1.1       kristaps 1530:        print_otag(h, TAG_SPAN, 1, &tag);
                   1531:        return(1);
                   1532: }
                   1533:
                   1534:
                   1535: /* ARGSUSED */
                   1536: static int
                   1537: mdoc_er_pre(MDOC_ARGS)
                   1538: {
                   1539:        struct htmlpair tag;
                   1540:
1.23      kristaps 1541:        PAIR_CLASS_INIT(&tag, "errno");
1.1       kristaps 1542:        print_otag(h, TAG_SPAN, 1, &tag);
                   1543:        return(1);
                   1544: }
                   1545:
                   1546:
                   1547: /* ARGSUSED */
                   1548: static int
                   1549: mdoc_fa_pre(MDOC_ARGS)
                   1550: {
                   1551:        const struct mdoc_node  *nn;
                   1552:        struct htmlpair          tag;
                   1553:        struct tag              *t;
                   1554:
1.23      kristaps 1555:        PAIR_CLASS_INIT(&tag, "farg");
1.1       kristaps 1556:        if (n->parent->tok != MDOC_Fo) {
                   1557:                print_otag(h, TAG_SPAN, 1, &tag);
                   1558:                return(1);
                   1559:        }
                   1560:
                   1561:        for (nn = n->child; nn; nn = nn->next) {
                   1562:                t = print_otag(h, TAG_SPAN, 1, &tag);
                   1563:                print_text(h, nn->string);
                   1564:                print_tagq(h, t);
                   1565:                if (nn->next)
                   1566:                        print_text(h, ",");
                   1567:        }
                   1568:
                   1569:        if (n->child && n->next && n->next->tok == MDOC_Fa)
                   1570:                print_text(h, ",");
                   1571:
                   1572:        return(0);
                   1573: }
                   1574:
                   1575:
                   1576: /* ARGSUSED */
                   1577: static int
                   1578: mdoc_fd_pre(MDOC_ARGS)
                   1579: {
1.23      kristaps 1580:        struct htmlpair  tag;
1.1       kristaps 1581:
1.78      kristaps 1582:        synopsis_pre(h, n);
                   1583:
1.23      kristaps 1584:        PAIR_CLASS_INIT(&tag, "macro");
1.1       kristaps 1585:        print_otag(h, TAG_SPAN, 1, &tag);
                   1586:        return(1);
                   1587: }
                   1588:
                   1589:
                   1590: /* ARGSUSED */
                   1591: static int
                   1592: mdoc_vt_pre(MDOC_ARGS)
                   1593: {
1.23      kristaps 1594:        struct htmlpair  tag;
1.1       kristaps 1595:
1.78      kristaps 1596:        if (MDOC_BLOCK == n->type) {
                   1597:                synopsis_pre(h, n);
1.54      kristaps 1598:                return(1);
1.78      kristaps 1599:        } else if (MDOC_ELEM == n->type) {
                   1600:                synopsis_pre(h, n);
1.54      kristaps 1601:        } else if (MDOC_HEAD == n->type)
                   1602:                return(0);
1.1       kristaps 1603:
1.23      kristaps 1604:        PAIR_CLASS_INIT(&tag, "type");
1.1       kristaps 1605:        print_otag(h, TAG_SPAN, 1, &tag);
                   1606:        return(1);
                   1607: }
                   1608:
1.2       kristaps 1609:
1.1       kristaps 1610: /* ARGSUSED */
                   1611: static int
                   1612: mdoc_ft_pre(MDOC_ARGS)
                   1613: {
1.23      kristaps 1614:        struct htmlpair  tag;
1.1       kristaps 1615:
1.78      kristaps 1616:        synopsis_pre(h, n);
1.23      kristaps 1617:        PAIR_CLASS_INIT(&tag, "ftype");
1.1       kristaps 1618:        print_otag(h, TAG_SPAN, 1, &tag);
                   1619:        return(1);
                   1620: }
                   1621:
                   1622:
                   1623: /* ARGSUSED */
                   1624: static int
                   1625: mdoc_fn_pre(MDOC_ARGS)
                   1626: {
                   1627:        struct tag              *t;
1.15      kristaps 1628:        struct htmlpair          tag[2];
1.1       kristaps 1629:        const struct mdoc_node  *nn;
1.7       kristaps 1630:        char                     nbuf[BUFSIZ];
                   1631:        const char              *sp, *ep;
1.15      kristaps 1632:        int                      sz, i;
1.1       kristaps 1633:
1.78      kristaps 1634:        synopsis_pre(h, n);
1.1       kristaps 1635:
1.7       kristaps 1636:        /* Split apart into type and name. */
                   1637:        assert(n->child->string);
                   1638:        sp = n->child->string;
1.19      kristaps 1639:
1.26      kristaps 1640:        ep = strchr(sp, ' ');
                   1641:        if (NULL != ep) {
1.23      kristaps 1642:                PAIR_CLASS_INIT(&tag[0], "ftype");
1.19      kristaps 1643:                t = print_otag(h, TAG_SPAN, 1, tag);
                   1644:
                   1645:                while (ep) {
                   1646:                        sz = MIN((int)(ep - sp), BUFSIZ - 1);
                   1647:                        (void)memcpy(nbuf, sp, (size_t)sz);
                   1648:                        nbuf[sz] = '\0';
                   1649:                        print_text(h, nbuf);
                   1650:                        sp = ++ep;
                   1651:                        ep = strchr(sp, ' ');
                   1652:                }
                   1653:                print_tagq(h, t);
1.7       kristaps 1654:        }
1.1       kristaps 1655:
1.23      kristaps 1656:        PAIR_CLASS_INIT(&tag[0], "fname");
1.57      kristaps 1657:
                   1658:        /*
                   1659:         * FIXME: only refer to IDs that we know exist.
                   1660:         */
                   1661:
                   1662: #if 0
1.87      kristaps 1663:        if (MDOC_SYNPRETTY & n->flags) {
1.57      kristaps 1664:                nbuf[0] = '\0';
                   1665:                html_idcat(nbuf, sp, BUFSIZ);
                   1666:                PAIR_ID_INIT(&tag[1], nbuf);
                   1667:        } else {
                   1668:                strlcpy(nbuf, "#", BUFSIZ);
                   1669:                html_idcat(nbuf, sp, BUFSIZ);
                   1670:                PAIR_HREF_INIT(&tag[1], nbuf);
                   1671:        }
                   1672: #endif
                   1673:
1.15      kristaps 1674:        t = print_otag(h, TAG_SPAN, 1, tag);
1.7       kristaps 1675:
                   1676:        if (sp) {
1.57      kristaps 1677:                strlcpy(nbuf, sp, BUFSIZ);
1.7       kristaps 1678:                print_text(h, nbuf);
                   1679:        }
                   1680:
1.1       kristaps 1681:        print_tagq(h, t);
                   1682:
                   1683:        h->flags |= HTML_NOSPACE;
                   1684:        print_text(h, "(");
                   1685:
1.23      kristaps 1686:        bufinit(h);
                   1687:        PAIR_CLASS_INIT(&tag[0], "farg");
                   1688:        bufcat_style(h, "white-space", "nowrap");
                   1689:        PAIR_STYLE_INIT(&tag[1], h);
                   1690:
1.1       kristaps 1691:        for (nn = n->child->next; nn; nn = nn->next) {
1.23      kristaps 1692:                i = 1;
1.87      kristaps 1693:                if (MDOC_SYNPRETTY & n->flags)
1.23      kristaps 1694:                        i = 2;
1.15      kristaps 1695:                t = print_otag(h, TAG_SPAN, i, tag);
1.1       kristaps 1696:                print_text(h, nn->string);
                   1697:                print_tagq(h, t);
                   1698:                if (nn->next)
                   1699:                        print_text(h, ",");
                   1700:        }
                   1701:
                   1702:        print_text(h, ")");
1.87      kristaps 1703:        if (MDOC_SYNPRETTY & n->flags)
1.1       kristaps 1704:                print_text(h, ";");
                   1705:
                   1706:        return(0);
                   1707: }
                   1708:
                   1709:
                   1710: /* ARGSUSED */
                   1711: static int
                   1712: mdoc_sp_pre(MDOC_ARGS)
                   1713: {
1.23      kristaps 1714:        int              len;
                   1715:        struct htmlpair  tag;
                   1716:        struct roffsu    su;
1.1       kristaps 1717:
                   1718:        switch (n->tok) {
                   1719:        case (MDOC_sp):
1.23      kristaps 1720:                /* FIXME: can this have a scaling indicator? */
1.1       kristaps 1721:                len = n->child ? atoi(n->child->string) : 1;
                   1722:                break;
                   1723:        case (MDOC_br):
                   1724:                len = 0;
                   1725:                break;
                   1726:        default:
                   1727:                len = 1;
                   1728:                break;
                   1729:        }
                   1730:
1.23      kristaps 1731:        SCALE_VS_INIT(&su, len);
                   1732:        bufcat_su(h, "height", &su);
                   1733:        PAIR_STYLE_INIT(&tag, h);
1.1       kristaps 1734:        print_otag(h, TAG_DIV, 1, &tag);
1.42      kristaps 1735:        /* So the div isn't empty: */
                   1736:        print_text(h, "\\~");
                   1737:
                   1738:        return(0);
1.1       kristaps 1739:
                   1740: }
1.2       kristaps 1741:
                   1742:
                   1743: /* ARGSUSED */
                   1744: static int
                   1745: mdoc_brq_pre(MDOC_ARGS)
                   1746: {
                   1747:
                   1748:        if (MDOC_BODY != n->type)
                   1749:                return(1);
                   1750:        print_text(h, "\\(lC");
                   1751:        h->flags |= HTML_NOSPACE;
                   1752:        return(1);
                   1753: }
                   1754:
                   1755:
                   1756: /* ARGSUSED */
                   1757: static void
                   1758: mdoc_brq_post(MDOC_ARGS)
                   1759: {
                   1760:
                   1761:        if (MDOC_BODY != n->type)
                   1762:                return;
                   1763:        h->flags |= HTML_NOSPACE;
                   1764:        print_text(h, "\\(rC");
                   1765: }
                   1766:
                   1767:
                   1768: /* ARGSUSED */
                   1769: static int
                   1770: mdoc_lk_pre(MDOC_ARGS)
                   1771: {
                   1772:        const struct mdoc_node  *nn;
                   1773:        struct htmlpair          tag[2];
                   1774:
                   1775:        nn = n->child;
                   1776:
1.23      kristaps 1777:        PAIR_CLASS_INIT(&tag[0], "link-ext");
1.57      kristaps 1778:        PAIR_HREF_INIT(&tag[1], nn->string);
1.2       kristaps 1779:        print_otag(h, TAG_A, 2, tag);
                   1780:
1.38      kristaps 1781:        if (NULL == nn->next)
                   1782:                return(1);
                   1783:
1.2       kristaps 1784:        for (nn = nn->next; nn; nn = nn->next)
                   1785:                print_text(h, nn->string);
                   1786:
                   1787:        return(0);
                   1788: }
                   1789:
                   1790:
                   1791: /* ARGSUSED */
                   1792: static int
                   1793: mdoc_mt_pre(MDOC_ARGS)
                   1794: {
                   1795:        struct htmlpair          tag[2];
                   1796:        struct tag              *t;
                   1797:        const struct mdoc_node  *nn;
                   1798:
1.23      kristaps 1799:        PAIR_CLASS_INIT(&tag[0], "link-mail");
1.2       kristaps 1800:
                   1801:        for (nn = n->child; nn; nn = nn->next) {
1.16      kristaps 1802:                bufinit(h);
                   1803:                bufcat(h, "mailto:");
                   1804:                bufcat(h, nn->string);
1.57      kristaps 1805:                PAIR_HREF_INIT(&tag[1], h->buf);
1.2       kristaps 1806:                t = print_otag(h, TAG_A, 2, tag);
                   1807:                print_text(h, nn->string);
                   1808:                print_tagq(h, t);
                   1809:        }
                   1810:
                   1811:        return(0);
                   1812: }
1.4       kristaps 1813:
                   1814:
                   1815: /* ARGSUSED */
                   1816: static int
                   1817: mdoc_fo_pre(MDOC_ARGS)
                   1818: {
1.77      kristaps 1819:        struct htmlpair  tag;
                   1820:        struct tag      *t;
1.4       kristaps 1821:
                   1822:        if (MDOC_BODY == n->type) {
                   1823:                h->flags |= HTML_NOSPACE;
                   1824:                print_text(h, "(");
                   1825:                h->flags |= HTML_NOSPACE;
                   1826:                return(1);
1.77      kristaps 1827:        } else if (MDOC_BLOCK == n->type) {
1.78      kristaps 1828:                synopsis_pre(h, n);
1.4       kristaps 1829:                return(1);
1.57      kristaps 1830:        }
1.4       kristaps 1831:
1.77      kristaps 1832:        /* XXX: we drop non-initial arguments as per groff. */
                   1833:
                   1834:        assert(n->child);
                   1835:        assert(n->child->string);
                   1836:
1.23      kristaps 1837:        PAIR_CLASS_INIT(&tag, "fname");
1.77      kristaps 1838:        t = print_otag(h, TAG_SPAN, 1, &tag);
                   1839:        print_text(h, n->child->string);
                   1840:        print_tagq(h, t);
                   1841:        return(0);
1.4       kristaps 1842: }
                   1843:
                   1844:
                   1845: /* ARGSUSED */
                   1846: static void
                   1847: mdoc_fo_post(MDOC_ARGS)
                   1848: {
1.78      kristaps 1849:
1.4       kristaps 1850:        if (MDOC_BODY != n->type)
                   1851:                return;
                   1852:        h->flags |= HTML_NOSPACE;
                   1853:        print_text(h, ")");
                   1854:        h->flags |= HTML_NOSPACE;
                   1855:        print_text(h, ";");
                   1856: }
                   1857:
                   1858:
                   1859: /* ARGSUSED */
                   1860: static int
                   1861: mdoc_in_pre(MDOC_ARGS)
                   1862: {
                   1863:        const struct mdoc_node  *nn;
1.23      kristaps 1864:        struct tag              *t;
1.17      kristaps 1865:        struct htmlpair          tag[2];
                   1866:        int                      i;
1.34      kristaps 1867:
1.78      kristaps 1868:        synopsis_pre(h, n);
                   1869:
1.23      kristaps 1870:        PAIR_CLASS_INIT(&tag[0], "includes");
1.17      kristaps 1871:        print_otag(h, TAG_SPAN, 1, tag);
1.4       kristaps 1872:
1.87      kristaps 1873:        if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags)
1.4       kristaps 1874:                print_text(h, "#include");
                   1875:
                   1876:        print_text(h, "<");
                   1877:        h->flags |= HTML_NOSPACE;
                   1878:
1.17      kristaps 1879:        for (nn = n->child; nn; nn = nn->next) {
1.23      kristaps 1880:                PAIR_CLASS_INIT(&tag[0], "link-includes");
                   1881:                i = 1;
1.41      kristaps 1882:                bufinit(h);
1.17      kristaps 1883:                if (h->base_includes) {
                   1884:                        buffmt_includes(h, nn->string);
1.57      kristaps 1885:                        PAIR_HREF_INIT(&tag[i], h->buf);
                   1886:                        i++;
1.17      kristaps 1887:                }
                   1888:                t = print_otag(h, TAG_A, i, tag);
1.4       kristaps 1889:                print_mdoc_node(m, nn, h);
1.17      kristaps 1890:                print_tagq(h, t);
                   1891:        }
1.4       kristaps 1892:
                   1893:        h->flags |= HTML_NOSPACE;
                   1894:        print_text(h, ">");
                   1895:
                   1896:        return(0);
                   1897: }
                   1898:
                   1899:
                   1900: /* ARGSUSED */
                   1901: static int
                   1902: mdoc_ic_pre(MDOC_ARGS)
                   1903: {
                   1904:        struct htmlpair tag;
                   1905:
1.23      kristaps 1906:        PAIR_CLASS_INIT(&tag, "cmd");
1.4       kristaps 1907:        print_otag(h, TAG_SPAN, 1, &tag);
                   1908:        return(1);
                   1909: }
                   1910:
                   1911:
                   1912: /* ARGSUSED */
                   1913: static int
                   1914: mdoc_rv_pre(MDOC_ARGS)
                   1915: {
                   1916:        const struct mdoc_node  *nn;
                   1917:        struct htmlpair          tag;
                   1918:        struct tag              *t;
                   1919:
                   1920:        print_otag(h, TAG_DIV, 0, NULL);
                   1921:        print_text(h, "The");
                   1922:
                   1923:        for (nn = n->child; nn; nn = nn->next) {
1.23      kristaps 1924:                PAIR_CLASS_INIT(&tag, "fname");
1.4       kristaps 1925:                t = print_otag(h, TAG_SPAN, 1, &tag);
                   1926:                print_text(h, nn->string);
                   1927:                print_tagq(h, t);
                   1928:
                   1929:                h->flags |= HTML_NOSPACE;
                   1930:                if (nn->next && NULL == nn->next->next)
                   1931:                        print_text(h, "(), and");
                   1932:                else if (nn->next)
                   1933:                        print_text(h, "(),");
                   1934:                else
                   1935:                        print_text(h, "()");
                   1936:        }
                   1937:
1.65      kristaps 1938:        if (n->child && n->child->next)
1.4       kristaps 1939:                print_text(h, "functions return");
                   1940:        else
                   1941:                print_text(h, "function returns");
                   1942:
                   1943:                print_text(h, "the value 0 if successful; otherwise the value "
                   1944:                        "-1 is returned and the global variable");
                   1945:
1.23      kristaps 1946:        PAIR_CLASS_INIT(&tag, "var");
1.4       kristaps 1947:        t = print_otag(h, TAG_SPAN, 1, &tag);
                   1948:        print_text(h, "errno");
                   1949:        print_tagq(h, t);
                   1950:                print_text(h, "is set to indicate the error.");
                   1951:        return(0);
                   1952: }
                   1953:
                   1954:
                   1955: /* ARGSUSED */
                   1956: static int
                   1957: mdoc_va_pre(MDOC_ARGS)
                   1958: {
                   1959:        struct htmlpair tag;
                   1960:
1.23      kristaps 1961:        PAIR_CLASS_INIT(&tag, "var");
1.4       kristaps 1962:        print_otag(h, TAG_SPAN, 1, &tag);
                   1963:        return(1);
                   1964: }
                   1965:
                   1966:
                   1967: /* ARGSUSED */
                   1968: static int
                   1969: mdoc_bq_pre(MDOC_ARGS)
                   1970: {
                   1971:
                   1972:        if (MDOC_BODY != n->type)
                   1973:                return(1);
                   1974:        print_text(h, "\\(lB");
                   1975:        h->flags |= HTML_NOSPACE;
                   1976:        return(1);
                   1977: }
                   1978:
                   1979:
                   1980: /* ARGSUSED */
                   1981: static void
                   1982: mdoc_bq_post(MDOC_ARGS)
                   1983: {
                   1984:
                   1985:        if (MDOC_BODY != n->type)
                   1986:                return;
                   1987:        h->flags |= HTML_NOSPACE;
                   1988:        print_text(h, "\\(rB");
                   1989: }
1.5       kristaps 1990:
                   1991:
                   1992: /* ARGSUSED */
                   1993: static int
                   1994: mdoc_ap_pre(MDOC_ARGS)
                   1995: {
                   1996:
                   1997:        h->flags |= HTML_NOSPACE;
                   1998:        print_text(h, "\\(aq");
                   1999:        h->flags |= HTML_NOSPACE;
                   2000:        return(1);
                   2001: }
                   2002:
                   2003:
                   2004: /* ARGSUSED */
                   2005: static int
                   2006: mdoc_bf_pre(MDOC_ARGS)
                   2007: {
1.23      kristaps 2008:        struct htmlpair  tag[2];
                   2009:        struct roffsu    su;
1.5       kristaps 2010:
                   2011:        if (MDOC_HEAD == n->type)
                   2012:                return(0);
1.92      kristaps 2013:        else if (MDOC_BODY != n->type)
1.5       kristaps 2014:                return(1);
                   2015:
1.92      kristaps 2016:        assert(n->data.Bf);
1.5       kristaps 2017:
1.92      kristaps 2018:        if (FONT_Em == n->data.Bf->font)
                   2019:                PAIR_CLASS_INIT(&tag[0], "emph");
                   2020:        else if (FONT_Sy == n->data.Bf->font)
                   2021:                PAIR_CLASS_INIT(&tag[0], "symb");
                   2022:        else if (FONT_Li == n->data.Bf->font)
                   2023:                PAIR_CLASS_INIT(&tag[0], "lit");
                   2024:        else
                   2025:                PAIR_CLASS_INIT(&tag[0], "none");
1.5       kristaps 2026:
1.92      kristaps 2027:        /*
                   2028:         * We want this to be inline-formatted, but needs to be div to
                   2029:         * accept block children.
                   2030:         */
1.23      kristaps 2031:        bufcat_style(h, "display", "inline");
                   2032:        SCALE_HS_INIT(&su, 1);
1.92      kristaps 2033:        /* Needs a left-margin for spacing. */
                   2034:        bufcat_su(h, "margin-left", &su);
1.23      kristaps 2035:        PAIR_STYLE_INIT(&tag[1], h);
1.5       kristaps 2036:        print_otag(h, TAG_DIV, 2, tag);
                   2037:        return(1);
                   2038: }
                   2039:
                   2040:
                   2041: /* ARGSUSED */
                   2042: static int
                   2043: mdoc_ms_pre(MDOC_ARGS)
                   2044: {
                   2045:        struct htmlpair tag;
                   2046:
1.23      kristaps 2047:        PAIR_CLASS_INIT(&tag, "symb");
1.5       kristaps 2048:        print_otag(h, TAG_SPAN, 1, &tag);
                   2049:        return(1);
                   2050: }
                   2051:
                   2052:
                   2053: /* ARGSUSED */
                   2054: static int
                   2055: mdoc_pf_pre(MDOC_ARGS)
                   2056: {
                   2057:
                   2058:        h->flags |= HTML_IGNDELIM;
                   2059:        return(1);
                   2060: }
                   2061:
                   2062:
                   2063: /* ARGSUSED */
                   2064: static void
                   2065: mdoc_pf_post(MDOC_ARGS)
                   2066: {
                   2067:
                   2068:        h->flags &= ~HTML_IGNDELIM;
                   2069:        h->flags |= HTML_NOSPACE;
                   2070: }
                   2071:
                   2072:
                   2073: /* ARGSUSED */
                   2074: static int
                   2075: mdoc_rs_pre(MDOC_ARGS)
                   2076: {
1.23      kristaps 2077:        struct htmlpair  tag;
                   2078:        struct roffsu    su;
1.5       kristaps 2079:
                   2080:        if (MDOC_BLOCK != n->type)
                   2081:                return(1);
                   2082:
1.8       kristaps 2083:        if (n->prev && SEC_SEE_ALSO == n->sec) {
1.23      kristaps 2084:                SCALE_VS_INIT(&su, 1);
                   2085:                bufcat_su(h, "margin-top", &su);
                   2086:                PAIR_STYLE_INIT(&tag, h);
1.8       kristaps 2087:                print_otag(h, TAG_DIV, 1, &tag);
1.5       kristaps 2088:        }
                   2089:
1.23      kristaps 2090:        PAIR_CLASS_INIT(&tag, "ref");
1.8       kristaps 2091:        print_otag(h, TAG_SPAN, 1, &tag);
1.5       kristaps 2092:        return(1);
                   2093: }
1.6       kristaps 2094:
                   2095:
                   2096:
                   2097: /* ARGSUSED */
                   2098: static int
                   2099: mdoc_li_pre(MDOC_ARGS)
                   2100: {
                   2101:        struct htmlpair tag;
                   2102:
1.23      kristaps 2103:        PAIR_CLASS_INIT(&tag, "lit");
1.6       kristaps 2104:        print_otag(h, TAG_SPAN, 1, &tag);
                   2105:        return(1);
                   2106: }
                   2107:
                   2108:
                   2109: /* ARGSUSED */
                   2110: static int
                   2111: mdoc_sy_pre(MDOC_ARGS)
                   2112: {
                   2113:        struct htmlpair tag;
                   2114:
1.23      kristaps 2115:        PAIR_CLASS_INIT(&tag, "symb");
1.6       kristaps 2116:        print_otag(h, TAG_SPAN, 1, &tag);
                   2117:        return(1);
                   2118: }
                   2119:
                   2120:
                   2121: /* ARGSUSED */
                   2122: static int
                   2123: mdoc_bt_pre(MDOC_ARGS)
                   2124: {
                   2125:
                   2126:        print_text(h, "is currently in beta test.");
                   2127:        return(0);
                   2128: }
                   2129:
                   2130:
                   2131: /* ARGSUSED */
                   2132: static int
                   2133: mdoc_ud_pre(MDOC_ARGS)
                   2134: {
                   2135:
                   2136:        print_text(h, "currently under development.");
                   2137:        return(0);
                   2138: }
                   2139:
                   2140:
                   2141: /* ARGSUSED */
                   2142: static int
                   2143: mdoc_lb_pre(MDOC_ARGS)
                   2144: {
                   2145:        struct htmlpair tag;
                   2146:
1.62      kristaps 2147:        if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags)
1.6       kristaps 2148:                print_otag(h, TAG_DIV, 0, NULL);
1.23      kristaps 2149:        PAIR_CLASS_INIT(&tag, "lib");
1.6       kristaps 2150:        print_otag(h, TAG_SPAN, 1, &tag);
                   2151:        return(1);
                   2152: }
1.10      kristaps 2153:
                   2154:
                   2155: /* ARGSUSED */
                   2156: static int
                   2157: mdoc__x_pre(MDOC_ARGS)
                   2158: {
1.38      kristaps 2159:        struct htmlpair tag[2];
1.37      kristaps 2160:
1.10      kristaps 2161:        switch (n->tok) {
                   2162:        case(MDOC__A):
1.38      kristaps 2163:                PAIR_CLASS_INIT(&tag[0], "ref-auth");
1.10      kristaps 2164:                break;
                   2165:        case(MDOC__B):
1.38      kristaps 2166:                PAIR_CLASS_INIT(&tag[0], "ref-book");
1.10      kristaps 2167:                break;
                   2168:        case(MDOC__C):
1.38      kristaps 2169:                PAIR_CLASS_INIT(&tag[0], "ref-city");
1.10      kristaps 2170:                break;
                   2171:        case(MDOC__D):
1.38      kristaps 2172:                PAIR_CLASS_INIT(&tag[0], "ref-date");
1.10      kristaps 2173:                break;
                   2174:        case(MDOC__I):
1.38      kristaps 2175:                PAIR_CLASS_INIT(&tag[0], "ref-issue");
1.10      kristaps 2176:                break;
                   2177:        case(MDOC__J):
1.38      kristaps 2178:                PAIR_CLASS_INIT(&tag[0], "ref-jrnl");
1.10      kristaps 2179:                break;
                   2180:        case(MDOC__N):
1.38      kristaps 2181:                PAIR_CLASS_INIT(&tag[0], "ref-num");
1.10      kristaps 2182:                break;
                   2183:        case(MDOC__O):
1.38      kristaps 2184:                PAIR_CLASS_INIT(&tag[0], "ref-opt");
1.10      kristaps 2185:                break;
                   2186:        case(MDOC__P):
1.38      kristaps 2187:                PAIR_CLASS_INIT(&tag[0], "ref-page");
1.10      kristaps 2188:                break;
                   2189:        case(MDOC__Q):
1.38      kristaps 2190:                PAIR_CLASS_INIT(&tag[0], "ref-corp");
1.10      kristaps 2191:                break;
                   2192:        case(MDOC__R):
1.38      kristaps 2193:                PAIR_CLASS_INIT(&tag[0], "ref-rep");
1.10      kristaps 2194:                break;
                   2195:        case(MDOC__T):
1.38      kristaps 2196:                PAIR_CLASS_INIT(&tag[0], "ref-title");
1.10      kristaps 2197:                break;
1.38      kristaps 2198:        case(MDOC__U):
                   2199:                PAIR_CLASS_INIT(&tag[0], "link-ref");
                   2200:                break;
1.10      kristaps 2201:        case(MDOC__V):
1.38      kristaps 2202:                PAIR_CLASS_INIT(&tag[0], "ref-vol");
1.10      kristaps 2203:                break;
                   2204:        default:
                   2205:                abort();
                   2206:                /* NOTREACHED */
                   2207:        }
                   2208:
1.38      kristaps 2209:        if (MDOC__U != n->tok) {
                   2210:                print_otag(h, TAG_SPAN, 1, tag);
                   2211:                return(1);
                   2212:        }
                   2213:
                   2214:        PAIR_HREF_INIT(&tag[1], n->child->string);
                   2215:        print_otag(h, TAG_A, 2, tag);
1.10      kristaps 2216:        return(1);
                   2217: }
                   2218:
                   2219:
                   2220: /* ARGSUSED */
                   2221: static void
                   2222: mdoc__x_post(MDOC_ARGS)
                   2223: {
                   2224:
1.61      kristaps 2225:        /* TODO: %U */
                   2226:
1.10      kristaps 2227:        h->flags |= HTML_NOSPACE;
                   2228:        print_text(h, n->next ? "," : ".");
                   2229: }

CVSweb