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

1.44    ! schwarze    1: /*     $Id: man_html.c,v 1.43 2011/10/09 17:59:56 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");
1.44    ! schwarze  308:        PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
        !           309:        t = print_otag(h, TAG_TABLE, 3, tag);
        !           310:        PAIR_INIT(&tag[0], ATTR_WIDTH, "30%");
        !           311:        print_otag(h, TAG_COL, 1, tag);
        !           312:        print_otag(h, TAG_COL, 1, tag);
        !           313:        print_otag(h, TAG_COL, 1, tag);
1.26      schwarze  314:
                    315:        print_otag(h, TAG_TBODY, 0, NULL);
1.3       schwarze  316:
1.1       schwarze  317:        tt = print_otag(h, TAG_TR, 0, NULL);
                    318:
1.25      schwarze  319:        PAIR_CLASS_INIT(&tag[0], "head-ltitle");
1.1       schwarze  320:        print_otag(h, TAG_TD, 1, tag);
                    321:        print_text(h, title);
                    322:        print_stagq(h, tt);
                    323:
1.25      schwarze  324:        PAIR_CLASS_INIT(&tag[0], "head-vol");
1.44    ! schwarze  325:        PAIR_INIT(&tag[1], ATTR_ALIGN, "center");
        !           326:        print_otag(h, TAG_TD, 2, tag);
1.1       schwarze  327:        print_text(h, b);
                    328:        print_stagq(h, tt);
                    329:
1.25      schwarze  330:        PAIR_CLASS_INIT(&tag[0], "head-rtitle");
1.44    ! schwarze  331:        PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
        !           332:        print_otag(h, TAG_TD, 2, tag);
1.1       schwarze  333:        print_text(h, title);
                    334:        print_tagq(h, t);
                    335: }
                    336:
                    337:
                    338: /* ARGSUSED */
                    339: static void
                    340: man_root_post(MAN_ARGS)
                    341: {
1.26      schwarze  342:        struct htmlpair  tag[3];
1.1       schwarze  343:        struct tag      *t, *tt;
                    344:
1.26      schwarze  345:        PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
                    346:        PAIR_CLASS_INIT(&tag[1], "foot");
1.44    ! schwarze  347:        PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
        !           348:        t = print_otag(h, TAG_TABLE, 3, tag);
        !           349:        PAIR_INIT(&tag[0], ATTR_WIDTH, "50%");
        !           350:        print_otag(h, TAG_COL, 1, tag);
        !           351:        print_otag(h, TAG_COL, 1, tag);
1.3       schwarze  352:
1.1       schwarze  353:        tt = print_otag(h, TAG_TR, 0, NULL);
                    354:
1.25      schwarze  355:        PAIR_CLASS_INIT(&tag[0], "foot-date");
1.1       schwarze  356:        print_otag(h, TAG_TD, 1, tag);
1.25      schwarze  357:
1.35      schwarze  358:        print_text(h, m->date);
1.1       schwarze  359:        print_stagq(h, tt);
                    360:
1.25      schwarze  361:        PAIR_CLASS_INIT(&tag[0], "foot-os");
1.44    ! schwarze  362:        PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
        !           363:        print_otag(h, TAG_TD, 2, tag);
1.25      schwarze  364:
1.1       schwarze  365:        if (m->source)
                    366:                print_text(h, m->source);
                    367:        print_tagq(h, t);
                    368: }
                    369:
                    370:
                    371: /* ARGSUSED */
                    372: static int
                    373: man_br_pre(MAN_ARGS)
                    374: {
                    375:        struct roffsu    su;
                    376:        struct htmlpair  tag;
                    377:
                    378:        SCALE_VS_INIT(&su, 1);
                    379:
1.21      schwarze  380:        if (MAN_sp == n->tok) {
1.39      schwarze  381:                if (NULL != (n = n->child))
                    382:                        if ( ! a2roffsu(n->string, &su, SCALE_VS))
                    383:                                SCALE_VS_INIT(&su, atoi(n->string));
1.21      schwarze  384:        } else
1.1       schwarze  385:                su.scale = 0;
                    386:
1.38      schwarze  387:        bufinit(h);
1.1       schwarze  388:        bufcat_su(h, "height", &su);
                    389:        PAIR_STYLE_INIT(&tag, h);
                    390:        print_otag(h, TAG_DIV, 1, &tag);
1.4       schwarze  391:
1.3       schwarze  392:        /* So the div isn't empty: */
                    393:        print_text(h, "\\~");
                    394:
1.1       schwarze  395:        return(0);
                    396: }
                    397:
                    398: /* ARGSUSED */
                    399: static int
                    400: man_SH_pre(MAN_ARGS)
                    401: {
1.25      schwarze  402:        struct htmlpair  tag;
1.1       schwarze  403:
1.25      schwarze  404:        if (MAN_BLOCK == n->type) {
1.39      schwarze  405:                mh->fl &= ~MANH_LITERAL;
1.25      schwarze  406:                PAIR_CLASS_INIT(&tag, "section");
                    407:                print_otag(h, TAG_DIV, 1, &tag);
1.1       schwarze  408:                return(1);
1.25      schwarze  409:        } else if (MAN_BODY == n->type)
1.1       schwarze  410:                return(1);
                    411:
1.25      schwarze  412:        print_otag(h, TAG_H1, 0, NULL);
1.1       schwarze  413:        return(1);
                    414: }
                    415:
                    416: /* ARGSUSED */
                    417: static int
                    418: man_alt_pre(MAN_ARGS)
                    419: {
                    420:        const struct man_node   *nn;
1.40      schwarze  421:        int              i, savelit;
1.27      schwarze  422:        enum htmltag     fp;
                    423:        struct tag      *t;
1.1       schwarze  424:
1.40      schwarze  425:        if ((savelit = mh->fl & MANH_LITERAL))
                    426:                print_otag(h, TAG_BR, 0, NULL);
                    427:
                    428:        mh->fl &= ~MANH_LITERAL;
                    429:
1.1       schwarze  430:        for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.27      schwarze  431:                t = NULL;
1.1       schwarze  432:                switch (n->tok) {
                    433:                case (MAN_BI):
1.27      schwarze  434:                        fp = i % 2 ? TAG_I : TAG_B;
1.1       schwarze  435:                        break;
                    436:                case (MAN_IB):
1.27      schwarze  437:                        fp = i % 2 ? TAG_B : TAG_I;
1.1       schwarze  438:                        break;
                    439:                case (MAN_RI):
1.27      schwarze  440:                        fp = i % 2 ? TAG_I : TAG_MAX;
1.1       schwarze  441:                        break;
                    442:                case (MAN_IR):
1.27      schwarze  443:                        fp = i % 2 ? TAG_MAX : TAG_I;
1.1       schwarze  444:                        break;
                    445:                case (MAN_BR):
1.27      schwarze  446:                        fp = i % 2 ? TAG_MAX : TAG_B;
1.1       schwarze  447:                        break;
                    448:                case (MAN_RB):
1.27      schwarze  449:                        fp = i % 2 ? TAG_B : TAG_MAX;
1.1       schwarze  450:                        break;
                    451:                default:
                    452:                        abort();
                    453:                        /* NOTREACHED */
                    454:                }
                    455:
                    456:                if (i)
                    457:                        h->flags |= HTML_NOSPACE;
                    458:
1.27      schwarze  459:                if (TAG_MAX != fp)
                    460:                        t = print_otag(h, fp, 0, NULL);
                    461:
1.18      schwarze  462:                print_man_node(m, nn, mh, h);
1.27      schwarze  463:
                    464:                if (t)
                    465:                        print_tagq(h, t);
1.1       schwarze  466:        }
                    467:
