[BACK]Return to mdoc_html.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Annotation of src/usr.bin/mandoc/mdoc_html.c, Revision 1.60

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