[BACK]Return to man_html.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Annotation of src/usr.bin/mandoc/man_html.c, Revision 1.125

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