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

Annotation of mandoc/mdoc_html.c, Revision 1.146

1.146   ! kristaps    1: /*     $Id: mdoc_html.c,v 1.145 2011/01/25 15:17:18 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);
                    826:        print_text(h, pp);
                    827:        return(1);
                    828: }
                    829:
                    830:
                    831: /* ARGSUSED */
                    832: static int
1.4       kristaps  833: mdoc_bx_pre(MDOC_ARGS)
                    834: {
1.146   ! kristaps  835:        struct htmlpair  tag;
        !           836:        char             buf[3];
1.4       kristaps  837:
1.23      kristaps  838:        PAIR_CLASS_INIT(&tag, "unix");
1.4       kristaps  839:        print_otag(h, TAG_SPAN, 1, &tag);
                    840:
1.145     kristaps  841:        if (NULL != (n = n->child)) {
                    842:                print_text(h, n->string);
                    843:                h->flags |= HTML_NOSPACE;
                    844:                print_text(h, "BSD");
                    845:        } else {
                    846:                print_text(h, "BSD");
                    847:                return(0);
                    848:        }
1.4       kristaps  849:
1.145     kristaps  850:        if (NULL != (n = n->next)) {
1.146   ! kristaps  851:                buf[0] = '-';
        !           852:                buf[1] = toupper((unsigned char)*n->string);
        !           853:                buf[2] = '\0';
        !           854:
1.145     kristaps  855:                h->flags |= HTML_NOSPACE;
1.146   ! kristaps  856:                print_text(h, buf);
1.4       kristaps  857:                h->flags |= HTML_NOSPACE;
1.146   ! kristaps  858:                print_text(h, n->string + 1);
1.145     kristaps  859:        }
1.4       kristaps  860:
                    861:        return(0);
                    862: }
                    863:
1.142     kristaps  864: /* ARGSUSED */
1.4       kristaps  865: static int
1.115     kristaps  866: mdoc_it_pre(MDOC_ARGS)
1.1       kristaps  867: {
1.115     kristaps  868:        struct roffsu    su;
                    869:        enum mdoc_list   type;
1.116     kristaps  870:        struct htmlpair  tag[2];
1.115     kristaps  871:        const struct mdoc_node *bl;
                    872:
                    873:        bl = n->parent;
                    874:        while (bl && MDOC_Bl != bl->tok)
                    875:                bl = bl->parent;
1.23      kristaps  876:
1.115     kristaps  877:        assert(bl);
1.23      kristaps  878:
1.137     kristaps  879:        type = bl->norm->Bl.type;
1.24      kristaps  880:
1.116     kristaps  881:        assert(lists[type]);
                    882:        PAIR_CLASS_INIT(&tag[0], lists[type]);
1.1       kristaps  883:
1.115     kristaps  884:        if (MDOC_HEAD == n->type) {
                    885:                switch (type) {
                    886:                case(LIST_bullet):
                    887:                        /* FALLTHROUGH */
                    888:                case(LIST_dash):
                    889:                        /* FALLTHROUGH */
                    890:                case(LIST_item):
                    891:                        /* FALLTHROUGH */
                    892:                case(LIST_hyphen):
                    893:                        /* FALLTHROUGH */
                    894:                case(LIST_enum):
                    895:                        return(0);
                    896:                case(LIST_diag):
                    897:                        /* FALLTHROUGH */
                    898:                case(LIST_hang):
                    899:                        /* FALLTHROUGH */
                    900:                case(LIST_inset):
                    901:                        /* FALLTHROUGH */
                    902:                case(LIST_ohang):
                    903:                        /* FALLTHROUGH */
                    904:                case(LIST_tag):
1.137     kristaps  905:                        SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
1.122     kristaps  906:                        bufcat_su(h, "margin-top", &su);
                    907:                        PAIR_STYLE_INIT(&tag[1], h);
1.116     kristaps  908:                        print_otag(h, TAG_DT, 2, tag);
1.134     kristaps  909:                        if (LIST_diag != type)
                    910:                                break;
                    911:                        PAIR_CLASS_INIT(&tag[0], "diag");
                    912:                        print_otag(h, TAG_B, 1, tag);
1.115     kristaps  913:                        break;
                    914:                case(LIST_column):
                    915:                        break;
                    916:                default:
                    917:                        break;
                    918:                }
                    919:        } else if (MDOC_BODY == n->type) {
                    920:                switch (type) {
                    921:                case(LIST_bullet):
                    922:                        /* FALLTHROUGH */
                    923:                case(LIST_hyphen):
                    924:                        /* FALLTHROUGH */
                    925:                case(LIST_dash):
                    926:                        /* FALLTHROUGH */
                    927:                case(LIST_enum):
                    928:                        /* FALLTHROUGH */
                    929:                case(LIST_item):
1.137     kristaps  930:                        SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
1.122     kristaps  931:                        bufcat_su(h, "margin-top", &su);
                    932:                        PAIR_STYLE_INIT(&tag[1], h);
1.116     kristaps  933:                        print_otag(h, TAG_LI, 2, tag);
1.115     kristaps  934:                        break;
                    935:                case(LIST_diag):
                    936:                        /* FALLTHROUGH */
                    937:                case(LIST_hang):
                    938:                        /* FALLTHROUGH */
                    939:                case(LIST_inset):
                    940:                        /* FALLTHROUGH */
                    941:                case(LIST_ohang):
                    942:                        /* FALLTHROUGH */
                    943:                case(LIST_tag):
1.137     kristaps  944:                        if (NULL == bl->norm->Bl.width) {
1.122     kristaps  945:                                print_otag(h, TAG_DD, 1, tag);
                    946:                                break;
                    947:                        }
1.137     kristaps  948:                        a2width(bl->norm->Bl.width, &su);
1.122     kristaps  949:                        bufcat_su(h, "margin-left", &su);
                    950:                        PAIR_STYLE_INIT(&tag[1], h);
                    951:                        print_otag(h, TAG_DD, 2, tag);
1.115     kristaps  952:                        break;
                    953:                case(LIST_column):
1.137     kristaps  954:                        SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
1.122     kristaps  955:                        bufcat_su(h, "margin-top", &su);
                    956:                        PAIR_STYLE_INIT(&tag[1], h);
1.116     kristaps  957:                        print_otag(h, TAG_TD, 2, tag);
1.115     kristaps  958:                        break;
                    959:                default:
                    960:                        break;
                    961:                }
                    962:        } else {
                    963:                switch (type) {
                    964:                case (LIST_column):
1.116     kristaps  965:                        print_otag(h, TAG_TR, 1, tag);
1.115     kristaps  966:                        break;
                    967:                default:
1.23      kristaps  968:                        break;
1.115     kristaps  969:                }
1.1       kristaps  970:        }
                    971:
                    972:        return(1);
                    973: }
                    974:
