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

Annotation of mandoc/mdoc_html.c, Revision 1.83

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

CVSweb