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

Annotation of mandoc/man_html.c, Revision 1.153

1.153   ! schwarze    1: /*     $Id: man_html.c,v 1.152 2018/06/25 13:33:04 schwarze Exp $ */
1.1       kristaps    2: /*
1.104     kristaps    3:  * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
1.147     schwarze    4:  * Copyright (c) 2013,2014,2015,2017,2018 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.144     schwarze   29: #include "mandoc.h"
1.113     schwarze   30: #include "roff.h"
1.105     schwarze   31: #include "man.h"
1.7       kristaps   32: #include "out.h"
1.1       kristaps   33: #include "html.h"
1.10      kristaps   34: #include "main.h"
1.1       kristaps   35:
1.13      kristaps   36: /* FIXME: have PD set the default vspace width. */
1.4       kristaps   37:
1.115     schwarze   38: #define        MAN_ARGS          const struct roff_meta *man, \
1.114     schwarze   39:                          const struct roff_node *n, \
1.3       kristaps   40:                          struct html *h
                     41:
                     42: struct htmlman {
                     43:        int             (*pre)(MAN_ARGS);
                     44:        int             (*post)(MAN_ARGS);
                     45: };
                     46:
1.93      schwarze   47: static void              print_bvspace(struct html *,
1.114     schwarze   48:                                const struct roff_node *);
1.147     schwarze   49: static void              print_man_head(const struct roff_meta *,
                     50:                                struct html *);
1.4       kristaps   51: static void              print_man_nodelist(MAN_ARGS);
                     52: static void              print_man_node(MAN_ARGS);
1.132     schwarze   53: static int               fillmode(struct html *, int);
1.8       kristaps   54: static int               man_B_pre(MAN_ARGS);
1.6       kristaps   55: static int               man_HP_pre(MAN_ARGS);
1.86      kristaps   56: static int               man_IP_pre(MAN_ARGS);
1.8       kristaps   57: static int               man_I_pre(MAN_ARGS);
1.86      kristaps   58: static int               man_OP_pre(MAN_ARGS);
1.4       kristaps   59: static int               man_PP_pre(MAN_ARGS);
1.9       kristaps   60: static int               man_RS_pre(MAN_ARGS);
1.4       kristaps   61: static int               man_SH_pre(MAN_ARGS);
1.8       kristaps   62: static int               man_SM_pre(MAN_ARGS);
1.4       kristaps   63: static int               man_SS_pre(MAN_ARGS);
1.90      schwarze   64: static int               man_UR_pre(MAN_ARGS);
1.86      kristaps   65: static int               man_alt_pre(MAN_ARGS);
                     66: static int               man_ign_pre(MAN_ARGS);
                     67: static int               man_in_pre(MAN_ARGS);
1.147     schwarze   68: static void              man_root_post(const struct roff_meta *,
                     69:                                struct html *);
                     70: static void              man_root_pre(const struct roff_meta *,
                     71:                                struct html *);
