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

1.36    ! schwarze    1: /*     $Id: man_html.c,v 1.35 2011/03/07 01:35:33 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 */
1.34      schwarze   99:        { man_ign_pre, NULL }, /* na */
1.1       schwarze  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:
                    185:        switch (n->type) {
                    186:        case (MAN_ROOT):
1.18      schwarze  187:                child = man_root_pre(m, n, mh, h);
1.1       schwarze  188:                break;
                    189:        case (MAN_TEXT):
1.31      schwarze  190:                if ('\0' == *n->string) {
                    191:                        print_otag(h, TAG_P, 0, NULL);
                    192:                        return;
1.32      schwarze  193:                } else if (' ' == *n->string && MAN_LINE & n->flags)
1.31      schwarze  194:                        print_otag(h, TAG_BR, 0, NULL);
                    195:
1.1       schwarze  196:                print_text(h, n->string);
1.31      schwarze  197:
1.32      schwarze  198:                if (MANH_LITERAL & mh->fl &&
                    199:                                (NULL == n->next ||
                    200:                                 n->next->line > n->line))
1.18      schwarze  201:                        print_otag(h, TAG_BR, 0, NULL);
1.36    ! schwarze  202:                return;
        !           203:        case (MAN_EQN):
        !           204:                print_text(h, n->eqn->data);
1.4       schwarze  205:                return;
1.29      schwarze  206:        case (MAN_TBL):
1.33      schwarze  207:                /*
                    208:                 * This will take care of initialising all of the table
                    209:                 * state data for the first table, then tearing it down
                    210:                 * for the last one.
                    211:                 */
1.29      schwarze  212:                print_tbl(h, n->span);
1.32      schwarze  213:                return;
1.1       schwarze  214:        default:
1.4       schwarze  215:                /*
                    216:                 * Close out scope of font prior to opening a macro
1.33      schwarze  217:                 * scope.
1.4       schwarze  218:                 */
1.27      schwarze  219:                if (HTMLFONT_NONE != h->metac) {
                    220:                        h->metal = h->metac;
                    221:                        h->metac = HTMLFONT_NONE;
1.33      schwarze  222:                }
                    223:
                    224:                /*
                    225:                 * Close out the current table, if it's open, and unset
                    226:                 * the "meta" table state.  This will be reopened on the
                    227:                 * next table element.
                    228:                 */
                    229:                if (h->tblt) {
                    230:                        print_tblclose(h);
                    231:                        t = h->tags.head;
1.4       schwarze  232:                }
1.1       schwarze  233:                if (mans[n->tok].pre)
1.18      schwarze  234:                        child = (*mans[n->tok].pre)(m, n, mh, h);
1.1       schwarze  235:                break;
                    236:        }
                    237:
                    238:        if (child && n->child)
