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

Annotation of src/usr.bin/mandoc/man_html.c, Revision 1.40

1.40    ! schwarze    1: /*     $Id: man_html.c,v 1.39 2011/07/05 04:12:41 schwarze Exp $ */
1.1       schwarze    2: /*
1.29      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:
1.14      schwarze   25: #include "mandoc.h"
1.1       schwarze   26: #include "out.h"
                     27: #include "html.h"
                     28: #include "man.h"
                     29: #include "main.h"
                     30:
                     31: /* TODO: preserve ident widths. */
1.2       schwarze   32: /* FIXME: have PD set the default vspace width. */
1.1       schwarze   33:
                     34: #define        INDENT            5
                     35: #define        HALFINDENT        3
                     36:
                     37: #define        MAN_ARGS          const struct man_meta *m, \
                     38:                          const struct man_node *n, \
1.18      schwarze   39:                          struct mhtml *mh, \
1.1       schwarze   40:                          struct html *h
                     41:
1.18      schwarze   42: struct mhtml {
                     43:        int               fl;
                     44: #define        MANH_LITERAL     (1 << 0) /* literal context */
                     45: };
                     46:
1.1       schwarze   47: struct htmlman {
                     48:        int             (*pre)(MAN_ARGS);
                     49:        int             (*post)(MAN_ARGS);
                     50: };
                     51:
1.39      schwarze   52: static void              print_bvspace(struct html *,
                     53:                                const struct man_node *);
1.1       schwarze   54: static void              print_man(MAN_ARGS);
                     55: static void              print_man_head(MAN_ARGS);
                     56: static void              print_man_nodelist(MAN_ARGS);
                     57: static void              print_man_node(MAN_ARGS);
                     58:
                     59: static int               a2width(const struct man_node *,
                     60:                                struct roffsu *);
                     61:
                     62: static int               man_alt_pre(MAN_ARGS);
                     63: static int               man_br_pre(MAN_ARGS);
                     64: static int               man_ign_pre(MAN_ARGS);
1.18      schwarze   65: static int               man_in_pre(MAN_ARGS);
                     66: static int               man_literal_pre(MAN_ARGS);
1.1       schwarze   67: static void              man_root_post(MAN_ARGS);
1.38      schwarze   68: static void              man_root_pre(MAN_ARGS);
1.1       schwarze   69: static int               man_B_pre(MAN_ARGS);
                     70: static int               man_HP_pre(MAN_ARGS);
                     71: static int               man_I_pre(MAN_ARGS);
                     72: static int               man_IP_pre(MAN_ARGS);
                     73: static int               man_PP_pre(MAN_ARGS);
                     74: static int               man_RS_pre(MAN_ARGS);
                     75: static int               man_SH_pre(MAN_ARGS);
                     76: static int               man_SM_pre(MAN_ARGS);
                     77: static int               man_SS_pre(MAN_ARGS);
                     78:
                     79: static const struct htmlman mans[MAN_MAX] = {
                     80:        { man_br_pre, NULL }, /* br */
                     81:        { NULL, NULL }, /* TH */
                     82:        { man_SH_pre, NULL }, /* SH */
                     83:        { man_SS_pre, NULL }, /* SS */
                     84:        { man_IP_pre, NULL }, /* TP */
                     85:        { man_PP_pre, NULL }, /* LP */
                     86:        { man_PP_pre, NULL }, /* PP */
                     87:        { man_PP_pre, NULL }, /* P */
                     88:        { man_IP_pre, NULL }, /* IP */
                     89:        { man_HP_pre, NULL }, /* HP */
                     90:        { man_SM_pre, NULL }, /* SM */
1.26      schwarze   91:        { man_SM_pre, NULL }, /* SB */
1.1       schwarze   92:        { man_alt_pre, NULL }, /* BI */
                     93:        { man_alt_pre, NULL }, /* IB */
                     94:        { man_alt_pre, NULL }, /* BR */
                     95:        { man_alt_pre, NULL }, /* RB */
                     96:        { NULL, NULL }, /* R */
                     97:        { man_B_pre, NULL }, /* B */
                     98:        { man_I_pre, NULL }, /* I */
                     99:        { man_alt_pre, NULL }, /* IR */
                    100:        { man_alt_pre, NULL }, /* RI */
1.34      schwarze  101:        { man_ign_pre, NULL }, /* na */
1.1       schwarze  102:        { man_br_pre, NULL }, /* sp */
1.18      schwarze  103:        { man_literal_pre, NULL }, /* nf */
                    104:        { man_literal_pre, NULL }, /* fi */
1.1       schwarze  105:        { NULL, NULL }, /* RE */
                    106:        { man_RS_pre, NULL }, /* RS */
                    107:        { man_ign_pre, NULL }, /* DT */
                    108:        { man_ign_pre, NULL }, /* UC */
1.2       schwarze  109:        { man_ign_pre, NULL }, /* PD */
1.13      schwarze  110:        { man_ign_pre, NULL }, /* AT */
1.18      schwarze  111:        { man_in_pre, NULL }, /* in */
1.23      schwarze  112:        { man_ign_pre, NULL }, /* ft */
1.1       schwarze  113: };
                    114:
