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

Annotation of mandoc/html.h, Revision 1.68

1.68    ! schwarze    1: /*     $Id: html.h,v 1.67 2014/10/28 17:36:19 schwarze Exp $ */
1.1       kristaps    2: /*
1.66      schwarze    3:  * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
1.1       kristaps    4:  *
                      5:  * Permission to use, copy, modify, and distribute this software for any
1.6       kristaps    6:  * purpose with or without fee is hereby granted, provided that the above
                      7:  * copyright notice and this permission notice appear in all copies.
1.1       kristaps    8:  *
1.6       kristaps    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.
1.1       kristaps   16:  */
                     17:
1.6       kristaps   18: __BEGIN_DECLS
                     19:
                     20: enum   htmltag {
                     21:        TAG_HTML,
                     22:        TAG_HEAD,
                     23:        TAG_BODY,
                     24:        TAG_META,
                     25:        TAG_TITLE,
                     26:        TAG_DIV,
                     27:        TAG_H1,
                     28:        TAG_H2,
                     29:        TAG_SPAN,
                     30:        TAG_LINK,
                     31:        TAG_BR,
                     32:        TAG_A,
                     33:        TAG_TABLE,
1.28      kristaps   34:        TAG_TBODY,
1.6       kristaps   35:        TAG_COL,
                     36:        TAG_TR,
                     37:        TAG_TD,
                     38:        TAG_LI,
                     39:        TAG_UL,
                     40:        TAG_OL,
1.28      kristaps   41:        TAG_DL,
                     42:        TAG_DT,
                     43:        TAG_DD,
1.29      kristaps   44:        TAG_BLOCKQUOTE,
1.31      kristaps   45:        TAG_PRE,
1.32      kristaps   46:        TAG_B,
1.33      kristaps   47:        TAG_I,
1.34      kristaps   48:        TAG_CODE,
1.35      kristaps   49:        TAG_SMALL,
1.56      kristaps   50:        TAG_STYLE,
1.63      kristaps   51:        TAG_MATH,
                     52:        TAG_MROW,
                     53:        TAG_MI,
                     54:        TAG_MO,
                     55:        TAG_MSUP,
                     56:        TAG_MSUB,
                     57:        TAG_MSUBSUP,
                     58:        TAG_MFRAC,
                     59:        TAG_MSQRT,
                     60:        TAG_MFENCED,
                     61:        TAG_MTABLE,
                     62:        TAG_MTR,
                     63:        TAG_MTD,
1.64      kristaps   64:        TAG_MUNDEROVER,
                     65:        TAG_MUNDER,
                     66:        TAG_MOVER,
1.6       kristaps   67:        TAG_MAX
                     68: };
                     69:
                     70: enum   htmlattr {
                     71:        ATTR_NAME,
                     72:        ATTR_REL,
                     73:        ATTR_HREF,
                     74:        ATTR_TYPE,
                     75:        ATTR_MEDIA,
                     76:        ATTR_CLASS,
                     77:        ATTR_STYLE,
1.11      kristaps   78:        ATTR_ID,
1.39      kristaps   79:        ATTR_COLSPAN,
1.55      kristaps   80:        ATTR_CHARSET,
1.63      kristaps   81:        ATTR_OPEN,
                     82:        ATTR_CLOSE,
1.65      kristaps   83:        ATTR_MATHVARIANT,
1.6       kristaps   84:        ATTR_MAX
                     85: };
                     86:
1.21      kristaps   87: enum   htmlfont {
                     88:        HTMLFONT_NONE = 0,
                     89:        HTMLFONT_BOLD,
                     90:        HTMLFONT_ITALIC,
1.49      schwarze   91:        HTMLFONT_BI,
1.21      kristaps   92:        HTMLFONT_MAX
                     93: };
                     94:
1.6       kristaps   95: struct tag {
1.14      kristaps   96:        struct tag       *next;
1.6       kristaps   97:        enum htmltag      tag;
                     98: };
                     99:
1.14      kristaps  100: struct tagq {
                    101:        struct tag       *head;
                    102: };
1.6       kristaps  103:
                    104: struct htmlpair {
                    105:        enum htmlattr     key;
1.13      kristaps  106:        const char       *val;
1.1       kristaps  107: };
                    108:
