[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.124

1.124   ! schwarze    1: /*     $OpenBSD: man_html.c,v 1.123 2019/01/18 14:36:16 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.87      schwarze  311:        char    *id;
                    312:
1.119     schwarze  313:        switch (n->type) {
                    314:        case ROFFT_BLOCK:
                    315:                html_close_paragraph(h);
                    316:                break;
                    317:        case ROFFT_HEAD:
1.103     schwarze  318:                id = html_make_id(n, 1);
1.119     schwarze  319:                if (n->tok == MAN_SH)
1.121     schwarze  320:                        print_otag(h, TAG_H1, "ci", "Sh", id);
1.119     schwarze  321:                else
1.121     schwarze  322:                        print_otag(h, TAG_H2, "ci", "Ss", id);
1.88      schwarze  323:                if (id != NULL)
1.101     schwarze  324:                        print_otag(h, TAG_A, "chR", "permalink", id);
1.119     schwarze  325:                break;
                    326:        case ROFFT_BODY:
                    327:                break;
                    328:        default:
                    329:                abort();
1.87      schwarze  330:        }
1.72      schwarze  331:        return 1;
1.1       schwarze  332: }
                    333:
                    334: static int
                    335: man_alt_pre(MAN_ARGS)
                    336: {
1.67      schwarze  337:        const struct roff_node  *nn;
1.117     schwarze  338:        struct tag      *t;
1.83      schwarze  339:        int              i;
1.27      schwarze  340:        enum htmltag     fp;
1.1       schwarze  341:
1.117     schwarze  342:        for (i = 0, nn = n->child; nn != NULL; nn = nn->next, i++) {
1.1       schwarze  343:                switch (n->tok) {
1.52      schwarze  344:                case MAN_BI:
1.27      schwarze  345:                        fp = i % 2 ? TAG_I : TAG_B;
1.1       schwarze  346:                        break;
1.52      schwarze  347:                case MAN_IB:
1.27      schwarze  348:                        fp = i % 2 ? TAG_B : TAG_I;
1.1       schwarze  349:                        break;
1.52      schwarze  350:                case MAN_RI:
1.27      schwarze  351:                        fp = i % 2 ? TAG_I : TAG_MAX;
1.1       schwarze  352:                        break;
1.52      schwarze  353:                case MAN_IR:
1.27      schwarze  354:                        fp = i % 2 ? TAG_MAX : TAG_I;
1.1       schwarze  355:                        break;
1.52      schwarze  356:                case MAN_BR:
1.27      schwarze  357:                        fp = i % 2 ? TAG_MAX : TAG_B;
1.1       schwarze  358:                        break;
1.52      schwarze  359:                case MAN_RB:
1.27      schwarze  360:                        fp = i % 2 ? TAG_B : TAG_MAX;
1.1       schwarze  361:                        break;
                    362:                default:
                    363:                        abort();
                    364:                }
                    365:
                    366:                if (i)
                    367:                        h->flags |= HTML_NOSPACE;
                    368:
1.83      schwarze  369:                if (fp != TAG_MAX)
1.75      schwarze  370:                        t = print_otag(h, fp, "");
1.27      schwarze  371:
1.83      schwarze  372:                print_text(h, nn->string);
1.27      schwarze  373:
1.83      schwarze  374:                if (fp != TAG_MAX)
1.27      schwarze  375:                        print_tagq(h, t);
1.1       schwarze  376:        }
1.72      schwarze  377:        return 0;
1.1       schwarze  378: }
                    379:
                    380: static int
1.26      schwarze  381: man_SM_pre(MAN_ARGS)
1.1       schwarze  382: {
1.75      schwarze  383:        print_otag(h, TAG_SMALL, "");
1.117     schwarze  384:        if (n->tok == MAN_SB)
1.75      schwarze  385:                print_otag(h, TAG_B, "");
1.72      schwarze  386:        return 1;
1.1       schwarze  387: }
                    388:
                    389: static int
                    390: man_PP_pre(MAN_ARGS)
                    391: {
1.119     schwarze  392:        switch (n->type) {
                    393:        case ROFFT_BLOCK:
                    394:                html_close_paragraph(h);
                    395:                break;
                    396:        case ROFFT_HEAD:
1.72      schwarze  397:                return 0;
1.119     schwarze  398:        case ROFFT_BODY:
                    399:                if (n->child != NULL &&
                    400:                    (n->child->flags & NODE_NOFILL) == 0)
                    401:                        print_otag(h, TAG_P, "c",
                    402:                            n->tok == MAN_PP ? "Pp" : "Pp HP");
                    403:                break;
                    404:        default:
                    405:                abort();
                    406:        }
1.72      schwarze  407:        return 1;
1.1       schwarze  408: }
                    409:
                    410: static int
                    411: man_IP_pre(MAN_ARGS)
                    412: {
1.67      schwarze  413:        const struct roff_node  *nn;
1.1       schwarze  414:
1.119     schwarze  415:        switch (n->type) {
                    416:        case ROFFT_BLOCK:
                    417:                html_close_paragraph(h);
1.124   ! schwarze  418:                /*
        !           419:                 * Open a new list unless there is an immediately
        !           420:                 * preceding item of the same type.
        !           421:                 */
        !           422:                if (n->prev == NULL ||
        !           423:                    (n->tok == MAN_IP && n->prev->tok != MAN_IP) ||
        !           424:                    (n->tok != MAN_IP &&
        !           425:                     n->prev->tok != MAN_TP && n->prev->tok != MAN_TQ))
        !           426:                        print_otag(h, TAG_DL, "c", "Bl-tag");
1.119     schwarze  427:                return 1;
                    428:        case ROFFT_HEAD:
                    429:                print_otag(h, TAG_DT, "");
                    430:                break;
                    431:        case ROFFT_BODY:
1.102     schwarze  432:                print_otag(h, TAG_DD, "");
1.72      schwarze  433:                return 1;
1.119     schwarze  434:        default:
                    435:                abort();
1.1       schwarze  436:        }
                    437:
1.107     schwarze  438:        switch(n->tok) {
                    439:        case MAN_IP:  /* Only print the first header element. */
                    440:                if (n->child != NULL)
                    441:                        print_man_node(man, n->child, h);
                    442:                break;
                    443:        case MAN_TP:  /* Only print next-line header elements. */
                    444:        case MAN_TQ:
1.50      schwarze  445:                nn = n->child;
1.107     schwarze  446:                while (nn != NULL && (NODE_LINE & nn->flags) == 0)
1.50      schwarze  447:                        nn = nn->next;
1.107     schwarze  448:                while (nn != NULL) {
1.85      schwarze  449:                        print_man_node(man, nn, h);
1.50      schwarze  450:                        nn = nn->next;
                    451:                }
1.107     schwarze  452:                break;
                    453:        default:
                    454:                abort();
1.50      schwarze  455:        }
1.72      schwarze  456:        return 0;
1.1       schwarze  457: }
                    458:
                    459: static int
1.46      schwarze  460: man_OP_pre(MAN_ARGS)
                    461: {
                    462:        struct tag      *tt;
                    463:
                    464:        print_text(h, "[");
                    465:        h->flags |= HTML_NOSPACE;
1.81      schwarze  466:        tt = print_otag(h, TAG_SPAN, "c", "Op");
1.46      schwarze  467:
1.117     schwarze  468:        if ((n = n->child) != NULL) {
1.75      schwarze  469:                print_otag(h, TAG_B, "");
1.46      schwarze  470:                print_text(h, n->string);
                    471:        }
                    472:
                    473:        print_stagq(h, tt);
                    474:
1.117     schwarze  475:        if (n != NULL && n->next != NULL) {
1.75      schwarze  476:                print_otag(h, TAG_I, "");
1.46      schwarze  477:                print_text(h, n->next->string);
                    478:        }
                    479:
                    480:        print_stagq(h, tt);
                    481:        h->flags |= HTML_NOSPACE;
                    482:        print_text(h, "]");
1.72      schwarze  483:        return 0;
1.46      schwarze  484: }
                    485:
1.1       schwarze  486: static int
                    487: man_B_pre(MAN_ARGS)
                    488: {
1.75      schwarze  489:        print_otag(h, TAG_B, "");
1.72      schwarze  490:        return 1;
1.1       schwarze  491: }
                    492:
                    493: static int
                    494: man_I_pre(MAN_ARGS)
                    495: {
1.75      schwarze  496:        print_otag(h, TAG_I, "");
1.72      schwarze  497:        return 1;
1.18      schwarze  498: }
                    499:
                    500: static int
                    501: man_in_pre(MAN_ARGS)
                    502: {
1.75      schwarze  503:        print_otag(h, TAG_BR, "");
1.72      schwarze  504:        return 0;
1.1       schwarze  505: }
                    506:
                    507: static int
                    508: man_ign_pre(MAN_ARGS)
                    509: {
1.72      schwarze  510:        return 0;
1.1       schwarze  511: }
                    512:
                    513: static int
                    514: man_RS_pre(MAN_ARGS)
                    515: {
1.119     schwarze  516:        switch (n->type) {
                    517:        case ROFFT_BLOCK:
                    518:                html_close_paragraph(h);
                    519:                break;
                    520:        case ROFFT_HEAD:
1.72      schwarze  521:                return 0;
1.119     schwarze  522:        case ROFFT_BODY:
1.105     schwarze  523:                print_otag(h, TAG_DIV, "c", "Bd-indent");
1.119     schwarze  524:                break;
                    525:        default:
                    526:                abort();
                    527:        }
1.109     schwarze  528:        return 1;
                    529: }
                    530:
                    531: static int
                    532: man_SY_pre(MAN_ARGS)
                    533: {
                    534:        switch (n->type) {
                    535:        case ROFFT_BLOCK:
1.119     schwarze  536:                html_close_paragraph(h);
1.109     schwarze  537:                print_otag(h, TAG_TABLE, "c", "Nm");
                    538:                print_otag(h, TAG_TR, "");
                    539:                break;
                    540:        case ROFFT_HEAD:
                    541:                print_otag(h, TAG_TD, "");
1.121     schwarze  542:                print_otag(h, TAG_CODE, "c", "Nm");
1.109     schwarze  543:                break;
                    544:        case ROFFT_BODY:
                    545:                print_otag(h, TAG_TD, "");
                    546:                break;
                    547:        default:
                    548:                abort();
                    549:        }
1.72      schwarze  550:        return 1;
1.49      schwarze  551: }
                    552:
                    553: static int
                    554: man_UR_pre(MAN_ARGS)
                    555: {
1.98      bentley   556:        char *cp;
1.117     schwarze  557:
1.49      schwarze  558:        n = n->child;
1.66      schwarze  559:        assert(n->type == ROFFT_HEAD);
1.73      schwarze  560:        if (n->child != NULL) {
1.66      schwarze  561:                assert(n->child->type == ROFFT_TEXT);
1.98      bentley   562:                if (n->tok == MAN_MT) {
                    563:                        mandoc_asprintf(&cp, "mailto:%s", n->child->string);
1.121     schwarze  564:                        print_otag(h, TAG_A, "ch", "Mt", cp);
1.98      bentley   565:                        free(cp);
                    566:                } else
1.121     schwarze  567:                        print_otag(h, TAG_A, "ch", "Lk", n->child->string);
1.49      schwarze  568:        }
                    569:
1.66      schwarze  570:        assert(n->next->type == ROFFT_BODY);
1.73      schwarze  571:        if (n->next->child != NULL)
1.49      schwarze  572:                n = n->next;
                    573:
1.85      schwarze  574:        print_man_nodelist(man, n->child, h);
1.72      schwarze  575:        return 0;
1.111     schwarze  576: }
                    577:
                    578: static int
                    579: man_abort_pre(MAN_ARGS)
                    580: {
                    581:        abort();
1.1       schwarze  582: }