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

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