1.23      kristaps  109: #define        PAIR_INIT(p, t, v) \
                    110:        do { \
                    111:                (p)->key = (t); \
                    112:                (p)->val = (v); \
                    113:        } while (/* CONSTCOND */ 0)
                    114:
                    115: #define        PAIR_ID_INIT(p, v)      PAIR_INIT(p, ATTR_ID, v)
                    116: #define        PAIR_CLASS_INIT(p, v)   PAIR_INIT(p, ATTR_CLASS, v)
                    117: #define        PAIR_HREF_INIT(p, v)    PAIR_INIT(p, ATTR_HREF, v)
                    118: #define        PAIR_STYLE_INIT(p, h)   PAIR_INIT(p, ATTR_STYLE, (h)->buf)
1.12      kristaps  119:
1.6       kristaps  120: struct html {
                    121:        int               flags;
1.40      kristaps  122: #define        HTML_NOSPACE     (1 << 0) /* suppress next space */
1.25      kristaps  123: #define        HTML_IGNDELIM    (1 << 1)
                    124: #define        HTML_KEEP        (1 << 2)
                    125: #define        HTML_PREKEEP     (1 << 3)
1.40      kristaps  126: #define        HTML_NONOSPACE   (1 << 4) /* never add spaces */
                    127: #define        HTML_LITERAL     (1 << 5) /* literal (e.g., <PRE>) context */
1.48      schwarze  128: #define        HTML_SKIPCHAR    (1 << 6) /* skip the next character */
1.54      schwarze  129: #define        HTML_NOSPLIT     (1 << 7) /* do not break line before .An */
                    130: #define        HTML_SPLIT       (1 << 8) /* break line before .An */
1.38      kristaps  131:        struct tagq       tags; /* stack of open tags */
                    132:        struct rofftbl    tbl; /* current table */
1.39      kristaps  133:        struct tag       *tblt; /* current open table scope */
1.67      schwarze  134:        const struct mchars *symtab; /* character table */
1.38      kristaps  135:        char             *base_man; /* base for manpage href */
                    136:        char             *base_includes; /* base for include href */
                    137:        char             *style; /* style-sheet URI */
                    138:        char              buf[BUFSIZ]; /* see bufcat and friends */
1.51      schwarze  139:        size_t            buflen;
1.35      kristaps  140:        struct tag       *metaf; /* current open font scope */
                    141:        enum htmlfont     metal; /* last used font */
                    142:        enum htmlfont     metac; /* current font mode */
1.47      kristaps  143:        int               oflags; /* output options */
                    144: #define        HTML_FRAGMENT    (1 << 0) /* don't emit HTML/HEAD/BODY */
1.6       kristaps  145: };
1.12      kristaps  146:
1.22      kristaps  147: void             print_gen_decls(struct html *);
1.6       kristaps  148: void             print_gen_head(struct html *);
1.51      schwarze  149: struct tag      *print_otag(struct html *, enum htmltag,
1.6       kristaps  150:                                int, const struct htmlpair *);
                    151: void             print_tagq(struct html *, const struct tag *);
                    152: void             print_stagq(struct html *, const struct tag *);
                    153: void             print_text(struct html *, const char *);
1.39      kristaps  154: void             print_tblclose(struct html *);
1.37      kristaps  155: void             print_tbl(struct html *, const struct tbl_span *);
1.45      kristaps  156: void             print_eqn(struct html *, const struct eqn *);
1.61      kristaps  157: void             print_paragraph(struct html *);
1.1       kristaps  158:
1.50      joerg     159: #if __GNUC__ - 0 >= 4
                    160: __attribute__((__format__ (__printf__, 2, 3)))
                    161: #endif
1.44      kristaps  162: void             bufcat_fmt(struct html *, const char *, ...);
                    163: void             bufcat(struct html *, const char *);
                    164: void             bufcat_id(struct html *, const char *);
1.51      schwarze  165: void             bufcat_style(struct html *,
1.44      kristaps  166:                        const char *, const char *);
1.51      schwarze  167: void             bufcat_su(struct html *, const char *,
1.12      kristaps  168:                        const struct roffsu *);
1.44      kristaps  169: void             bufinit(struct html *);
1.51      schwarze  170: void             buffmt_man(struct html *,
1.12      kristaps  171:                        const char *, const char *);
1.10      kristaps  172: void             buffmt_includes(struct html *, const char *);
                    173:
1.42      kristaps  174: int              html_strlen(const char *);
1.16      kristaps  175:
1.1       kristaps  176: __END_DECLS

CVSweb