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

Annotation of mandoc/man_html.c, Revision 1.165

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

CVSweb