1.39      schwarze  115: /*
                    116:  * Printing leading vertical space before a block.
                    117:  * This is used for the paragraph macros.
                    118:  * The rules are pretty simple, since there's very little nesting going
                    119:  * on here.  Basically, if we're the first within another block (SS/SH),
                    120:  * then don't emit vertical space.  If we are (RS), then do.  If not the
                    121:  * first, print it.
                    122:  */
                    123: static void
                    124: print_bvspace(struct html *h, const struct man_node *n)
                    125: {
                    126:
                    127:        if (n->body && n->body->child)
                    128:                if (MAN_TBL == n->body->child->type)
                    129:                        return;
                    130:
                    131:        if (MAN_ROOT == n->parent->type || MAN_RS != n->parent->tok)
                    132:                if (NULL == n->prev)
                    133:                        return;
                    134:
                    135:        print_otag(h, TAG_P, 0, NULL);
                    136: }
1.1       schwarze  137:
                    138: void
                    139: html_man(void *arg, const struct man *m)
                    140: {
                    141:        struct html     *h;
                    142:        struct tag      *t;
1.18      schwarze  143:        struct mhtml     mh;
1.1       schwarze  144:
                    145:        h = (struct html *)arg;
                    146:
1.5       schwarze  147:        print_gen_decls(h);
1.1       schwarze  148:
1.18      schwarze  149:        memset(&mh, 0, sizeof(struct mhtml));
                    150:
1.1       schwarze  151:        t = print_otag(h, TAG_HTML, 0, NULL);
1.18      schwarze  152:        print_man(man_meta(m), man_node(m), &mh, h);
1.1       schwarze  153:        print_tagq(h, t);
                    154:
                    155:        printf("\n");
                    156: }
                    157:
                    158: static void
                    159: print_man(MAN_ARGS)
                    160: {
                    161:        struct tag      *t;
                    162:
                    163:        t = print_otag(h, TAG_HEAD, 0, NULL);
1.18      schwarze  164:        print_man_head(m, n, mh, h);
1.1       schwarze  165:        print_tagq(h, t);
1.25      schwarze  166:
1.1       schwarze  167:        t = print_otag(h, TAG_BODY, 0, NULL);
1.18      schwarze  168:        print_man_nodelist(m, n, mh, h);
1.1       schwarze  169:        print_tagq(h, t);
                    170: }
                    171:
                    172:
                    173: /* ARGSUSED */
                    174: static void
                    175: print_man_head(MAN_ARGS)
                    176: {
                    177:
                    178:        print_gen_head(h);
1.38      schwarze  179:        bufcat_fmt(h, "%s(%s)", m->title, m->msec);
1.1       schwarze  180:        print_otag(h, TAG_TITLE, 0, NULL);
                    181:        print_text(h, h->buf);
                    182: }
                    183:
                    184:
                    185: static void
                    186: print_man_nodelist(MAN_ARGS)
                    187: {
                    188:
1.18      schwarze  189:        print_man_node(m, n, mh, h);
1.1       schwarze  190:        if (n->next)
1.18      schwarze  191:                print_man_nodelist(m, n->next, mh, h);
1.1       schwarze  192: }
                    193:
                    194:
                    195: static void
                    196: print_man_node(MAN_ARGS)
                    197: {
                    198:        int              child;
                    199:        struct tag      *t;
1.37      schwarze  200:        struct htmlpair  tag;
1.1       schwarze  201:
                    202:        child = 1;
1.2       schwarze  203:        t = h->tags.head;
1.1       schwarze  204:
                    205:        switch (n->type) {
                    206:        case (MAN_ROOT):
1.38      schwarze  207:                man_root_pre(m, n, mh, h);
1.1       schwarze  208:                break;
                    209:        case (MAN_TEXT):
1.38      schwarze  210:                /*
                    211:                 * If we have a blank line, output a vertical space.
                    212:                 * If we have a space as the first character, break
                    213:                 * before printing the line's data.
                    214:                 */
1.31      schwarze  215:                if ('\0' == *n->string) {
                    216:                        print_otag(h, TAG_P, 0, NULL);
                    217:                        return;
1.40    ! schwarze  218:                }
        !           219:
        !           220:                if (' ' == *n->string && MAN_LINE & n->flags)
        !           221:                        print_otag(h, TAG_BR, 0, NULL);
        !           222:                else if (MANH_LITERAL & mh->fl && n->prev)
1.31      schwarze  223:                        print_otag(h, TAG_BR, 0, NULL);
                    224:
1.1       schwarze  225:                print_text(h, n->string);
1.36      schwarze  226:                return;
                    227:        case (MAN_EQN):
1.37      schwarze  228:                PAIR_CLASS_INIT(&tag, "eqn");
                    229:                print_otag(h, TAG_SPAN, 1, &tag);
1.36      schwarze  230:                print_text(h, n->eqn->data);
1.37      schwarze  231:                break;
1.29      schwarze  232:        case (MAN_TBL):
1.33      schwarze  233:                /*
                    234:                 * This will take care of initialising all of the table
                    235:                 * state data for the first table, then tearing it down
                    236:                 * for the last one.
                    237:                 */
1.29      schwarze  238:                print_tbl(h, n->span);
1.32      schwarze  239:                return;
1.1       schwarze  240:        default:
1.4       schwarze  241:                /*
                    242:                 * Close out scope of font prior to opening a macro
1.33      schwarze  243:                 * scope.
1.4       schwarze  244:                 */
1.27      schwarze  245:                if (HTMLFONT_NONE != h->metac) {
                    246:                        h->metal = h->metac;
                    247:                        h->metac = HTMLFONT_NONE;
1.33      schwarze  248:                }
                    249:
                    250:                /*
                    251:                 * Close out the current table, if it's open, and unset
                    252:                 * the "meta" table state.  This will be reopened on the
                    253:                 * next table element.
                    254:                 */
                    255:                if (h->tblt) {
                    256:                        print_tblclose(h);
                    257:                        t = h->tags.head;
1.4       schwarze  258:                }
1.1       schwarze  259:                if (mans[n->tok].pre)
1.18      schwarze  260:                        child = (*mans[n->tok].pre)(m, n, mh, h);
1.1       schwarze  261:                break;
                    262:        }
                    263:
                    264:        if (child && n->child)
1.18      schwarze  265:                print_man_nodelist(m, n->child, mh, h);
1.1       schwarze  266:
1.4       schwarze  267:        /* This will automatically close out any font scope. */
1.1       schwarze  268:        print_stagq(h, t);
                    269:
                    270:        switch (n->type) {
                    271:        case (MAN_ROOT):
1.18      schwarze  272:                man_root_post(m, n, mh, h);
1.37      schwarze  273:                break;
                    274:        case (MAN_EQN):
1.1       schwarze  275:                break;
                    276:        default:
                    277:                if (mans[n->tok].post)
1.18      schwarze  278:                        (*mans[n->tok].post)(m, n, mh, h);
1.1       schwarze  279:                break;
                    280:        }
                    281: }
                    282:
                    283:
                    284: static int
                    285: a2width(const struct man_node *n, struct roffsu *su)
                    286: {
                    287:
                    288:        if (MAN_TEXT != n->type)
                    289:                return(0);
                    290:        if (a2roffsu(n->string, su, SCALE_BU))
                    291:                return(1);
                    292:
                    293:        return(0);
                    294: }
                    295:
                    296:
                    297: /* ARGSUSED */