1.25      kristaps  975: /* ARGSUSED */
1.1       kristaps  976: static int
1.115     kristaps  977: mdoc_bl_pre(MDOC_ARGS)
1.1       kristaps  978: {
1.142     kristaps  979:        int              i;
1.119     kristaps  980:        struct htmlpair  tag[3];
1.23      kristaps  981:        struct roffsu    su;
1.134     kristaps  982:        char             buf[BUFSIZ];
1.23      kristaps  983:
1.115     kristaps  984:        if (MDOC_BODY == n->type) {
1.137     kristaps  985:                if (LIST_column == n->norm->Bl.type)
1.115     kristaps  986:                        print_otag(h, TAG_TBODY, 0, NULL);
                    987:                return(1);
1.23      kristaps  988:        }
1.1       kristaps  989:
1.115     kristaps  990:        if (MDOC_HEAD == n->type) {
1.137     kristaps  991:                if (LIST_column != n->norm->Bl.type)
1.115     kristaps  992:                        return(0);
                    993:
                    994:                /*
                    995:                 * For each column, print out the <COL> tag with our
                    996:                 * suggested width.  The last column gets min-width, as
                    997:                 * in terminal mode it auto-sizes to the width of the
                    998:                 * screen and we want to preserve that behaviour.
                    999:                 */
1.1       kristaps 1000:
1.142     kristaps 1001:                for (i = 0; i < (int)n->norm->Bl.ncols; i++) {
1.137     kristaps 1002:                        a2width(n->norm->Bl.cols[i], &su);
1.115     kristaps 1003:                        bufinit(h);
1.142     kristaps 1004:                        if (i < (int)n->norm->Bl.ncols - 1)
1.115     kristaps 1005:                                bufcat_su(h, "width", &su);
                   1006:                        else
                   1007:                                bufcat_su(h, "min-width", &su);
                   1008:                        PAIR_STYLE_INIT(&tag[0], h);
                   1009:                        print_otag(h, TAG_COL, 1, tag);
                   1010:                }
1.1       kristaps 1011:
                   1012:                return(0);
                   1013:        }
                   1014:
1.119     kristaps 1015:        SCALE_VS_INIT(&su, 0);
                   1016:        bufcat_su(h, "margin-top", &su);
                   1017:        bufcat_su(h, "margin-bottom", &su);
                   1018:        PAIR_STYLE_INIT(&tag[0], h);
                   1019:
1.137     kristaps 1020:        assert(lists[n->norm->Bl.type]);
1.134     kristaps 1021:        strlcpy(buf, "list ", BUFSIZ);
1.137     kristaps 1022:        strlcat(buf, lists[n->norm->Bl.type], BUFSIZ);
1.134     kristaps 1023:        PAIR_INIT(&tag[1], ATTR_CLASS, buf);
1.1       kristaps 1024:
1.115     kristaps 1025:        /* Set the block's left-hand margin. */
1.1       kristaps 1026:
1.137     kristaps 1027:        if (n->norm->Bl.offs) {
                   1028:                a2offs(n->norm->Bl.offs, &su);
1.115     kristaps 1029:                bufcat_su(h, "margin-left", &su);
                   1030:        }
1.1       kristaps 1031:
1.137     kristaps 1032:        switch (n->norm->Bl.type) {
1.115     kristaps 1033:        case(LIST_bullet):
1.1       kristaps 1034:                /* FALLTHROUGH */
1.115     kristaps 1035:        case(LIST_dash):
1.1       kristaps 1036:                /* FALLTHROUGH */
1.115     kristaps 1037:        case(LIST_hyphen):
1.1       kristaps 1038:                /* FALLTHROUGH */
1.115     kristaps 1039:        case(LIST_item):
1.134     kristaps 1040:                print_otag(h, TAG_UL, 2, tag);
1.1       kristaps 1041:                break;
1.115     kristaps 1042:        case(LIST_enum):
1.134     kristaps 1043:                print_otag(h, TAG_OL, 2, tag);
1.23      kristaps 1044:                break;
1.115     kristaps 1045:        case(LIST_diag):
                   1046:                /* FALLTHROUGH */
                   1047:        case(LIST_hang):
1.46      kristaps 1048:                /* FALLTHROUGH */
1.115     kristaps 1049:        case(LIST_inset):
1.33      kristaps 1050:                /* FALLTHROUGH */
1.115     kristaps 1051:        case(LIST_ohang):
1.1       kristaps 1052:                /* FALLTHROUGH */
1.115     kristaps 1053:        case(LIST_tag):
1.134     kristaps 1054:                print_otag(h, TAG_DL, 2, tag);
1.115     kristaps 1055:                break;
                   1056:        case(LIST_column):
1.134     kristaps 1057:                print_otag(h, TAG_TABLE, 2, tag);
1.1       kristaps 1058:                break;
                   1059:        default:
1.115     kristaps 1060:                abort();
                   1061:                /* NOTREACHED */
1.1       kristaps 1062:        }
                   1063:
                   1064:        return(1);
                   1065: }
                   1066:
                   1067: /* ARGSUSED */
                   1068: static int
                   1069: mdoc_ex_pre(MDOC_ARGS)
                   1070: {
                   1071:        const struct mdoc_node  *nn;
                   1072:        struct tag              *t;
                   1073:        struct htmlpair          tag;
                   1074:
1.127     kristaps 1075:        if (n->prev)
                   1076:                print_otag(h, TAG_BR, 0, NULL);
                   1077:
1.23      kristaps 1078:        PAIR_CLASS_INIT(&tag, "utility");
                   1079:
1.1       kristaps 1080:        print_text(h, "The");
                   1081:        for (nn = n->child; nn; nn = nn->next) {
1.132     kristaps 1082:                t = print_otag(h, TAG_B, 1, &tag);
1.1       kristaps 1083:                print_text(h, nn->string);
                   1084:                print_tagq(h, t);
                   1085:
                   1086:                h->flags |= HTML_NOSPACE;
                   1087:
                   1088:                if (nn->next && NULL == nn->next->next)
                   1089:                        print_text(h, ", and");
                   1090:                else if (nn->next)
                   1091:                        print_text(h, ",");
                   1092:                else
                   1093:                        h->flags &= ~HTML_NOSPACE;
                   1094:        }
                   1095:
1.65      kristaps 1096:        if (n->child && n->child->next)
1.1       kristaps 1097:                print_text(h, "utilities exit");
                   1098:        else
                   1099:                print_text(h, "utility exits");
                   1100:
                   1101:                print_text(h, "0 on success, and >0 if an error occurs.");
                   1102:        return(0);
                   1103: }
                   1104:
                   1105:
                   1106: /* ARGSUSED */
                   1107: static int
                   1108: mdoc_em_pre(MDOC_ARGS)
                   1109: {
                   1110:        struct htmlpair tag;
                   1111:
1.23      kristaps 1112:        PAIR_CLASS_INIT(&tag, "emph");
1.1       kristaps 1113:        print_otag(h, TAG_SPAN, 1, &tag);
                   1114:        return(1);
                   1115: }
                   1116:
                   1117:
                   1118: /* ARGSUSED */
                   1119: static int
                   1120: mdoc_d1_pre(MDOC_ARGS)
                   1121: {
1.23      kristaps 1122:        struct htmlpair  tag[2];
                   1123:        struct roffsu    su;
1.1       kristaps 1124:
                   1125:        if (MDOC_BLOCK != n->type)
                   1126:                return(1);
                   1127:
1.118     kristaps 1128:        SCALE_VS_INIT(&su, 0);
                   1129:        bufcat_su(h, "margin-top", &su);
                   1130:        bufcat_su(h, "margin-bottom", &su);
                   1131:        PAIR_STYLE_INIT(&tag[0], h);
1.120     kristaps 1132:        print_otag(h, TAG_BLOCKQUOTE, 1, tag);
                   1133:
                   1134:        /* BLOCKQUOTE needs a block body. */
1.118     kristaps 1135:
1.136     kristaps 1136:        PAIR_CLASS_INIT(&tag[0], "display");
                   1137:        print_otag(h, TAG_DIV, 1, tag);
                   1138:
1.135     kristaps 1139:        if (MDOC_Dl == n->tok) {
1.136     kristaps 1140:                PAIR_CLASS_INIT(&tag[0], "lit");
1.135     kristaps 1141:                print_otag(h, TAG_CODE, 1, tag);
1.136     kristaps 1142:        }
1.35      kristaps 1143:
1.1       kristaps 1144:        return(1);
                   1145: }
                   1146:
                   1147:
                   1148: /* ARGSUSED */
                   1149: static int
                   1150: mdoc_sx_pre(MDOC_ARGS)
                   1151: {
1.18      kristaps 1152:        struct htmlpair          tag[2];
1.1       kristaps 1153:        const struct mdoc_node  *nn;
1.35      kristaps 1154:        char                     buf[BUFSIZ];
1.1       kristaps 1155:
1.41      kristaps 1156:        strlcpy(buf, "#", BUFSIZ);
1.1       kristaps 1157:        for (nn = n->child; nn; nn = nn->next) {
1.41      kristaps 1158:                html_idcat(buf, nn->string, BUFSIZ);
1.1       kristaps 1159:                if (nn->next)
1.42      kristaps 1160:                        html_idcat(buf, " ", BUFSIZ);
1.1       kristaps 1161:        }
                   1162:
1.23      kristaps 1163:        PAIR_CLASS_INIT(&tag[0], "link-sec");
1.57      kristaps 1164:        PAIR_HREF_INIT(&tag[1], buf);
1.1       kristaps 1165:
1.134     kristaps 1166:        print_otag(h, TAG_I, 1, tag);
1.18      kristaps 1167:        print_otag(h, TAG_A, 2, tag);
1.1       kristaps 1168:        return(1);
                   1169: }
                   1170:
                   1171:
                   1172: /* ARGSUSED */
                   1173: static int
                   1174: mdoc_bd_pre(MDOC_ARGS)
                   1175: {
                   1176:        struct htmlpair          tag[2];
1.80      kristaps 1177:        int                      comp;
                   1178:        const struct mdoc_node  *nn;
1.23      kristaps 1179:        struct roffsu            su;
1.1       kristaps 1180:
1.80      kristaps 1181:        if (MDOC_HEAD == n->type)
1.1       kristaps 1182:                return(0);
                   1183:
                   1184:        if (MDOC_BLOCK == n->type) {
1.137     kristaps 1185:                comp = n->norm->Bd.comp;
1.23      kristaps 1186:                for (nn = n; nn && ! comp; nn = nn->parent) {
                   1187:                        if (MDOC_BLOCK != nn->type)
                   1188:                                continue;
                   1189:                        if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
                   1190:                                comp = 1;
                   1191:                        if (nn->prev)
                   1192:                                break;
                   1193:                }
1.126     kristaps 1194:                if ( ! comp)
                   1195:                        print_otag(h, TAG_P, 0, NULL);
1.1       kristaps 1196:                return(1);
                   1197:        }
                   1198:
1.126     kristaps 1199:        SCALE_HS_INIT(&su, 0);
1.137     kristaps 1200:        if (n->norm->Bd.offs)
                   1201:                a2offs(n->norm->Bd.offs, &su);
1.126     kristaps 1202:
                   1203:        bufcat_su(h, "margin-left", &su);
                   1204:        PAIR_STYLE_INIT(&tag[0], h);
                   1205:
1.137     kristaps 1206:        if (DISP_unfilled != n->norm->Bd.type &&
                   1207:                        DISP_literal != n->norm->Bd.type) {
1.126     kristaps 1208:                PAIR_CLASS_INIT(&tag[1], "display");
                   1209:                print_otag(h, TAG_DIV, 2, tag);
1.1       kristaps 1210:                return(1);
1.126     kristaps 1211:        }
1.1       kristaps 1212:
1.126     kristaps 1213:        PAIR_CLASS_INIT(&tag[1], "lit display");
                   1214:        print_otag(h, TAG_PRE, 2, tag);
1.1       kristaps 1215:
1.14      kristaps 1216:        for (nn = n->child; nn; nn = nn->next) {
                   1217:                print_mdoc_node(m, nn, h);
1.108     kristaps 1218:                /*
                   1219:                 * If the printed node flushes its own line, then we
                   1220:                 * needn't do it here as well.  This is hacky, but the
                   1221:                 * notion of selective eoln whitespace is pretty dumb
                   1222:                 * anyway, so don't sweat it.
                   1223:                 */
                   1224:                switch (nn->tok) {
1.111     kristaps 1225:                case (MDOC_Sm):
                   1226:                        /* FALLTHROUGH */
1.108     kristaps 1227:                case (MDOC_br):
                   1228:                        /* FALLTHROUGH */
                   1229:                case (MDOC_sp):
                   1230:                        /* FALLTHROUGH */
                   1231:                case (MDOC_Bl):
1.114     kristaps 1232:                        /* FALLTHROUGH */
                   1233:                case (MDOC_D1):
                   1234:                        /* FALLTHROUGH */
                   1235:                case (MDOC_Dl):
1.108     kristaps 1236:                        /* FALLTHROUGH */
                   1237:                case (MDOC_Lp):
                   1238:                        /* FALLTHROUGH */
                   1239:                case (MDOC_Pp):
                   1240:                        continue;
                   1241:                default:
                   1242:                        break;
                   1243:                }
1.101     schwarze 1244:                if (nn->next && nn->next->line == nn->line)
                   1245:                        continue;
1.126     kristaps 1246:                else if (nn->next)
                   1247:                        print_text(h, "\n");
1.125     kristaps 1248:
1.101     schwarze 1249:                h->flags |= HTML_NOSPACE;
1.1       kristaps 1250:        }
                   1251:
                   1252:        return(0);
                   1253: }
                   1254:
                   1255:
                   1256: /* ARGSUSED */
                   1257: static int
                   1258: mdoc_pa_pre(MDOC_ARGS)
                   1259: {
                   1260:        struct htmlpair tag;
                   1261:
1.23      kristaps 1262:        PAIR_CLASS_INIT(&tag, "file");
1.133     kristaps 1263:        print_otag(h, TAG_I, 1, &tag);
1.1       kristaps 1264:        return(1);
                   1265: }
                   1266:
                   1267:
                   1268: /* ARGSUSED */
                   1269: static int
                   1270: mdoc_ad_pre(MDOC_ARGS)
                   1271: {
                   1272:        struct htmlpair tag;
                   1273:
1.23      kristaps 1274:        PAIR_CLASS_INIT(&tag, "addr");
1.133     kristaps 1275:        print_otag(h, TAG_I, 1, &tag);
1.1       kristaps 1276:        return(1);
                   1277: }
                   1278:
                   1279:
                   1280: /* ARGSUSED */
                   1281: static int
                   1282: mdoc_an_pre(MDOC_ARGS)
                   1283: {
                   1284:        struct htmlpair tag;
                   1285:
1.19      kristaps 1286:        /* TODO: -split and -nosplit (see termp_an_pre()). */
                   1287:
1.23      kristaps 1288:        PAIR_CLASS_INIT(&tag, "author");
1.1       kristaps 1289:        print_otag(h, TAG_SPAN, 1, &tag);
                   1290:        return(1);
                   1291: }
                   1292:
                   1293:
                   1294: /* ARGSUSED */
                   1295: static int
                   1296: mdoc_cd_pre(MDOC_ARGS)
                   1297: {
                   1298:        struct htmlpair tag;
                   1299:
1.78      kristaps 1300:        synopsis_pre(h, n);
1.23      kristaps 1301:        PAIR_CLASS_INIT(&tag, "config");
1.132     kristaps 1302:        print_otag(h, TAG_B, 1, &tag);
1.1       kristaps 1303:        return(1);
                   1304: }
                   1305:
                   1306:
                   1307: /* ARGSUSED */
                   1308: static int
                   1309: mdoc_dv_pre(MDOC_ARGS)
                   1310: {
                   1311:        struct htmlpair tag;
                   1312:
1.23      kristaps 1313:        PAIR_CLASS_INIT(&tag, "define");
1.1       kristaps 1314:        print_otag(h, TAG_SPAN, 1, &tag);
                   1315:        return(1);
                   1316: }
                   1317:
                   1318:
                   1319: /* ARGSUSED */
                   1320: static int
                   1321: mdoc_ev_pre(MDOC_ARGS)
                   1322: {
                   1323:        struct htmlpair tag;
                   1324:
1.23      kristaps 1325:        PAIR_CLASS_INIT(&tag, "env");
1.1       kristaps 1326:        print_otag(h, TAG_SPAN, 1, &tag);
                   1327:        return(1);
                   1328: }
                   1329:
                   1330:
                   1331: /* ARGSUSED */
                   1332: static int
                   1333: mdoc_er_pre(MDOC_ARGS)
                   1334: {
                   1335:        struct htmlpair tag;
                   1336:
1.23      kristaps 1337:        PAIR_CLASS_INIT(&tag, "errno");
1.1       kristaps 1338:        print_otag(h, TAG_SPAN, 1, &tag);
                   1339:        return(1);
                   1340: }
                   1341:
                   1342:
                   1343: /* ARGSUSED */
                   1344: static int
                   1345: mdoc_fa_pre(MDOC_ARGS)
                   1346: {
                   1347:        const struct mdoc_node  *nn;
                   1348:        struct htmlpair          tag;
                   1349:        struct tag              *t;
                   1350:
1.23      kristaps 1351:        PAIR_CLASS_INIT(&tag, "farg");
1.1       kristaps 1352:        if (n->parent->tok != MDOC_Fo) {
1.133     kristaps 1353:                print_otag(h, TAG_I, 1, &tag);
1.1       kristaps 1354:                return(1);
                   1355:        }
                   1356:
                   1357:        for (nn = n->child; nn; nn = nn->next) {
1.133     kristaps 1358:                t = print_otag(h, TAG_I, 1, &tag);
1.1       kristaps 1359:                print_text(h, nn->string);
                   1360:                print_tagq(h, t);
                   1361:                if (nn->next)
                   1362:                        print_text(h, ",");
                   1363:        }
                   1364:
                   1365:        if (n->child && n->next && n->next->tok == MDOC_Fa)
                   1366:                print_text(h, ",");
                   1367:
                   1368:        return(0);
                   1369: }
                   1370:
                   1371:
                   1372: /* ARGSUSED */
                   1373: static int
                   1374: mdoc_fd_pre(MDOC_ARGS)
                   1375: {
1.23      kristaps 1376:        struct htmlpair  tag;
1.1       kristaps 1377:
1.78      kristaps 1378:        synopsis_pre(h, n);
                   1379:
1.23      kristaps 1380:        PAIR_CLASS_INIT(&tag, "macro");
1.132     kristaps 1381:        print_otag(h, TAG_B, 1, &tag);
1.1       kristaps 1382:        return(1);
                   1383: }
                   1384:
                   1385:
                   1386: /* ARGSUSED */
                   1387: static int
                   1388: mdoc_vt_pre(MDOC_ARGS)
                   1389: {
1.23      kristaps 1390:        struct htmlpair  tag;
1.1       kristaps 1391:
1.78      kristaps 1392:        if (MDOC_BLOCK == n->type) {
                   1393:                synopsis_pre(h, n);
1.54      kristaps 1394:                return(1);
1.78      kristaps 1395:        } else if (MDOC_ELEM == n->type) {
                   1396:                synopsis_pre(h, n);
1.54      kristaps 1397:        } else if (MDOC_HEAD == n->type)
                   1398:                return(0);
1.1       kristaps 1399:
1.23      kristaps 1400:        PAIR_CLASS_INIT(&tag, "type");
1.1       kristaps 1401:        print_otag(h, TAG_SPAN, 1, &tag);
                   1402:        return(1);
                   1403: }
                   1404:
