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

Annotation of mandoc/man_html.c, Revision 1.171

1.171   ! schwarze    1: /*     $Id: man_html.c,v 1.170 2019/01/18 14:36:21 schwarze Exp $ */
1.1       kristaps    2: /*
1.104     kristaps    3:  * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
1.163     schwarze    4:  * Copyright (c) 2013-2015, 2017-2019 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.160     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.115     schwarze   36: #define        MAN_ARGS          const struct roff_meta *man, \
1.114     schwarze   37:                          const struct roff_node *n, \
1.3       kristaps   38:                          struct html *h
                     39:
1.155     schwarze   40: struct man_html_act {
1.3       kristaps   41:        int             (*pre)(MAN_ARGS);
                     42:        int             (*post)(MAN_ARGS);
                     43: };
                     44:
1.147     schwarze   45: static void              print_man_head(const struct roff_meta *,
                     46:                                struct html *);
1.4       kristaps   47: static void              print_man_nodelist(MAN_ARGS);
                     48: static void              print_man_node(MAN_ARGS);
1.8       kristaps   49: static int               man_B_pre(MAN_ARGS);
1.86      kristaps   50: static int               man_IP_pre(MAN_ARGS);
1.8       kristaps   51: static int               man_I_pre(MAN_ARGS);
1.86      kristaps   52: static int               man_OP_pre(MAN_ARGS);
1.4       kristaps   53: static int               man_PP_pre(MAN_ARGS);
1.9       kristaps   54: static int               man_RS_pre(MAN_ARGS);
1.4       kristaps   55: static int               man_SH_pre(MAN_ARGS);
1.8       kristaps   56: static int               man_SM_pre(MAN_ARGS);
1.156     schwarze   57: static int               man_SY_pre(MAN_ARGS);
1.90      schwarze   58: static int               man_UR_pre(MAN_ARGS);
1.158     schwarze   59: static int               man_abort_pre(MAN_ARGS);
1.86      kristaps   60: static int               man_alt_pre(MAN_ARGS);
                     61: static int               man_ign_pre(MAN_ARGS);
                     62: static int               man_in_pre(MAN_ARGS);
1.147     schwarze   63: static void              man_root_post(const struct roff_meta *,
                     64:                                struct html *);
                     65: static void              man_root_pre(const struct roff_meta *,
                     66:                                struct html *);
1.4       kristaps   67:
1.155     schwarze   68: static const struct man_html_act man_html_acts[MAN_MAX - MAN_TH] = {
1.3       kristaps   69:        { NULL, NULL }, /* TH */
1.4       kristaps   70:        { man_SH_pre, NULL }, /* SH */
1.166     schwarze   71:        { man_SH_pre, NULL }, /* SS */
1.6       kristaps   72:        { man_IP_pre, NULL }, /* TP */
1.154     schwarze   73:        { man_IP_pre, NULL }, /* TQ */
1.158     schwarze   74:        { man_abort_pre, NULL }, /* LP */
1.4       kristaps   75:        { man_PP_pre, NULL }, /* PP */
1.158     schwarze   76:        { man_abort_pre, NULL }, /* P */
1.5       kristaps   77:        { man_IP_pre, NULL }, /* IP */
1.166     schwarze   78:        { man_PP_pre, NULL }, /* HP */
1.8       kristaps   79:        { man_SM_pre, NULL }, /* SM */
1.56      kristaps   80:        { man_SM_pre, NULL }, /* SB */
1.8       kristaps   81:        { man_alt_pre, NULL }, /* BI */
                     82:        { man_alt_pre, NULL }, /* IB */
                     83:        { man_alt_pre, NULL }, /* BR */
                     84:        { man_alt_pre, NULL }, /* RB */
1.3       kristaps   85:        { NULL, NULL }, /* R */
1.8       kristaps   86:        { man_B_pre, NULL }, /* B */
                     87:        { man_I_pre, NULL }, /* I */
                     88:        { man_alt_pre, NULL }, /* IR */
                     89:        { man_alt_pre, NULL }, /* RI */
