]> git.cameronkatri.com Git - mandoc.git/blob - html.h
afceebad7ca64a52f7e060cb777c8528a4469dbe
[mandoc.git] / html.h
1 /* $Id: html.h,v 1.81 2017/02/05 18:15:39 schwarze Exp $ */
2 /*
3 * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
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 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
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 */
18
19 enum htmltag {
20 TAG_HTML,
21 TAG_HEAD,
22 TAG_BODY,
23 TAG_META,
24 TAG_TITLE,
25 TAG_DIV,
26 TAG_H1,
27 TAG_H2,
28 TAG_SPAN,
29 TAG_LINK,
30 TAG_BR,
31 TAG_A,
32 TAG_TABLE,
33 TAG_COLGROUP,
34 TAG_COL,
35 TAG_TR,
36 TAG_TD,
37 TAG_LI,
38 TAG_UL,
39 TAG_OL,
40 TAG_DL,
41 TAG_DT,
42 TAG_DD,
43 TAG_PRE,
44 TAG_B,
45 TAG_I,
46 TAG_CODE,
47 TAG_SMALL,
48 TAG_STYLE,
49 TAG_MATH,
50 TAG_MROW,
51 TAG_MI,
52 TAG_MO,
53 TAG_MSUP,
54 TAG_MSUB,
55 TAG_MSUBSUP,
56 TAG_MFRAC,
57 TAG_MSQRT,
58 TAG_MFENCED,
59 TAG_MTABLE,
60 TAG_MTR,
61 TAG_MTD,
62 TAG_MUNDEROVER,
63 TAG_MUNDER,
64 TAG_MOVER,
65 TAG_MAX
66 };
67
68 enum htmlfont {
69 HTMLFONT_NONE = 0,
70 HTMLFONT_BOLD,
71 HTMLFONT_ITALIC,
72 HTMLFONT_BI,
73 HTMLFONT_MAX
74 };
75
76 struct tag {
77 struct tag *next;
78 enum htmltag tag;
79 };
80
81 struct html {
82 int flags;
83 #define HTML_NOSPACE (1 << 0) /* suppress next space */
84 #define HTML_IGNDELIM (1 << 1)
85 #define HTML_KEEP (1 << 2)
86 #define HTML_PREKEEP (1 << 3)
87 #define HTML_NONOSPACE (1 << 4) /* never add spaces */
88 #define HTML_LITERAL (1 << 5) /* literal (e.g., <PRE>) context */
89 #define HTML_SKIPCHAR (1 << 6) /* skip the next character */
90 #define HTML_NOSPLIT (1 << 7) /* do not break line before .An */
91 #define HTML_SPLIT (1 << 8) /* break line before .An */
92 #define HTML_NONEWLINE (1 << 9) /* No line break in nofill mode. */
93 #define HTML_BUFFER (1 << 10) /* Collect a word to see if it fits. */
94 size_t indent; /* current output indentation level */
95 int noindent; /* indent disabled by <pre> */
96 size_t col; /* current output byte position */
97 size_t bufcol; /* current buf byte position */
98 char buf[80]; /* output buffer */
99 struct tag *tag; /* last open tag */
100 struct rofftbl tbl; /* current table */
101 struct tag *tblt; /* current open table scope */
102 char *base_man; /* base for manpage href */
103 char *base_includes; /* base for include href */
104 char *style; /* style-sheet URI */
105 struct tag *metaf; /* current open font scope */
106 enum htmlfont metal; /* last used font */
107 enum htmlfont metac; /* current font mode */
108 int oflags; /* output options */
109 #define HTML_FRAGMENT (1 << 0) /* don't emit HTML/HEAD/BODY */
110 };
111
112
113 struct tbl_span;
114 struct eqn;
115
116 void print_gen_decls(struct html *);
117 void print_gen_head(struct html *);
118 struct tag *print_otag(struct html *, enum htmltag, const char *, ...);
119 void print_tagq(struct html *, const struct tag *);
120 void print_stagq(struct html *, const struct tag *);
121 void print_text(struct html *, const char *);
122 void print_tblclose(struct html *);
123 void print_tbl(struct html *, const struct tbl_span *);
124 void print_eqn(struct html *, const struct eqn *);
125 void print_paragraph(struct html *);
126 void print_endline(struct html *);
127
128 int html_strlen(const char *);