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

Annotation of mandoc/man_html.c, Revision 1.123

1.123   ! schwarze    1: /*     $Id: man_html.c,v 1.122 2017/01/17 01:47:51 schwarze Exp $ */
1.1       kristaps    2: /*
1.104     kristaps    3:  * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
1.122     schwarze    4:  * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
1.1       kristaps    5:  *
                      6:  * Permission to use, copy, modify, and distribute this software for any
                      7:  * purpose with or without fee is hereby granted, provided that the above
                      8:  * copyright notice and this permission notice appear in all copies.
                      9:  *
1.113     schwarze   10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
1.1       kristaps   11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1.113     schwarze   12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
1.1       kristaps   13:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     14:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     15:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     16:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     17:  */
1.25      kristaps   18: #include "config.h"
                     19:
1.1       kristaps   20: #include <sys/types.h>
                     21:
1.5       kristaps   22: #include <assert.h>
                     23: #include <ctype.h>
1.2       kristaps   24: #include <stdio.h>
1.1       kristaps   25: #include <stdlib.h>
1.4       kristaps   26: #include <string.h>
1.1       kristaps   27:
1.94      schwarze   28: #include "mandoc_aux.h"
1.113     schwarze   29: #include "roff.h"
1.105     schwarze   30: #include "man.h"
1.7       kristaps   31: #include "out.h"
1.1       kristaps   32: #include "html.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.115     schwarze   40: #define        MAN_ARGS          const struct roff_meta *man, \
1.114     schwarze   41:                          const struct roff_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.93      schwarze   55: static void              print_bvspace(struct html *,
1.114     schwarze   56:                                const struct roff_node *);
1.3       kristaps   57: static void              print_man_head(MAN_ARGS);
1.4       kristaps   58: static void              print_man_nodelist(MAN_ARGS);
                     59: static void              print_man_node(MAN_ARGS);
1.114     schwarze   60: static int               a2width(const struct roff_node *,
1.7       kristaps   61:                                struct roffsu *);
1.8       kristaps   62: static int               man_B_pre(MAN_ARGS);
1.6       kristaps   63: static int               man_HP_pre(MAN_ARGS);
1.86      kristaps   64: static int               man_IP_pre(MAN_ARGS);
1.8       kristaps   65: static int               man_I_pre(MAN_ARGS);
1.86      kristaps   66: static int               man_OP_pre(MAN_ARGS);
1.4       kristaps   67: static int               man_PP_pre(MAN_ARGS);
1.9       kristaps   68: static int               man_RS_pre(MAN_ARGS);
1.4       kristaps   69: static int               man_SH_pre(MAN_ARGS);
1.8       kristaps   70: static int               man_SM_pre(MAN_ARGS);
1.4       kristaps   71: static int               man_SS_pre(MAN_ARGS);
1.90      schwarze   72: static int               man_UR_pre(MAN_ARGS);
1.86      kristaps   73: static int               man_alt_pre(MAN_ARGS);
                     74: static int               man_br_pre(MAN_ARGS);
                     75: static int               man_ign_pre(MAN_ARGS);
                     76: static int               man_in_pre(MAN_ARGS);
                     77: static int               man_literal_pre(MAN_ARGS);
                     78: static void              man_root_post(MAN_ARGS);
                     79: static void              man_root_pre(MAN_ARGS);
