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

Annotation of mandoc/mdoc_html.c, Revision 1.115

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

CVSweb