1.4       kristaps   72:
1.136     schwarze   73: static const struct htmlman __mans[MAN_MAX - MAN_TH] = {
1.3       kristaps   74:        { NULL, NULL }, /* TH */
1.4       kristaps   75:        { man_SH_pre, NULL }, /* SH */
                     76:        { man_SS_pre, NULL }, /* SS */
1.6       kristaps   77:        { man_IP_pre, NULL }, /* TP */
1.4       kristaps   78:        { man_PP_pre, NULL }, /* LP */
                     79:        { man_PP_pre, NULL }, /* PP */
                     80:        { man_PP_pre, NULL }, /* P */
1.5       kristaps   81:        { man_IP_pre, NULL }, /* IP */
1.93      schwarze   82:        { man_HP_pre, NULL }, /* HP */
1.8       kristaps   83:        { man_SM_pre, NULL }, /* SM */
1.56      kristaps   84:        { man_SM_pre, NULL }, /* SB */
1.8       kristaps   85:        { man_alt_pre, NULL }, /* BI */
                     86:        { man_alt_pre, NULL }, /* IB */
                     87:        { man_alt_pre, NULL }, /* BR */
                     88:        { man_alt_pre, NULL }, /* RB */
1.3       kristaps   89:        { NULL, NULL }, /* R */
1.8       kristaps   90:        { man_B_pre, NULL }, /* B */
                     91:        { man_I_pre, NULL }, /* I */
                     92:        { man_alt_pre, NULL }, /* IR */
                     93:        { man_alt_pre, NULL }, /* RI */
1.132     schwarze   94:        { NULL, NULL }, /* nf */
                     95:        { NULL, NULL }, /* fi */
1.3       kristaps   96:        { NULL, NULL }, /* RE */
1.9       kristaps   97:        { man_RS_pre, NULL }, /* RS */
1.8       kristaps   98:        { man_ign_pre, NULL }, /* DT */
                     99:        { man_ign_pre, NULL }, /* UC */
1.13      kristaps  100:        { man_ign_pre, NULL }, /* PD */
1.34      joerg     101:        { man_ign_pre, NULL }, /* AT */
1.45      kristaps  102:        { man_in_pre, NULL }, /* in */
1.86      kristaps  103:        { man_OP_pre, NULL }, /* OP */
1.132     schwarze  104:        { NULL, NULL }, /* EX */
                    105:        { NULL, NULL }, /* EE */
1.90      schwarze  106:        { man_UR_pre, NULL }, /* UR */
                    107:        { NULL, NULL }, /* UE */
1.145     schwarze  108:        { man_UR_pre, NULL }, /* MT */
                    109:        { NULL, NULL }, /* ME */
1.3       kristaps  110: };
1.136     schwarze  111: static const struct htmlman *const mans = __mans - MAN_TH;
1.3       kristaps  112:
1.93      schwarze  113:
1.74      kristaps  114: /*
                    115:  * Printing leading vertical space before a block.
                    116:  * This is used for the paragraph macros.
                    117:  * The rules are pretty simple, since there's very little nesting going
                    118:  * on here.  Basically, if we're the first within another block (SS/SH),
                    119:  * then don't emit vertical space.  If we are (RS), then do.  If not the
                    120:  * first, print it.
                    121:  */
                    122: static void
1.114     schwarze  123: print_bvspace(struct html *h, const struct roff_node *n)
1.74      kristaps  124: {
                    125:
                    126:        if (n->body && n->body->child)
1.113     schwarze  127:                if (n->body->child->type == ROFFT_TBL)
1.74      kristaps  128:                        return;
                    129:
1.113     schwarze  130:        if (n->parent->type == ROFFT_ROOT || n->parent->tok != MAN_RS)
1.74      kristaps  131:                if (NULL == n->prev)
                    132:                        return;
                    133:
1.103     kristaps  134:        print_paragraph(h);
1.74      kristaps  135: }
1.1       kristaps  136:
                    137: void
1.116     schwarze  138: html_man(void *arg, const struct roff_man *man)
1.1       kristaps  139: {
1.147     schwarze  140:        struct html             *h;
                    141:        struct roff_node        *n;
                    142:        struct tag              *t;
1.82      kristaps  143:
1.117     schwarze  144:        h = (struct html *)arg;
1.147     schwarze  145:        n = man->first->child;
1.3       kristaps  146:
1.126     schwarze  147:        if ((h->oflags & HTML_FRAGMENT) == 0) {
1.82      kristaps  148:                print_gen_decls(h);
1.126     schwarze  149:                print_otag(h, TAG_HTML, "");
1.147     schwarze  150:                if (n->type == ROFFT_COMMENT)
                    151:                        print_gen_comment(h, n);
1.126     schwarze  152:                t = print_otag(h, TAG_HEAD, "");
1.147     schwarze  153:                print_man_head(&man->meta, h);
1.126     schwarze  154:                print_tagq(h, t);
1.122     schwarze  155:                print_otag(h, TAG_BODY, "");
1.126     schwarze  156:        }
1.53      kristaps  157:
1.147     schwarze  158:        man_root_pre(&man->meta, h);
1.127     schwarze  159:        t = print_otag(h, TAG_DIV, "c", "manual-text");
1.147     schwarze  160:        print_man_nodelist(&man->meta, n, h);
1.127     schwarze  161:        print_tagq(h, t);
1.147     schwarze  162:        man_root_post(&man->meta, h);
1.126     schwarze  163:        print_tagq(h, NULL);
1.3       kristaps  164: }
                    165:
                    166: static void
