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

Annotation of mandoc/mdoc_html.c, Revision 1.148

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

CVSweb