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

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