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

Annotation of mandoc/man_html.c, Revision 1.8

1.8     ! kristaps    1: /*     $Id: man_html.c,v 1.7 2009/10/07 12:35:23 kristaps Exp $ */
1.1       kristaps    2: /*
                      3:  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
                      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: #include <sys/queue.h>
                     19:
1.5       kristaps   20: #include <assert.h>
                     21: #include <ctype.h>
1.4       kristaps   22: #include <err.h>
1.2       kristaps   23: #include <stdio.h>
1.1       kristaps   24: #include <stdlib.h>
1.4       kristaps   25: #include <string.h>
1.1       kristaps   26:
1.7       kristaps   27: #include "out.h"
1.1       kristaps   28: #include "html.h"
                     29: #include "man.h"
                     30:
1.6       kristaps   31: /* TODO: preserve ident widths. */
                     32:
                     33: #define        INDENT            5
1.4       kristaps   34: #define        HALFINDENT        3
                     35:
1.3       kristaps   36: #define        MAN_ARGS          const struct man_meta *m, \
                     37:                          const struct man_node *n, \
                     38:                          struct html *h
                     39:
                     40: struct htmlman {
                     41:        int             (*pre)(MAN_ARGS);
                     42:        int             (*post)(MAN_ARGS);
                     43: };
                     44:
                     45: static void              print_man(MAN_ARGS);
                     46: static void              print_man_head(MAN_ARGS);
1.4       kristaps   47: static void              print_man_nodelist(MAN_ARGS);
                     48: static void              print_man_node(MAN_ARGS);
1.3       kristaps   49:
1.7       kristaps   50: static int               a2width(const struct man_node *,
                     51:                                struct roffsu *);
1.5       kristaps   52:
1.8     ! kristaps   53: static int               man_alt_pre(MAN_ARGS);
1.4       kristaps   54: static int               man_br_pre(MAN_ARGS);
1.8     ! kristaps   55: static int               man_ign_pre(MAN_ARGS);
        !            56: static void              man_root_post(MAN_ARGS);
        !            57: static int               man_root_pre(MAN_ARGS);
        !            58: static int               man_B_pre(MAN_ARGS);
1.6       kristaps   59: static int               man_HP_pre(MAN_ARGS);
1.8     ! kristaps   60: static int               man_I_pre(MAN_ARGS);
1.5       kristaps   61: static int               man_IP_pre(MAN_ARGS);
1.4       kristaps   62: static int               man_PP_pre(MAN_ARGS);
1.8     ! kristaps   63: static int               man_SB_pre(MAN_ARGS);
1.4       kristaps   64: static int               man_SH_pre(MAN_ARGS);
1.8     ! kristaps   65: static int               man_SM_pre(MAN_ARGS);
1.4       kristaps   66: static int               man_SS_pre(MAN_ARGS);
                     67:
                     68: #ifdef __linux__
                     69: extern size_t            strlcpy(char *, const char *, size_t);
                     70: extern size_t            strlcat(char *, const char *, size_t);
                     71: #endif