1.18      schwarze  239:                print_man_nodelist(m, n->child, mh, h);
1.1       schwarze  240:
1.4       schwarze  241:        /* This will automatically close out any font scope. */
1.1       schwarze  242:        print_stagq(h, t);
                    243:
                    244:        bufinit(h);
                    245:
                    246:        switch (n->type) {
                    247:        case (MAN_ROOT):
1.18      schwarze  248:                man_root_post(m, n, mh, h);
1.1       schwarze  249:                break;
                    250:        default:
                    251:                if (mans[n->tok].post)
1.18      schwarze  252:                        (*mans[n->tok].post)(m, n, mh, h);
1.1       schwarze  253:                break;
                    254:        }
                    255: }
                    256:
                    257:
                    258: static int
                    259: a2width(const struct man_node *n, struct roffsu *su)
                    260: {
                    261:
                    262:        if (MAN_TEXT != n->type)
                    263:                return(0);
                    264:        if (a2roffsu(n->string, su, SCALE_BU))
                    265:                return(1);
                    266:
                    267:        return(0);
                    268: }
                    269:
                    270:
                    271: /* ARGSUSED */
                    272: static int
                    273: man_root_pre(MAN_ARGS)
                    274: {
1.26      schwarze  275:        struct htmlpair  tag[3];
1.1       schwarze  276:        struct tag      *t, *tt;
                    277:        char             b[BUFSIZ], title[BUFSIZ];
                    278:
                    279:        b[0] = 0;
                    280:        if (m->vol)
                    281:                (void)strlcat(b, m->vol, BUFSIZ);
                    282:
1.10      schwarze  283:        snprintf(title, BUFSIZ - 1, "%s(%s)", m->title, m->msec);
1.1       schwarze  284:
1.26      schwarze  285:        PAIR_SUMMARY_INIT(&tag[0], "Document Header");
                    286:        PAIR_CLASS_INIT(&tag[1], "head");
                    287:        if (NULL == h->style) {
                    288:                PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
                    289:                t = print_otag(h, TAG_TABLE, 3, tag);
                    290:                PAIR_INIT(&tag[0], ATTR_WIDTH, "30%");
                    291:                print_otag(h, TAG_COL, 1, tag);
                    292:                print_otag(h, TAG_COL, 1, tag);
                    293:                print_otag(h, TAG_COL, 1, tag);
                    294:        } else
                    295:                t = print_otag(h, TAG_TABLE, 2, tag);
                    296:
                    297:        print_otag(h, TAG_TBODY, 0, NULL);
1.3       schwarze  298:
1.1       schwarze  299:        tt = print_otag(h, TAG_TR, 0, NULL);
                    300:
1.25      schwarze  301:        PAIR_CLASS_INIT(&tag[0], "head-ltitle");
1.1       schwarze  302:        print_otag(h, TAG_TD, 1, tag);
1.25      schwarze  303:
1.1       schwarze  304:        print_text(h, title);
                    305:        print_stagq(h, tt);
                    306:
1.25      schwarze  307:        PAIR_CLASS_INIT(&tag[0], "head-vol");
1.26      schwarze  308:        if (NULL == h->style) {
                    309:                PAIR_INIT(&tag[1], ATTR_ALIGN, "center");
                    310:                print_otag(h, TAG_TD, 2, tag);
                    311:        } else
                    312:                print_otag(h, TAG_TD, 1, tag);
1.25      schwarze  313:
1.1       schwarze  314:        print_text(h, b);
                    315:        print_stagq(h, tt);
                    316:
1.25      schwarze  317:        PAIR_CLASS_INIT(&tag[0], "head-rtitle");
1.26      schwarze  318:        if (NULL == h->style) {
                    319:                PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
                    320:                print_otag(h, TAG_TD, 2, tag);
                    321:        } else
                    322:                print_otag(h, TAG_TD, 1, tag);
1.25      schwarze  323:
1.1       schwarze  324:        print_text(h, title);
                    325:        print_tagq(h, t);
                    326:        return(1);
                    327: }
                    328:
                    329:
                    330: /* ARGSUSED */
                    331: static void
                    332: man_root_post(MAN_ARGS)
                    333: {
1.26      schwarze  334:        struct htmlpair  tag[3];
1.1       schwarze  335:        struct tag      *t, *tt;
                    336:
1.26      schwarze  337:        PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
                    338:        PAIR_CLASS_INIT(&tag[1], "foot");
                    339:        if (NULL == h->style) {
                    340:                PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
                    341:                t = print_otag(h, TAG_TABLE, 3, tag);
                    342:                PAIR_INIT(&tag[0], ATTR_WIDTH, "50%");
                    343:                print_otag(h, TAG_COL, 1, tag);
                    344:                print_otag(h, TAG_COL, 1, tag);
                    345:        } else
                    346:                t = print_otag(h, TAG_TABLE, 2, tag);
1.3       schwarze  347:
1.1       schwarze  348:        tt = print_otag(h, TAG_TR, 0, NULL);
                    349:
1.25      schwarze  350:        PAIR_CLASS_INIT(&tag[0], "foot-date");
1.1       schwarze  351:        print_otag(h, TAG_TD, 1, tag);
1.25      schwarze  352:
1.35      schwarze  353:        print_text(h, m->date);
1.1       schwarze  354:        print_stagq(h, tt);
                    355:
1.25      schwarze  356:        PAIR_CLASS_INIT(&tag[0], "foot-os");
1.26      schwarze  357:        if (NULL == h->style) {
                    358:                PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
                    359:                print_otag(h, TAG_TD, 2, tag);
                    360:        } else
                    361:                print_otag(h, TAG_TD, 1, tag);
1.25      schwarze  362:
1.1       schwarze  363:        if (m->source)
                    364:                print_text(h, m->source);
                    365:        print_tagq(h, t);
                    366: }
                    367:
                    368:
                    369:
                    370: /* ARGSUSED */
                    371: static int
                    372: man_br_pre(MAN_ARGS)
                    373: {
                    374:        struct roffsu    su;
                    375:        struct htmlpair  tag;
                    376:
                    377:        SCALE_VS_INIT(&su, 1);
                    378:
1.21      schwarze  379:        if (MAN_sp == n->tok) {
1.8       schwarze  380:                if (n->child)
                    381:                        a2roffsu(n->child->string, &su, SCALE_VS);
1.21      schwarze  382:        } else
1.1       schwarze  383:                su.scale = 0;
                    384:
                    385:        bufcat_su(h, "height", &su);
                    386:        PAIR_STYLE_INIT(&tag, h);
                    387:        print_otag(h, TAG_DIV, 1, &tag);
1.4       schwarze  388:
1.3       schwarze  389:        /* So the div isn't empty: */
                    390:        print_text(h, "\\~");
                    391:
1.1       schwarze  392:        return(0);
                    393: }
                    394:
                    395:
                    396: /* ARGSUSED */
                    397: static int
                    398: man_SH_pre(MAN_ARGS)
                    399: {
1.25      schwarze  400:        struct htmlpair  tag;
1.1       schwarze  401:
1.25      schwarze  402:        if (MAN_BLOCK == n->type) {
                    403:                PAIR_CLASS_INIT(&tag, "section");
                    404:                print_otag(h, TAG_DIV, 1, &tag);
1.1       schwarze  405:                return(1);
1.25      schwarze  406:        } else if (MAN_BODY == n->type)
1.1       schwarze  407:                return(1);
                    408:
1.25      schwarze  409:        print_otag(h, TAG_H1, 0, NULL);
1.1       schwarze  410:        return(1);
                    411: }
                    412:
                    413:
                    414: /* ARGSUSED */
                    415: static int
                    416: man_alt_pre(MAN_ARGS)
                    417: {
                    418:        const struct man_node   *nn;
1.27      schwarze  419:        int              i;
                    420:        enum htmltag     fp;
                    421:        struct tag      *t;
1.1       schwarze  422:
                    423:        for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.27      schwarze  424:                t = NULL;
1.1       schwarze  425:                switch (n->tok) {
                    426:                case (MAN_BI):
1.27      schwarze  427:                        fp = i % 2 ? TAG_I : TAG_B;
1.1       schwarze  428:                        break;
                    429:                case (MAN_IB):
1.27      schwarze  430:                        fp = i % 2 ? TAG_B : TAG_I;
1.1       schwarze  431:                        break;
                    432:                case (MAN_RI):
1.27      schwarze  433:                        fp = i % 2 ? TAG_I : TAG_MAX;
1.1       schwarze  434:                        break;
                    435:                case (MAN_IR):
1.27      schwarze  436:                        fp = i % 2 ? TAG_MAX : TAG_I;
1.1       schwarze  437:                        break;
                    438:                case (MAN_BR):
1.27      schwarze  439:                        fp = i % 2 ? TAG_MAX : TAG_B;
1.1       schwarze  440:                        break;
                    441:                case (MAN_RB):
1.27      schwarze  442:                        fp = i % 2 ? TAG_B : TAG_MAX;
1.1       schwarze  443:                        break;
                    444:                default:
                    445:                        abort();
                    446:                        /* NOTREACHED */
                    447:                }
                    448:
                    449:                if (i)
                    450:                        h->flags |= HTML_NOSPACE;
                    451:
1.27      schwarze  452:                if (TAG_MAX != fp)
                    453:                        t = print_otag(h, fp, 0, NULL);
                    454:
1.18      schwarze  455:                print_man_node(m, nn, mh, h);
1.27      schwarze  456:
                    457:                if (t)
                    458:                        print_tagq(h, t);
1.1       schwarze  459:        }
                    460:
                    461:        return(0);
                    462: }
                    463:
                    464:
                    465: /* ARGSUSED */
                    466: static int
