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

Annotation of mandoc/man_html.c, Revision 1.81

1.81    ! kristaps    1: /*     $Id: man_html.c,v 1.80 2011/07/23 22:57:13 kristaps 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.3       kristaps  144:        struct html     *h;
                    145:        struct tag      *t;
1.45      kristaps  146:        struct mhtml     mh;
1.3       kristaps  147:
                    148:        h = (struct html *)arg;
                    149:
1.26      kristaps  150:        print_gen_decls(h);
1.3       kristaps  151:
1.45      kristaps  152:        memset(&mh, 0, sizeof(struct mhtml));
                    153:
1.3       kristaps  154:        t = print_otag(h, TAG_HTML, 0, NULL);
1.45      kristaps  155:        print_man(man_meta(m), man_node(m), &mh, h);
1.3       kristaps  156:        print_tagq(h, t);
                    157:
                    158:        printf("\n");
                    159: }
                    160:
                    161: static void
                    162: print_man(MAN_ARGS)
                    163: {
                    164:        struct tag      *t;
                    165:
                    166:        t = print_otag(h, TAG_HEAD, 0, NULL);
1.45      kristaps  167:        print_man_head(m, n, mh, h);
1.3       kristaps  168:        print_tagq(h, t);
1.53      kristaps  169:
1.3       kristaps  170:        t = print_otag(h, TAG_BODY, 0, NULL);
1.45      kristaps  171:        print_man_nodelist(m, n, mh, h);
1.3       kristaps  172:        print_tagq(h, t);
                    173: }
                    174:
                    175:
                    176: /* ARGSUSED */
                    177: static void
                    178: print_man_head(MAN_ARGS)
                    179: {
                    180:
                    181:        print_gen_head(h);
1.71      kristaps  182:        bufcat_fmt(h, "%s(%s)", m->title, m->msec);
1.3       kristaps  183:        print_otag(h, TAG_TITLE, 0, NULL);
                    184:        print_text(h, h->buf);
1.1       kristaps  185: }
1.4       kristaps  186:
                    187:
                    188: static void
                    189: print_man_nodelist(MAN_ARGS)
                    190: {
                    191:
1.45      kristaps  192:        print_man_node(m, n, mh, h);
1.4       kristaps  193:        if (n->next)
1.45      kristaps  194:                print_man_nodelist(m, n->next, mh, h);
1.4       kristaps  195: }
                    196:
                    197:
                    198: static void
                    199: print_man_node(MAN_ARGS)
                    200: {
                    201:        int              child;
                    202:        struct tag      *t;
                    203:
                    204:        child = 1;
1.14      kristaps  205:        t = h->tags.head;
1.4       kristaps  206:
                    207:        switch (n->type) {
                    208:        case (MAN_ROOT):
1.65      kristaps  209:                man_root_pre(m, n, mh, h);
1.4       kristaps  210:                break;
                    211:        case (MAN_TEXT):
1.65      kristaps  212:                /*
                    213:                 * If we have a blank line, output a vertical space.
                    214:                 * If we have a space as the first character, break
                    215:                 * before printing the line's data.
                    216:                 */
1.63      kristaps  217:                if ('\0' == *n->string) {
                    218:                        print_otag(h, TAG_P, 0, NULL);
                    219:                        return;
1.78      kristaps  220:                }
                    221:
                    222:                if (' ' == *n->string && MAN_LINE & n->flags)
                    223:                        print_otag(h, TAG_BR, 0, NULL);
                    224:                else if (MANH_LITERAL & mh->fl && n->prev)
1.63      kristaps  225:                        print_otag(h, TAG_BR, 0, NULL);
                    226:
1.4       kristaps  227:                print_text(h, n->string);
1.68      kristaps  228:                return;
                    229:        case (MAN_EQN):
1.80      kristaps  230:                print_eqn(h, n->eqn);
1.69      kristaps  231:                break;
1.58      kristaps  232:        case (MAN_TBL):
1.66      kristaps  233:                /*
                    234:                 * This will take care of initialising all of the table
                    235:                 * state data for the first table, then tearing it down
                    236:                 * for the last one.
                    237:                 */
1.60      kristaps  238:                print_tbl(h, n->span);
1.64      kristaps  239:                return;
1.4       kristaps  240:        default:
1.21      kristaps  241:                /*
                    242:                 * Close out scope of font prior to opening a macro
1.66      kristaps  243:                 * scope.
1.21      kristaps  244:                 */
1.57      kristaps  245:                if (HTMLFONT_NONE != h->metac) {
                    246:                        h->metal = h->metac;
                    247:                        h->metac = HTMLFONT_NONE;
1.66      kristaps  248:                }
                    249:
                    250:                /*
                    251:                 * Close out the current table, if it's open, and unset
                    252:                 * the "meta" table state.  This will be reopened on the
                    253:                 * next table element.
                    254:                 */
                    255:                if (h->tblt) {
                    256:                        print_tblclose(h);
                    257:                        t = h->tags.head;
1.20      kristaps  258:                }
1.4       kristaps  259:                if (mans[n->tok].pre)
1.45      kristaps  260:                        child = (*mans[n->tok].pre)(m, n, mh, h);
1.4       kristaps  261:                break;
                    262:        }
                    263:
1.21      kristaps  264:        if (child && n->child)
1.45      kristaps  265:                print_man_nodelist(m, n->child, mh, h);
1.21      kristaps  266:
1.24      kristaps  267:        /* This will automatically close out any font scope. */
1.4       kristaps  268:        print_stagq(h, t);
                    269:
1.61      kristaps  270:        switch (n->type) {
                    271:        case (MAN_ROOT):
1.45      kristaps  272:                man_root_post(m, n, mh, h);
1.69      kristaps  273:                break;
                    274:        case (MAN_EQN):
1.61      kristaps  275:                break;
                    276:        default:
                    277:                if (mans[n->tok].post)
                    278:                        (*mans[n->tok].post)(m, n, mh, h);
                    279:                break;
                    280:        }
1.4       kristaps  281: }
                    282:
                    283:
1.5       kristaps  284: static int
1.7       kristaps  285: a2width(const struct man_node *n, struct roffsu *su)
1.5       kristaps  286: {
                    287:
1.6       kristaps  288:        if (MAN_TEXT != n->type)
1.7       kristaps  289:                return(0);
1.11      kristaps  290:        if (a2roffsu(n->string, su, SCALE_BU))
1.7       kristaps  291:                return(1);
1.5       kristaps  292:
1.7       kristaps  293:        return(0);
1.5       kristaps  294: }
                    295:
                    296:
1.40      kristaps  297: /* ARGSUSED */
1.65      kristaps  298: static void
1.4       kristaps  299: man_root_pre(MAN_ARGS)
                    300: {
1.56      kristaps  301:        struct htmlpair  tag[3];
1.4       kristaps  302:        struct tag      *t, *tt;
                    303:        char             b[BUFSIZ], title[BUFSIZ];
                    304:
                    305:        b[0] = 0;
                    306:        if (m->vol)
                    307:                (void)strlcat(b, m->vol, BUFSIZ);
                    308:
1.31      kristaps  309:        snprintf(title, BUFSIZ - 1, "%s(%s)", m->title, m->msec);
1.4       kristaps  310:
1.56      kristaps  311:        PAIR_SUMMARY_INIT(&tag[0], "Document Header");
                    312:        PAIR_CLASS_INIT(&tag[1], "head");
                    313:        if (NULL == h->style) {
                    314:                PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
                    315:                t = print_otag(h, TAG_TABLE, 3, tag);
                    316:                PAIR_INIT(&tag[0], ATTR_WIDTH, "30%");
                    317:                print_otag(h, TAG_COL, 1, tag);
                    318:                print_otag(h, TAG_COL, 1, tag);
                    319:                print_otag(h, TAG_COL, 1, tag);
                    320:        } else
                    321:                t = print_otag(h, TAG_TABLE, 2, tag);
                    322:
                    323:        print_otag(h, TAG_TBODY, 0, NULL);
1.15      kristaps  324:
1.4       kristaps  325:        tt = print_otag(h, TAG_TR, 0, NULL);
                    326:
1.55      kristaps  327:        PAIR_CLASS_INIT(&tag[0], "head-ltitle");
1.4       kristaps  328:        print_otag(h, TAG_TD, 1, tag);
1.55      kristaps  329:
1.4       kristaps  330:        print_text(h, title);
                    331:        print_stagq(h, tt);
                    332:
1.55      kristaps  333:        PAIR_CLASS_INIT(&tag[0], "head-vol");
1.56      kristaps  334:        if (NULL == h->style) {
                    335:                PAIR_INIT(&tag[1], ATTR_ALIGN, "center");
                    336:                print_otag(h, TAG_TD, 2, tag);
                    337:        } else
                    338:                print_otag(h, TAG_TD, 1, tag);
1.55      kristaps  339:
1.4       kristaps  340:        print_text(h, b);
                    341:        print_stagq(h, tt);
                    342:
1.55      kristaps  343:        PAIR_CLASS_INIT(&tag[0], "head-rtitle");
1.56      kristaps  344:        if (NULL == h->style) {
                    345:                PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
                    346:                print_otag(h, TAG_TD, 2, tag);
                    347:        } else
                    348:                print_otag(h, TAG_TD, 1, tag);
1.55      kristaps  349:
1.4       kristaps  350:        print_text(h, title);
                    351:        print_tagq(h, t);
                    352: }
                    353:
                    354:
                    355: /* ARGSUSED */
                    356: static void
                    357: man_root_post(MAN_ARGS)
                    358: {
1.56      kristaps  359:        struct htmlpair  tag[3];
1.4       kristaps  360:        struct tag      *t, *tt;
                    361:
1.56      kristaps  362:        PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
                    363:        PAIR_CLASS_INIT(&tag[1], "foot");
                    364:        if (NULL == h->style) {
                    365:                PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
                    366:                t = print_otag(h, TAG_TABLE, 3, tag);
                    367:                PAIR_INIT(&tag[0], ATTR_WIDTH, "50%");
                    368:                print_otag(h, TAG_COL, 1, tag);
                    369:                print_otag(h, TAG_COL, 1, tag);
                    370:        } else
                    371:                t = print_otag(h, TAG_TABLE, 2, tag);
1.15      kristaps  372:
1.4       kristaps  373:        tt = print_otag(h, TAG_TR, 0, NULL);
                    374:
1.55      kristaps  375:        PAIR_CLASS_INIT(&tag[0], "foot-date");
1.4       kristaps  376:        print_otag(h, TAG_TD, 1, tag);
1.55      kristaps  377:
1.70      schwarze  378:        print_text(h, m->date);
1.4       kristaps  379:        print_stagq(h, tt);
                    380:
1.55      kristaps  381:        PAIR_CLASS_INIT(&tag[0], "foot-os");
1.56      kristaps  382:        if (NULL == h->style) {
                    383:                PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
                    384:                print_otag(h, TAG_TD, 2, tag);
                    385:        } else
                    386:                print_otag(h, TAG_TD, 1, tag);
1.55      kristaps  387:
1.4       kristaps  388:        if (m->source)
                    389:                print_text(h, m->source);
                    390:        print_tagq(h, t);
                    391: }
                    392:
                    393:
                    394: /* ARGSUSED */
                    395: static int
                    396: man_br_pre(MAN_ARGS)
                    397: {
1.7       kristaps  398:        struct roffsu    su;
                    399:        struct htmlpair  tag;
1.4       kristaps  400:
1.7       kristaps  401:        SCALE_VS_INIT(&su, 1);
                    402:
1.49      kristaps  403:        if (MAN_sp == n->tok) {
1.75      kristaps  404:                if (NULL != (n = n->child))
                    405:                        if ( ! a2roffsu(n->string, &su, SCALE_VS))
                    406:                                SCALE_VS_INIT(&su, atoi(n->string));
1.49      kristaps  407:        } else
1.7       kristaps  408:                su.scale = 0;
1.4       kristaps  409:
1.72      kristaps  410:        bufinit(h);
1.7       kristaps  411:        bufcat_su(h, "height", &su);
                    412:        PAIR_STYLE_INIT(&tag, h);
1.4       kristaps  413:        print_otag(h, TAG_DIV, 1, &tag);
1.24      kristaps  414:
1.16      kristaps  415:        /* So the div isn't empty: */
                    416:        print_text(h, "\\~");
                    417:
1.7       kristaps  418:        return(0);
1.4       kristaps  419: }
                    420:
                    421: /* ARGSUSED */
                    422: static int
                    423: man_SH_pre(MAN_ARGS)
                    424: {
1.54      kristaps  425:        struct htmlpair  tag;
1.4       kristaps  426:
1.54      kristaps  427:        if (MAN_BLOCK == n->type) {
1.76      kristaps  428:                mh->fl &= ~MANH_LITERAL;
1.54      kristaps  429:                PAIR_CLASS_INIT(&tag, "section");
                    430:                print_otag(h, TAG_DIV, 1, &tag);
1.4       kristaps  431:                return(1);
1.54      kristaps  432:        } else if (MAN_BODY == n->type)
1.4       kristaps  433:                return(1);
                    434:
1.54      kristaps  435:        print_otag(h, TAG_H1, 0, NULL);
1.4       kristaps  436:        return(1);
                    437: }
                    438:
                    439: /* ARGSUSED */
                    440: static int