1.3       kristaps   90:        { NULL, NULL }, /* RE */
1.9       kristaps   91:        { man_RS_pre, NULL }, /* RS */
1.8       kristaps   92:        { man_ign_pre, NULL }, /* DT */
                     93:        { man_ign_pre, NULL }, /* UC */
1.13      kristaps   94:        { man_ign_pre, NULL }, /* PD */
1.34      joerg      95:        { man_ign_pre, NULL }, /* AT */
1.45      kristaps   96:        { man_in_pre, NULL }, /* in */
1.156     schwarze   97:        { man_SY_pre, NULL }, /* SY */
                     98:        { NULL, NULL }, /* YS */
1.86      kristaps   99:        { man_OP_pre, NULL }, /* OP */
1.132     schwarze  100:        { NULL, NULL }, /* EX */
                    101:        { NULL, NULL }, /* EE */
1.90      schwarze  102:        { man_UR_pre, NULL }, /* UR */
                    103:        { NULL, NULL }, /* UE */
1.145     schwarze  104:        { man_UR_pre, NULL }, /* MT */
                    105:        { NULL, NULL }, /* ME */
1.3       kristaps  106: };
                    107:
1.93      schwarze  108:
1.1       kristaps  109: void
1.161     schwarze  110: html_man(void *arg, const struct roff_meta *man)
1.1       kristaps  111: {
1.147     schwarze  112:        struct html             *h;
                    113:        struct roff_node        *n;
                    114:        struct tag              *t;
1.82      kristaps  115:
1.117     schwarze  116:        h = (struct html *)arg;
1.147     schwarze  117:        n = man->first->child;
1.3       kristaps  118:
1.126     schwarze  119:        if ((h->oflags & HTML_FRAGMENT) == 0) {
1.82      kristaps  120:                print_gen_decls(h);
1.126     schwarze  121:                print_otag(h, TAG_HTML, "");
1.169     schwarze  122:                if (n != NULL && n->type == ROFFT_COMMENT)
1.147     schwarze  123:                        print_gen_comment(h, n);
1.126     schwarze  124:                t = print_otag(h, TAG_HEAD, "");
1.161     schwarze  125:                print_man_head(man, h);
1.126     schwarze  126:                print_tagq(h, t);
1.122     schwarze  127:                print_otag(h, TAG_BODY, "");
1.126     schwarze  128:        }
1.53      kristaps  129:
1.161     schwarze  130:        man_root_pre(man, h);
1.127     schwarze  131:        t = print_otag(h, TAG_DIV, "c", "manual-text");
1.161     schwarze  132:        print_man_nodelist(man, n, h);
1.127     schwarze  133:        print_tagq(h, t);
1.161     schwarze  134:        man_root_post(man, h);
1.126     schwarze  135:        print_tagq(h, NULL);
1.3       kristaps  136: }
                    137:
                    138: static void
1.147     schwarze  139: print_man_head(const struct roff_meta *man, struct html *h)
1.3       kristaps  140: {
1.123     schwarze  141:        char    *cp;
1.3       kristaps  142:
                    143:        print_gen_head(h);
1.123     schwarze  144:        mandoc_asprintf(&cp, "%s(%s)", man->title, man->msec);
1.122     schwarze  145:        print_otag(h, TAG_TITLE, "");
1.123     schwarze  146:        print_text(h, cp);
                    147:        free(cp);
1.1       kristaps  148: }
1.4       kristaps  149:
                    150: static void
                    151: print_man_nodelist(MAN_ARGS)
                    152: {
1.110     schwarze  153:        while (n != NULL) {
1.132     schwarze  154:                print_man_node(man, n, h);
1.110     schwarze  155:                n = n->next;
                    156:        }
1.4       kristaps  157: }
                    158:
                    159: static void
                    160: print_man_node(MAN_ARGS)
                    161: {
1.132     schwarze  162:        struct tag      *t;
1.4       kristaps  163:        int              child;
                    164:
1.167     schwarze  165:        if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT)
                    166:                return;
                    167:
1.163     schwarze  168:        html_fillmode(h, n->flags & NODE_NOFILL ? ROFF_nf : ROFF_fi);
1.132     schwarze  169:
                    170:        child = 1;
                    171:        switch (n->type) {
                    172:        case ROFFT_TEXT:
1.163     schwarze  173:                if (*n->string == '\0') {
                    174:                        print_endline(h);
                    175:                        return;
                    176:                }
                    177:                if (*n->string == ' ' && n->flags & NODE_LINE &&
                    178:                    (h->flags & HTML_NONEWLINE) == 0)
                    179:                        print_endline(h);
                    180:                else if (n->flags & NODE_DELIMC)
                    181:                        h->flags |= HTML_NOSPACE;
1.170     schwarze  182:                t = h->tag;
                    183:                t->refcnt++;
1.4       kristaps  184:                print_text(h, n->string);
1.130     schwarze  185:                break;
1.113     schwarze  186:        case ROFFT_EQN:
1.170     schwarze  187:                t = h->tag;
                    188:                t->refcnt++;
1.80      kristaps  189:                print_eqn(h, n->eqn);
1.69      kristaps  190:                break;
1.113     schwarze  191:        case ROFFT_TBL:
1.66      kristaps  192:                /*
                    193:                 * This will take care of initialising all of the table
                    194:                 * state data for the first table, then tearing it down
                    195:                 * for the last one.
                    196:                 */
1.60      kristaps  197:                print_tbl(h, n->span);
1.64      kristaps  198:                return;
1.4       kristaps  199:        default:
1.93      schwarze  200:                /*
1.21      kristaps  201:                 * Close out scope of font prior to opening a macro
1.66      kristaps  202:                 * scope.
1.21      kristaps  203:                 */
1.57      kristaps  204:                if (HTMLFONT_NONE != h->metac) {
                    205:                        h->metal = h->metac;
                    206:                        h->metac = HTMLFONT_NONE;
1.66      kristaps  207:                }
                    208:
                    209:                /*
                    210:                 * Close out the current table, if it's open, and unset
                    211:                 * the "meta" table state.  This will be reopened on the
                    212:                 * next table element.
                    213:                 */
1.170     schwarze  214:                if (h->tblt != NULL)
1.66      kristaps  215:                        print_tblclose(h);
1.170     schwarze  216:                t = h->tag;
                    217:                t->refcnt++;
1.137     schwarze  218:                if (n->tok < ROFF_MAX) {
1.138     schwarze  219:                        roff_html_pre(h, n);
1.170     schwarze  220:                        t->refcnt--;
1.167     schwarze  221:                        print_stagq(h, t);
1.163     schwarze  222:                        return;
1.137     schwarze  223:                }
                    224:                assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
1.155     schwarze  225:                if (man_html_acts[n->tok - MAN_TH].pre != NULL)
                    226:                        child = (*man_html_acts[n->tok - MAN_TH].pre)(man,
                    227:                            n, h);
1.4       kristaps  228:                break;
                    229:        }
                    230:
1.164     schwarze  231:        if (child && n->child != NULL)
1.132     schwarze  232:                print_man_nodelist(man, n->child, h);
1.21      kristaps  233:
1.24      kristaps  234:        /* This will automatically close out any font scope. */
1.170     schwarze  235:        t->refcnt--;
1.171   ! schwarze  236:        if (n->type == ROFFT_BLOCK &&
        !           237:            (n->tok == MAN_IP || n->tok == MAN_TP || n->tok == MAN_TQ)) {
        !           238:                t = h->tag;
        !           239:                while (t->tag != TAG_DL)
        !           240:                        t = t->next;
        !           241:                /*
        !           242:                 * Close the list if no further item of the same type
        !           243:                 * follows; otherwise, close the item only.
        !           244:                 */
        !           245:                if (n->next == NULL ||
        !           246:                    (n->tok == MAN_IP && n->next->tok != MAN_IP) ||
        !           247:                    (n->tok != MAN_IP &&
        !           248:                     n->next->tok != MAN_TP && n->next->tok != MAN_TQ)) {
        !           249:                        print_tagq(h, t);
        !           250:                        t = NULL;
        !           251:                }
        !           252:        }
        !           253:        if (t != NULL)
        !           254:                print_stagq(h, t);
1.132     schwarze  255:
1.165     schwarze  256:        if (n->flags & NODE_NOFILL && n->tok != MAN_YS &&
                    257:            (n->next != NULL && n->next->flags & NODE_LINE)) {
1.157     schwarze  258:                /* In .nf = <pre>, print even empty lines. */
                    259:                h->col++;
1.132     schwarze  260:                print_endline(h);
1.157     schwarze  261:        }
1.4       kristaps  262: }
                    263:
1.65      kristaps  264: static void
1.147     schwarze  265: man_root_pre(const struct roff_meta *man, struct html *h)
1.4       kristaps  266: {
                    267:        struct tag      *t, *tt;
1.94      schwarze  268:        char            *title;
1.4       kristaps  269:
1.89      schwarze  270:        assert(man->title);
                    271:        assert(man->msec);
1.94      schwarze  272:        mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.4       kristaps  273:
1.122     schwarze  274:        t = print_otag(h, TAG_TABLE, "c", "head");
                    275:        tt = print_otag(h, TAG_TR, "");
1.4       kristaps  276:
1.122     schwarze  277:        print_otag(h, TAG_TD, "c", "head-ltitle");
1.4       kristaps  278:        print_text(h, title);
                    279:        print_stagq(h, tt);
                    280:
1.122     schwarze  281:        print_otag(h, TAG_TD, "c", "head-vol");
1.164     schwarze  282:        if (man->vol != NULL)
1.95      schwarze  283:                print_text(h, man->vol);
1.4       kristaps  284:        print_stagq(h, tt);
                    285:
1.122     schwarze  286:        print_otag(h, TAG_TD, "c", "head-rtitle");
1.4       kristaps  287:        print_text(h, title);
                    288:        print_tagq(h, t);
1.94      schwarze  289:        free(title);
1.4       kristaps  290: }
                    291:
                    292: static void
1.147     schwarze  293: man_root_post(const struct roff_meta *man, struct html *h)
1.4       kristaps  294: {
                    295:        struct tag      *t, *tt;
                    296:
1.122     schwarze  297:        t = print_otag(h, TAG_TABLE, "c", "foot");
                    298:        tt = print_otag(h, TAG_TR, "");
1.55      kristaps  299:
1.122     schwarze  300:        print_otag(h, TAG_TD, "c", "foot-date");
1.89      schwarze  301:        print_text(h, man->date);
1.4       kristaps  302:        print_stagq(h, tt);
                    303:
1.122     schwarze  304:        print_otag(h, TAG_TD, "c", "foot-os");
1.164     schwarze  305:        if (man->os != NULL)
1.115     schwarze  306:                print_text(h, man->os);
1.4       kristaps  307:        print_tagq(h, t);
                    308: }
                    309:
                    310: static int
                    311: man_SH_pre(MAN_ARGS)
                    312: {
1.134     schwarze  313:        char    *id;
                    314:
1.166     schwarze  315:        switch (n->type) {
                    316:        case ROFFT_BLOCK:
                    317:                html_close_paragraph(h);
                    318:                break;
                    319:        case ROFFT_HEAD:
1.150     schwarze  320:                id = html_make_id(n, 1);
1.166     schwarze  321:                if (n->tok == MAN_SH)
1.168     schwarze  322:                        print_otag(h, TAG_H1, "ci", "Sh", id);
1.166     schwarze  323:                else
1.168     schwarze  324:                        print_otag(h, TAG_H2, "ci", "Ss", id);
1.135     schwarze  325:                if (id != NULL)
1.148     schwarze  326:                        print_otag(h, TAG_A, "chR", "permalink", id);
1.166     schwarze  327:                break;
                    328:        case ROFFT_BODY:
                    329:                break;
                    330:        default:
                    331:                abort();
1.134     schwarze  332:        }
1.119     schwarze  333:        return 1;
1.4       kristaps  334: }
                    335:
                    336: static int