1.147     schwarze  167: print_man_head(const struct roff_meta *man, struct html *h)
1.3       kristaps  168: {
1.123     schwarze  169:        char    *cp;
1.3       kristaps  170:
                    171:        print_gen_head(h);
1.123     schwarze  172:        mandoc_asprintf(&cp, "%s(%s)", man->title, man->msec);
1.122     schwarze  173:        print_otag(h, TAG_TITLE, "");
1.123     schwarze  174:        print_text(h, cp);
                    175:        free(cp);
1.1       kristaps  176: }
1.4       kristaps  177:
                    178: static void
                    179: print_man_nodelist(MAN_ARGS)
                    180: {
                    181:
1.110     schwarze  182:        while (n != NULL) {
1.132     schwarze  183:                print_man_node(man, n, h);
1.110     schwarze  184:                n = n->next;
                    185:        }
1.4       kristaps  186: }
                    187:
                    188: static void
                    189: print_man_node(MAN_ARGS)
                    190: {
1.132     schwarze  191:        static int       want_fillmode = MAN_fi;
                    192:        static int       save_fillmode;
                    193:
                    194:        struct tag      *t;
1.4       kristaps  195:        int              child;
                    196:
1.132     schwarze  197:        /*
                    198:         * Handle fill mode switch requests up front,
                    199:         * they would just cause trouble in the subsequent code.
                    200:         */
                    201:
                    202:        switch (n->tok) {
                    203:        case MAN_nf:
                    204:        case MAN_EX:
                    205:                want_fillmode = MAN_nf;
                    206:                return;
                    207:        case MAN_fi:
                    208:        case MAN_EE:
                    209:                want_fillmode = MAN_fi;
                    210:                if (fillmode(h, 0) == MAN_fi)
                    211:                        print_otag(h, TAG_BR, "");
                    212:                return;
                    213:        default:
                    214:                break;
                    215:        }
                    216:
                    217:        /* Set up fill mode for the upcoming node. */
1.4       kristaps  218:
                    219:        switch (n->type) {
1.132     schwarze  220:        case ROFFT_BLOCK:
                    221:                save_fillmode = 0;
                    222:                /* Some block macros suspend or cancel .nf. */
                    223:                switch (n->tok) {
                    224:                case MAN_TP:  /* Tagged paragraphs              */
                    225:                case MAN_IP:  /* temporarily disable .nf        */
                    226:                case MAN_HP:  /* for the head.                  */
                    227:                        save_fillmode = want_fillmode;
                    228:                        /* FALLTHROUGH */
                    229:                case MAN_SH:  /* Section headers                */
                    230:                case MAN_SS:  /* permanently cancel .nf.        */
                    231:                        want_fillmode = MAN_fi;
                    232:                        /* FALLTHROUGH */
                    233:                case MAN_PP:  /* These have no head.            */
                    234:                case MAN_LP:  /* They will simply               */
                    235:                case MAN_P:   /* reopen .nf in the body.        */
                    236:                case MAN_RS:
                    237:                case MAN_UR:
1.145     schwarze  238:                case MAN_MT:
1.132     schwarze  239:                        fillmode(h, MAN_fi);
                    240:                        break;
                    241:                default:
                    242:                        break;
                    243:                }
                    244:                break;
                    245:        case ROFFT_TBL:
                    246:                fillmode(h, MAN_fi);
                    247:                break;
                    248:        case ROFFT_ELEM:
                    249:                /*
                    250:                 * Some in-line macros produce tags and/or text
                    251:                 * in the handler, so they require fill mode to be
                    252:                 * configured up front just like for text nodes.
                    253:                 * For the others, keep the traditional approach
                    254:                 * of doing the same, for now.
                    255:                 */
                    256:                fillmode(h, want_fillmode);
                    257:                break;
1.113     schwarze  258:        case ROFFT_TEXT:
1.132     schwarze  259:                if (fillmode(h, want_fillmode) == MAN_fi &&
                    260:                    want_fillmode == MAN_fi &&
1.142     schwarze  261:                    n->flags & NODE_LINE && *n->string == ' ' &&
                    262:                    (h->flags & HTML_NONEWLINE) == 0)
1.122     schwarze  263:                        print_otag(h, TAG_BR, "");
1.132     schwarze  264:                if (*n->string != '\0')
                    265:                        break;
                    266:                print_paragraph(h);
1.146     schwarze  267:                return;
                    268:        case ROFFT_COMMENT:
1.132     schwarze  269:                return;
                    270:        default:
                    271:                break;
                    272:        }
                    273:
                    274:        /* Produce output for this node. */
                    275:
                    276:        child = 1;
                    277:        switch (n->type) {
                    278:        case ROFFT_TEXT:
                    279:                t = h->tag;
1.4       kristaps  280:                print_text(h, n->string);
1.130     schwarze  281:                break;
1.113     schwarze  282:        case ROFFT_EQN:
1.132     schwarze  283:                t = h->tag;
1.80      kristaps  284:                print_eqn(h, n->eqn);
1.69      kristaps  285:                break;
1.113     schwarze  286:        case ROFFT_TBL:
1.66      kristaps  287:                /*
                    288:                 * This will take care of initialising all of the table
                    289:                 * state data for the first table, then tearing it down
                    290:                 * for the last one.
                    291:                 */
1.60      kristaps  292:                print_tbl(h, n->span);
1.64      kristaps  293:                return;
1.4       kristaps  294:        default:
1.93      schwarze  295:                /*
1.21      kristaps  296:                 * Close out scope of font prior to opening a macro
1.66      kristaps  297:                 * scope.
1.21      kristaps  298:                 */
1.57      kristaps  299:                if (HTMLFONT_NONE != h->metac) {
                    300:                        h->metal = h->metac;
                    301:                        h->metac = HTMLFONT_NONE;
1.66      kristaps  302:                }
                    303:
                    304:                /*
                    305:                 * Close out the current table, if it's open, and unset
                    306:                 * the "meta" table state.  This will be reopened on the
                    307:                 * next table element.
                    308:                 */
1.132     schwarze  309:                if (h->tblt)
1.66      kristaps  310:                        print_tblclose(h);
1.132     schwarze  311:
                    312:                t = h->tag;
1.137     schwarze  313:                if (n->tok < ROFF_MAX) {
1.138     schwarze  314:                        roff_html_pre(h, n);
1.141     schwarze  315:                        child = 0;
1.137     schwarze  316:                        break;
                    317:                }
                    318:
                    319:                assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
1.4       kristaps  320:                if (mans[n->tok].pre)
1.132     schwarze  321:                        child = (*mans[n->tok].pre)(man, n, h);
                    322:
                    323:                /* Some block macros resume .nf in the body. */
                    324:                if (save_fillmode && n->type == ROFFT_BODY)
                    325:                        want_fillmode = save_fillmode;
                    326:
1.4       kristaps  327:                break;
                    328:        }
                    329:
1.21      kristaps  330:        if (child && n->child)
1.132     schwarze  331:                print_man_nodelist(man, n->child, h);
1.21      kristaps  332:
1.24      kristaps  333:        /* This will automatically close out any font scope. */
1.132     schwarze  334:        print_stagq(h, t);
                    335:
                    336:        if (fillmode(h, 0) == MAN_nf &&
                    337:            n->next != NULL && n->next->flags & NODE_LINE)
                    338:                print_endline(h);
                    339: }
                    340:
                    341: /*
                    342:  * MAN_nf switches to no-fill mode, MAN_fi to fill mode.
                    343:  * Other arguments do not switch.
                    344:  * The old mode is returned.
                    345:  */
                    346: static int
                    347: fillmode(struct html *h, int want)
                    348: {
                    349:        struct tag      *pre;
                    350:        int              had;
1.4       kristaps  351:
1.132     schwarze  352:        for (pre = h->tag; pre != NULL; pre = pre->next)
                    353:                if (pre->tag == TAG_PRE)
                    354:                        break;
                    355:
                    356:        had = pre == NULL ? MAN_fi : MAN_nf;
1.130     schwarze  357:
1.132     schwarze  358:        if (want && want != had) {
                    359:                if (want == MAN_nf)
                    360:                        print_otag(h, TAG_PRE, "");
                    361:                else
                    362:                        print_tagq(h, pre);
                    363:        }
                    364:        return had;
1.4       kristaps  365: }
                    366:
1.65      kristaps  367: static void
1.147     schwarze  368: man_root_pre(const struct roff_meta *man, struct html *h)
1.4       kristaps  369: {
                    370:        struct tag      *t, *tt;
1.94      schwarze  371:        char            *title;
1.4       kristaps  372:
1.89      schwarze  373:        assert(man->title);
                    374:        assert(man->msec);
1.94      schwarze  375:        mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.4       kristaps  376:
1.122     schwarze  377:        t = print_otag(h, TAG_TABLE, "c", "head");
                    378:        tt = print_otag(h, TAG_TR, "");
1.4       kristaps  379:
1.122     schwarze  380:        print_otag(h, TAG_TD, "c", "head-ltitle");
1.4       kristaps  381:        print_text(h, title);
                    382:        print_stagq(h, tt);
                    383:
1.122     schwarze  384:        print_otag(h, TAG_TD, "c", "head-vol");
1.95      schwarze  385:        if (NULL != man->vol)
                    386:                print_text(h, man->vol);
1.4       kristaps  387:        print_stagq(h, tt);
                    388:
1.122     schwarze  389:        print_otag(h, TAG_TD, "c", "head-rtitle");
1.4       kristaps  390:        print_text(h, title);
                    391:        print_tagq(h, t);
1.94      schwarze  392:        free(title);
1.4       kristaps  393: }
                    394:
                    395: static void
