Annotation of mandoc/html.h, Revision 1.21
1.21 ! kristaps 1: /* $Id: html.h,v 1.20 2009/11/14 12:04:59 kristaps Exp $ */
1.1 kristaps 2: /*
1.6 kristaps 3: * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
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_P,
32: TAG_SPAN,
33: TAG_LINK,
34: TAG_BR,
35: TAG_A,
36: TAG_TABLE,
37: TAG_COL,
38: TAG_TR,
39: TAG_TD,
40: TAG_LI,
41: TAG_UL,
42: TAG_OL,
43: TAG_BASE,
44: TAG_MAX
45: };
46:
47: enum htmlattr {
48: ATTR_HTTPEQUIV,
49: ATTR_CONTENT,
50: ATTR_NAME,
51: ATTR_REL,
52: ATTR_HREF,
53: ATTR_TYPE,
54: ATTR_MEDIA,
55: ATTR_CLASS,
56: ATTR_STYLE,
57: ATTR_WIDTH,
58: ATTR_VALIGN,
1.9 kristaps 59: ATTR_TARGET,
1.11 kristaps 60: ATTR_ID,
1.15 kristaps 61: ATTR_SUMMARY,
1.6 kristaps 62: ATTR_MAX
63: };
64:
1.21 ! kristaps 65: enum htmlfont {
! 66: HTMLFONT_NONE = 0,
! 67: HTMLFONT_BOLD,
! 68: HTMLFONT_ITALIC,
! 69: HTMLFONT_MAX
! 70: };
! 71:
1.6 kristaps 72: struct tag {
1.14 kristaps 73: struct tag *next;
1.6 kristaps 74: enum htmltag tag;
75: };
76:
77: struct ord {
1.14 kristaps 78: struct ord *next;
79: const void *cookie;
1.6 kristaps 80: int pos;
81: };
1.1 kristaps 82:
1.14 kristaps 83: struct tagq {
84: struct tag *head;
85: };
86: struct ordq {
87: struct ord *head;
88: };
1.6 kristaps 89:
90: struct htmlpair {
91: enum htmlattr key;
1.13 kristaps 92: const char *val;
1.1 kristaps 93: };
94:
1.12 kristaps 95: #define PAIR_CLASS_INIT(p, v) \
96: do { (p)->key = ATTR_CLASS; \
97: (p)->val = (v); } while (/* CONSTCOND */ 0)
98: #define PAIR_HREF_INIT(p, v) \
99: do { (p)->key = ATTR_HREF; \
100: (p)->val = (v); } while (/* CONSTCOND */ 0)
101: #define PAIR_STYLE_INIT(p, h) \
102: do { (p)->key = ATTR_STYLE; \
103: (p)->val = (h)->buf; } while (/* CONSTCOND */ 0)
1.15 kristaps 104: #define PAIR_SUMMARY_INIT(p, v) \
105: do { (p)->key = ATTR_SUMMARY; \
106: (p)->val = (v); } while (/* CONSTCOND */ 0)
1.12 kristaps 107:
1.6 kristaps 108: struct html {
109: int flags;
110: #define HTML_NOSPACE (1 << 0)
1.7 kristaps 111: #define HTML_IGNDELIM (1 << 2)
1.6 kristaps 112: struct tagq tags;
113: struct ordq ords;
114: void *symtab;
115: char *base;
1.8 kristaps 116: char *base_man;
1.9 kristaps 117: char *base_includes;
1.6 kristaps 118: char *style;
1.8 kristaps 119: char buf[BUFSIZ];
120: size_t buflen;
1.19 kristaps 121: struct tag *metaf;
1.21 ! kristaps 122: enum htmlfont metal;
! 123: enum htmlfont metac;
1.6 kristaps 124: };
1.1 kristaps 125:
1.12 kristaps 126: struct roffsu;
127:
1.6 kristaps 128: void print_gen_doctype(struct html *);
129: void print_gen_head(struct html *);
1.21 ! kristaps 130: struct tag *print_ofont(struct html *, enum htmlfont);
1.6 kristaps 131: struct tag *print_otag(struct html *, enum htmltag,
132: int, const struct htmlpair *);
133: void print_tagq(struct html *, const struct tag *);
134: void print_stagq(struct html *, const struct tag *);
135: void print_text(struct html *, const char *);
1.1 kristaps 136:
1.12 kristaps 137: void bufcat_su(struct html *, const char *,
138: const struct roffsu *);
139: void buffmt_man(struct html *,
140: const char *, const char *);
1.10 kristaps 141: void buffmt_includes(struct html *, const char *);
142: void buffmt(struct html *, const char *, ...);
143: void bufcat(struct html *, const char *);
1.12 kristaps 144: void bufcat_style(struct html *,
145: const char *, const char *);
1.10 kristaps 146: void bufncat(struct html *, const char *, size_t);
147: void bufinit(struct html *);
148:
1.16 kristaps 149: void html_idcat(char *, const char *, int);
150:
1.1 kristaps 151: __END_DECLS
152:
153: #endif /*!HTML_H*/
CVSweb