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

Annotation of mandoc/mdoc_html.c, Revision 1.120

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

CVSweb