1.8       kristaps  441: man_alt_pre(MAN_ARGS)
                    442: {
                    443:        const struct man_node   *nn;
1.78      kristaps  444:        int              i, savelit;
1.57      kristaps  445:        enum htmltag     fp;
                    446:        struct tag      *t;
1.8       kristaps  447:
1.78      kristaps  448:        if ((savelit = mh->fl & MANH_LITERAL))
                    449:                print_otag(h, TAG_BR, 0, NULL);
                    450:
                    451:        mh->fl &= ~MANH_LITERAL;
                    452:
1.8       kristaps  453:        for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.57      kristaps  454:                t = NULL;
1.8       kristaps  455:                switch (n->tok) {
                    456:                case (MAN_BI):
1.57      kristaps  457:                        fp = i % 2 ? TAG_I : TAG_B;
1.8       kristaps  458:                        break;
                    459:                case (MAN_IB):
1.57      kristaps  460:                        fp = i % 2 ? TAG_B : TAG_I;
1.8       kristaps  461:                        break;
                    462:                case (MAN_RI):
1.57      kristaps  463:                        fp = i % 2 ? TAG_I : TAG_MAX;
1.8       kristaps  464:                        break;
                    465:                case (MAN_IR):
1.57      kristaps  466:                        fp = i % 2 ? TAG_MAX : TAG_I;
1.8       kristaps  467:                        break;
                    468:                case (MAN_BR):
1.57      kristaps  469:                        fp = i % 2 ? TAG_MAX : TAG_B;
1.8       kristaps  470:                        break;
                    471:                case (MAN_RB):
1.57      kristaps  472:                        fp = i % 2 ? TAG_B : TAG_MAX;
1.8       kristaps  473:                        break;
                    474:                default:
                    475:                        abort();
                    476:                        /* NOTREACHED */
                    477:                }
                    478:
                    479:                if (i)
                    480:                        h->flags |= HTML_NOSPACE;
                    481:
1.57      kristaps  482:                if (TAG_MAX != fp)
                    483:                        t = print_otag(h, fp, 0, NULL);
                    484:
1.45      kristaps  485:                print_man_node(m, nn, mh, h);
1.57      kristaps  486:
                    487:                if (t)
                    488:                        print_tagq(h, t);
1.8       kristaps  489:        }
                    490:
1.78      kristaps  491:        if (savelit)
                    492:                mh->fl |= MANH_LITERAL;
                    493:
1.8       kristaps  494:        return(0);
                    495: }
                    496:
                    497: /* ARGSUSED */
                    498: static int
1.56      kristaps  499: man_SM_pre(MAN_ARGS)
1.8       kristaps  500: {
                    501:
1.57      kristaps  502:        print_otag(h, TAG_SMALL, 0, NULL);
1.56      kristaps  503:        if (MAN_SB == n->tok)
1.57      kristaps  504:                print_otag(h, TAG_B, 0, NULL);
1.8       kristaps  505:        return(1);
                    506: }
                    507:
                    508: /* ARGSUSED */
                    509: static int
1.4       kristaps  510: man_SS_pre(MAN_ARGS)
                    511: {
1.54      kristaps  512:        struct htmlpair  tag;
1.4       kristaps  513:
1.54      kristaps  514:        if (MAN_BLOCK == n->type) {
1.76      kristaps  515:                mh->fl &= ~MANH_LITERAL;
1.54      kristaps  516:                PAIR_CLASS_INIT(&tag, "subsection");
                    517:                print_otag(h, TAG_DIV, 1, &tag);
1.4       kristaps  518:                return(1);
1.54      kristaps  519:        } else if (MAN_BODY == n->type)
1.4       kristaps  520:                return(1);
                    521:
1.54      kristaps  522:        print_otag(h, TAG_H2, 0, NULL);
1.4       kristaps  523:        return(1);
                    524: }
                    525:
                    526: /* ARGSUSED */
                    527: static int
                    528: man_PP_pre(MAN_ARGS)
                    529: {
                    530:
1.47      kristaps  531:        if (MAN_HEAD == n->type)
                    532:                return(0);
1.74      kristaps  533:        else if (MAN_BLOCK == n->type)
                    534:                print_bvspace(h, n);
1.47      kristaps  535:
1.5       kristaps  536:        return(1);
                    537: }
                    538:
                    539: /* ARGSUSED */
                    540: static int
                    541: man_IP_pre(MAN_ARGS)
                    542: {
                    543:        const struct man_node   *nn;
                    544:
1.7       kristaps  545:        if (MAN_BODY == n->type) {
1.77      kristaps  546:                print_otag(h, TAG_DD, 0, NULL);
                    547:                return(1);
                    548:        } else if (MAN_HEAD != n->type) {
                    549:                print_otag(h, TAG_DL, 0, NULL);
1.6       kristaps  550:                return(1);
                    551:        }
                    552:
1.78      kristaps  553:        /* FIXME: width specification. */
                    554:
1.77      kristaps  555:        print_otag(h, TAG_DT, 0, NULL);
1.6       kristaps  556:
1.59      schwarze  557:        /* For IP, only print the first header element. */
1.7       kristaps  558:
1.59      schwarze  559:        if (MAN_IP == n->tok && n->child)
                    560:                print_man_node(m, n->child, mh, h);
1.27      kristaps  561:
1.59      schwarze  562:        /* For TP, only print next-line header elements. */
1.6       kristaps  563:
1.7       kristaps  564:        if (MAN_TP == n->tok)
1.59      schwarze  565:                for (nn = n->child; nn; nn = nn->next)
                    566:                        if (nn->line > n->line)
                    567:                                print_man_node(m, nn, mh, h);
1.6       kristaps  568:
                    569:        return(0);
                    570: }
                    571:
                    572: /* ARGSUSED */
                    573: static int
                    574: man_HP_pre(MAN_ARGS)
                    575: {
1.56      kristaps  576:        struct htmlpair  tag;
                    577:        struct roffsu    su;
                    578:        const struct man_node *np;
1.6       kristaps  579:
1.77      kristaps  580:        if (MAN_HEAD == n->type)
                    581:                return(0);
                    582:        else if (MAN_BLOCK != n->type)
                    583:                return(1);
1.72      kristaps  584:
1.77      kristaps  585:        np = n->head->child;
1.6       kristaps  586:
1.56      kristaps  587:        if (NULL == np || ! a2width(np, &su))
                    588:                SCALE_HS_INIT(&su, INDENT);
1.6       kristaps  589:
1.77      kristaps  590:        bufinit(h);
1.5       kristaps  591:
1.77      kristaps  592:        print_bvspace(h, n);
                    593:        bufcat_su(h, "margin-left", &su);
1.56      kristaps  594:        su.scale = -su.scale;
1.7       kristaps  595:        bufcat_su(h, "text-indent", &su);
                    596:        PAIR_STYLE_INIT(&tag, h);
1.77      kristaps  597:        print_otag(h, TAG_P, 1, &tag);
1.4       kristaps  598:        return(1);
                    599: }