1.4       kristaps   80:
1.3       kristaps   81: static const struct htmlman mans[MAN_MAX] = {
1.4       kristaps   82:        { man_br_pre, NULL }, /* br */
1.3       kristaps   83:        { NULL, NULL }, /* TH */
1.4       kristaps   84:        { man_SH_pre, NULL }, /* SH */
                     85:        { man_SS_pre, NULL }, /* SS */
1.6       kristaps   86:        { man_IP_pre, NULL }, /* TP */
1.4       kristaps   87:        { man_PP_pre, NULL }, /* LP */
                     88:        { man_PP_pre, NULL }, /* PP */
                     89:        { man_PP_pre, NULL }, /* P */
1.5       kristaps   90:        { man_IP_pre, NULL }, /* IP */
1.93      schwarze   91:        { man_HP_pre, NULL }, /* HP */
1.8       kristaps   92:        { man_SM_pre, NULL }, /* SM */
1.56      kristaps   93:        { man_SM_pre, NULL }, /* SB */
1.8       kristaps   94:        { man_alt_pre, NULL }, /* BI */
                     95:        { man_alt_pre, NULL }, /* IB */
                     96:        { man_alt_pre, NULL }, /* BR */
                     97:        { man_alt_pre, NULL }, /* RB */
1.3       kristaps   98:        { NULL, NULL }, /* R */
1.8       kristaps   99:        { man_B_pre, NULL }, /* B */
                    100:        { man_I_pre, NULL }, /* I */
                    101:        { man_alt_pre, NULL }, /* IR */
                    102:        { man_alt_pre, NULL }, /* RI */
1.4       kristaps  103:        { man_br_pre, NULL }, /* sp */
1.45      kristaps  104:        { man_literal_pre, NULL }, /* nf */
                    105:        { man_literal_pre, NULL }, /* fi */
1.3       kristaps  106:        { NULL, NULL }, /* RE */
1.9       kristaps  107:        { man_RS_pre, NULL }, /* RS */
1.8       kristaps  108:        { man_ign_pre, NULL }, /* DT */
                    109:        { man_ign_pre, NULL }, /* UC */
1.13      kristaps  110:        { man_ign_pre, NULL }, /* PD */
1.34      joerg     111:        { man_ign_pre, NULL }, /* AT */
1.45      kristaps  112:        { man_in_pre, NULL }, /* in */
1.51      kristaps  113:        { man_ign_pre, NULL }, /* ft */
1.86      kristaps  114:        { man_OP_pre, NULL }, /* OP */
1.88      schwarze  115:        { man_literal_pre, NULL }, /* EX */
                    116:        { man_literal_pre, NULL }, /* EE */
1.90      schwarze  117:        { man_UR_pre, NULL }, /* UR */
                    118:        { NULL, NULL }, /* UE */
1.92      schwarze  119:        { man_ign_pre, NULL }, /* ll */
1.3       kristaps  120: };
                    121:
1.93      schwarze  122:
1.74      kristaps  123: /*
                    124:  * Printing leading vertical space before a block.
                    125:  * This is used for the paragraph macros.
                    126:  * The rules are pretty simple, since there's very little nesting going
                    127:  * on here.  Basically, if we're the first within another block (SS/SH),
                    128:  * then don't emit vertical space.  If we are (RS), then do.  If not the
                    129:  * first, print it.
                    130:  */
                    131: static void
1.114     schwarze  132: print_bvspace(struct html *h, const struct roff_node *n)
1.74      kristaps  133: {
                    134:
                    135:        if (n->body && n->body->child)
1.113     schwarze  136:                if (n->body->child->type == ROFFT_TBL)
1.74      kristaps  137:                        return;
                    138:
1.113     schwarze  139:        if (n->parent->type == ROFFT_ROOT || n->parent->tok != MAN_RS)
1.74      kristaps  140:                if (NULL == n->prev)
                    141:                        return;
                    142:
1.103     kristaps  143:        print_paragraph(h);
1.74      kristaps  144: }
1.1       kristaps  145:
                    146: void