1.8       kristaps  337: man_alt_pre(MAN_ARGS)
                    338: {
1.114     schwarze  339:        const struct roff_node  *nn;
1.164     schwarze  340:        struct tag      *t;
1.130     schwarze  341:        int              i;
1.57      kristaps  342:        enum htmltag     fp;
1.8       kristaps  343:
1.164     schwarze  344:        for (i = 0, nn = n->child; nn != NULL; nn = nn->next, i++) {
1.8       kristaps  345:                switch (n->tok) {
1.93      schwarze  346:                case MAN_BI:
1.57      kristaps  347:                        fp = i % 2 ? TAG_I : TAG_B;
1.8       kristaps  348:                        break;
1.93      schwarze  349:                case MAN_IB:
1.57      kristaps  350:                        fp = i % 2 ? TAG_B : TAG_I;
1.8       kristaps  351:                        break;
1.93      schwarze  352:                case MAN_RI:
1.57      kristaps  353:                        fp = i % 2 ? TAG_I : TAG_MAX;
1.8       kristaps  354:                        break;
1.93      schwarze  355:                case MAN_IR:
1.57      kristaps  356:                        fp = i % 2 ? TAG_MAX : TAG_I;
1.8       kristaps  357:                        break;
1.93      schwarze  358:                case MAN_BR:
1.57      kristaps  359:                        fp = i % 2 ? TAG_MAX : TAG_B;
1.8       kristaps  360:                        break;
1.93      schwarze  361:                case MAN_RB:
1.57      kristaps  362:                        fp = i % 2 ? TAG_B : TAG_MAX;
1.8       kristaps  363:                        break;
                    364:                default:
                    365:                        abort();
                    366:                }
                    367:
                    368:                if (i)
                    369:                        h->flags |= HTML_NOSPACE;
                    370:
1.130     schwarze  371:                if (fp != TAG_MAX)
1.122     schwarze  372:                        t = print_otag(h, fp, "");
1.57      kristaps  373:
1.130     schwarze  374:                print_text(h, nn->string);
1.57      kristaps  375:
1.130     schwarze  376:                if (fp != TAG_MAX)
1.57      kristaps  377:                        print_tagq(h, t);
1.8       kristaps  378:        }
1.119     schwarze  379:        return 0;
1.8       kristaps  380: }
                    381:
                    382: static int
1.56      kristaps  383: man_SM_pre(MAN_ARGS)
1.8       kristaps  384: {
1.122     schwarze  385:        print_otag(h, TAG_SMALL, "");
1.164     schwarze  386:        if (n->tok == MAN_SB)
1.122     schwarze  387:                print_otag(h, TAG_B, "");
1.119     schwarze  388:        return 1;
1.8       kristaps  389: }
                    390:
                    391: static int