1.2       kristaps 1405:
1.1       kristaps 1406: /* ARGSUSED */
                   1407: static int
                   1408: mdoc_ft_pre(MDOC_ARGS)
                   1409: {
1.23      kristaps 1410:        struct htmlpair  tag;
1.1       kristaps 1411:
1.78      kristaps 1412:        synopsis_pre(h, n);
1.23      kristaps 1413:        PAIR_CLASS_INIT(&tag, "ftype");
1.133     kristaps 1414:        print_otag(h, TAG_I, 1, &tag);
1.1       kristaps 1415:        return(1);
                   1416: }
                   1417:
                   1418:
                   1419: /* ARGSUSED */
                   1420: static int
                   1421: mdoc_fn_pre(MDOC_ARGS)
                   1422: {
                   1423:        struct tag              *t;
1.15      kristaps 1424:        struct htmlpair          tag[2];
1.1       kristaps 1425:        const struct mdoc_node  *nn;
1.7       kristaps 1426:        char                     nbuf[BUFSIZ];
                   1427:        const char              *sp, *ep;
1.15      kristaps 1428:        int                      sz, i;
1.1       kristaps 1429:
1.78      kristaps 1430:        synopsis_pre(h, n);
1.1       kristaps 1431:
1.7       kristaps 1432:        /* Split apart into type and name. */
                   1433:        assert(n->child->string);
                   1434:        sp = n->child->string;
1.19      kristaps 1435:
1.26      kristaps 1436:        ep = strchr(sp, ' ');
                   1437:        if (NULL != ep) {
1.23      kristaps 1438:                PAIR_CLASS_INIT(&tag[0], "ftype");
1.133     kristaps 1439:                t = print_otag(h, TAG_I, 1, tag);
1.19      kristaps 1440:
                   1441:                while (ep) {
                   1442:                        sz = MIN((int)(ep - sp), BUFSIZ - 1);
                   1443:                        (void)memcpy(nbuf, sp, (size_t)sz);
                   1444:                        nbuf[sz] = '\0';
                   1445:                        print_text(h, nbuf);
                   1446:                        sp = ++ep;
                   1447:                        ep = strchr(sp, ' ');
                   1448:                }
                   1449:                print_tagq(h, t);
1.7       kristaps 1450:        }
1.1       kristaps 1451:
1.23      kristaps 1452:        PAIR_CLASS_INIT(&tag[0], "fname");
1.57      kristaps 1453:
                   1454:        /*
                   1455:         * FIXME: only refer to IDs that we know exist.
                   1456:         */
                   1457:
                   1458: #if 0
1.87      kristaps 1459:        if (MDOC_SYNPRETTY & n->flags) {
1.57      kristaps 1460:                nbuf[0] = '\0';
                   1461:                html_idcat(nbuf, sp, BUFSIZ);
                   1462:                PAIR_ID_INIT(&tag[1], nbuf);
                   1463:        } else {
                   1464:                strlcpy(nbuf, "#", BUFSIZ);
                   1465:                html_idcat(nbuf, sp, BUFSIZ);
                   1466:                PAIR_HREF_INIT(&tag[1], nbuf);
                   1467:        }
                   1468: #endif
                   1469:
1.132     kristaps 1470:        t = print_otag(h, TAG_B, 1, tag);
1.7       kristaps 1471:
                   1472:        if (sp) {
1.57      kristaps 1473:                strlcpy(nbuf, sp, BUFSIZ);
1.7       kristaps 1474:                print_text(h, nbuf);
                   1475:        }
                   1476:
1.1       kristaps 1477:        print_tagq(h, t);
                   1478:
                   1479:        h->flags |= HTML_NOSPACE;
                   1480:        print_text(h, "(");
                   1481:
1.23      kristaps 1482:        bufinit(h);
                   1483:        PAIR_CLASS_INIT(&tag[0], "farg");
                   1484:        bufcat_style(h, "white-space", "nowrap");
                   1485:        PAIR_STYLE_INIT(&tag[1], h);
                   1486:
1.1       kristaps 1487:        for (nn = n->child->next; nn; nn = nn->next) {
1.23      kristaps 1488:                i = 1;
1.87      kristaps 1489:                if (MDOC_SYNPRETTY & n->flags)
1.23      kristaps 1490:                        i = 2;
1.133     kristaps 1491:                t = print_otag(h, TAG_I, i, tag);
1.1       kristaps 1492:                print_text(h, nn->string);
                   1493:                print_tagq(h, t);
                   1494:                if (nn->next)
                   1495:                        print_text(h, ",");
                   1496:        }
                   1497:
                   1498:        print_text(h, ")");
1.87      kristaps 1499:        if (MDOC_SYNPRETTY & n->flags)
1.1       kristaps 1500:                print_text(h, ";");
1.99      kristaps 1501:
                   1502:        return(0);
                   1503: }
                   1504:
                   1505:
                   1506: /* ARGSUSED */
                   1507: static int
                   1508: mdoc_sm_pre(MDOC_ARGS)
                   1509: {
                   1510:
                   1511:        assert(n->child && MDOC_TEXT == n->child->type);
                   1512:        if (0 == strcmp("on", n->child->string)) {
1.111     kristaps 1513:                /*
                   1514:                 * FIXME: no p->col to check.  Thus, if we have
                   1515:                 *  .Bd -literal
                   1516:                 *  .Sm off
                   1517:                 *  1 2
                   1518:                 *  .Sm on
                   1519:                 *  3
                   1520:                 *  .Ed
                   1521:                 * the "3" is preceded by a space.
                   1522:                 */
1.99      kristaps 1523:                h->flags &= ~HTML_NOSPACE;
                   1524:                h->flags &= ~HTML_NONOSPACE;
                   1525:        } else
                   1526:                h->flags |= HTML_NONOSPACE;
1.1       kristaps 1527:
                   1528:        return(0);
                   1529: }
                   1530:
1.120     kristaps 1531: /* ARGSUSED */
                   1532: static int
                   1533: mdoc_pp_pre(MDOC_ARGS)
                   1534: {
                   1535:
                   1536:        print_otag(h, TAG_P, 0, NULL);
                   1537:        return(0);
                   1538:
                   1539: }
1.1       kristaps 1540:
                   1541: /* ARGSUSED */
                   1542: static int
                   1543: mdoc_sp_pre(MDOC_ARGS)
                   1544: {
1.120     kristaps 1545:        struct roffsu    su;
1.23      kristaps 1546:        struct htmlpair  tag;
1.1       kristaps 1547:
1.120     kristaps 1548:        SCALE_VS_INIT(&su, 1);
                   1549:
                   1550:        if (MDOC_sp == n->tok) {
                   1551:                if (n->child)
                   1552:                        a2roffsu(n->child->string, &su, SCALE_VS);
                   1553:        } else
                   1554:                su.scale = 0;
1.1       kristaps 1555:
1.23      kristaps 1556:        bufcat_su(h, "height", &su);
                   1557:        PAIR_STYLE_INIT(&tag, h);
1.1       kristaps 1558:        print_otag(h, TAG_DIV, 1, &tag);
1.120     kristaps 1559:
1.42      kristaps 1560:        /* So the div isn't empty: */
                   1561:        print_text(h, "\\~");
                   1562:
                   1563:        return(0);
1.1       kristaps 1564:
                   1565: }