1.147     schwarze  396: man_root_post(const struct roff_meta *man, struct html *h)
1.4       kristaps  397: {
                    398:        struct tag      *t, *tt;
                    399:
1.122     schwarze  400:        t = print_otag(h, TAG_TABLE, "c", "foot");
                    401:        tt = print_otag(h, TAG_TR, "");
1.55      kristaps  402:
1.122     schwarze  403:        print_otag(h, TAG_TD, "c", "foot-date");
1.89      schwarze  404:        print_text(h, man->date);
1.4       kristaps  405:        print_stagq(h, tt);
                    406:
1.122     schwarze  407:        print_otag(h, TAG_TD, "c", "foot-os");
1.115     schwarze  408:        if (man->os)
                    409:                print_text(h, man->os);
1.4       kristaps  410:        print_tagq(h, t);
                    411: }
                    412:
                    413: static int
                    414: man_SH_pre(MAN_ARGS)
                    415: {
1.134     schwarze  416:        char    *id;
                    417:
                    418:        if (n->type == ROFFT_HEAD) {
1.150     schwarze  419:                id = html_make_id(n, 1);
1.134     schwarze  420:                print_otag(h, TAG_H1, "cTi", "Sh", id);
1.135     schwarze  421:                if (id != NULL)
1.148     schwarze  422:                        print_otag(h, TAG_A, "chR", "permalink", id);
1.134     schwarze  423:        }
1.119     schwarze  424:        return 1;
1.4       kristaps  425: }
                    426:
                    427: static int
1.8       kristaps  428: man_alt_pre(MAN_ARGS)
                    429: {
1.114     schwarze  430:        const struct roff_node  *nn;
1.130     schwarze  431:        int              i;
1.57      kristaps  432:        enum htmltag     fp;
                    433:        struct tag      *t;
1.8       kristaps  434:
                    435:        for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
                    436:                switch (n->tok) {
1.93      schwarze  437:                case MAN_BI:
1.57      kristaps  438:                        fp = i % 2 ? TAG_I : TAG_B;
1.8       kristaps  439:                        break;
1.93      schwarze  440:                case MAN_IB:
1.57      kristaps  441:                        fp = i % 2 ? TAG_B : TAG_I;
1.8       kristaps  442:                        break;
1.93      schwarze  443:                case MAN_RI:
1.57      kristaps  444:                        fp = i % 2 ? TAG_I : TAG_MAX;
1.8       kristaps  445:                        break;
1.93      schwarze  446:                case MAN_IR:
1.57      kristaps  447:                        fp = i % 2 ? TAG_MAX : TAG_I;
1.8       kristaps  448:                        break;
1.93      schwarze  449:                case MAN_BR:
1.57      kristaps  450:                        fp = i % 2 ? TAG_MAX : TAG_B;
1.8       kristaps  451:                        break;
1.93      schwarze  452:                case MAN_RB:
1.57      kristaps  453:                        fp = i % 2 ? TAG_B : TAG_MAX;
1.8       kristaps  454:                        break;
                    455:                default:
                    456:                        abort();
                    457:                }
                    458:
                    459:                if (i)
                    460:                        h->flags |= HTML_NOSPACE;
                    461:
1.130     schwarze  462:                if (fp != TAG_MAX)
1.122     schwarze  463:                        t = print_otag(h, fp, "");
1.57      kristaps  464:
1.130     schwarze  465:                print_text(h, nn->string);
1.57      kristaps  466:
1.130     schwarze  467:                if (fp != TAG_MAX)
1.57      kristaps  468:                        print_tagq(h, t);
1.8       kristaps  469:        }
1.119     schwarze  470:        return 0;
1.8       kristaps  471: }
                    472:
                    473: static int