1.26      schwarze  467: man_SM_pre(MAN_ARGS)
1.1       schwarze  468: {
                    469:
1.27      schwarze  470:        print_otag(h, TAG_SMALL, 0, NULL);
1.26      schwarze  471:        if (MAN_SB == n->tok)
1.27      schwarze  472:                print_otag(h, TAG_B, 0, NULL);
1.1       schwarze  473:        return(1);
                    474: }
                    475:
                    476:
                    477: /* ARGSUSED */
                    478: static int
                    479: man_SS_pre(MAN_ARGS)
                    480: {
1.25      schwarze  481:        struct htmlpair  tag;
1.1       schwarze  482:
1.25      schwarze  483:        if (MAN_BLOCK == n->type) {
                    484:                PAIR_CLASS_INIT(&tag, "subsection");
                    485:                print_otag(h, TAG_DIV, 1, &tag);
1.1       schwarze  486:                return(1);
1.25      schwarze  487:        } else if (MAN_BODY == n->type)
1.1       schwarze  488:                return(1);
                    489:
1.25      schwarze  490:        print_otag(h, TAG_H2, 0, NULL);
1.1       schwarze  491:        return(1);
                    492: }
                    493:
                    494:
                    495: /* ARGSUSED */
                    496: static int
                    497: man_PP_pre(MAN_ARGS)
                    498: {
                    499:
1.22      schwarze  500:        if (MAN_HEAD == n->type)
                    501:                return(0);
1.26      schwarze  502:        else if (MAN_BODY == n->type && n->prev)
                    503:                print_otag(h, TAG_P, 0, NULL);
1.22      schwarze  504:
1.1       schwarze  505:        return(1);
                    506: }
                    507:
                    508:
                    509: /* ARGSUSED */
                    510: static int
                    511: man_IP_pre(MAN_ARGS)
                    512: {
                    513:        struct roffsu            su;
                    514:        struct htmlpair          tag;
                    515:        const struct man_node   *nn;
                    516:
                    517:        /*
                    518:         * This scattering of 1-BU margins and pads is to make sure that
                    519:         * when text overruns its box, the subsequent text isn't flush
                    520:         * up against it.  However, the rest of the right-hand box must
                    521:         * also be adjusted in consideration of this 1-BU space.
                    522:         */
                    523:
                    524:        if (MAN_BODY == n->type) {
1.26      schwarze  525:                print_otag(h, TAG_TD, 0, NULL);
1.1       schwarze  526:                return(1);
                    527:        }
                    528:
                    529:        nn = MAN_BLOCK == n->type ?
                    530:                n->head->child : n->parent->head->child;
                    531:
                    532:        SCALE_HS_INIT(&su, INDENT);
                    533:
1.28      schwarze  534:        /* Width is the second token. */
1.7       schwarze  535:
1.1       schwarze  536:        if (MAN_IP == n->tok && NULL != nn)
1.28      schwarze  537:                if (NULL != (nn = nn->next))
1.30      schwarze  538:                        a2width(nn, &su);
1.1       schwarze  539:
1.7       schwarze  540:        /* Width is the first token. */
                    541:
                    542:        if (MAN_TP == n->tok && NULL != nn) {
                    543:                /* Skip past non-text children. */
                    544:                while (nn && MAN_TEXT != nn->type)
                    545:                        nn = nn->next;
                    546:                if (nn)
1.30      schwarze  547:                        a2width(nn, &su);
1.7       schwarze  548:        }
1.1       schwarze  549:
                    550:        if (MAN_BLOCK == n->type) {
1.26      schwarze  551:                print_otag(h, TAG_P, 0, NULL);
                    552:                print_otag(h, TAG_TABLE, 0, NULL);
                    553:                bufcat_su(h, "width", &su);
1.1       schwarze  554:                PAIR_STYLE_INIT(&tag, h);
1.26      schwarze  555:                print_otag(h, TAG_COL, 1, &tag);
                    556:                print_otag(h, TAG_COL, 0, NULL);
                    557:                print_otag(h, TAG_TBODY, 0, NULL);
                    558:                print_otag(h, TAG_TR, 0, NULL);
1.1       schwarze  559:                return(1);
                    560:        }
                    561:
1.26      schwarze  562:        print_otag(h, TAG_TD, 0, NULL);
1.1       schwarze  563:
1.28      schwarze  564:        /* For IP, only print the first header element. */
1.1       schwarze  565:
1.28      schwarze  566:        if (MAN_IP == n->tok && n->child)
                    567:                print_man_node(m, n->child, mh, h);
1.7       schwarze  568:
1.28      schwarze  569:        /* For TP, only print next-line header elements. */
1.1       schwarze  570:
                    571:        if (MAN_TP == n->tok)
1.28      schwarze  572:                for (nn = n->child; nn; nn = nn->next)
                    573:                        if (nn->line > n->line)
                    574:                                print_man_node(m, nn, mh, h);
1.1       schwarze  575:
                    576:        return(0);
                    577: }
                    578:
                    579:
                    580: /* ARGSUSED */
                    581: static int
                    582: man_HP_pre(MAN_ARGS)
                    583: {
1.26      schwarze  584:        struct htmlpair  tag;
                    585:        struct roffsu    su;
                    586:        const struct man_node *np;
1.1       schwarze  587:
1.26      schwarze  588:        np = MAN_BLOCK == n->type ?
                    589:                n->head->child :
                    590:                n->parent->head->child;
1.1       schwarze  591:
1.26      schwarze  592:        if (NULL == np || ! a2width(np, &su))
                    593:                SCALE_HS_INIT(&su, INDENT);
1.1       schwarze  594:
1.26      schwarze  595:        if (MAN_HEAD == n->type) {
                    596:                print_otag(h, TAG_TD, 0, NULL);
                    597:                return(0);
                    598:        } else if (MAN_BLOCK == n->type) {
                    599:                print_otag(h, TAG_P, 0, NULL);
                    600:                print_otag(h, TAG_TABLE, 0, NULL);
                    601:                bufcat_su(h, "width", &su);
1.1       schwarze  602:                PAIR_STYLE_INIT(&tag, h);
1.26      schwarze  603:                print_otag(h, TAG_COL, 1, &tag);
                    604:                print_otag(h, TAG_COL, 0, NULL);
                    605:                print_otag(h, TAG_TBODY, 0, NULL);
                    606:                print_otag(h, TAG_TR, 0, NULL);
1.1       schwarze  607:                return(1);
                    608:        }
                    609:
1.26      schwarze  610:        su.scale = -su.scale;
1.1       schwarze  611:        bufcat_su(h, "text-indent", &su);
                    612:        PAIR_STYLE_INIT(&tag, h);
1.26      schwarze  613:        print_otag(h, TAG_TD, 1, &tag);
1.1       schwarze  614:        return(1);
                    615: }
                    616:
                    617:
                    618: /* ARGSUSED */
                    619: static int
                    620: man_B_pre(MAN_ARGS)
                    621: {
                    622:
1.27      schwarze  623:        print_otag(h, TAG_B, 0, NULL);
1.1       schwarze  624:        return(1);
                    625: }
                    626:
                    627:
                    628: /* ARGSUSED */
                    629: static int
                    630: man_I_pre(MAN_ARGS)
                    631: {
1.4       schwarze  632:
1.27      schwarze  633:        print_otag(h, TAG_I, 0, NULL);
1.1       schwarze  634:        return(1);
1.18      schwarze  635: }
                    636:
                    637:
                    638: /* ARGSUSED */
                    639: static int
                    640: man_literal_pre(MAN_ARGS)
                    641: {
                    642:
1.21      schwarze  643:        if (MAN_nf == n->tok) {
1.18      schwarze  644:                print_otag(h, TAG_BR, 0, NULL);
                    645:                mh->fl |= MANH_LITERAL;
1.21      schwarze  646:        } else
1.18      schwarze  647:                mh->fl &= ~MANH_LITERAL;
                    648:
1.34      schwarze  649:        return(0);
1.18      schwarze  650: }
                    651:
                    652:
                    653: /* ARGSUSED */
                    654: static int
                    655: man_in_pre(MAN_ARGS)
                    656: {
                    657:
                    658:        print_otag(h, TAG_BR, 0, NULL);
                    659:        return(0);
1.1       schwarze  660: }
                    661:
                    662:
                    663: /* ARGSUSED */
                    664: static int
                    665: man_ign_pre(MAN_ARGS)
                    666: {
                    667:
                    668:        return(0);
                    669: }
                    670:
                    671:
                    672: /* ARGSUSED */
                    673: static int
                    674: man_RS_pre(MAN_ARGS)
                    675: {
                    676:        struct htmlpair  tag;
                    677:        struct roffsu    su;
                    678:
                    679:        if (MAN_HEAD == n->type)
                    680:                return(0);
                    681:        else if (MAN_BODY == n->type)
                    682:                return(1);
                    683:
                    684:        SCALE_HS_INIT(&su, INDENT);
1.26      schwarze  685:        if (n->head->child)
1.1       schwarze  686:                a2width(n->head->child, &su);
                    687:
1.26      schwarze  688:        bufcat_su(h, "margin-left", &su);
1.1       schwarze  689:        PAIR_STYLE_INIT(&tag, h);
                    690:        print_otag(h, TAG_DIV, 1, &tag);
                    691:        return(1);
                    692: }