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

Annotation of mandoc/mdoc_html.c, Revision 1.117

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

CVSweb