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

Annotation of mandoc/man_html.c, Revision 1.126

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

CVSweb