1.2       kristaps 1566:
                   1567: /* ARGSUSED */
                   1568: static int
                   1569: mdoc_lk_pre(MDOC_ARGS)
                   1570: {
                   1571:        const struct mdoc_node  *nn;
                   1572:        struct htmlpair          tag[2];
                   1573:
                   1574:        nn = n->child;
                   1575:
1.23      kristaps 1576:        PAIR_CLASS_INIT(&tag[0], "link-ext");
1.57      kristaps 1577:        PAIR_HREF_INIT(&tag[1], nn->string);
1.2       kristaps 1578:        print_otag(h, TAG_A, 2, tag);
                   1579:
1.113     kristaps 1580:        if (NULL == nn || NULL == nn->next)
1.38      kristaps 1581:                return(1);
                   1582:
1.2       kristaps 1583:        for (nn = nn->next; nn; nn = nn->next)
                   1584:                print_text(h, nn->string);
                   1585:
                   1586:        return(0);
                   1587: }
                   1588:
                   1589:
                   1590: /* ARGSUSED */
                   1591: static int
                   1592: mdoc_mt_pre(MDOC_ARGS)
                   1593: {
                   1594:        struct htmlpair          tag[2];
                   1595:        struct tag              *t;
                   1596:        const struct mdoc_node  *nn;
                   1597:
1.23      kristaps 1598:        PAIR_CLASS_INIT(&tag[0], "link-mail");
1.2       kristaps 1599:
                   1600:        for (nn = n->child; nn; nn = nn->next) {
1.16      kristaps 1601:                bufinit(h);
                   1602:                bufcat(h, "mailto:");
                   1603:                bufcat(h, nn->string);
1.57      kristaps 1604:                PAIR_HREF_INIT(&tag[1], h->buf);
1.2       kristaps 1605:                t = print_otag(h, TAG_A, 2, tag);
                   1606:                print_text(h, nn->string);
                   1607:                print_tagq(h, t);
                   1608:        }
                   1609:
                   1610:        return(0);
                   1611: }