1.3       kristaps   72:
                     73: static const struct htmlman mans[MAN_MAX] = {
1.4       kristaps   74:        { man_br_pre, NULL }, /* br */
1.3       kristaps   75:        { NULL, NULL }, /* TH */
1.4       kristaps   76:        { man_SH_pre, NULL }, /* SH */
                     77:        { man_SS_pre, NULL }, /* SS */
1.6       kristaps   78:        { man_IP_pre, NULL }, /* TP */
1.4       kristaps   79:        { man_PP_pre, NULL }, /* LP */
                     80:        { man_PP_pre, NULL }, /* PP */
                     81:        { man_PP_pre, NULL }, /* P */
1.5       kristaps   82:        { man_IP_pre, NULL }, /* IP */
1.6       kristaps   83:        { man_HP_pre, NULL }, /* HP */
1.8     ! kristaps   84:        { man_SM_pre, NULL }, /* SM */
        !            85:        { man_SB_pre, NULL }, /* SB */
        !            86:        { man_alt_pre, NULL }, /* BI */
        !            87:        { man_alt_pre, NULL }, /* IB */
        !            88:        { man_alt_pre, NULL }, /* BR */
        !            89:        { man_alt_pre, NULL }, /* RB */
1.3       kristaps   90:        { NULL, NULL }, /* R */
1.8     ! kristaps   91:        { man_B_pre, NULL }, /* B */
        !            92:        { man_I_pre, NULL }, /* I */
        !            93:        { man_alt_pre, NULL }, /* IR */
        !            94:        { man_alt_pre, NULL }, /* RI */
1.3       kristaps   95:        { NULL, NULL }, /* na */
                     96:        { NULL, NULL }, /* i */
1.4       kristaps   97:        { man_br_pre, NULL }, /* sp */
1.3       kristaps   98:        { NULL, NULL }, /* nf */
                     99:        { NULL, NULL }, /* fi */
                    100:        { NULL, NULL }, /* r */
                    101:        { NULL, NULL }, /* RE */
                    102:        { NULL, NULL }, /* RS */
1.8     ! kristaps  103:        { man_ign_pre, NULL }, /* DT */
        !           104:        { man_ign_pre, NULL }, /* UC */
1.3       kristaps  105: };
                    106:
1.1       kristaps  107:
                    108: void
                    109: html_man(void *arg, const struct man *m)
                    110: {
1.3       kristaps  111:        struct html     *h;
                    112:        struct tag      *t;
                    113:
                    114:        h = (struct html *)arg;
                    115:
                    116:        print_gen_doctype(h);
                    117:
                    118:        t = print_otag(h, TAG_HTML, 0, NULL);
                    119:        print_man(man_meta(m), man_node(m), h);
                    120:        print_tagq(h, t);
                    121:
                    122:        printf("\n");
                    123: }
                    124:
                    125:
                    126: static void
                    127: print_man(MAN_ARGS)
                    128: {
                    129:        struct tag      *t;
                    130:        struct htmlpair  tag;
                    131:
                    132:        t = print_otag(h, TAG_HEAD, 0, NULL);
                    133:
                    134:        print_man_head(m, n, h);
                    135:        print_tagq(h, t);
                    136:        t = print_otag(h, TAG_BODY, 0, NULL);
                    137:
                    138:        tag.key = ATTR_CLASS;
                    139:        tag.val = "body";
                    140:        print_otag(h, TAG_DIV, 1, &tag);
                    141:
1.4       kristaps  142:        print_man_nodelist(m, n, h);
1.3       kristaps  143:
                    144:        print_tagq(h, t);
                    145: }
                    146:
                    147:
                    148: /* ARGSUSED */
                    149: static void
                    150: print_man_head(MAN_ARGS)
                    151: {
                    152:
                    153:        print_gen_head(h);
                    154:        bufinit(h);
                    155:        buffmt(h, "%s(%d)", m->title, m->msec);
                    156:
                    157:        print_otag(h, TAG_TITLE, 0, NULL);
                    158:        print_text(h, h->buf);
1.1       kristaps  159: }
1.4       kristaps  160:
                    161:
                    162: static void
                    163: print_man_nodelist(MAN_ARGS)
                    164: {
                    165:
                    166:        print_man_node(m, n, h);
                    167:        if (n->next)
                    168:                print_man_nodelist(m, n->next, h);
                    169: }
                    170:
                    171:
                    172: static void
                    173: print_man_node(MAN_ARGS)
                    174: {
                    175:        int              child;
                    176:        struct tag      *t;
                    177:
                    178:        child = 1;
                    179:        t = SLIST_FIRST(&h->tags);
                    180:
                    181:        bufinit(h);
                    182:
                    183:        switch (n->type) {
                    184:        case (MAN_ROOT):
                    185:                child = man_root_pre(m, n, h);
                    186:                break;
                    187:        case (MAN_TEXT):
                    188:                print_text(h, n->string);
                    189:                break;
                    190:        default:
                    191:                if (mans[n->tok].pre)
                    192:                        child = (*mans[n->tok].pre)(m, n, h);
                    193:                break;
                    194:        }
                    195:
                    196:        if (child && n->child)
                    197:                print_man_nodelist(m, n->child, h);
                    198:
                    199:        print_stagq(h, t);
                    200:
                    201:        bufinit(h);
                    202:
                    203:        switch (n->type) {
                    204:        case (MAN_ROOT):
                    205:                man_root_post(m, n, h);
                    206:                break;
                    207:        case (MAN_TEXT):
                    208:                break;
                    209:        default:
                    210:                if (mans[n->tok].post)
                    211:                        (*mans[n->tok].post)(m, n, h);
                    212:                break;
                    213:        }
                    214: }
                    215:
                    216:
1.5       kristaps  217: static int
1.7       kristaps  218: a2width(const struct man_node *n, struct roffsu *su)
1.5       kristaps  219: {
                    220:
1.6       kristaps  221:        if (MAN_TEXT != n->type)
1.7       kristaps  222:                return(0);
                    223:        if (a2roffsu(n->string, su))
                    224:                return(1);
1.5       kristaps  225:
1.7       kristaps  226:        return(0);
1.5       kristaps  227: }
                    228:
                    229:
1.4       kristaps  230: /* ARGSUSED */
                    231: static int
                    232: man_root_pre(MAN_ARGS)
                    233: {
                    234:        struct htmlpair  tag[2];
                    235:        struct tag      *t, *tt;
                    236:        char             b[BUFSIZ], title[BUFSIZ];
                    237:
                    238:        b[0] = 0;
                    239:        if (m->vol)
                    240:                (void)strlcat(b, m->vol, BUFSIZ);
                    241:
                    242:        (void)snprintf(title, BUFSIZ - 1,
                    243:                        "%s(%d)", m->title, m->msec);
                    244:
1.7       kristaps  245:        PAIR_CLASS_INIT(&tag[0], "header");
                    246:        bufcat_style(h, "width", "100%");
                    247:        PAIR_STYLE_INIT(&tag[1], h);
1.4       kristaps  248:        t = print_otag(h, TAG_TABLE, 2, tag);
                    249:        tt = print_otag(h, TAG_TR, 0, NULL);
                    250:
1.7       kristaps  251:        bufinit(h);
                    252:        bufcat_style(h, "width", "10%");
                    253:        PAIR_STYLE_INIT(&tag[0], h);
1.4       kristaps  254:        print_otag(h, TAG_TD, 1, tag);
                    255:        print_text(h, title);
                    256:        print_stagq(h, tt);
                    257:
1.7       kristaps  258:        bufinit(h);
                    259:        bufcat_style(h, "width", "80%");
                    260:        bufcat_style(h, "white-space", "nowrap");
                    261:        bufcat_style(h, "text-align", "center");
                    262:        PAIR_STYLE_INIT(&tag[0], h);
1.4       kristaps  263:        print_otag(h, TAG_TD, 1, tag);
                    264:        print_text(h, b);
                    265:        print_stagq(h, tt);
                    266:
1.7       kristaps  267:        bufinit(h);
                    268:        bufcat_style(h, "width", "10%");
                    269:        bufcat_style(h, "text-align", "right");
                    270:        PAIR_STYLE_INIT(&tag[0], h);
1.4       kristaps  271:        print_otag(h, TAG_TD, 1, tag);
                    272:        print_text(h, title);
                    273:        print_tagq(h, t);
                    274:        return(1);
                    275: }
                    276:
                    277:
                    278: /* ARGSUSED */
                    279: static void
                    280: man_root_post(MAN_ARGS)
                    281: {
                    282:        struct tm        tm;
                    283:        struct htmlpair  tag[2];
                    284:        struct tag      *t, *tt;
                    285:        char             b[BUFSIZ];
                    286:
                    287:        (void)localtime_r(&m->date, &tm);
                    288:
                    289:        if (0 == strftime(b, BUFSIZ - 1, "%B %e, %Y", &tm))
                    290:                err(EXIT_FAILURE, "strftime");
                    291:
1.7       kristaps  292:        PAIR_CLASS_INIT(&tag[0], "footer");
                    293:        bufcat_style(h, "width", "100%");
                    294:        PAIR_STYLE_INIT(&tag[1], h);
1.4       kristaps  295:        t = print_otag(h, TAG_TABLE, 2, tag);
                    296:        tt = print_otag(h, TAG_TR, 0, NULL);
                    297:
1.7       kristaps  298:        bufinit(h);
                    299:        bufcat_style(h, "width", "50%");
                    300:        PAIR_STYLE_INIT(&tag[0], h);
1.4       kristaps  301:        print_otag(h, TAG_TD, 1, tag);
                    302:        print_text(h, b);
                    303:        print_stagq(h, tt);
                    304:
1.7       kristaps  305:        bufinit(h);
                    306:        bufcat_style(h, "width", "50%");
                    307:        bufcat_style(h, "text-align", "right");
                    308:        PAIR_STYLE_INIT(&tag[0], h);
1.4       kristaps  309:        print_otag(h, TAG_TD, 1, tag);
                    310:        if (m->source)
                    311:                print_text(h, m->source);
                    312:        print_tagq(h, t);
                    313: }
                    314:
                    315:
                    316:
                    317: /* ARGSUSED */
                    318: static int
                    319: man_br_pre(MAN_ARGS)
                    320: {
1.7       kristaps  321:        struct roffsu    su;
                    322:        struct htmlpair  tag;
1.4       kristaps  323:
1.7       kristaps  324:        SCALE_VS_INIT(&su, 1);
                    325:
                    326:        if (MAN_sp == n->tok) {
                    327:                su.scale = 1;
                    328:                if (n->child)
                    329:                        a2roffsu(n->child->string, &su);
                    330:        } else if (MAN_br == n->tok)
                    331:                su.scale = 0;
1.4       kristaps  332:
1.7       kristaps  333:        bufcat_su(h, "height", &su);
                    334:        PAIR_STYLE_INIT(&tag, h);
1.4       kristaps  335:        print_otag(h, TAG_DIV, 1, &tag);
1.7       kristaps  336:        return(0);
1.4       kristaps  337: }
                    338:
                    339:
                    340: /* ARGSUSED */
                    341: static int
                    342: man_SH_pre(MAN_ARGS)
                    343: {
1.7       kristaps  344:        struct htmlpair  tag[2];
                    345:        struct roffsu    su;
1.4       kristaps  346:
                    347:        if (MAN_BODY == n->type) {
1.7       kristaps  348:                SCALE_HS_INIT(&su, INDENT);
                    349:                bufcat_su(h, "margin-left", &su);
                    350:                PAIR_CLASS_INIT(&tag[0], "sec-body");
                    351:                PAIR_STYLE_INIT(&tag[1], h);
1.4       kristaps  352:                print_otag(h, TAG_DIV, 2, tag);
                    353:                return(1);
                    354:        } else if (MAN_BLOCK == n->type) {
1.7       kristaps  355:                PAIR_CLASS_INIT(&tag[0], "sec-block");
1.4       kristaps  356:                if (n->prev && MAN_SH == n->prev->tok)
                    357:                        if (NULL == n->prev->body->child) {
                    358:                                print_otag(h, TAG_DIV, 1, tag);
                    359:                                return(1);
                    360:                        }
                    361:
1.7       kristaps  362:                SCALE_VS_INIT(&su, 1);
                    363:                bufcat_su(h, "margin-top", &su);
1.4       kristaps  364:                if (NULL == n->next)
1.7       kristaps  365:                        bufcat_su(h, "margin-bottom", &su);
                    366:                PAIR_STYLE_INIT(&tag[1], h);
1.4       kristaps  367:                print_otag(h, TAG_DIV, 2, tag);
                    368:                return(1);
                    369:        }
                    370:
1.7       kristaps  371:        PAIR_CLASS_INIT(&tag[0], "sec-head");
1.4       kristaps  372:        print_otag(h, TAG_DIV, 1, tag);
                    373:        return(1);
                    374: }
                    375:
                    376:
                    377: /* ARGSUSED */
                    378: static int
