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

1.30    ! schwarze    1: /*     $Id: man_html.c,v 1.29 2011/01/04 22:28:17 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:
                    505:        /*
                    506:         * This scattering of 1-BU margins and pads is to make sure that
                    507:         * when text overruns its box, the subsequent text isn't flush
                    508:         * up against it.  However, the rest of the right-hand box must
                    509:         * also be adjusted in consideration of this 1-BU space.
                    510:         */
                    511:
                    512:        if (MAN_BODY == n->type) {
1.26      schwarze  513:                print_otag(h, TAG_TD, 0, NULL);
1.1       schwarze  514:                return(1);
                    515:        }
                    516:
                    517:        nn = MAN_BLOCK == n->type ?
                    518:                n->head->child : n->parent->head->child;
                    519:
                    520:        SCALE_HS_INIT(&su, INDENT);
                    521:
1.28      schwarze  522:        /* Width is the second token. */
1.7       schwarze  523:
1.1       schwarze  524:        if (MAN_IP == n->tok && NULL != nn)
1.28      schwarze  525:                if (NULL != (nn = nn->next))
1.30    ! schwarze  526:                        a2width(nn, &su);
1.1       schwarze  527:
1.7       schwarze  528:        /* Width is the first token. */
                    529:
                    530:        if (MAN_TP == n->tok && NULL != nn) {
                    531:                /* Skip past non-text children. */
                    532:                while (nn && MAN_TEXT != nn->type)
                    533:                        nn = nn->next;
                    534:                if (nn)
1.30    ! schwarze  535:                        a2width(nn, &su);
1.7       schwarze  536:        }
1.1       schwarze  537:
                    538:        if (MAN_BLOCK == n->type) {
1.26      schwarze  539:                print_otag(h, TAG_P, 0, NULL);
                    540:                print_otag(h, TAG_TABLE, 0, NULL);
                    541:                bufcat_su(h, "width", &su);
1.1       schwarze  542:                PAIR_STYLE_INIT(&tag, h);
1.26      schwarze  543:                print_otag(h, TAG_COL, 1, &tag);
                    544:                print_otag(h, TAG_COL, 0, NULL);
                    545:                print_otag(h, TAG_TBODY, 0, NULL);
                    546:                print_otag(h, TAG_TR, 0, NULL);
1.1       schwarze  547:                return(1);
                    548:        }
                    549:
1.26      schwarze  550:        print_otag(h, TAG_TD, 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:
                    568: /* ARGSUSED */
                    569: static int
                    570: man_HP_pre(MAN_ARGS)
                    571: {
1.26      schwarze  572:        struct htmlpair  tag;
                    573:        struct roffsu    su;
                    574:        const struct man_node *np;
1.1       schwarze  575:
1.26      schwarze  576:        np = MAN_BLOCK == n->type ?
                    577:                n->head->child :
                    578:                n->parent->head->child;
1.1       schwarze  579:
1.26      schwarze  580:        if (NULL == np || ! a2width(np, &su))
                    581:                SCALE_HS_INIT(&su, INDENT);
1.1       schwarze  582:
1.26      schwarze  583:        if (MAN_HEAD == n->type) {
                    584:                print_otag(h, TAG_TD, 0, NULL);
                    585:                return(0);
                    586:        } else if (MAN_BLOCK == n->type) {
                    587:                print_otag(h, TAG_P, 0, NULL);
                    588:                print_otag(h, TAG_TABLE, 0, NULL);
                    589:                bufcat_su(h, "width", &su);
1.1       schwarze  590:                PAIR_STYLE_INIT(&tag, h);
1.26      schwarze  591:                print_otag(h, TAG_COL, 1, &tag);
                    592:                print_otag(h, TAG_COL, 0, NULL);
                    593:                print_otag(h, TAG_TBODY, 0, NULL);
                    594:                print_otag(h, TAG_TR, 0, NULL);
1.1       schwarze  595:                return(1);
                    596:        }
                    597:
1.26      schwarze  598:        su.scale = -su.scale;
1.1       schwarze  599:        bufcat_su(h, "text-indent", &su);
                    600:        PAIR_STYLE_INIT(&tag, h);
1.26      schwarze  601:        print_otag(h, TAG_TD, 1, &tag);
1.1       schwarze  602:        return(1);
                    603: }
                    604:
                    605:
                    606: /* ARGSUSED */
                    607: static int
                    608: man_B_pre(MAN_ARGS)
                    609: {
                    610:
1.27      schwarze  611:        print_otag(h, TAG_B, 0, NULL);
1.1       schwarze  612:        return(1);
                    613: }
                    614:
                    615:
                    616: /* ARGSUSED */
                    617: static int
                    618: man_I_pre(MAN_ARGS)
                    619: {
1.4       schwarze  620:
1.27      schwarze  621:        print_otag(h, TAG_I, 0, NULL);
1.1       schwarze  622:        return(1);
1.18      schwarze  623: }
                    624:
                    625:
                    626: /* ARGSUSED */
                    627: static int
                    628: man_literal_pre(MAN_ARGS)
                    629: {
                    630:
1.21      schwarze  631:        if (MAN_nf == n->tok) {
1.18      schwarze  632:                print_otag(h, TAG_BR, 0, NULL);
                    633:                mh->fl |= MANH_LITERAL;
1.21      schwarze  634:        } else
1.18      schwarze  635:                mh->fl &= ~MANH_LITERAL;
                    636:
                    637:        return(1);
                    638: }
                    639:
                    640:
                    641: /* ARGSUSED */
                    642: static int
                    643: man_in_pre(MAN_ARGS)
                    644: {
                    645:
                    646:        print_otag(h, TAG_BR, 0, NULL);
                    647:        return(0);
1.1       schwarze  648: }
                    649:
                    650:
                    651: /* ARGSUSED */
                    652: static int
                    653: man_ign_pre(MAN_ARGS)
                    654: {
                    655:
                    656:        return(0);
                    657: }
                    658:
                    659:
                    660: /* ARGSUSED */
                    661: static int
                    662: man_RS_pre(MAN_ARGS)
                    663: {
                    664:        struct htmlpair  tag;
                    665:        struct roffsu    su;
                    666:
                    667:        if (MAN_HEAD == n->type)
                    668:                return(0);
                    669:        else if (MAN_BODY == n->type)
                    670:                return(1);
                    671:
                    672:        SCALE_HS_INIT(&su, INDENT);
1.26      schwarze  673:        if (n->head->child)
1.1       schwarze  674:                a2width(n->head->child, &su);
                    675:
1.26      schwarze  676:        bufcat_su(h, "margin-left", &su);
1.1       schwarze  677:        PAIR_STYLE_INIT(&tag, h);
                    678:        print_otag(h, TAG_DIV, 1, &tag);
                    679:        return(1);
                    680: }