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

Annotation of mandoc/man_html.c, Revision 1.124

1.124   ! schwarze    1: /*     $Id: man_html.c,v 1.123 2017/01/17 15:32:44 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);
                    169: }
                    170:
                    171: static void
                    172: print_man_head(MAN_ARGS)
                    173: {
1.123     schwarze  174:        char    *cp;
1.3       kristaps  175:
                    176:        print_gen_head(h);
1.123     schwarze  177:        mandoc_asprintf(&cp, "%s(%s)", man->title, man->msec);
1.122     schwarze  178:        print_otag(h, TAG_TITLE, "");
1.123     schwarze  179:        print_text(h, cp);
                    180:        free(cp);
1.1       kristaps  181: }
1.4       kristaps  182:
                    183: static void
                    184: print_man_nodelist(MAN_ARGS)
                    185: {
                    186:
1.110     schwarze  187:        while (n != NULL) {
                    188:                print_man_node(man, n, mh, h);
                    189:                n = n->next;
                    190:        }
1.4       kristaps  191: }
                    192:
                    193: static void
                    194: print_man_node(MAN_ARGS)
                    195: {
                    196:        int              child;
                    197:        struct tag      *t;
                    198:
                    199:        child = 1;
1.14      kristaps  200:        t = h->tags.head;
1.4       kristaps  201:
                    202:        switch (n->type) {
1.113     schwarze  203:        case ROFFT_ROOT:
1.89      schwarze  204:                man_root_pre(man, n, mh, h);
1.4       kristaps  205:                break;
1.113     schwarze  206:        case ROFFT_TEXT:
1.63      kristaps  207:                if ('\0' == *n->string) {
1.103     kristaps  208:                        print_paragraph(h);
1.63      kristaps  209:                        return;
1.78      kristaps  210:                }
1.121     schwarze  211:                if (n->flags & NODE_LINE && (*n->string == ' ' ||
1.106     schwarze  212:                    (n->prev != NULL && mh->fl & MANH_LITERAL &&
                    213:                     ! (h->flags & HTML_NONEWLINE))))
1.122     schwarze  214:                        print_otag(h, TAG_BR, "");
1.4       kristaps  215:                print_text(h, n->string);
1.68      kristaps  216:                return;
1.113     schwarze  217:        case ROFFT_EQN:
1.121     schwarze  218:                if (n->flags & NODE_LINE)
1.112     schwarze  219:                        putchar('\n');
1.80      kristaps  220:                print_eqn(h, n->eqn);
1.69      kristaps  221:                break;
1.113     schwarze  222:        case ROFFT_TBL:
1.66      kristaps  223:                /*
                    224:                 * This will take care of initialising all of the table
                    225:                 * state data for the first table, then tearing it down
                    226:                 * for the last one.
                    227:                 */
1.60      kristaps  228:                print_tbl(h, n->span);
1.64      kristaps  229:                return;
1.4       kristaps  230:        default:
1.93      schwarze  231:                /*
1.21      kristaps  232:                 * Close out scope of font prior to opening a macro
1.66      kristaps  233:                 * scope.
1.21      kristaps  234:                 */
1.57      kristaps  235:                if (HTMLFONT_NONE != h->metac) {
                    236:                        h->metal = h->metac;
                    237:                        h->metac = HTMLFONT_NONE;
1.66      kristaps  238:                }
                    239:
                    240:                /*
                    241:                 * Close out the current table, if it's open, and unset
                    242:                 * the "meta" table state.  This will be reopened on the
                    243:                 * next table element.
                    244:                 */
                    245:                if (h->tblt) {
                    246:                        print_tblclose(h);
                    247:                        t = h->tags.head;
1.20      kristaps  248:                }
1.4       kristaps  249:                if (mans[n->tok].pre)
1.89      schwarze  250:                        child = (*mans[n->tok].pre)(man, n, mh, h);
1.4       kristaps  251:                break;
                    252:        }
                    253:
1.21      kristaps  254:        if (child && n->child)
1.89      schwarze  255:                print_man_nodelist(man, n->child, mh, h);
1.21      kristaps  256:
1.24      kristaps  257:        /* This will automatically close out any font scope. */
1.4       kristaps  258:        print_stagq(h, t);
                    259:
1.61      kristaps  260:        switch (n->type) {
1.113     schwarze  261:        case ROFFT_ROOT:
1.89      schwarze  262:                man_root_post(man, n, mh, h);
1.69      kristaps  263:                break;
1.113     schwarze  264:        case ROFFT_EQN:
1.61      kristaps  265:                break;
                    266:        default:
                    267:                if (mans[n->tok].post)
1.89      schwarze  268:                        (*mans[n->tok].post)(man, n, mh, h);
1.61      kristaps  269:                break;
                    270:        }
1.4       kristaps  271: }
                    272:
1.5       kristaps  273: static int
1.114     schwarze  274: a2width(const struct roff_node *n, struct roffsu *su)
1.5       kristaps  275: {
                    276:
1.113     schwarze  277:        if (n->type != ROFFT_TEXT)
1.119     schwarze  278:                return 0;
1.107     schwarze  279:        if (a2roffsu(n->string, su, SCALE_EN))
1.119     schwarze  280:                return 1;
1.5       kristaps  281:
1.119     schwarze  282:        return 0;
1.5       kristaps  283: }
                    284:
1.65      kristaps  285: static void
1.4       kristaps  286: man_root_pre(MAN_ARGS)
                    287: {
                    288:        struct tag      *t, *tt;
1.94      schwarze  289:        char            *title;
1.4       kristaps  290:
1.89      schwarze  291:        assert(man->title);
                    292:        assert(man->msec);
1.94      schwarze  293:        mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.4       kristaps  294:
1.122     schwarze  295:        t = print_otag(h, TAG_TABLE, "c", "head");
                    296:        print_otag(h, TAG_TBODY, "");
                    297:        tt = print_otag(h, TAG_TR, "");
1.4       kristaps  298:
1.122     schwarze  299:        print_otag(h, TAG_TD, "c", "head-ltitle");
1.4       kristaps  300:        print_text(h, title);
                    301:        print_stagq(h, tt);
                    302:
1.122     schwarze  303:        print_otag(h, TAG_TD, "c", "head-vol");
1.95      schwarze  304:        if (NULL != man->vol)
                    305:                print_text(h, man->vol);
1.4       kristaps  306:        print_stagq(h, tt);
                    307:
1.122     schwarze  308:        print_otag(h, TAG_TD, "c", "head-rtitle");
1.4       kristaps  309:        print_text(h, title);
                    310:        print_tagq(h, t);
1.94      schwarze  311:        free(title);
1.4       kristaps  312: }
                    313:
                    314: static void
                    315: man_root_post(MAN_ARGS)
                    316: {
                    317:        struct tag      *t, *tt;
                    318:
1.122     schwarze  319:        t = print_otag(h, TAG_TABLE, "c", "foot");
                    320:        tt = print_otag(h, TAG_TR, "");
1.55      kristaps  321:
1.122     schwarze  322:        print_otag(h, TAG_TD, "c", "foot-date");
1.89      schwarze  323:        print_text(h, man->date);
1.4       kristaps  324:        print_stagq(h, tt);
                    325:
1.122     schwarze  326:        print_otag(h, TAG_TD, "c", "foot-os");
1.115     schwarze  327:        if (man->os)
                    328:                print_text(h, man->os);
1.4       kristaps  329:        print_tagq(h, t);
                    330: }
                    331:
                    332:
                    333: static int
                    334: man_br_pre(MAN_ARGS)
                    335: {
1.7       kristaps  336:        struct roffsu    su;
1.4       kristaps  337:
1.7       kristaps  338:        SCALE_VS_INIT(&su, 1);
                    339:
1.49      kristaps  340:        if (MAN_sp == n->tok) {
1.75      kristaps  341:                if (NULL != (n = n->child))
                    342:                        if ( ! a2roffsu(n->string, &su, SCALE_VS))
1.108     schwarze  343:                                su.scale = 1.0;
1.49      kristaps  344:        } else
1.96      schwarze  345:                su.scale = 0.0;
1.4       kristaps  346:
1.122     schwarze  347:        print_otag(h, TAG_DIV, "suh", &su);
1.24      kristaps  348:
1.16      kristaps  349:        /* So the div isn't empty: */
                    350:        print_text(h, "\\~");
                    351:
1.119     schwarze  352:        return 0;
1.4       kristaps  353: }
                    354:
                    355: static int
                    356: man_SH_pre(MAN_ARGS)
                    357: {
1.113     schwarze  358:        if (n->type == ROFFT_BLOCK) {
1.76      kristaps  359:                mh->fl &= ~MANH_LITERAL;
1.122     schwarze  360:                print_otag(h, TAG_DIV, "c", "section");
1.119     schwarze  361:                return 1;
1.113     schwarze  362:        } else if (n->type == ROFFT_BODY)
1.119     schwarze  363:                return 1;
1.4       kristaps  364:
1.122     schwarze  365:        print_otag(h, TAG_H1, "");
1.119     schwarze  366:        return 1;
1.4       kristaps  367: }
                    368:
                    369: static int
