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

Annotation of mandoc/mdoc_html.c, Revision 1.92

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

CVSweb