1.116     schwarze  147: html_man(void *arg, const struct roff_man *man)
1.1       kristaps  148: {
1.45      kristaps  149:        struct mhtml     mh;
1.117     schwarze  150:        struct html     *h;
1.82      kristaps  151:        struct tag      *t, *tt;
                    152:
1.117     schwarze  153:        memset(&mh, 0, sizeof(mh));
                    154:        h = (struct html *)arg;
1.3       kristaps  155:
1.82      kristaps  156:        if ( ! (HTML_FRAGMENT & h->oflags)) {
                    157:                print_gen_decls(h);
1.122     schwarze  158:                t = print_otag(h, TAG_HTML, "");
                    159:                tt = print_otag(h, TAG_HEAD, "");
1.117     schwarze  160:                print_man_head(&man->meta, man->first, &mh, h);
1.82      kristaps  161:                print_tagq(h, tt);
1.122     schwarze  162:                print_otag(h, TAG_BODY, "");
                    163:                print_otag(h, TAG_DIV, "c", "mandoc");
1.93      schwarze  164:        } else
1.122     schwarze  165:                t = print_otag(h, TAG_DIV, "c", "mandoc");
1.53      kristaps  166:
1.117     schwarze  167:        print_man_nodelist(&man->meta, man->first, &mh, h);
1.3       kristaps  168:        print_tagq(h, t);
1.117     schwarze  169:        putchar('\n');
1.3       kristaps  170: }
                    171:
                    172: static void
                    173: print_man_head(MAN_ARGS)
                    174: {
1.123   ! schwarze  175:        char    *cp;
1.3       kristaps  176:
                    177:        print_gen_head(h);
1.123   ! schwarze  178:        mandoc_asprintf(&cp, "%s(%s)", man->title, man->msec);
1.122     schwarze  179:        print_otag(h, TAG_TITLE, "");
1.123   ! schwarze  180:        print_text(h, cp);
        !           181:        free(cp);
1.1       kristaps  182: }
1.4       kristaps  183:
                    184: static void
                    185: print_man_nodelist(MAN_ARGS)
                    186: {
                    187:
1.110     schwarze  188:        while (n != NULL) {
                    189:                print_man_node(man, n, mh, h);
                    190:                n = n->next;
                    191:        }
1.4       kristaps  192: }
                    193:
                    194: static void
                    195: print_man_node(MAN_ARGS)
                    196: {
                    197:        int              child;
                    198:        struct tag      *t;
                    199:
                    200:        child = 1;
1.14      kristaps  201:        t = h->tags.head;
1.4       kristaps  202:
                    203:        switch (n->type) {
1.113     schwarze  204:        case ROFFT_ROOT:
1.89      schwarze  205:                man_root_pre(man, n, mh, h);
1.4       kristaps  206:                break;
1.113     schwarze  207:        case ROFFT_TEXT:
1.63      kristaps  208:                if ('\0' == *n->string) {
1.103     kristaps  209:                        print_paragraph(h);
1.63      kristaps  210:                        return;
1.78      kristaps  211:                }
1.121     schwarze  212:                if (n->flags & NODE_LINE && (*n->string == ' ' ||
1.106     schwarze  213:                    (n->prev != NULL && mh->fl & MANH_LITERAL &&
                    214:                     ! (h->flags & HTML_NONEWLINE))))
1.122     schwarze  215:                        print_otag(h, TAG_BR, "");
1.4       kristaps  216:                print_text(h, n->string);
1.68      kristaps  217:                return;
1.113     schwarze  218:        case ROFFT_EQN:
1.121     schwarze  219:                if (n->flags & NODE_LINE)
1.112     schwarze  220:                        putchar('\n');
1.80      kristaps  221:                print_eqn(h, n->eqn);
1.69      kristaps  222:                break;
1.113     schwarze  223:        case ROFFT_TBL:
1.66      kristaps  224:                /*
                    225:                 * This will take care of initialising all of the table
                    226:                 * state data for the first table, then tearing it down
                    227:                 * for the last one.
                    228:                 */
1.60      kristaps  229:                print_tbl(h, n->span);
1.64      kristaps  230:                return;
1.4       kristaps  231:        default:
1.93      schwarze  232:                /*
1.21      kristaps  233:                 * Close out scope of font prior to opening a macro
1.66      kristaps  234:                 * scope.
1.21      kristaps  235:                 */
1.57      kristaps  236:                if (HTMLFONT_NONE != h->metac) {
                    237:                        h->metal = h->metac;
                    238:                        h->metac = HTMLFONT_NONE;
1.66      kristaps  239:                }
                    240:
                    241:                /*
                    242:                 * Close out the current table, if it's open, and unset
                    243:                 * the "meta" table state.  This will be reopened on the
                    244:                 * next table element.
                    245:                 */
                    246:                if (h->tblt) {
                    247:                        print_tblclose(h);
                    248:                        t = h->tags.head;
1.20      kristaps  249:                }
1.4       kristaps  250:                if (mans[n->tok].pre)
1.89      schwarze  251:                        child = (*mans[n->tok].pre)(man, n, mh, h);
1.4       kristaps  252:                break;
                    253:        }
                    254:
1.21      kristaps  255:        if (child && n->child)
1.89      schwarze  256:                print_man_nodelist(man, n->child, mh, h);
1.21      kristaps  257:
1.24      kristaps  258:        /* This will automatically close out any font scope. */
1.4       kristaps  259:        print_stagq(h, t);
                    260:
1.61      kristaps  261:        switch (n->type) {
1.113     schwarze  262:        case ROFFT_ROOT:
1.89      schwarze  263:                man_root_post(man, n, mh, h);
1.69      kristaps  264:                break;
1.113     schwarze  265:        case ROFFT_EQN:
1.61      kristaps  266:                break;
                    267:        default:
                    268:                if (mans[n->tok].post)
1.89      schwarze  269:                        (*mans[n->tok].post)(man, n, mh, h);
1.61      kristaps  270:                break;
                    271:        }
1.4       kristaps  272: }
                    273:
1.5       kristaps  274: static int
1.114     schwarze  275: a2width(const struct roff_node *n, struct roffsu *su)
1.5       kristaps  276: {
                    277:
1.113     schwarze  278:        if (n->type != ROFFT_TEXT)
1.119     schwarze  279:                return 0;
1.107     schwarze  280:        if (a2roffsu(n->string, su, SCALE_EN))
1.119     schwarze  281:                return 1;
1.5       kristaps  282:
1.119     schwarze  283:        return 0;
1.5       kristaps  284: }
                    285:
1.65      kristaps  286: static void
1.4       kristaps  287: man_root_pre(MAN_ARGS)
                    288: {
                    289:        struct tag      *t, *tt;
1.94      schwarze  290:        char            *title;
1.4       kristaps  291:
1.89      schwarze  292:        assert(man->title);
                    293:        assert(man->msec);
1.94      schwarze  294:        mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.4       kristaps  295:
1.122     schwarze  296:        t = print_otag(h, TAG_TABLE, "c", "head");
                    297:        print_otag(h, TAG_TBODY, "");
                    298:        tt = print_otag(h, TAG_TR, "");
1.4       kristaps  299:
1.122     schwarze  300:        print_otag(h, TAG_TD, "c", "head-ltitle");
1.4       kristaps  301:        print_text(h, title);
                    302:        print_stagq(h, tt);
                    303:
1.122     schwarze  304:        print_otag(h, TAG_TD, "c", "head-vol");
1.95      schwarze  305:        if (NULL != man->vol)
                    306:                print_text(h, man->vol);
1.4       kristaps  307:        print_stagq(h, tt);
                    308:
1.122     schwarze  309:        print_otag(h, TAG_TD, "c", "head-rtitle");
1.4       kristaps  310:        print_text(h, title);
                    311:        print_tagq(h, t);
1.94      schwarze  312:        free(title);
1.4       kristaps  313: }
                    314:
                    315: static void
                    316: man_root_post(MAN_ARGS)
                    317: {
                    318:        struct tag      *t, *tt;
                    319:
1.122     schwarze  320:        t = print_otag(h, TAG_TABLE, "c", "foot");
                    321:        tt = print_otag(h, TAG_TR, "");
1.55      kristaps  322:
1.122     schwarze  323:        print_otag(h, TAG_TD, "c", "foot-date");
1.89      schwarze  324:        print_text(h, man->date);
1.4       kristaps  325:        print_stagq(h, tt);
                    326:
1.122     schwarze  327:        print_otag(h, TAG_TD, "c", "foot-os");
1.115     schwarze  328:        if (man->os)
                    329:                print_text(h, man->os);
1.4       kristaps  330:        print_tagq(h, t);
                    331: }
                    332:
                    333:
                    334: static int
                    335: man_br_pre(MAN_ARGS)
                    336: {
1.7       kristaps  337:        struct roffsu    su;
1.4       kristaps  338:
1.7       kristaps  339:        SCALE_VS_INIT(&su, 1);
                    340:
1.49      kristaps  341:        if (MAN_sp == n->tok) {
1.75      kristaps  342:                if (NULL != (n = n->child))
                    343:                        if ( ! a2roffsu(n->string, &su, SCALE_VS))
1.108     schwarze  344:                                su.scale = 1.0;
1.49      kristaps  345:        } else
1.96      schwarze  346:                su.scale = 0.0;
1.4       kristaps  347:
1.122     schwarze  348:        print_otag(h, TAG_DIV, "suh", &su);
1.24      kristaps  349:
1.16      kristaps  350:        /* So the div isn't empty: */
                    351:        print_text(h, "\\~");
                    352:
1.119     schwarze  353:        return 0;
1.4       kristaps  354: }
                    355:
                    356: static int
                    357: man_SH_pre(MAN_ARGS)
                    358: {
1.113     schwarze  359:        if (n->type == ROFFT_BLOCK) {
1.76      kristaps  360:                mh->fl &= ~MANH_LITERAL;
1.122     schwarze  361:                print_otag(h, TAG_DIV, "c", "section");
1.119     schwarze  362:                return 1;
1.113     schwarze  363:        } else if (n->type == ROFFT_BODY)
1.119     schwarze  364:                return 1;
1.4       kristaps  365:
1.122     schwarze  366:        print_otag(h, TAG_H1, "");
1.119     schwarze  367:        return 1;
1.4       kristaps  368: }
                    369:
                    370: static int