1.4       kristaps 1612:
                   1613:
                   1614: /* ARGSUSED */
                   1615: static int
                   1616: mdoc_fo_pre(MDOC_ARGS)
                   1617: {
1.77      kristaps 1618:        struct htmlpair  tag;
                   1619:        struct tag      *t;
1.4       kristaps 1620:
                   1621:        if (MDOC_BODY == n->type) {
                   1622:                h->flags |= HTML_NOSPACE;
                   1623:                print_text(h, "(");
                   1624:                h->flags |= HTML_NOSPACE;
                   1625:                return(1);
1.77      kristaps 1626:        } else if (MDOC_BLOCK == n->type) {
1.78      kristaps 1627:                synopsis_pre(h, n);
1.4       kristaps 1628:                return(1);
1.57      kristaps 1629:        }
1.4       kristaps 1630:
1.77      kristaps 1631:        /* XXX: we drop non-initial arguments as per groff. */
                   1632:
                   1633:        assert(n->child);
                   1634:        assert(n->child->string);
                   1635:
1.23      kristaps 1636:        PAIR_CLASS_INIT(&tag, "fname");
1.139     kristaps 1637:        t = print_otag(h, TAG_B, 1, &tag);
1.77      kristaps 1638:        print_text(h, n->child->string);
                   1639:        print_tagq(h, t);
                   1640:        return(0);
1.4       kristaps 1641: }
                   1642:
                   1643:
                   1644: /* ARGSUSED */
                   1645: static void
                   1646: mdoc_fo_post(MDOC_ARGS)
                   1647: {
1.78      kristaps 1648:
1.4       kristaps 1649:        if (MDOC_BODY != n->type)
                   1650:                return;
                   1651:        print_text(h, ")");
                   1652:        print_text(h, ";");
                   1653: }
                   1654:
                   1655:
                   1656: /* ARGSUSED */
                   1657: static int
                   1658: mdoc_in_pre(MDOC_ARGS)
                   1659: {
                   1660:        const struct mdoc_node  *nn;
1.23      kristaps 1661:        struct tag              *t;
1.17      kristaps 1662:        struct htmlpair          tag[2];
                   1663:        int                      i;
1.34      kristaps 1664:
1.78      kristaps 1665:        synopsis_pre(h, n);
                   1666:
1.23      kristaps 1667:        PAIR_CLASS_INIT(&tag[0], "includes");
1.132     kristaps 1668:        print_otag(h, TAG_B, 1, tag);
1.4       kristaps 1669:
1.87      kristaps 1670:        if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags)
1.4       kristaps 1671:                print_text(h, "#include");
                   1672:
                   1673:        print_text(h, "<");
                   1674:        h->flags |= HTML_NOSPACE;
                   1675:
1.17      kristaps 1676:        for (nn = n->child; nn; nn = nn->next) {
1.23      kristaps 1677:                PAIR_CLASS_INIT(&tag[0], "link-includes");
                   1678:                i = 1;
1.41      kristaps 1679:                bufinit(h);
1.17      kristaps 1680:                if (h->base_includes) {
                   1681:                        buffmt_includes(h, nn->string);
1.57      kristaps 1682:                        PAIR_HREF_INIT(&tag[i], h->buf);
                   1683:                        i++;
1.17      kristaps 1684:                }
                   1685:                t = print_otag(h, TAG_A, i, tag);
1.4       kristaps 1686:                print_mdoc_node(m, nn, h);
1.17      kristaps 1687:                print_tagq(h, t);
                   1688:        }
1.4       kristaps 1689:
                   1690:        h->flags |= HTML_NOSPACE;
                   1691:        print_text(h, ">");
                   1692:
                   1693:        return(0);
                   1694: }
                   1695:
                   1696:
                   1697: /* ARGSUSED */
                   1698: static int
                   1699: mdoc_ic_pre(MDOC_ARGS)
                   1700: {
                   1701:        struct htmlpair tag;
                   1702:
1.23      kristaps 1703:        PAIR_CLASS_INIT(&tag, "cmd");
1.132     kristaps 1704:        print_otag(h, TAG_B, 1, &tag);
1.4       kristaps 1705:        return(1);
                   1706: }
                   1707:
                   1708:
                   1709: /* ARGSUSED */
                   1710: static int
                   1711: mdoc_rv_pre(MDOC_ARGS)
                   1712: {
                   1713:        const struct mdoc_node  *nn;
                   1714:        struct htmlpair          tag;
                   1715:        struct tag              *t;
                   1716:
1.127     kristaps 1717:        if (n->prev)
                   1718:                print_otag(h, TAG_BR, 0, NULL);
                   1719:
1.4       kristaps 1720:        print_text(h, "The");
                   1721:
                   1722:        for (nn = n->child; nn; nn = nn->next) {
1.23      kristaps 1723:                PAIR_CLASS_INIT(&tag, "fname");
1.139     kristaps 1724:                t = print_otag(h, TAG_B, 1, &tag);
1.4       kristaps 1725:                print_text(h, nn->string);
                   1726:                print_tagq(h, t);
                   1727:
                   1728:                h->flags |= HTML_NOSPACE;
                   1729:                if (nn->next && NULL == nn->next->next)
                   1730:                        print_text(h, "(), and");
                   1731:                else if (nn->next)
                   1732:                        print_text(h, "(),");
                   1733:                else
                   1734:                        print_text(h, "()");
                   1735:        }
                   1736:
1.65      kristaps 1737:        if (n->child && n->child->next)
1.4       kristaps 1738:                print_text(h, "functions return");
                   1739:        else
                   1740:                print_text(h, "function returns");
                   1741:
                   1742:                print_text(h, "the value 0 if successful; otherwise the value "
                   1743:                        "-1 is returned and the global variable");
                   1744:
1.23      kristaps 1745:        PAIR_CLASS_INIT(&tag, "var");
1.132     kristaps 1746:        t = print_otag(h, TAG_B, 1, &tag);
1.4       kristaps 1747:        print_text(h, "errno");
                   1748:        print_tagq(h, t);
                   1749:                print_text(h, "is set to indicate the error.");
                   1750:        return(0);
                   1751: }
                   1752:
                   1753:
                   1754: /* ARGSUSED */
                   1755: static int
                   1756: mdoc_va_pre(MDOC_ARGS)
                   1757: {
                   1758:        struct htmlpair tag;
                   1759:
1.23      kristaps 1760:        PAIR_CLASS_INIT(&tag, "var");
1.132     kristaps 1761:        print_otag(h, TAG_B, 1, &tag);
1.4       kristaps 1762:        return(1);
                   1763: }
                   1764:
                   1765:
                   1766: /* ARGSUSED */
                   1767: static int
1.5       kristaps 1768: mdoc_ap_pre(MDOC_ARGS)
                   1769: {
                   1770:
                   1771:        h->flags |= HTML_NOSPACE;
                   1772:        print_text(h, "\\(aq");
                   1773:        h->flags |= HTML_NOSPACE;
                   1774:        return(1);
                   1775: }
                   1776:
                   1777:
                   1778: /* ARGSUSED */
                   1779: static int
                   1780: mdoc_bf_pre(MDOC_ARGS)
                   1781: {
1.23      kristaps 1782:        struct htmlpair  tag[2];
                   1783:        struct roffsu    su;
1.5       kristaps 1784:
                   1785:        if (MDOC_HEAD == n->type)
                   1786:                return(0);
1.92      kristaps 1787:        else if (MDOC_BODY != n->type)
1.5       kristaps 1788:                return(1);
                   1789:
1.137     kristaps 1790:        if (FONT_Em == n->norm->Bf.font)
1.92      kristaps 1791:                PAIR_CLASS_INIT(&tag[0], "emph");
1.137     kristaps 1792:        else if (FONT_Sy == n->norm->Bf.font)
1.92      kristaps 1793:                PAIR_CLASS_INIT(&tag[0], "symb");
1.137     kristaps 1794:        else if (FONT_Li == n->norm->Bf.font)
1.92      kristaps 1795:                PAIR_CLASS_INIT(&tag[0], "lit");
                   1796:        else
                   1797:                PAIR_CLASS_INIT(&tag[0], "none");
1.5       kristaps 1798:
1.92      kristaps 1799:        /*
                   1800:         * We want this to be inline-formatted, but needs to be div to
                   1801:         * accept block children.
                   1802:         */
1.23      kristaps 1803:        bufcat_style(h, "display", "inline");
                   1804:        SCALE_HS_INIT(&su, 1);
1.92      kristaps 1805:        /* Needs a left-margin for spacing. */
                   1806:        bufcat_su(h, "margin-left", &su);
1.23      kristaps 1807:        PAIR_STYLE_INIT(&tag[1], h);
1.5       kristaps 1808:        print_otag(h, TAG_DIV, 2, tag);
                   1809:        return(1);
                   1810: }
                   1811:
                   1812:
                   1813: /* ARGSUSED */
                   1814: static int
                   1815: mdoc_ms_pre(MDOC_ARGS)
                   1816: {
                   1817:        struct htmlpair tag;
                   1818:
1.23      kristaps 1819:        PAIR_CLASS_INIT(&tag, "symb");
1.5       kristaps 1820:        print_otag(h, TAG_SPAN, 1, &tag);
                   1821:        return(1);
                   1822: }
                   1823:
                   1824:
                   1825: /* ARGSUSED */
                   1826: static int