1.8     ! kristaps  379: man_alt_pre(MAN_ARGS)
        !           380: {
        !           381:        const struct man_node   *nn;
        !           382:        struct tag              *t;
        !           383:        int                      i;
        !           384:        struct htmlpair          tagi, tagb, *tagp;
        !           385:
        !           386:        PAIR_CLASS_INIT(&tagi, "italic");
        !           387:        PAIR_CLASS_INIT(&tagb, "bold");
        !           388:
        !           389:        for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
        !           390:                switch (n->tok) {
        !           391:                case (MAN_BI):
        !           392:                        tagp = i % 2 ? &tagi : &tagb;
        !           393:                        break;
        !           394:                case (MAN_IB):
        !           395:                        tagp = i % 2 ? &tagb : &tagi;
        !           396:                        break;
        !           397:                case (MAN_RI):
        !           398:                        tagp = i % 2 ? &tagi : NULL;
        !           399:                        break;
        !           400:                case (MAN_IR):
        !           401:                        tagp = i % 2 ? NULL : &tagi;
        !           402:                        break;
        !           403:                case (MAN_BR):
        !           404:                        tagp = i % 2 ? NULL : &tagb;
        !           405:                        break;
        !           406:                case (MAN_RB):
        !           407:                        tagp = i % 2 ? &tagb : NULL;
        !           408:                        break;
        !           409:                default:
        !           410:                        abort();
        !           411:                        /* NOTREACHED */
        !           412:                }
        !           413:
        !           414:                if (i)
        !           415:                        h->flags |= HTML_NOSPACE;
        !           416:
        !           417:                if (tagp) {
        !           418:                        t = print_otag(h, TAG_SPAN, 1, tagp);
        !           419:                        print_man_node(m, nn, h);
        !           420:                        print_tagq(h, t);
        !           421:                } else
        !           422:                        print_man_node(m, nn, h);
        !           423:        }
        !           424:
        !           425:        return(0);
        !           426: }
        !           427:
        !           428:
        !           429: /* ARGSUSED */
        !           430: static int
        !           431: man_SB_pre(MAN_ARGS)
        !           432: {
        !           433:        struct htmlpair  tag;
        !           434:
        !           435:        PAIR_CLASS_INIT(&tag, "small bold");
        !           436:        print_otag(h, TAG_SPAN, 1, &tag);
        !           437:        return(1);
        !           438: }
        !           439:
        !           440:
        !           441: /* ARGSUSED */
        !           442: static int
        !           443: man_SM_pre(MAN_ARGS)
        !           444: {
        !           445:        struct htmlpair  tag;
        !           446:
        !           447:        PAIR_CLASS_INIT(&tag, "small");
        !           448:        print_otag(h, TAG_SPAN, 1, &tag);
        !           449:        return(1);
        !           450: }
        !           451:
        !           452:
        !           453: /* ARGSUSED */
        !           454: static int