1.8       kristaps  371: man_alt_pre(MAN_ARGS)
                    372: {
1.114     schwarze  373:        const struct roff_node  *nn;
1.78      kristaps  374:        int              i, savelit;
1.57      kristaps  375:        enum htmltag     fp;
                    376:        struct tag      *t;
1.8       kristaps  377:
1.93      schwarze  378:        if ((savelit = mh->fl & MANH_LITERAL))
1.122     schwarze  379:                print_otag(h, TAG_BR, "");
1.78      kristaps  380:
                    381:        mh->fl &= ~MANH_LITERAL;
                    382:
1.8       kristaps  383:        for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.57      kristaps  384:                t = NULL;
1.8       kristaps  385:                switch (n->tok) {
1.93      schwarze  386:                case MAN_BI:
1.57      kristaps  387:                        fp = i % 2 ? TAG_I : TAG_B;
1.8       kristaps  388:                        break;
1.93      schwarze  389:                case MAN_IB:
1.57      kristaps  390:                        fp = i % 2 ? TAG_B : TAG_I;
1.8       kristaps  391:                        break;
1.93      schwarze  392:                case MAN_RI:
1.57      kristaps  393:                        fp = i % 2 ? TAG_I : TAG_MAX;
1.8       kristaps  394:                        break;
1.93      schwarze  395:                case MAN_IR:
1.57      kristaps  396:                        fp = i % 2 ? TAG_MAX : TAG_I;
1.8       kristaps  397:                        break;
1.93      schwarze  398:                case MAN_BR:
1.57      kristaps  399:                        fp = i % 2 ? TAG_MAX : TAG_B;
1.8       kristaps  400:                        break;
1.93      schwarze  401:                case MAN_RB:
1.57      kristaps  402:                        fp = i % 2 ? TAG_B : TAG_MAX;
1.8       kristaps  403:                        break;
                    404:                default:
                    405:                        abort();
                    406:                }
                    407:
                    408:                if (i)
                    409:                        h->flags |= HTML_NOSPACE;
                    410:
1.57      kristaps  411:                if (TAG_MAX != fp)
1.122     schwarze  412:                        t = print_otag(h, fp, "");
1.57      kristaps  413:
1.89      schwarze  414:                print_man_node(man, nn, mh, h);
1.57      kristaps  415:
                    416:                if (t)
                    417:                        print_tagq(h, t);
1.8       kristaps  418:        }
                    419:
1.78      kristaps  420:        if (savelit)
                    421:                mh->fl |= MANH_LITERAL;
                    422:
1.119     schwarze  423:        return 0;
1.8       kristaps  424: }
                    425:
                    426: static int
1.56      kristaps  427: man_SM_pre(MAN_ARGS)
1.8       kristaps  428: {
1.122     schwarze  429:        print_otag(h, TAG_SMALL, "");
1.56      kristaps  430:        if (MAN_SB == n->tok)
1.122     schwarze  431:                print_otag(h, TAG_B, "");
1.119     schwarze  432:        return 1;
1.8       kristaps  433: }
                    434:
                    435: static int