1.38      schwarze  298: static void
1.1       schwarze  299: man_root_pre(MAN_ARGS)
                    300: {
1.26      schwarze  301:        struct htmlpair  tag[3];
1.1       schwarze  302:        struct tag      *t, *tt;
                    303:        char             b[BUFSIZ], title[BUFSIZ];
                    304:
                    305:        b[0] = 0;
                    306:        if (m->vol)
                    307:                (void)strlcat(b, m->vol, BUFSIZ);
                    308:
1.10      schwarze  309:        snprintf(title, BUFSIZ - 1, "%s(%s)", m->title, m->msec);
1.1       schwarze  310:
1.26      schwarze  311:        PAIR_SUMMARY_INIT(&tag[0], "Document Header");
                    312:        PAIR_CLASS_INIT(&tag[1], "head");
                    313:        if (NULL == h->style) {
                    314:                PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
                    315:                t = print_otag(h, TAG_TABLE, 3, tag);
                    316:                PAIR_INIT(&tag[0], ATTR_WIDTH, "30%");
                    317:                print_otag(h, TAG_COL, 1, tag);
                    318:                print_otag(h, TAG_COL, 1, tag);
                    319:                print_otag(h, TAG_COL, 1, tag);
                    320:        } else
                    321:                t = print_otag(h, TAG_TABLE, 2, tag);
                    322:
                    323:        print_otag(h, TAG_TBODY, 0, NULL);
1.3       schwarze  324:
1.1       schwarze  325:        tt = print_otag(h, TAG_TR, 0, NULL);
                    326:
1.25      schwarze  327:        PAIR_CLASS_INIT(&tag[0], "head-ltitle");
1.1       schwarze  328:        print_otag(h, TAG_TD, 1, tag);
1.25      schwarze  329:
1.1       schwarze  330:        print_text(h, title);
                    331:        print_stagq(h, tt);
                    332:
1.25      schwarze  333:        PAIR_CLASS_INIT(&tag[0], "head-vol");
1.26      schwarze  334:        if (NULL == h->style) {
                    335:                PAIR_INIT(&tag[1], ATTR_ALIGN, "center");
                    336:                print_otag(h, TAG_TD, 2, tag);
                    337:        } else
                    338:                print_otag(h, TAG_TD, 1, tag);
1.25      schwarze  339:
1.1       schwarze  340:        print_text(h, b);
                    341:        print_stagq(h, tt);
                    342:
1.25      schwarze  343:        PAIR_CLASS_INIT(&tag[0], "head-rtitle");
1.26      schwarze  344:        if (NULL == h->style) {
                    345:                PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
                    346:                print_otag(h, TAG_TD, 2, tag);
                    347:        } else
                    348:                print_otag(h, TAG_TD, 1, tag);
1.25      schwarze  349:
1.1       schwarze  350:        print_text(h, title);
                    351:        print_tagq(h, t);
                    352: }
                    353:
                    354:
                    355: /* ARGSUSED */
                    356: static void
                    357: man_root_post(MAN_ARGS)
                    358: {
1.26      schwarze  359:        struct htmlpair  tag[3];
1.1       schwarze  360:        struct tag      *t, *tt;
                    361:
1.26      schwarze  362:        PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
                    363:        PAIR_CLASS_INIT(&tag[1], "foot");
                    364:        if (NULL == h->style) {
                    365:                PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
                    366:                t = print_otag(h, TAG_TABLE, 3, tag);
                    367:                PAIR_INIT(&tag[0], ATTR_WIDTH, "50%");
                    368:                print_otag(h, TAG_COL, 1, tag);
                    369:                print_otag(h, TAG_COL, 1, tag);
                    370:        } else
                    371:                t = print_otag(h, TAG_TABLE, 2, tag);
1.3       schwarze  372:
1.1       schwarze  373:        tt = print_otag(h, TAG_TR, 0, NULL);
                    374:
1.25      schwarze  375:        PAIR_CLASS_INIT(&tag[0], "foot-date");
1.1       schwarze  376:        print_otag(h, TAG_TD, 1, tag);
1.25      schwarze  377:
1.35      schwarze  378:        print_text(h, m->date);
1.1       schwarze  379:        print_stagq(h, tt);
                    380:
1.25      schwarze  381:        PAIR_CLASS_INIT(&tag[0], "foot-os");
1.26      schwarze  382:        if (NULL == h->style) {
                    383:                PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
                    384:                print_otag(h, TAG_TD, 2, tag);
                    385:        } else
                    386:                print_otag(h, TAG_TD, 1, tag);
1.25      schwarze  387:
1.1       schwarze  388:        if (m->source)
                    389:                print_text(h, m->source);
                    390:        print_tagq(h, t);
                    391: }
                    392:
                    393:
                    394: /* ARGSUSED */
                    395: static int
                    396: man_br_pre(MAN_ARGS)
                    397: {
                    398:        struct roffsu    su;
                    399:        struct htmlpair  tag;
                    400:
                    401:        SCALE_VS_INIT(&su, 1);
                    402:
1.21      schwarze  403:        if (MAN_sp == n->tok) {
1.39      schwarze  404:                if (NULL != (n = n->child))
                    405:                        if ( ! a2roffsu(n->string, &su, SCALE_VS))
                    406:                                SCALE_VS_INIT(&su, atoi(n->string));
1.21      schwarze  407:        } else
1.1       schwarze  408:                su.scale = 0;
                    409:
1.38      schwarze  410:        bufinit(h);
1.1       schwarze  411:        bufcat_su(h, "height", &su);
                    412:        PAIR_STYLE_INIT(&tag, h);
                    413:        print_otag(h, TAG_DIV, 1, &tag);
1.4       schwarze  414:
1.3       schwarze  415:        /* So the div isn't empty: */
                    416:        print_text(h, "\\~");
                    417:
1.1       schwarze  418:        return(0);
                    419: }
                    420:
                    421: /* ARGSUSED */
                    422: static int
                    423: man_SH_pre(MAN_ARGS)
                    424: {
1.25      schwarze  425:        struct htmlpair  tag;
1.1       schwarze  426:
1.25      schwarze  427:        if (MAN_BLOCK == n->type) {
1.39      schwarze  428:                mh->fl &= ~MANH_LITERAL;
1.25      schwarze  429:                PAIR_CLASS_INIT(&tag, "section");
                    430:                print_otag(h, TAG_DIV, 1, &tag);
1.1       schwarze  431:                return(1);
1.25      schwarze  432:        } else if (MAN_BODY == n->type)
1.1       schwarze  433:                return(1);
                    434:
1.25      schwarze  435:        print_otag(h, TAG_H1, 0, NULL);
1.1       schwarze  436:        return(1);
                    437: }
                    438:
                    439: /* ARGSUSED */
                    440: static int
                    441: man_alt_pre(MAN_ARGS)
                    442: {
                    443:        const struct man_node   *nn;
1.40    ! schwarze  444:        int              i, savelit;
1.27      schwarze  445:        enum htmltag     fp;
                    446:        struct tag      *t;
1.1       schwarze  447:
1.40    ! schwarze  448:        if ((savelit = mh->fl & MANH_LITERAL))
        !           449:                print_otag(h, TAG_BR, 0, NULL);
        !           450:
        !           451:        mh->fl &= ~MANH_LITERAL;
        !           452:
1.1       schwarze  453:        for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.27      schwarze  454:                t = NULL;
1.1       schwarze  455:                switch (n->tok) {
                    456:                case (MAN_BI):
1.27      schwarze  457:                        fp = i % 2 ? TAG_I : TAG_B;
1.1       schwarze  458:                        break;
                    459:                case (MAN_IB):
1.27      schwarze  460:                        fp = i % 2 ? TAG_B : TAG_I;
1.1       schwarze  461:                        break;
                    462:                case (MAN_RI):
1.27      schwarze  463:                        fp = i % 2 ? TAG_I : TAG_MAX;
1.1       schwarze  464:                        break;
                    465:                case (MAN_IR):
1.27      schwarze  466:                        fp = i % 2 ? TAG_MAX : TAG_I;
1.1       schwarze  467:                        break;
                    468:                case (MAN_BR):
1.27      schwarze  469:                        fp = i % 2 ? TAG_MAX : TAG_B;
1.1       schwarze  470:                        break;
                    471:                case (MAN_RB):
1.27      schwarze  472:                        fp = i % 2 ? TAG_B : TAG_MAX;
1.1       schwarze  473:                        break;
                    474:                default:
                    475:                        abort();
                    476:                        /* NOTREACHED */
                    477:                }
                    478:
                    479:                if (i)
                    480:                        h->flags |= HTML_NOSPACE;
                    481:
1.27      schwarze  482:                if (TAG_MAX != fp)
                    483:                        t = print_otag(h, fp, 0, NULL);
                    484:
1.18      schwarze  485:                print_man_node(m, nn, mh, h);
1.27      schwarze  486:
                    487:                if (t)
                    488:                        print_tagq(h, t);
1.1       schwarze  489:        }
                    490:
1.40    ! schwarze  491:        if (savelit)
        !           492:                mh->fl |= MANH_LITERAL;
        !           493:
1.1       schwarze  494:        return(0);
                    495: }
                    496:
                    497: /* ARGSUSED */
                    498: static int
1.26      schwarze  499: man_SM_pre(MAN_ARGS)
1.1       schwarze  500: {
                    501:
1.27      schwarze  502:        print_otag(h, TAG_SMALL, 0, NULL);
1.26      schwarze  503:        if (MAN_SB == n->tok)
1.27      schwarze  504:                print_otag(h, TAG_B, 0, NULL);
1.1       schwarze  505:        return(1);
                    506: }
                    507:
                    508: /* ARGSUSED */
                    509: static int
                    510: man_SS_pre(MAN_ARGS)
                    511: {
1.25      schwarze  512:        struct htmlpair  tag;
1.1       schwarze  513:
1.25      schwarze  514:        if (MAN_BLOCK == n->type) {
1.39      schwarze  515:                mh->fl &= ~MANH_LITERAL;
1.25      schwarze  516:                PAIR_CLASS_INIT(&tag, "subsection");
                    517:                print_otag(h, TAG_DIV, 1, &tag);
1.1       schwarze  518:                return(1);
1.25      schwarze  519:        } else if (MAN_BODY == n->type)
1.1       schwarze  520:                return(1);
                    521:
1.25      schwarze  522:        print_otag(h, TAG_H2, 0, NULL);
1.1       schwarze  523:        return(1);
                    524: }
                    525:
                    526: /* ARGSUSED */
                    527: static int
                    528: man_PP_pre(MAN_ARGS)
                    529: {
                    530:
1.22      schwarze  531:        if (MAN_HEAD == n->type)
                    532:                return(0);
1.39      schwarze  533:        else if (MAN_BLOCK == n->type)
                    534:                print_bvspace(h, n);
1.22      schwarze  535:
1.1       schwarze  536:        return(1);
                    537: }
                    538:
                    539: /* ARGSUSED */
                    540: static int
                    541: man_IP_pre(MAN_ARGS)
                    542: {
                    543:        const struct man_node   *nn;
                    544:
                    545:        if (MAN_BODY == n->type) {
1.40    ! schwarze  546:                print_otag(h, TAG_DD, 0, NULL);
        !           547:                return(1);
        !           548:        } else if (MAN_HEAD != n->type) {
        !           549:                print_otag(h, TAG_DL, 0, NULL);
1.1       schwarze  550:                return(1);
                    551:        }
                    552:
1.40    ! schwarze  553:        /* FIXME: width specification. */
1.7       schwarze  554:
1.40    ! schwarze  555:        print_otag(h, TAG_DT, 0, NULL);
1.1       schwarze  556:
1.28      schwarze  557:        /* For IP, only print the first header element. */
1.1       schwarze  558:
1.28      schwarze  559:        if (MAN_IP == n->tok && n->child)
                    560:                print_man_node(m, n->child, mh, h);
1.7       schwarze  561:
1.28      schwarze  562:        /* For TP, only print next-line header elements. */
1.1       schwarze  563:
                    564:        if (MAN_TP == n->tok)
1.28      schwarze  565:                for (nn = n->child; nn; nn = nn->next)
                    566:                        if (nn->line > n->line)
                    567:                                print_man_node(m, nn, mh, h);
1.1       schwarze  568:
                    569:        return(0);
                    570: }
                    571:
                    572: /* ARGSUSED */
                    573: static int
                    574: man_HP_pre(MAN_ARGS)
                    575: {
1.26      schwarze  576:        struct htmlpair  tag;
                    577:        struct roffsu    su;
                    578:        const struct man_node *np;
1.1       schwarze  579:
1.40    ! schwarze  580:        if (MAN_HEAD == n->type)
        !           581:                return(0);
        !           582:        else if (MAN_BLOCK != n->type)
        !           583:                return(1);
1.38      schwarze  584:
1.40    ! schwarze  585:        np = n->head->child;
1.1       schwarze  586:
1.26      schwarze  587:        if (NULL == np || ! a2width(np, &su))
                    588:                SCALE_HS_INIT(&su, INDENT);
1.1       schwarze  589:
1.40    ! schwarze  590:        bufinit(h);
1.1       schwarze  591:
1.40    ! schwarze  592:        print_bvspace(h, n);
        !           593:        bufcat_su(h, "margin-left", &su);
1.26      schwarze  594:        su.scale = -su.scale;
1.1       schwarze  595:        bufcat_su(h, "text-indent", &su);
                    596:        PAIR_STYLE_INIT(&tag, h);
1.40    ! schwarze  597:        print_otag(h, TAG_P, 1, &tag);
1.1       schwarze  598:        return(1);
                    599: }
                    600:
                    601: /* ARGSUSED */
                    602: static int
                    603: man_B_pre(MAN_ARGS)
                    604: {
                    605:
1.27      schwarze  606:        print_otag(h, TAG_B, 0, NULL);
1.1       schwarze  607:        return(1);
                    608: }
                    609:
                    610: /* ARGSUSED */
                    611: static int
                    612: man_I_pre(MAN_ARGS)
                    613: {
1.4       schwarze  614:
1.27      schwarze  615:        print_otag(h, TAG_I, 0, NULL);
1.1       schwarze  616:        return(1);
1.18      schwarze  617: }
                    618:
                    619: /* ARGSUSED */
                    620: static int
                    621: man_literal_pre(MAN_ARGS)
                    622: {
                    623:
1.40    ! schwarze  624:        if (MAN_nf != n->tok) {
1.18      schwarze  625:                print_otag(h, TAG_BR, 0, NULL);
1.40    ! schwarze  626:                mh->fl &= ~MANH_LITERAL;
        !           627:        } else
1.18      schwarze  628:                mh->fl |= MANH_LITERAL;
                    629:
1.34      schwarze  630:        return(0);
1.18      schwarze  631: }
                    632:
                    633: /* ARGSUSED */
                    634: static int
                    635: man_in_pre(MAN_ARGS)
                    636: {
                    637:
                    638:        print_otag(h, TAG_BR, 0, NULL);
                    639:        return(0);
1.1       schwarze  640: }
                    641:
                    642: /* ARGSUSED */
                    643: static int
                    644: man_ign_pre(MAN_ARGS)
                    645: {
                    646:
                    647:        return(0);
                    648: }
                    649:
                    650: /* ARGSUSED */
                    651: static int
                    652: man_RS_pre(MAN_ARGS)
                    653: {
                    654:        struct htmlpair  tag;
                    655:        struct roffsu    su;
                    656:
                    657:        if (MAN_HEAD == n->type)
                    658:                return(0);
                    659:        else if (MAN_BODY == n->type)
                    660:                return(1);
                    661:
                    662:        SCALE_HS_INIT(&su, INDENT);
1.26      schwarze  663:        if (n->head->child)
1.1       schwarze  664:                a2width(n->head->child, &su);
                    665:
1.38      schwarze  666:        bufinit(h);
1.26      schwarze  667:        bufcat_su(h, "margin-left", &su);
1.1       schwarze  668:        PAIR_STYLE_INIT(&tag, h);
                    669:        print_otag(h, TAG_DIV, 1, &tag);
                    670:        return(1);
                    671: }