Annotation of mandoc/html.h, Revision 1.30
1.30 ! kristaps 1: /* $Id: html.h,v 1.29 2010/12/15 15:59:23 kristaps Exp $ */
1.1 kristaps 2: /*
1.26 schwarze 3: * Copyright (c) 2008, 2009, 2010 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: #ifndef HTML_H
18: #define HTML_H
19:
1.6 kristaps 20: __BEGIN_DECLS
21:
22: enum htmltag {
23: TAG_HTML,
24: TAG_HEAD,
25: TAG_BODY,
26: TAG_META,
27: TAG_TITLE,
28: TAG_DIV,
29: TAG_H1,
30: TAG_H2,
31: TAG_SPAN,
32: TAG_LINK,
33: TAG_BR,
34: TAG_A,
35: TAG_TABLE,
1.28 kristaps 36: TAG_TBODY,
1.6 kristaps 37: TAG_COL,
38: TAG_TR,
39: TAG_TD,
40: TAG_LI,
41: TAG_UL,
42: TAG_OL,
1.28 kristaps 43: TAG_DL,
44: TAG_DT,
45: TAG_DD,
1.29 kristaps 46: TAG_BLOCKQUOTE,
1.30 ! kristaps 47: TAG_P,
1.6 kristaps 48: TAG_MAX
49: };
50:
51: enum htmlattr {
52: ATTR_HTTPEQUIV,
53: ATTR_CONTENT,
54: ATTR_NAME,
55: ATTR_REL,
56: ATTR_HREF,
57: ATTR_TYPE,
58: ATTR_MEDIA,
59: ATTR_CLASS,
60: ATTR_STYLE,
61: ATTR_WIDTH,
62: ATTR_VALIGN,
1.9 kristaps 63: ATTR_TARGET,
1.11 kristaps 64: ATTR_ID,
1.15 kristaps 65: ATTR_SUMMARY,
1.6 kristaps 66: ATTR_MAX
67: };
68:
1.21 kristaps 69: enum htmlfont {
70: HTMLFONT_NONE = 0,
71: HTMLFONT_BOLD,
72: HTMLFONT_ITALIC,
73: HTMLFONT_MAX
74: };
75:
1.6 kristaps 76: struct tag {
1.14 kristaps 77: struct tag *next;
1.6 kristaps 78: enum htmltag tag;
79: };
80:
1.14 kristaps 81: struct tagq {
82: struct tag *head;
83: };
1.6 kristaps 84:
85: struct htmlpair {
86: enum htmlattr key;
1.13 kristaps 87: const char *val;
1.1 kristaps 88: };
89:
1.23 kristaps 90: #define PAIR_INIT(p, t, v) \
91: do { \
92: (p)->key = (t); \
93: (p)->val = (v); \
94: } while (/* CONSTCOND */ 0)
95:
96: #define PAIR_ID_INIT(p, v) PAIR_INIT(p, ATTR_ID, v)
97: #define PAIR_CLASS_INIT(p, v) PAIR_INIT(p, ATTR_CLASS, v)
98: #define PAIR_HREF_INIT(p, v) PAIR_INIT(p, ATTR_HREF, v)
99: #define PAIR_STYLE_INIT(p, h) PAIR_INIT(p, ATTR_STYLE, (h)->buf)
100: #define PAIR_SUMMARY_INIT(p, v) PAIR_INIT(p, ATTR_SUMMARY, v)
1.12 kristaps 101:
1.22 kristaps 102: enum htmltype {
103: HTML_HTML_4_01_STRICT,
104: HTML_XHTML_1_0_STRICT
105: };
106:
1.6 kristaps 107: struct html {
108: int flags;
109: #define HTML_NOSPACE (1 << 0)
1.25 kristaps 110: #define HTML_IGNDELIM (1 << 1)
111: #define HTML_KEEP (1 << 2)
112: #define HTML_PREKEEP (1 << 3)
1.27 kristaps 113: #define HTML_NONOSPACE (1 << 4)
1.6 kristaps 114: struct tagq tags;
115: void *symtab;
116: char *base;
1.8 kristaps 117: char *base_man;
1.9 kristaps 118: char *base_includes;
1.6 kristaps 119: char *style;
1.8 kristaps 120: char buf[BUFSIZ];
121: size_t buflen;
1.19 kristaps 122: struct tag *metaf;
1.21 kristaps 123: enum htmlfont metal;
124: enum htmlfont metac;
1.22 kristaps 125: enum htmltype type;
1.6 kristaps 126: };
1.1 kristaps 127:
1.12 kristaps 128: struct roffsu;
129:
1.22 kristaps 130: void print_gen_decls(struct html *);
1.6 kristaps 131: void print_gen_head(struct html *);
1.21 kristaps 132: struct tag *print_ofont(struct html *, enum htmlfont);
1.6 kristaps 133: struct tag *print_otag(struct html *, enum htmltag,
134: int, const struct htmlpair *);
135: void print_tagq(struct html *, const struct tag *);
136: void print_stagq(struct html *, const struct tag *);
137: void print_text(struct html *, const char *);
1.1 kristaps 138:
1.12 kristaps 139: void bufcat_su(struct html *, const char *,
140: const struct roffsu *);
141: void buffmt_man(struct html *,
142: const char *, const char *);
1.10 kristaps 143: void buffmt_includes(struct html *, const char *);
144: void buffmt(struct html *, const char *, ...);
145: void bufcat(struct html *, const char *);
1.12 kristaps 146: void bufcat_style(struct html *,
147: const char *, const char *);
1.10 kristaps 148: void bufncat(struct html *, const char *, size_t);
149: void bufinit(struct html *);
150:
1.16 kristaps 151: void html_idcat(char *, const char *, int);
152:
1.1 kristaps 153: __END_DECLS
154:
155: #endif /*!HTML_H*/
CVSweb