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

Annotation of mandoc/mdoc_html.c, Revision 1.118

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

CVSweb