1.6       kristaps  600:
1.8       kristaps  601: /* ARGSUSED */
                    602: static int
                    603: man_B_pre(MAN_ARGS)
                    604: {
                    605:
1.57      kristaps  606:        print_otag(h, TAG_B, 0, NULL);
1.8       kristaps  607:        return(1);
                    608: }
                    609:
                    610: /* ARGSUSED */
                    611: static int
                    612: man_I_pre(MAN_ARGS)
                    613: {
1.23      kristaps  614:
1.57      kristaps  615:        print_otag(h, TAG_I, 0, NULL);
1.8       kristaps  616:        return(1);
1.45      kristaps  617: }
                    618:
                    619: /* ARGSUSED */
                    620: static int
                    621: man_literal_pre(MAN_ARGS)
                    622: {
                    623:
1.78      kristaps  624:        if (MAN_nf != n->tok) {
1.45      kristaps  625:                print_otag(h, TAG_BR, 0, NULL);
1.78      kristaps  626:                mh->fl &= ~MANH_LITERAL;
                    627:        } else
1.45      kristaps  628:                mh->fl |= MANH_LITERAL;
                    629:
1.67      schwarze  630:        return(0);
1.45      kristaps  631: }
                    632:
                    633: /* ARGSUSED */
                    634: static int
                    635: man_in_pre(MAN_ARGS)
                    636: {
                    637:
                    638:        print_otag(h, TAG_BR, 0, NULL);
                    639:        return(0);
1.8       kristaps  640: }
                    641:
                    642: /* ARGSUSED */
                    643: static int
                    644: man_ign_pre(MAN_ARGS)
                    645: {
                    646:
                    647:        return(0);
                    648: }
1.9       kristaps  649:
                    650: /* ARGSUSED */
                    651: static int
                    652: man_RS_pre(MAN_ARGS)
                    653: {
                    654:        struct htmlpair  tag;
                    655:        struct roffsu    su;
                    656:
                    657:        if (MAN_HEAD == n->type)
                    658:                return(0);
                    659:        else if (MAN_BODY == n->type)
                    660:                return(1);
                    661:
                    662:        SCALE_HS_INIT(&su, INDENT);
1.56      kristaps  663:        if (n->head->child)
1.9       kristaps  664:                a2width(n->head->child, &su);
                    665:
1.72      kristaps  666:        bufinit(h);
1.56      kristaps  667:        bufcat_su(h, "margin-left", &su);
1.9       kristaps  668:        PAIR_STYLE_INIT(&tag, h);
                    669:        print_otag(h, TAG_DIV, 1, &tag);
                    670:        return(1);
                    671: }

CVSweb