1.8       kristaps  370: man_alt_pre(MAN_ARGS)
                    371: {
1.114     schwarze  372:        const struct roff_node  *nn;
1.78      kristaps  373:        int              i, savelit;
1.57      kristaps  374:        enum htmltag     fp;
                    375:        struct tag      *t;
1.8       kristaps  376:
1.93      schwarze  377:        if ((savelit = mh->fl & MANH_LITERAL))
1.122     schwarze  378:                print_otag(h, TAG_BR, "");
1.78      kristaps  379:
                    380:        mh->fl &= ~MANH_LITERAL;
                    381:
1.8       kristaps  382:        for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.57      kristaps  383:                t = NULL;
1.8       kristaps  384:                switch (n->tok) {
1.93      schwarze  385:                case MAN_BI:
1.57      kristaps  386:                        fp = i % 2 ? TAG_I : TAG_B;
1.8       kristaps  387:                        break;
1.93      schwarze  388:                case MAN_IB:
1.57      kristaps  389:                        fp = i % 2 ? TAG_B : TAG_I;
1.8       kristaps  390:                        break;
1.93      schwarze  391:                case MAN_RI:
1.57      kristaps  392:                        fp = i % 2 ? TAG_I : TAG_MAX;
1.8       kristaps  393:                        break;
1.93      schwarze  394:                case MAN_IR:
1.57      kristaps  395:                        fp = i % 2 ? TAG_MAX : TAG_I;
1.8       kristaps  396:                        break;
1.93      schwarze  397:                case MAN_BR:
1.57      kristaps  398:                        fp = i % 2 ? TAG_MAX : TAG_B;
1.8       kristaps  399:                        break;
1.93      schwarze  400:                case MAN_RB:
1.57      kristaps  401:                        fp = i % 2 ? TAG_B : TAG_MAX;
1.8       kristaps  402:                        break;
                    403:                default:
                    404:                        abort();
                    405:                }
                    406:
                    407:                if (i)
                    408:                        h->flags |= HTML_NOSPACE;
                    409:
1.57      kristaps  410:                if (TAG_MAX != fp)
1.122     schwarze  411:                        t = print_otag(h, fp, "");
1.57      kristaps  412:
1.89      schwarze  413:                print_man_node(man, nn, mh, h);
1.57      kristaps  414:
                    415:                if (t)
                    416:                        print_tagq(h, t);
1.8       kristaps  417:        }
                    418:
1.78      kristaps  419:        if (savelit)
                    420:                mh->fl |= MANH_LITERAL;
                    421:
1.119     schwarze  422:        return 0;
1.8       kristaps  423: }
                    424:
                    425: static int
1.56      kristaps  426: man_SM_pre(MAN_ARGS)
1.8       kristaps  427: {
1.122     schwarze  428:        print_otag(h, TAG_SMALL, "");
1.56      kristaps  429:        if (MAN_SB == n->tok)
1.122     schwarze  430:                print_otag(h, TAG_B, "");
1.119     schwarze  431:        return 1;
1.8       kristaps  432: }
                    433:
                    434: static int
