[BACK]Return to man_html.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Annotation of mandoc/man_html.c, Revision 1.84

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

CVSweb