1.56      kristaps  474: man_SM_pre(MAN_ARGS)
1.8       kristaps  475: {
1.122     schwarze  476:        print_otag(h, TAG_SMALL, "");
1.56      kristaps  477:        if (MAN_SB == n->tok)
1.122     schwarze  478:                print_otag(h, TAG_B, "");
1.119     schwarze  479:        return 1;
1.8       kristaps  480: }
                    481:
                    482: static int
1.4       kristaps  483: man_SS_pre(MAN_ARGS)
                    484: {
1.134     schwarze  485:        char    *id;
                    486:
                    487:        if (n->type == ROFFT_HEAD) {
1.150     schwarze  488:                id = html_make_id(n, 1);
1.134     schwarze  489:                print_otag(h, TAG_H2, "cTi", "Ss", id);
1.135     schwarze  490:                if (id != NULL)
1.148     schwarze  491:                        print_otag(h, TAG_A, "chR", "permalink", id);
1.134     schwarze  492:        }
1.119     schwarze  493:        return 1;
1.4       kristaps  494: }
                    495:
                    496: static int
                    497: man_PP_pre(MAN_ARGS)
                    498: {
                    499:
1.113     schwarze  500:        if (n->type == ROFFT_HEAD)
1.119     schwarze  501:                return 0;
1.113     schwarze  502:        else if (n->type == ROFFT_BLOCK)
1.74      kristaps  503:                print_bvspace(h, n);
1.47      kristaps  504:
1.119     schwarze  505:        return 1;
1.5       kristaps  506: }
                    507:
                    508: static int
                    509: man_IP_pre(MAN_ARGS)
                    510: {
1.114     schwarze  511:        const struct roff_node  *nn;
1.5       kristaps  512:
1.113     schwarze  513:        if (n->type == ROFFT_BODY) {
1.149     schwarze  514:                print_otag(h, TAG_DD, "");
1.119     schwarze  515:                return 1;
1.113     schwarze  516:        } else if (n->type != ROFFT_HEAD) {
1.129     schwarze  517:                print_otag(h, TAG_DL, "c", "Bl-tag");
1.119     schwarze  518:                return 1;
1.6       kristaps  519:        }
                    520:
1.78      kristaps  521:        /* FIXME: width specification. */
                    522:
1.149     schwarze  523:        print_otag(h, TAG_DT, "");
1.6       kristaps  524:
1.59      schwarze  525:        /* For IP, only print the first header element. */
1.7       kristaps  526:
1.59      schwarze  527:        if (MAN_IP == n->tok && n->child)
1.132     schwarze  528:                print_man_node(man, n->child, h);
1.27      kristaps  529:
1.59      schwarze  530:        /* For TP, only print next-line header elements. */
1.6       kristaps  531:
1.91      schwarze  532:        if (MAN_TP == n->tok) {
                    533:                nn = n->child;
1.121     schwarze  534:                while (NULL != nn && 0 == (NODE_LINE & nn->flags))
1.91      schwarze  535:                        nn = nn->next;
                    536:                while (NULL != nn) {
1.132     schwarze  537:                        print_man_node(man, nn, h);
1.91      schwarze  538:                        nn = nn->next;
                    539:                }
                    540:        }
1.6       kristaps  541:
1.119     schwarze  542:        return 0;
1.6       kristaps  543: }
                    544:
                    545: static int
                    546: man_HP_pre(MAN_ARGS)
                    547: {
1.113     schwarze  548:        if (n->type == ROFFT_HEAD)
1.119     schwarze  549:                return 0;
1.72      kristaps  550:
1.151     schwarze  551:        if (n->type == ROFFT_BLOCK) {
                    552:                print_bvspace(h, n);
                    553:                print_otag(h, TAG_DIV, "c", "HP");
                    554:        }
1.119     schwarze  555:        return 1;
1.4       kristaps  556: }
1.86      kristaps  557:
                    558: static int
                    559: man_OP_pre(MAN_ARGS)
                    560: {
                    561:        struct tag      *tt;
                    562:
                    563:        print_text(h, "[");
                    564:        h->flags |= HTML_NOSPACE;
1.128     schwarze  565:        tt = print_otag(h, TAG_SPAN, "c", "Op");
1.86      kristaps  566:
                    567:        if (NULL != (n = n->child)) {
1.122     schwarze  568:                print_otag(h, TAG_B, "");
1.86      kristaps  569:                print_text(h, n->string);
                    570:        }
                    571:
                    572:        print_stagq(h, tt);
                    573:
                    574:        if (NULL != n && NULL != n->next) {
1.122     schwarze  575:                print_otag(h, TAG_I, "");
1.86      kristaps  576:                print_text(h, n->next->string);
                    577:        }
                    578:
                    579:        print_stagq(h, tt);
                    580:        h->flags |= HTML_NOSPACE;
                    581:        print_text(h, "]");
1.119     schwarze  582:        return 0;
1.86      kristaps  583: }
                    584:
1.8       kristaps  585: static int
                    586: man_B_pre(MAN_ARGS)
                    587: {
1.122     schwarze  588:        print_otag(h, TAG_B, "");
1.119     schwarze  589:        return 1;
1.8       kristaps  590: }
                    591:
                    592: static int
                    593: man_I_pre(MAN_ARGS)
                    594: {
1.122     schwarze  595:        print_otag(h, TAG_I, "");
1.119     schwarze  596:        return 1;
1.45      kristaps  597: }
                    598:
                    599: static int
                    600: man_in_pre(MAN_ARGS)
                    601: {
1.122     schwarze  602:        print_otag(h, TAG_BR, "");
1.119     schwarze  603:        return 0;
1.8       kristaps  604: }
                    605:
                    606: static int
                    607: man_ign_pre(MAN_ARGS)
                    608: {
                    609:
1.119     schwarze  610:        return 0;
1.8       kristaps  611: }
1.9       kristaps  612:
                    613: static int
                    614: man_RS_pre(MAN_ARGS)
                    615: {
1.113     schwarze  616:        if (n->type == ROFFT_HEAD)
1.119     schwarze  617:                return 0;
1.152     schwarze  618:        if (n->type == ROFFT_BLOCK)
                    619:                print_otag(h, TAG_DIV, "c", "Bd-indent");
1.119     schwarze  620:        return 1;
1.90      schwarze  621: }
                    622:
                    623: static int
                    624: man_UR_pre(MAN_ARGS)
                    625: {
1.145     schwarze  626:        char *cp;
1.90      schwarze  627:        n = n->child;
1.113     schwarze  628:        assert(n->type == ROFFT_HEAD);
1.120     schwarze  629:        if (n->child != NULL) {
1.113     schwarze  630:                assert(n->child->type == ROFFT_TEXT);
1.145     schwarze  631:                if (n->tok == MAN_MT) {
                    632:                        mandoc_asprintf(&cp, "mailto:%s", n->child->string);
                    633:                        print_otag(h, TAG_A, "cTh", "Mt", cp);
                    634:                        free(cp);
                    635:                } else
                    636:                        print_otag(h, TAG_A, "cTh", "Lk", n->child->string);
1.90      schwarze  637:        }
                    638:
1.113     schwarze  639:        assert(n->next->type == ROFFT_BODY);
1.120     schwarze  640:        if (n->next->child != NULL)
1.90      schwarze  641:                n = n->next;
                    642:
1.132     schwarze  643:        print_man_nodelist(man, n->child, h);
1.90      schwarze  644:
1.119     schwarze  645:        return 0;
1.9       kristaps  646: }

CVSweb