1.4       kristaps  435: man_SS_pre(MAN_ARGS)
                    436: {
1.113     schwarze  437:        if (n->type == ROFFT_BLOCK) {
1.76      kristaps  438:                mh->fl &= ~MANH_LITERAL;
1.122     schwarze  439:                print_otag(h, TAG_DIV, "c", "subsection");
1.119     schwarze  440:                return 1;
1.113     schwarze  441:        } else if (n->type == ROFFT_BODY)
1.119     schwarze  442:                return 1;
1.4       kristaps  443:
1.122     schwarze  444:        print_otag(h, TAG_H2, "");
1.119     schwarze  445:        return 1;
1.4       kristaps  446: }
                    447:
                    448: static int
                    449: man_PP_pre(MAN_ARGS)
                    450: {
                    451:
1.113     schwarze  452:        if (n->type == ROFFT_HEAD)
1.119     schwarze  453:                return 0;
1.113     schwarze  454:        else if (n->type == ROFFT_BLOCK)
1.74      kristaps  455:                print_bvspace(h, n);
1.47      kristaps  456:
1.119     schwarze  457:        return 1;
1.5       kristaps  458: }
                    459:
                    460: static int
                    461: man_IP_pre(MAN_ARGS)
                    462: {
1.114     schwarze  463:        const struct roff_node  *nn;
1.5       kristaps  464:
1.113     schwarze  465:        if (n->type == ROFFT_BODY) {
1.122     schwarze  466:                print_otag(h, TAG_DD, "");
1.119     schwarze  467:                return 1;
1.113     schwarze  468:        } else if (n->type != ROFFT_HEAD) {
1.122     schwarze  469:                print_otag(h, TAG_DL, "");
1.119     schwarze  470:                return 1;
1.6       kristaps  471:        }
                    472:
1.78      kristaps  473:        /* FIXME: width specification. */
                    474:
1.122     schwarze  475:        print_otag(h, TAG_DT, "");
1.6       kristaps  476:
1.59      schwarze  477:        /* For IP, only print the first header element. */
1.7       kristaps  478:
1.59      schwarze  479:        if (MAN_IP == n->tok && n->child)
1.89      schwarze  480:                print_man_node(man, n->child, mh, h);
1.27      kristaps  481:
1.59      schwarze  482:        /* For TP, only print next-line header elements. */
1.6       kristaps  483:
1.91      schwarze  484:        if (MAN_TP == n->tok) {
                    485:                nn = n->child;
1.121     schwarze  486:                while (NULL != nn && 0 == (NODE_LINE & nn->flags))
1.91      schwarze  487:                        nn = nn->next;
                    488:                while (NULL != nn) {
                    489:                        print_man_node(man, nn, mh, h);
                    490:                        nn = nn->next;
                    491:                }
                    492:        }
1.6       kristaps  493:
1.119     schwarze  494:        return 0;
1.6       kristaps  495: }
                    496:
                    497: static int
                    498: man_HP_pre(MAN_ARGS)
                    499: {
1.122     schwarze  500:        struct roffsu    sum, sui;
1.114     schwarze  501:        const struct roff_node *np;
1.6       kristaps  502:
1.113     schwarze  503:        if (n->type == ROFFT_HEAD)
1.119     schwarze  504:                return 0;
1.113     schwarze  505:        else if (n->type != ROFFT_BLOCK)
1.119     schwarze  506:                return 1;
1.72      kristaps  507:
1.77      kristaps  508:        np = n->head->child;
1.6       kristaps  509:
1.122     schwarze  510:        if (np == NULL || !a2width(np, &sum))
                    511:                SCALE_HS_INIT(&sum, INDENT);
1.6       kristaps  512:
1.122     schwarze  513:        sui.unit = sum.unit;
                    514:        sui.scale = -sum.scale;
1.5       kristaps  515:
1.77      kristaps  516:        print_bvspace(h, n);
1.122     schwarze  517:        print_otag(h, TAG_DIV, "csului", "spacer", &sum, &sui);
1.119     schwarze  518:        return 1;
1.4       kristaps  519: }
1.86      kristaps  520:
                    521: static int
                    522: man_OP_pre(MAN_ARGS)
                    523: {
                    524:        struct tag      *tt;
                    525:
                    526:        print_text(h, "[");
                    527:        h->flags |= HTML_NOSPACE;
1.122     schwarze  528:        tt = print_otag(h, TAG_SPAN, "c", "opt");
1.86      kristaps  529:
                    530:        if (NULL != (n = n->child)) {
1.122     schwarze  531:                print_otag(h, TAG_B, "");
1.86      kristaps  532:                print_text(h, n->string);
                    533:        }
                    534:
                    535:        print_stagq(h, tt);
                    536:
                    537:        if (NULL != n && NULL != n->next) {
1.122     schwarze  538:                print_otag(h, TAG_I, "");
1.86      kristaps  539:                print_text(h, n->next->string);
                    540:        }
                    541:
                    542:        print_stagq(h, tt);
                    543:        h->flags |= HTML_NOSPACE;
                    544:        print_text(h, "]");
1.119     schwarze  545:        return 0;
1.86      kristaps  546: }
                    547:
1.8       kristaps  548: static int
                    549: man_B_pre(MAN_ARGS)
                    550: {
1.122     schwarze  551:        print_otag(h, TAG_B, "");
1.119     schwarze  552:        return 1;
1.8       kristaps  553: }
                    554:
                    555: static int
                    556: man_I_pre(MAN_ARGS)
                    557: {
1.122     schwarze  558:        print_otag(h, TAG_I, "");
1.119     schwarze  559:        return 1;
1.45      kristaps  560: }
                    561:
                    562: static int
                    563: man_literal_pre(MAN_ARGS)
                    564: {
                    565:
1.88      schwarze  566:        if (MAN_fi == n->tok || MAN_EE == n->tok) {
1.122     schwarze  567:                print_otag(h, TAG_BR, "");
1.78      kristaps  568:                mh->fl &= ~MANH_LITERAL;
                    569:        } else
1.45      kristaps  570:                mh->fl |= MANH_LITERAL;
                    571:
1.119     schwarze  572:        return 0;
1.45      kristaps  573: }
                    574:
                    575: static int
                    576: man_in_pre(MAN_ARGS)
                    577: {
1.122     schwarze  578:        print_otag(h, TAG_BR, "");
1.119     schwarze  579:        return 0;
1.8       kristaps  580: }
                    581:
                    582: static int
                    583: man_ign_pre(MAN_ARGS)
                    584: {
                    585:
1.119     schwarze  586:        return 0;
1.8       kristaps  587: }
1.9       kristaps  588:
                    589: static int
                    590: man_RS_pre(MAN_ARGS)
                    591: {
                    592:        struct roffsu    su;
                    593:
1.113     schwarze  594:        if (n->type == ROFFT_HEAD)
1.119     schwarze  595:                return 0;
1.113     schwarze  596:        else if (n->type == ROFFT_BODY)
1.119     schwarze  597:                return 1;
1.9       kristaps  598:
                    599:        SCALE_HS_INIT(&su, INDENT);
1.56      kristaps  600:        if (n->head->child)
1.9       kristaps  601:                a2width(n->head->child, &su);
                    602:
1.122     schwarze  603:        print_otag(h, TAG_DIV, "sul", &su);
1.119     schwarze  604:        return 1;
1.90      schwarze  605: }
                    606:
                    607: static int
                    608: man_UR_pre(MAN_ARGS)
                    609: {
                    610:        n = n->child;
1.113     schwarze  611:        assert(n->type == ROFFT_HEAD);
1.120     schwarze  612:        if (n->child != NULL) {
1.113     schwarze  613:                assert(n->child->type == ROFFT_TEXT);
1.122     schwarze  614:                print_otag(h, TAG_A, "ch", "link-ext", n->child->string);
1.90      schwarze  615:        }
                    616:
1.113     schwarze  617:        assert(n->next->type == ROFFT_BODY);
1.120     schwarze  618:        if (n->next->child != NULL)
1.90      schwarze  619:                n = n->next;
                    620:
                    621:        print_man_nodelist(man, n->child, mh, h);
                    622:
1.119     schwarze  623:        return 0;
1.9       kristaps  624: }

CVSweb