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

Annotation of mandoc/man_html.c, Revision 1.3

1.3     ! kristaps    1: /*     $Id: man_html.c,v 1.2 2009/10/03 15:08:09 kristaps Exp $ */
1.1       kristaps    2: /*
                      3:  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
                      4:  *
                      5:  * Permission to use, copy, modify, and distribute this software for any
                      6:  * purpose with or without fee is hereby granted, provided that the above
                      7:  * copyright notice and this permission notice appear in all copies.
                      8:  *
                      9:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     10:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     11:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     12:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     13:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     14:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     15:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     16:  */
                     17: #include <sys/types.h>
                     18: #include <sys/queue.h>
                     19:
1.2       kristaps   20: #include <stdio.h>
1.1       kristaps   21: #include <stdlib.h>
                     22:
                     23: #include "html.h"
                     24: #include "man.h"
                     25:
1.3     ! kristaps   26: #define        MAN_ARGS          const struct man_meta *m, \
        !            27:                          const struct man_node *n, \
        !            28:                          struct html *h
        !            29:
        !            30: struct htmlman {
        !            31:        int             (*pre)(MAN_ARGS);
        !            32:        int             (*post)(MAN_ARGS);
        !            33: };
        !            34:
        !            35:
        !            36: static void              print_man(MAN_ARGS);
        !            37: static void              print_man_head(MAN_ARGS);
        !            38:
        !            39:
        !            40: static const struct htmlman mans[MAN_MAX] = {
        !            41:        { NULL, NULL }, /* br */
        !            42:        { NULL, NULL }, /* TH */
        !            43:        { NULL, NULL }, /* SH */
        !            44:        { NULL, NULL }, /* SS */
        !            45:        { NULL, NULL }, /* TP */
        !            46:        { NULL, NULL }, /* LP */
        !            47:        { NULL, NULL }, /* PP */
        !            48:        { NULL, NULL }, /* P */
        !            49:        { NULL, NULL }, /* IP */
        !            50:        { NULL, NULL }, /* HP */
        !            51:        { NULL, NULL }, /* SM */
        !            52:        { NULL, NULL }, /* SB */
        !            53:        { NULL, NULL }, /* BI */
        !            54:        { NULL, NULL }, /* IB */
        !            55:        { NULL, NULL }, /* BR */
        !            56:        { NULL, NULL }, /* RB */
        !            57:        { NULL, NULL }, /* R */
        !            58:        { NULL, NULL }, /* B */
        !            59:        { NULL, NULL }, /* I */
        !            60:        { NULL, NULL }, /* IR */
        !            61:        { NULL, NULL }, /* RI */
        !            62:        { NULL, NULL }, /* na */
        !            63:        { NULL, NULL }, /* i */
        !            64:        { NULL, NULL }, /* sp */
        !            65:        { NULL, NULL }, /* nf */
        !            66:        { NULL, NULL }, /* fi */
        !            67:        { NULL, NULL }, /* r */
        !            68:        { NULL, NULL }, /* RE */
        !            69:        { NULL, NULL }, /* RS */
        !            70:        { NULL, NULL }, /* DT */
        !            71:        { NULL, NULL }, /* UC */
        !            72: };
        !            73:
1.1       kristaps   74:
                     75: void
                     76: html_man(void *arg, const struct man *m)
                     77: {
1.3     ! kristaps   78:        struct html     *h;
        !            79:        struct tag      *t;
        !            80:
        !            81:        h = (struct html *)arg;
        !            82:
        !            83:        print_gen_doctype(h);
        !            84:
        !            85:        t = print_otag(h, TAG_HTML, 0, NULL);
        !            86:        print_man(man_meta(m), man_node(m), h);
        !            87:        print_tagq(h, t);
        !            88:
        !            89:        printf("\n");
        !            90: }
        !            91:
        !            92:
        !            93: static void
        !            94: print_man(MAN_ARGS)
        !            95: {
        !            96:        struct tag      *t;
        !            97:        struct htmlpair  tag;
        !            98:
        !            99:        t = print_otag(h, TAG_HEAD, 0, NULL);
        !           100:
        !           101:        print_man_head(m, n, h);
        !           102:        print_tagq(h, t);
        !           103:        t = print_otag(h, TAG_BODY, 0, NULL);
        !           104:
        !           105:        tag.key = ATTR_CLASS;
        !           106:        tag.val = "body";
        !           107:        print_otag(h, TAG_DIV, 1, &tag);
        !           108:
        !           109:        /*print_man_nodelist(m, n, h);*/
        !           110:
        !           111:        print_tagq(h, t);
        !           112: }
        !           113:
        !           114:
        !           115: /* ARGSUSED */
        !           116: static void
        !           117: print_man_head(MAN_ARGS)
        !           118: {
        !           119:
        !           120:        print_gen_head(h);
        !           121:        bufinit(h);
        !           122:        buffmt(h, "%s(%d)", m->title, m->msec);
        !           123:
        !           124:        print_otag(h, TAG_TITLE, 0, NULL);
        !           125:        print_text(h, h->buf);
1.1       kristaps  126: }

CVSweb