1.40      schwarze  468:        if (savelit)
                    469:                mh->fl |= MANH_LITERAL;
                    470:
1.1       schwarze  471:        return(0);
                    472: }
                    473:
                    474: /* ARGSUSED */
                    475: static int
1.26      schwarze  476: man_SM_pre(MAN_ARGS)
1.1       schwarze  477: {
                    478:
1.27      schwarze  479:        print_otag(h, TAG_SMALL, 0, NULL);
1.26      schwarze  480:        if (MAN_SB == n->tok)
1.27      schwarze  481:                print_otag(h, TAG_B, 0, NULL);
1.1       schwarze  482:        return(1);
                    483: }
                    484:
                    485: /* ARGSUSED */
                    486: static int
                    487: man_SS_pre(MAN_ARGS)
                    488: {
1.25      schwarze  489:        struct htmlpair  tag;
1.1       schwarze  490:
1.25      schwarze  491:        if (MAN_BLOCK == n->type) {
1.39      schwarze  492:                mh->fl &= ~MANH_LITERAL;
1.25      schwarze  493:                PAIR_CLASS_INIT(&tag, "subsection");
                    494:                print_otag(h, TAG_DIV, 1, &tag);
1.1       schwarze  495:                return(1);
1.25      schwarze  496:        } else if (MAN_BODY == n->type)
1.1       schwarze  497:                return(1);
                    498:
1.25      schwarze  499:        print_otag(h, TAG_H2, 0, NULL);
1.1       schwarze  500:        return(1);
                    501: }
                    502:
                    503: /* ARGSUSED */
                    504: static int
                    505: man_PP_pre(MAN_ARGS)
                    506: {
                    507:
1.22      schwarze  508:        if (MAN_HEAD == n->type)
                    509:                return(0);
1.39      schwarze  510:        else if (MAN_BLOCK == n->type)
                    511:                print_bvspace(h, n);
1.22      schwarze  512:
1.1       schwarze  513:        return(1);
                    514: }
                    515:
                    516: /* ARGSUSED */
                    517: static int
                    518: man_IP_pre(MAN_ARGS)
                    519: {
                    520:        const struct man_node   *nn;
                    521:
                    522:        if (MAN_BODY == n->type) {
1.40      schwarze  523:                print_otag(h, TAG_DD, 0, NULL);
                    524:                return(1);
                    525:        } else if (MAN_HEAD != n->type) {
                    526:                print_otag(h, TAG_DL, 0, NULL);
1.1       schwarze  527:                return(1);
                    528:        }
                    529:
1.40      schwarze  530:        /* FIXME: width specification. */
1.7       schwarze  531:
1.40      schwarze  532:        print_otag(h, TAG_DT, 0, NULL);
1.1       schwarze  533:
1.28      schwarze  534:        /* For IP, only print the first header element. */
1.1       schwarze  535:
1.28      schwarze  536:        if (MAN_IP == n->tok && n->child)
                    537:                print_man_node(m, n->child, mh, h);
1.7       schwarze  538:
1.28      schwarze  539:        /* For TP, only print next-line header elements. */
1.1       schwarze  540:
                    541:        if (MAN_TP == n->tok)
1.28      schwarze  542:                for (nn = n->child; nn; nn = nn->next)
                    543:                        if (nn->line > n->line)
                    544:                                print_man_node(m, nn, mh, h);
1.1       schwarze  545:
                    546:        return(0);
                    547: }
                    548:
                    549: /* ARGSUSED */
                    550: static int
                    551: man_HP_pre(MAN_ARGS)
                    552: {
1.26      schwarze  553:        struct htmlpair  tag;
                    554:        struct roffsu    su;
                    555:        const struct man_node *np;
1.1       schwarze  556:
1.40      schwarze  557:        if (MAN_HEAD == n->type)
                    558:                return(0);
                    559:        else if (MAN_BLOCK != n->type)
                    560:                return(1);
1.38      schwarze  561:
1.40      schwarze  562:        np = n->head->child;
1.1       schwarze  563:
1.26      schwarze  564:        if (NULL == np || ! a2width(np, &su))
                    565:                SCALE_HS_INIT(&su, INDENT);
1.1       schwarze  566:
1.40      schwarze  567:        bufinit(h);
1.1       schwarze  568:
1.40      schwarze  569:        print_bvspace(h, n);
                    570:        bufcat_su(h, "margin-left", &su);
1.26      schwarze  571:        su.scale = -su.scale;
1.1       schwarze  572:        bufcat_su(h, "text-indent", &su);
                    573:        PAIR_STYLE_INIT(&tag, h);
1.40      schwarze  574:        print_otag(h, TAG_P, 1, &tag);
1.1       schwarze  575:        return(1);
                    576: }
                    577:
                    578: /* ARGSUSED */
                    579: static int
                    580: man_B_pre(MAN_ARGS)
                    581: {
                    582:
1.27      schwarze  583:        print_otag(h, TAG_B, 0, NULL);
1.1       schwarze  584:        return(1);
                    585: }
                    586:
                    587: /* ARGSUSED */
                    588: static int
                    589: man_I_pre(MAN_ARGS)
                    590: {
1.4       schwarze  591:
1.27      schwarze  592:        print_otag(h, TAG_I, 0, NULL);
1.1       schwarze  593:        return(1);
1.18      schwarze  594: }
                    595:
                    596: /* ARGSUSED */
                    597: static int
                    598: man_literal_pre(MAN_ARGS)
                    599: {
                    600:
1.40      schwarze  601:        if (MAN_nf != n->tok) {
1.18      schwarze  602:                print_otag(h, TAG_BR, 0, NULL);
1.40      schwarze  603:                mh->fl &= ~MANH_LITERAL;
                    604:        } else
1.18      schwarze  605:                mh->fl |= MANH_LITERAL;
                    606:
1.34      schwarze  607:        return(0);
1.18      schwarze  608: }
                    609:
                    610: /* ARGSUSED */
                    611: static int
                    612: man_in_pre(MAN_ARGS)
                    613: {
                    614:
                    615:        print_otag(h, TAG_BR, 0, NULL);
                    616:        return(0);
1.1       schwarze  617: }
                    618:
                    619: /* ARGSUSED */
                    620: static int
                    621: man_ign_pre(MAN_ARGS)
                    622: {
                    623:
                    624:        return(0);
                    625: }
                    626:
                    627: /* ARGSUSED */
                    628: static int
                    629: man_RS_pre(MAN_ARGS)
                    630: {
                    631:        struct htmlpair  tag;
                    632:        struct roffsu    su;
                    633:
                    634:        if (MAN_HEAD == n->type)
                    635:                return(0);
                    636:        else if (MAN_BODY == n->type)
                    637:                return(1);
                    638:
                    639:        SCALE_HS_INIT(&su, INDENT);
1.26      schwarze  640:        if (n->head->child)
1.1       schwarze  641:                a2width(n->head->child, &su);
                    642:
1.38      schwarze  643:        bufinit(h);
1.26      schwarze  644:        bufcat_su(h, "margin-left", &su);
1.1       schwarze  645:        PAIR_STYLE_INIT(&tag, h);
                    646:        print_otag(h, TAG_DIV, 1, &tag);
                    647:        return(1);
                    648: }