1.4       kristaps  455: man_SS_pre(MAN_ARGS)
                    456: {
                    457:        struct htmlpair  tag[3];
1.7       kristaps  458:        struct roffsu    su;
1.4       kristaps  459:
1.7       kristaps  460:        SCALE_VS_INIT(&su, 1);
1.4       kristaps  461:
                    462:        if (MAN_BODY == n->type) {
1.7       kristaps  463:                PAIR_CLASS_INIT(&tag[0], "ssec-body");
1.4       kristaps  464:                if (n->parent->next && n->child) {
1.7       kristaps  465:                        bufcat_su(h, "margin-bottom", &su);
                    466:                        PAIR_STYLE_INIT(&tag[1], h);
                    467:                        print_otag(h, TAG_DIV, 2, tag);
                    468:                        return(1);
1.4       kristaps  469:                }
                    470:
1.7       kristaps  471:                print_otag(h, TAG_DIV, 1, tag);
1.4       kristaps  472:                return(1);
                    473:        } else if (MAN_BLOCK == n->type) {
1.7       kristaps  474:                PAIR_CLASS_INIT(&tag[0], "ssec-block");
1.4       kristaps  475:                if (n->prev && MAN_SS == n->prev->tok)
                    476:                        if (n->prev->body->child) {
1.7       kristaps  477:                                bufcat_su(h, "margin-top", &su);
                    478:                                PAIR_STYLE_INIT(&tag[1], h);
                    479:                                print_otag(h, TAG_DIV, 2, tag);
                    480:                                return(1);
1.4       kristaps  481:                        }
                    482:
1.7       kristaps  483:                print_otag(h, TAG_DIV, 1, tag);
1.4       kristaps  484:                return(1);
                    485:        }
                    486:
1.7       kristaps  487:        SCALE_HS_INIT(&su, INDENT - HALFINDENT);
                    488:        bufcat_su(h, "margin-left", &su);
                    489:        PAIR_CLASS_INIT(&tag[0], "ssec-head");
                    490:        PAIR_STYLE_INIT(&tag[1], h);
1.4       kristaps  491:        print_otag(h, TAG_DIV, 2, tag);
                    492:        return(1);
                    493: }
                    494:
                    495:
                    496: /* ARGSUSED */
                    497: static int
                    498: man_PP_pre(MAN_ARGS)
                    499: {
1.5       kristaps  500:        struct htmlpair  tag;
1.7       kristaps  501:        struct roffsu    su;
1.5       kristaps  502:        int              i;
1.4       kristaps  503:
                    504:        if (MAN_BLOCK != n->type)
                    505:                return(1);
                    506:
1.5       kristaps  507:        i = 0;
                    508:
                    509:        if (MAN_ROOT == n->parent->tok) {
1.7       kristaps  510:                SCALE_HS_INIT(&su, INDENT);
                    511:                bufcat_su(h, "margin-left", &su);
                    512:                i++;
1.5       kristaps  513:        }
                    514:        if (n->next && n->next->child) {
1.7       kristaps  515:                SCALE_VS_INIT(&su, 1);
                    516:                bufcat_su(h, "margin-bottom", &su);
                    517:                i++;
1.5       kristaps  518:        }
1.4       kristaps  519:
1.7       kristaps  520:        PAIR_STYLE_INIT(&tag, h);
                    521:        print_otag(h, TAG_DIV, i ? 1 : 0, &tag);
1.5       kristaps  522:        return(1);
                    523: }
                    524:
                    525:
                    526: /* ARGSUSED */
                    527: static int
                    528: man_IP_pre(MAN_ARGS)
                    529: {
1.7       kristaps  530:        struct roffsu            su;
1.5       kristaps  531:        struct htmlpair          tag;
                    532:        const struct man_node   *nn;
1.7       kristaps  533:        int                      width;
1.5       kristaps  534:
1.7       kristaps  535:        /*
                    536:         * This scattering of 1-BU margins and pads is to make sure that
                    537:         * when text overruns its box, the subsequent text isn't flush
                    538:         * up against it.  However, the rest of the right-hand box must
                    539:         * also be adjusted in consideration of this 1-BU space.
                    540:         */
                    541:
                    542:        if (MAN_BODY == n->type) {
                    543:                SCALE_HS_INIT(&su, INDENT);
                    544:                bufcat_su(h, "margin-left", &su);
                    545:                PAIR_STYLE_INIT(&tag, h);
                    546:                print_otag(h, TAG_DIV, 1, &tag);
1.6       kristaps  547:                return(1);
                    548:        }
                    549:
                    550:        nn = MAN_BLOCK == n->type ?
                    551:                n->head->child : n->parent->head->child;
                    552:
1.7       kristaps  553:        SCALE_HS_INIT(&su, INDENT);
                    554:        width = 0;
1.6       kristaps  555:
1.7       kristaps  556:        if (MAN_IP == n->tok && NULL != nn)
1.5       kristaps  557:                if (NULL != (nn = nn->next)) {
                    558:                        for ( ; nn->next; nn = nn->next)
                    559:                                /* Do nothing. */ ;
1.7       kristaps  560:                        width = a2width(nn, &su);
1.5       kristaps  561:                }
                    562:
1.7       kristaps  563:        if (MAN_TP == n->tok && NULL != nn)
                    564:                width = a2width(nn, &su);
                    565:
1.5       kristaps  566:        if (MAN_BLOCK == n->type) {
1.7       kristaps  567:                bufcat_su(h, "margin-left", &su);
                    568:                bufcat_style(h, "clear", "both");
                    569:                PAIR_STYLE_INIT(&tag, h);
1.5       kristaps  570:                print_otag(h, TAG_DIV, 1, &tag);
                    571:                return(1);
1.6       kristaps  572:        }
                    573:
1.7       kristaps  574:        bufcat_su(h, "min-width", &su);
                    575:        SCALE_INVERT(&su);
                    576:        bufcat_su(h, "margin-left", &su);
                    577:        SCALE_HS_INIT(&su, 1);
                    578:        bufcat_su(h, "margin-right", &su);
                    579:        bufcat_style(h, "clear", "left");
1.6       kristaps  580:
                    581:        if (n->next && n->next->child)
1.7       kristaps  582:                bufcat_style(h, "float", "left");
1.6       kristaps  583:
1.7       kristaps  584:        PAIR_STYLE_INIT(&tag, h);
1.6       kristaps  585:        print_otag(h, TAG_DIV, 1, &tag);
                    586:
1.7       kristaps  587:        /* With a length string, manually omit the last child. */
                    588:
                    589:        if ( ! width)
1.6       kristaps  590:                return(1);
                    591:
1.7       kristaps  592:        if (MAN_IP == n->tok)
                    593:                for (nn = n->child; nn->next; nn = nn->next)
                    594:                        print_man_node(m, nn, h);
                    595:        if (MAN_TP == n->tok)
                    596:                for (nn = n->child->next; nn; nn = nn->next)
                    597:                        print_man_node(m, nn, h);
1.6       kristaps  598:
                    599:        return(0);
                    600: }
                    601:
                    602:
                    603: /* ARGSUSED */
                    604: static int
                    605: man_HP_pre(MAN_ARGS)
                    606: {
                    607:        const struct man_node   *nn;
                    608:        struct htmlpair          tag;
1.7       kristaps  609:        struct roffsu            su;
1.6       kristaps  610:
                    611:        if (MAN_HEAD == n->type)
                    612:                return(0);
                    613:
                    614:        nn = MAN_BLOCK == n->type ?
                    615:                n->head->child : n->parent->head->child;
                    616:
1.7       kristaps  617:        SCALE_HS_INIT(&su, INDENT);
1.6       kristaps  618:
                    619:        if (NULL != nn)
1.7       kristaps  620:                (void)a2width(nn, &su);
1.6       kristaps  621:
                    622:        if (MAN_BLOCK == n->type) {
1.7       kristaps  623:                bufcat_su(h, "margin-left", &su);
                    624:                bufcat_style(h, "clear", "both");
                    625:                PAIR_STYLE_INIT(&tag, h);
1.5       kristaps  626:                print_otag(h, TAG_DIV, 1, &tag);
1.6       kristaps  627:                return(1);
                    628:        }
1.5       kristaps  629:
1.7       kristaps  630:        bufcat_su(h, "margin-left", &su);
                    631:        SCALE_INVERT(&su);
                    632:        bufcat_su(h, "text-indent", &su);
1.5       kristaps  633:
1.7       kristaps  634:        PAIR_STYLE_INIT(&tag, h);
1.6       kristaps  635:        print_otag(h, TAG_DIV, 1, &tag);
1.4       kristaps  636:        return(1);
                    637: }
1.6       kristaps  638:
1.8     ! kristaps  639:
        !           640: /* ARGSUSED */
        !           641: static int
        !           642: man_B_pre(MAN_ARGS)
        !           643: {
        !           644:        struct htmlpair  tag;
        !           645:
        !           646:        PAIR_CLASS_INIT(&tag, "bold");
        !           647:        print_otag(h, TAG_SPAN, 1, &tag);
        !           648:        return(1);
        !           649: }
        !           650:
        !           651:
        !           652: /* ARGSUSED */
        !           653: static int
        !           654: man_I_pre(MAN_ARGS)
        !           655: {
        !           656:        struct htmlpair  tag;
        !           657:
        !           658:        PAIR_CLASS_INIT(&tag, "italic");
        !           659:        print_otag(h, TAG_SPAN, 1, &tag);
        !           660:        return(1);
        !           661: }
        !           662:
        !           663:
        !           664: /* ARGSUSED */
        !           665: static int
        !           666: man_ign_pre(MAN_ARGS)
        !           667: {
        !           668:
        !           669:        return(0);
        !           670: }

CVSweb