1.4       kristaps  392: man_PP_pre(MAN_ARGS)
                    393: {
1.166     schwarze  394:        switch (n->type) {
                    395:        case ROFFT_BLOCK:
                    396:                html_close_paragraph(h);
                    397:                break;
                    398:        case ROFFT_HEAD:
1.119     schwarze  399:                return 0;
1.166     schwarze  400:        case ROFFT_BODY:
                    401:                if (n->child != NULL &&
                    402:                    (n->child->flags & NODE_NOFILL) == 0)
                    403:                        print_otag(h, TAG_P, "c",
                    404:                            n->tok == MAN_PP ? "Pp" : "Pp HP");
                    405:                break;
                    406:        default:
                    407:                abort();
                    408:        }
1.119     schwarze  409:        return 1;
1.5       kristaps  410: }
                    411:
                    412: static int
                    413: man_IP_pre(MAN_ARGS)
                    414: {
1.114     schwarze  415:        const struct roff_node  *nn;
1.5       kristaps  416:
1.166     schwarze  417:        switch (n->type) {
                    418:        case ROFFT_BLOCK:
                    419:                html_close_paragraph(h);
1.171   ! schwarze  420:                /*
        !           421:                 * Open a new list unless there is an immediately
        !           422:                 * preceding item of the same type.
        !           423:                 */
        !           424:                if (n->prev == NULL ||
        !           425:                    (n->tok == MAN_IP && n->prev->tok != MAN_IP) ||
        !           426:                    (n->tok != MAN_IP &&
        !           427:                     n->prev->tok != MAN_TP && n->prev->tok != MAN_TQ))
        !           428:                        print_otag(h, TAG_DL, "c", "Bl-tag");
1.166     schwarze  429:                return 1;
                    430:        case ROFFT_HEAD:
                    431:                print_otag(h, TAG_DT, "");
                    432:                break;
                    433:        case ROFFT_BODY:
1.149     schwarze  434:                print_otag(h, TAG_DD, "");
1.119     schwarze  435:                return 1;
1.166     schwarze  436:        default:
                    437:                abort();
1.6       kristaps  438:        }
                    439:
1.154     schwarze  440:        switch(n->tok) {
                    441:        case MAN_IP:  /* Only print the first header element. */
                    442:                if (n->child != NULL)
                    443:                        print_man_node(man, n->child, h);
                    444:                break;
                    445:        case MAN_TP:  /* Only print next-line header elements. */
                    446:        case MAN_TQ:
1.91      schwarze  447:                nn = n->child;
1.154     schwarze  448:                while (nn != NULL && (NODE_LINE & nn->flags) == 0)
1.91      schwarze  449:                        nn = nn->next;
1.154     schwarze  450:                while (nn != NULL) {
1.132     schwarze  451:                        print_man_node(man, nn, h);
1.91      schwarze  452:                        nn = nn->next;
                    453:                }
1.154     schwarze  454:                break;
                    455:        default:
                    456:                abort();
1.91      schwarze  457:        }
1.119     schwarze  458:        return 0;
1.6       kristaps  459: }
                    460:
                    461: static int
1.86      kristaps  462: man_OP_pre(MAN_ARGS)
                    463: {
                    464:        struct tag      *tt;
                    465:
                    466:        print_text(h, "[");
                    467:        h->flags |= HTML_NOSPACE;
1.128     schwarze  468:        tt = print_otag(h, TAG_SPAN, "c", "Op");
1.86      kristaps  469:
1.164     schwarze  470:        if ((n = n->child) != NULL) {
1.122     schwarze  471:                print_otag(h, TAG_B, "");
1.86      kristaps  472:                print_text(h, n->string);
                    473:        }
                    474:
                    475:        print_stagq(h, tt);
                    476:
1.164     schwarze  477:        if (n != NULL && n->next != NULL) {
1.122     schwarze  478:                print_otag(h, TAG_I, "");
1.86      kristaps  479:                print_text(h, n->next->string);
                    480:        }
                    481:
                    482:        print_stagq(h, tt);
                    483:        h->flags |= HTML_NOSPACE;
                    484:        print_text(h, "]");
1.119     schwarze  485:        return 0;
1.86      kristaps  486: }
                    487:
1.8       kristaps  488: static int
                    489: man_B_pre(MAN_ARGS)
                    490: {
1.122     schwarze  491:        print_otag(h, TAG_B, "");
1.119     schwarze  492:        return 1;
1.8       kristaps  493: }
                    494:
                    495: static int
                    496: man_I_pre(MAN_ARGS)
                    497: {
1.122     schwarze  498:        print_otag(h, TAG_I, "");
1.119     schwarze  499:        return 1;
1.45      kristaps  500: }
                    501:
                    502: static int
                    503: man_in_pre(MAN_ARGS)
                    504: {
1.122     schwarze  505:        print_otag(h, TAG_BR, "");
1.119     schwarze  506:        return 0;
1.8       kristaps  507: }
                    508:
                    509: static int
                    510: man_ign_pre(MAN_ARGS)
                    511: {
1.119     schwarze  512:        return 0;
1.8       kristaps  513: }
1.9       kristaps  514:
                    515: static int
                    516: man_RS_pre(MAN_ARGS)
                    517: {
1.166     schwarze  518:        switch (n->type) {
                    519:        case ROFFT_BLOCK:
                    520:                html_close_paragraph(h);
                    521:                break;
                    522:        case ROFFT_HEAD:
1.119     schwarze  523:                return 0;
1.166     schwarze  524:        case ROFFT_BODY:
1.152     schwarze  525:                print_otag(h, TAG_DIV, "c", "Bd-indent");
1.166     schwarze  526:                break;
                    527:        default:
                    528:                abort();
                    529:        }
1.156     schwarze  530:        return 1;
                    531: }
                    532:
                    533: static int
                    534: man_SY_pre(MAN_ARGS)
                    535: {
                    536:        switch (n->type) {
                    537:        case ROFFT_BLOCK:
1.166     schwarze  538:                html_close_paragraph(h);
1.156     schwarze  539:                print_otag(h, TAG_TABLE, "c", "Nm");
                    540:                print_otag(h, TAG_TR, "");
                    541:                break;
                    542:        case ROFFT_HEAD:
                    543:                print_otag(h, TAG_TD, "");
1.168     schwarze  544:                print_otag(h, TAG_CODE, "c", "Nm");
1.156     schwarze  545:                break;
                    546:        case ROFFT_BODY:
                    547:                print_otag(h, TAG_TD, "");
                    548:                break;
                    549:        default:
                    550:                abort();
                    551:        }
1.119     schwarze  552:        return 1;
1.90      schwarze  553: }
                    554:
                    555: static int
                    556: man_UR_pre(MAN_ARGS)
                    557: {
1.145     schwarze  558:        char *cp;
1.164     schwarze  559:
1.90      schwarze  560:        n = n->child;
1.113     schwarze  561:        assert(n->type == ROFFT_HEAD);
1.120     schwarze  562:        if (n->child != NULL) {
1.113     schwarze  563:                assert(n->child->type == ROFFT_TEXT);
1.145     schwarze  564:                if (n->tok == MAN_MT) {
                    565:                        mandoc_asprintf(&cp, "mailto:%s", n->child->string);
1.168     schwarze  566:                        print_otag(h, TAG_A, "ch", "Mt", cp);
1.145     schwarze  567:                        free(cp);
                    568:                } else
1.168     schwarze  569:                        print_otag(h, TAG_A, "ch", "Lk", n->child->string);
1.90      schwarze  570:        }
                    571:
1.113     schwarze  572:        assert(n->next->type == ROFFT_BODY);
1.120     schwarze  573:        if (n->next->child != NULL)
1.90      schwarze  574:                n = n->next;
                    575:
1.132     schwarze  576:        print_man_nodelist(man, n->child, h);
1.119     schwarze  577:        return 0;
1.158     schwarze  578: }
                    579:
                    580: static int
                    581: man_abort_pre(MAN_ARGS)
                    582: {
                    583:        abort();
1.9       kristaps  584: }

CVSweb