[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.43

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