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

Annotation of mandoc/mdoc_html.c, Revision 1.78

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

CVSweb