1.110     schwarze 1827: mdoc_igndelim_pre(MDOC_ARGS)
1.5       kristaps 1828: {
                   1829:
                   1830:        h->flags |= HTML_IGNDELIM;
                   1831:        return(1);
                   1832: }
                   1833:
                   1834:
                   1835: /* ARGSUSED */
                   1836: static void
                   1837: mdoc_pf_post(MDOC_ARGS)
                   1838: {
                   1839:
                   1840:        h->flags |= HTML_NOSPACE;
                   1841: }
                   1842:
                   1843:
                   1844: /* ARGSUSED */
                   1845: static int
                   1846: mdoc_rs_pre(MDOC_ARGS)
                   1847: {
1.23      kristaps 1848:        struct htmlpair  tag;
1.5       kristaps 1849:
                   1850:        if (MDOC_BLOCK != n->type)
                   1851:                return(1);
                   1852:
1.120     kristaps 1853:        if (n->prev && SEC_SEE_ALSO == n->sec)
                   1854:                print_otag(h, TAG_P, 0, NULL);
1.5       kristaps 1855:
1.23      kristaps 1856:        PAIR_CLASS_INIT(&tag, "ref");
1.8       kristaps 1857:        print_otag(h, TAG_SPAN, 1, &tag);
1.5       kristaps 1858:        return(1);
                   1859: }
1.6       kristaps 1860:
                   1861:
                   1862:
                   1863: /* ARGSUSED */
                   1864: static int
                   1865: mdoc_li_pre(MDOC_ARGS)
                   1866: {
                   1867:        struct htmlpair tag;
                   1868:
1.23      kristaps 1869:        PAIR_CLASS_INIT(&tag, "lit");
1.6       kristaps 1870:        print_otag(h, TAG_SPAN, 1, &tag);
                   1871:        return(1);
                   1872: }
                   1873:
                   1874:
                   1875: /* ARGSUSED */
                   1876: static int
                   1877: mdoc_sy_pre(MDOC_ARGS)
                   1878: {
                   1879:        struct htmlpair tag;
                   1880:
1.23      kristaps 1881:        PAIR_CLASS_INIT(&tag, "symb");
1.6       kristaps 1882:        print_otag(h, TAG_SPAN, 1, &tag);
                   1883:        return(1);
                   1884: }
                   1885:
                   1886:
                   1887: /* ARGSUSED */
                   1888: static int
                   1889: mdoc_bt_pre(MDOC_ARGS)
                   1890: {
                   1891:
                   1892:        print_text(h, "is currently in beta test.");
                   1893:        return(0);
                   1894: }
                   1895:
                   1896:
                   1897: /* ARGSUSED */
                   1898: static int
                   1899: mdoc_ud_pre(MDOC_ARGS)
                   1900: {
                   1901:
                   1902:        print_text(h, "currently under development.");
                   1903:        return(0);
                   1904: }
                   1905:
                   1906:
                   1907: /* ARGSUSED */
                   1908: static int
                   1909: mdoc_lb_pre(MDOC_ARGS)
                   1910: {
                   1911:        struct htmlpair tag;
                   1912:
1.127     kristaps 1913:        if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags && n->prev)
                   1914:                print_otag(h, TAG_BR, 0, NULL);
                   1915:
1.23      kristaps 1916:        PAIR_CLASS_INIT(&tag, "lib");
1.6       kristaps 1917:        print_otag(h, TAG_SPAN, 1, &tag);
                   1918:        return(1);
                   1919: }
1.10      kristaps 1920:
                   1921:
                   1922: /* ARGSUSED */
                   1923: static int
                   1924: mdoc__x_pre(MDOC_ARGS)
                   1925: {
1.38      kristaps 1926:        struct htmlpair tag[2];
1.133     kristaps 1927:        enum htmltag    t;
                   1928:
                   1929:        t = TAG_SPAN;
1.37      kristaps 1930:
1.10      kristaps 1931:        switch (n->tok) {
                   1932:        case(MDOC__A):
1.38      kristaps 1933:                PAIR_CLASS_INIT(&tag[0], "ref-auth");
1.103     kristaps 1934:                if (n->prev && MDOC__A == n->prev->tok)
                   1935:                        if (NULL == n->next || MDOC__A != n->next->tok)
                   1936:                                print_text(h, "and");
1.10      kristaps 1937:                break;
                   1938:        case(MDOC__B):
1.38      kristaps 1939:                PAIR_CLASS_INIT(&tag[0], "ref-book");
1.133     kristaps 1940:                t = TAG_I;
1.10      kristaps 1941:                break;
                   1942:        case(MDOC__C):
1.38      kristaps 1943:                PAIR_CLASS_INIT(&tag[0], "ref-city");
1.10      kristaps 1944:                break;
                   1945:        case(MDOC__D):
1.38      kristaps 1946:                PAIR_CLASS_INIT(&tag[0], "ref-date");
1.10      kristaps 1947:                break;
                   1948:        case(MDOC__I):
1.38      kristaps 1949:                PAIR_CLASS_INIT(&tag[0], "ref-issue");
1.133     kristaps 1950:                t = TAG_I;
1.10      kristaps 1951:                break;
                   1952:        case(MDOC__J):
1.38      kristaps 1953:                PAIR_CLASS_INIT(&tag[0], "ref-jrnl");
1.133     kristaps 1954:                t = TAG_I;
1.10      kristaps 1955:                break;
                   1956:        case(MDOC__N):
1.38      kristaps 1957:                PAIR_CLASS_INIT(&tag[0], "ref-num");
1.10      kristaps 1958:                break;
                   1959:        case(MDOC__O):
1.38      kristaps 1960:                PAIR_CLASS_INIT(&tag[0], "ref-opt");
1.10      kristaps 1961:                break;
                   1962:        case(MDOC__P):
1.38      kristaps 1963:                PAIR_CLASS_INIT(&tag[0], "ref-page");
1.10      kristaps 1964:                break;
                   1965:        case(MDOC__Q):
1.38      kristaps 1966:                PAIR_CLASS_INIT(&tag[0], "ref-corp");
1.10      kristaps 1967:                break;
                   1968:        case(MDOC__R):
1.38      kristaps 1969:                PAIR_CLASS_INIT(&tag[0], "ref-rep");
1.10      kristaps 1970:                break;
                   1971:        case(MDOC__T):
1.38      kristaps 1972:                PAIR_CLASS_INIT(&tag[0], "ref-title");
1.10      kristaps 1973:                break;
1.38      kristaps 1974:        case(MDOC__U):
                   1975:                PAIR_CLASS_INIT(&tag[0], "link-ref");
                   1976:                break;
1.10      kristaps 1977:        case(MDOC__V):
1.38      kristaps 1978:                PAIR_CLASS_INIT(&tag[0], "ref-vol");
1.10      kristaps 1979:                break;
                   1980:        default:
                   1981:                abort();
                   1982:                /* NOTREACHED */
                   1983:        }
                   1984:
1.38      kristaps 1985:        if (MDOC__U != n->tok) {
1.133     kristaps 1986:                print_otag(h, t, 1, tag);
1.38      kristaps 1987:                return(1);
                   1988:        }
                   1989:
                   1990:        PAIR_HREF_INIT(&tag[1], n->child->string);
                   1991:        print_otag(h, TAG_A, 2, tag);
1.103     kristaps 1992:
1.10      kristaps 1993:        return(1);
                   1994: }
                   1995:
                   1996:
                   1997: /* ARGSUSED */
                   1998: static void
                   1999: mdoc__x_post(MDOC_ARGS)
                   2000: {
1.103     kristaps 2001:
                   2002:        if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok)
                   2003:                if (NULL == n->next->next || MDOC__A != n->next->next->tok)
                   2004:                        if (NULL == n->prev || MDOC__A != n->prev->tok)
                   2005:                                return;