1.4       kristaps  436: man_SS_pre(MAN_ARGS)
                    437: {
1.113     schwarze  438:        if (n->type == ROFFT_BLOCK) {
1.76      kristaps  439:                mh->fl &= ~MANH_LITERAL;
1.122     schwarze  440:                print_otag(h, TAG_DIV, "c", "subsection");
1.119     schwarze  441:                return 1;
1.113     schwarze  442:        } else if (n->type == ROFFT_BODY)
1.119     schwarze  443:                return 1;
1.4       kristaps  444:
1.122     schwarze  445:        print_otag(h, TAG_H2, "");
1.119     schwarze  446:        return 1;
1.4       kristaps  447: }
                    448:
                    449: static int
                    450: man_PP_pre(MAN_ARGS)
                    451: {
                    452:
1.113     schwarze  453:        if (n->type == ROFFT_HEAD)
1.119     schwarze  454:                return 0;
1.113     schwarze  455:        else if (n->type == ROFFT_BLOCK)
1.74      kristaps  456:                print_bvspace(h, n);
1.47      kristaps  457:
1.119     schwarze  458:        return 1;
1.5       kristaps  459: }
                    460:
                    461: static int
                    462: man_IP_pre(MAN_ARGS)
                    463: {
1.114     schwarze  464:        const struct roff_node  *nn;
1.5       kristaps  465:
1.113     schwarze  466:        if (n->type == ROFFT_BODY) {
1.122     schwarze  467:                print_otag(h, TAG_DD, "");
1.119     schwarze  468:                return 1;
1.113     schwarze  469:        } else if (n->type != ROFFT_HEAD) {
1.122     schwarze  470:                print_otag(h, TAG_DL, "");
1.119     schwarze  471:                return 1;
1.6       kristaps  472:        }
                    473:
1.78      kristaps  474:        /* FIXME: width specification. */
                    475:
1.122     schwarze  476:        print_otag(h, TAG_DT, "");
1.6       kristaps  477:
1.59      schwarze  478:        /* For IP, only print the first header element. */
1.7       kristaps  479:
1.59      schwarze  480:        if (MAN_IP == n->tok && n->child)
1.89      schwarze  481:                print_man_node(man, n->child, mh, h);
1.27      kristaps  482:
1.59      schwarze  483:        /* For TP, only print next-line header elements. */
1.6       kristaps  484:
1.91      schwarze  485:        if (MAN_TP == n->tok) {
                    486:                nn = n->child;
1.121     schwarze  487:                while (NULL != nn && 0 == (NODE_LINE & nn->flags))
1.91      schwarze  488:                        nn = nn->next;
                    489:                while (NULL != nn) {
                    490:                        print_man_node(man, nn, mh, h);
                    491:                        nn = nn->next;
                    492:                }
                    493:        }
1.6       kristaps  494:
1.119     schwarze  495:        return 0;
1.6       kristaps  496: }
                    497:
                    498: static int
                    499: man_HP_pre(MAN_ARGS)
                    500: {
1.122     schwarze  501:        struct roffsu    sum, sui;
1.114     schwarze  502:        const struct roff_node *np;
1.6       kristaps  503:
1.113     schwarze  504:        if (n->type == ROFFT_HEAD)
1.119     schwarze  505:                return 0;
1.113     schwarze  506:        else if (n->type != ROFFT_BLOCK)
1.119     schwarze  507:                return 1;
1.72      kristaps  508:
1.77      kristaps  509:        np = n->head->child;
1.6       kristaps  510:
1.122     schwarze  511:        if (np == NULL || !a2width(np, &sum))
                    512:                SCALE_HS_INIT(&sum, INDENT);
1.6       kristaps  513:
1.122     schwarze  514:        sui.unit = sum.unit;
                    515:        sui.scale = -sum.scale;
1.5       kristaps  516:
1.77      kristaps  517:        print_bvspace(h, n);
1.122     schwarze  518:        print_otag(h, TAG_DIV, "csului", "spacer", &sum, &sui);
1.119     schwarze  519:        return 1;
1.4       kristaps  520: }
1.86      kristaps  521:
                    522: static int
                    523: man_OP_pre(MAN_ARGS)
                    524: {
                    525:        struct tag      *tt;
                    526:
                    527:        print_text(h, "[");
                    528:        h->flags |= HTML_NOSPACE;
1.122     schwarze  529:        tt = print_otag(h, TAG_SPAN, "c", "opt");
1.86      kristaps  530:
                    531:        if (NULL != (n = n->child)) {
1.122     schwarze  532:                print_otag(h, TAG_B, "");
1.86      kristaps  533:                print_text(h, n->string);
                    534:        }
                    535:
                    536:        print_stagq(h, tt);
                    537:
                    538:        if (NULL != n && NULL != n->next) {
1.122     schwarze  539:                print_otag(h, TAG_I, "");
1.86      kristaps  540:                print_text(h, n->next->string);
                    541:        }
                    542:
                    543:        print_stagq(h, tt);
                    544:        h->flags |= HTML_NOSPACE;
                    545:        print_text(h, "]");
1.119     schwarze  546:        return 0;
1.86      kristaps  547: }
                    548:
1.8       kristaps  549: static int
                    550: man_B_pre(MAN_ARGS)
                    551: {
1.122     schwarze  552:        print_otag(h, TAG_B, "");
1.119     schwarze  553:        return 1;
1.8       kristaps  554: }
                    555:
                    556: static int
                    557: man_I_pre(MAN_ARGS)
                    558: {
1.122     schwarze  559:        print_otag(h, TAG_I, "");
1.119     schwarze  560:        return 1;
1.45      kristaps  561: }
                    562:
                    563: static int
                    564: man_literal_pre(MAN_ARGS)
                    565: {
                    566:
1.88      schwarze  567:        if (MAN_fi == n->tok || MAN_EE == n->tok) {
1.122     schwarze  568:                print_otag(h, TAG_BR, "");
1.78      kristaps  569:                mh->fl &= ~MANH_LITERAL;
                    570:        } else
1.45      kristaps  571:                mh->fl |= MANH_LITERAL;
                    572:
1.119     schwarze  573:        return 0;
1.45      kristaps  574: }
                    575:
                    576: static int
                    577: man_in_pre(MAN_ARGS)
                    578: {
1.122     schwarze  579:        print_otag(h, TAG_BR, "");
1.119     schwarze  580:        return 0;
1.8       kristaps  581: }
                    582:
                    583: static int
                    584: man_ign_pre(MAN_ARGS)
                    585: {
                    586:
1.119     schwarze  587:        return 0;
1.8       kristaps  588: }
1.9       kristaps  589:
                    590: static int
                    591: man_RS_pre(MAN_ARGS)
                    592: {
                    593:        struct roffsu    su;
                    594:
1.113     schwarze  595:        if (n->type == ROFFT_HEAD)
1.119     schwarze  596:                return 0;
1.113     schwarze  597:        else if (n->type == ROFFT_BODY)
1.119     schwarze  598:                return 1;
1.9       kristaps  599:
                    600:        SCALE_HS_INIT(&su, INDENT);
1.56      kristaps  601:        if (n->head->child)
1.9       kristaps  602:                a2width(n->head->child, &su);
                    603:
1.122     schwarze  604:        print_otag(h, TAG_DIV, "sul", &su);
1.119     schwarze  605:        return 1;
1.90      schwarze  606: }
                    607:
                    608: static int
                    609: man_UR_pre(MAN_ARGS)
                    610: {
                    611:        n = n->child;
1.113     schwarze  612:        assert(n->type == ROFFT_HEAD);
1.120     schwarze  613:        if (n->child != NULL) {
1.113     schwarze  614:                assert(n->child->type == ROFFT_TEXT);
1.122     schwarze  615:                print_otag(h, TAG_A, "ch", "link-ext", n->child->string);
1.90      schwarze  616:        }
                    617:
1.113     schwarze  618:        assert(n->next->type == ROFFT_BODY);
1.120     schwarze  619:        if (n->next->child != NULL)
1.90      schwarze  620:                n = n->next;
                    621:
                    622:        print_man_nodelist(man, n->child, mh, h);
                    623:
1.119     schwarze  624:        return 0;
1.9       kristaps  625: }

CVSweb