1.10      kristaps 2006:
1.61      kristaps 2007:        /* TODO: %U */
                   2008:
1.106     kristaps 2009:        if (NULL == n->parent || MDOC_Rs != n->parent->tok)
                   2010:                return;
                   2011:
1.10      kristaps 2012:        print_text(h, n->next ? "," : ".");
1.94      kristaps 2013: }
                   2014:
                   2015:
                   2016: /* ARGSUSED */
                   2017: static int
                   2018: mdoc_bk_pre(MDOC_ARGS)
                   2019: {
                   2020:
                   2021:        switch (n->type) {
                   2022:        case (MDOC_BLOCK):
                   2023:                break;
                   2024:        case (MDOC_HEAD):
                   2025:                return(0);
                   2026:        case (MDOC_BODY):
1.131     kristaps 2027:                if (n->parent->args || 0 == n->prev->nchild)
                   2028:                        h->flags |= HTML_PREKEEP;
1.94      kristaps 2029:                break;
                   2030:        default:
                   2031:                abort();
                   2032:                /* NOTREACHED */
                   2033:        }
                   2034:
                   2035:        return(1);
                   2036: }
                   2037:
                   2038:
                   2039: /* ARGSUSED */
                   2040: static void
                   2041: mdoc_bk_post(MDOC_ARGS)
                   2042: {
                   2043:
                   2044:        if (MDOC_BODY == n->type)
                   2045:                h->flags &= ~(HTML_KEEP | HTML_PREKEEP);
1.10      kristaps 2046: }
1.107     kristaps 2047:
                   2048:
                   2049: /* ARGSUSED */
                   2050: static int
                   2051: mdoc_quote_pre(MDOC_ARGS)
                   2052: {
                   2053:        struct htmlpair tag;
                   2054:
                   2055:        if (MDOC_BODY != n->type)
                   2056:                return(1);
                   2057:
                   2058:        switch (n->tok) {
                   2059:        case (MDOC_Ao):
                   2060:                /* FALLTHROUGH */
                   2061:        case (MDOC_Aq):
                   2062:                print_text(h, "\\(la");
                   2063:                break;
                   2064:        case (MDOC_Bro):
                   2065:                /* FALLTHROUGH */
                   2066:        case (MDOC_Brq):
                   2067:                print_text(h, "\\(lC");
                   2068:                break;
                   2069:        case (MDOC_Bo):
                   2070:                /* FALLTHROUGH */
                   2071:        case (MDOC_Bq):
                   2072:                print_text(h, "\\(lB");
                   2073:                break;
                   2074:        case (MDOC_Oo):
                   2075:                /* FALLTHROUGH */
                   2076:        case (MDOC_Op):
                   2077:                print_text(h, "\\(lB");
1.109     kristaps 2078:                h->flags |= HTML_NOSPACE;
1.107     kristaps 2079:                PAIR_CLASS_INIT(&tag, "opt");
                   2080:                print_otag(h, TAG_SPAN, 1, &tag);
                   2081:                break;
                   2082:        case (MDOC_Do):
                   2083:                /* FALLTHROUGH */
                   2084:        case (MDOC_Dq):
                   2085:                /* FALLTHROUGH */
                   2086:        case (MDOC_Qo):
                   2087:                /* FALLTHROUGH */
                   2088:        case (MDOC_Qq):
                   2089:                print_text(h, "\\(lq");
                   2090:                break;
                   2091:        case (MDOC_Po):
                   2092:                /* FALLTHROUGH */
                   2093:        case (MDOC_Pq):
                   2094:                print_text(h, "(");
                   2095:                break;
                   2096:        case (MDOC_Ql):
                   2097:                /* FALLTHROUGH */
                   2098:        case (MDOC_So):
                   2099:                /* FALLTHROUGH */
                   2100:        case (MDOC_Sq):
                   2101:                print_text(h, "\\(oq");
                   2102:                break;
                   2103:        default:
                   2104:                abort();
                   2105:                /* NOTREACHED */
                   2106:        }
                   2107:
                   2108:        h->flags |= HTML_NOSPACE;
                   2109:        return(1);
                   2110: }
                   2111:
                   2112:
                   2113: /* ARGSUSED */
                   2114: static void
                   2115: mdoc_quote_post(MDOC_ARGS)
                   2116: {
                   2117:
                   2118:        if (MDOC_BODY != n->type)
                   2119:                return;
                   2120:
                   2121:        h->flags |= HTML_NOSPACE;
                   2122:
                   2123:        switch (n->tok) {
                   2124:        case (MDOC_Ao):
                   2125:                /* FALLTHROUGH */
                   2126:        case (MDOC_Aq):
                   2127:                print_text(h, "\\(ra");
                   2128:                break;
                   2129:        case (MDOC_Bro):
                   2130:                /* FALLTHROUGH */
                   2131:        case (MDOC_Brq):
                   2132:                print_text(h, "\\(rC");
                   2133:                break;
                   2134:        case (MDOC_Oo):
                   2135:                /* FALLTHROUGH */
                   2136:        case (MDOC_Op):
                   2137:                /* FALLTHROUGH */
                   2138:        case (MDOC_Bo):
                   2139:                /* FALLTHROUGH */
                   2140:        case (MDOC_Bq):
                   2141:                print_text(h, "\\(rB");
                   2142:                break;
                   2143:        case (MDOC_Qo):
                   2144:                /* FALLTHROUGH */
                   2145:        case (MDOC_Qq):
                   2146:                /* FALLTHROUGH */
                   2147:        case (MDOC_Do):
                   2148:                /* FALLTHROUGH */
                   2149:        case (MDOC_Dq):
                   2150:                print_text(h, "\\(rq");
                   2151:                break;
                   2152:        case (MDOC_Po):
                   2153:                /* FALLTHROUGH */
                   2154:        case (MDOC_Pq):
                   2155:                print_text(h, ")");
                   2156:                break;
                   2157:        case (MDOC_Ql):
                   2158:                /* FALLTHROUGH */
                   2159:        case (MDOC_So):
                   2160:                /* FALLTHROUGH */
                   2161:        case (MDOC_Sq):
                   2162:                print_text(h, "\\(aq");
                   2163:                break;
                   2164:        default:
                   2165:                abort();
                   2166:                /* NOTREACHED */
                   2167:        }
                   2168: }
                   2169:
                   2170:

CVSweb