]> git.cameronkatri.com Git - mandoc.git/blob - html.h
The .UR and .MT blocks in man(7) are represented by <a> elements
[mandoc.git] / html.h
1 /* $Id: html.h,v 1.101 2019/01/18 14:36:21 schwarze Exp $ */
2 /*
3 * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2017, 2018, 2019 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_IDIV,
27 TAG_H1,
28 TAG_H2,
29 TAG_SPAN,
30 TAG_LINK,
31 TAG_BR,
32 TAG_A,
33 TAG_TABLE,
34 TAG_TR,
35 TAG_TD,
36 TAG_LI,
37 TAG_UL,
38 TAG_OL,
39 TAG_DL,
40 TAG_DT,
41 TAG_DD,
42 TAG_P,
43 TAG_PRE,
44 TAG_VAR,
45 TAG_CITE,
46 TAG_B,
47 TAG_I,
48 TAG_CODE,
49 TAG_SMALL,
50 TAG_STYLE,
51 TAG_MATH,
52 TAG_MROW,
53 TAG_MI,
54 TAG_MN,
55 TAG_MO,
56 TAG_MSUP,
57 TAG_MSUB,
58 TAG_MSUBSUP,
59 TAG_MFRAC,
60 TAG_MSQRT,
61 TAG_MFENCED,
62 TAG_MTABLE,
63 TAG_MTR,
64 TAG_MTD,
65 TAG_MUNDEROVER,
66 TAG_MUNDER,
67 TAG_MOVER,
68 TAG_MAX
69 };
70
71 enum htmlfont {
72 HTMLFONT_NONE = 0,
73 HTMLFONT_BOLD,
74 HTMLFONT_ITALIC,
75 HTMLFONT_BI,
76 HTMLFONT_CW,
77 HTMLFONT_MAX
78 };
79
80 struct tag {
81 struct tag *next;
82 int refcnt;
83 int closed;
84 enum htmltag tag;
85 };
86
87 struct html {
88 int flags;
89 #define HTML_NOSPACE (1 << 0) /* suppress next space */
90 #define HTML_IGNDELIM (1 << 1)
91 #define HTML_KEEP (1 << 2)
92 #define HTML_PREKEEP (1 << 3)
93 #define HTML_NONOSPACE (1 << 4) /* never add spaces */
94 #define HTML_SKIPCHAR (1 << 6) /* skip the next character */
95 #define HTML_NOSPLIT (1 << 7) /* do not break line before .An */
96 #define HTML_SPLIT (1 << 8) /* break line before .An */
97 #define HTML_NONEWLINE (1 << 9) /* No line break in nofill mode. */
98 #define HTML_BUFFER (1 << 10) /* Collect a word to see if it fits. */
99 #define HTML_TOCDONE (1 << 11) /* The TOC was already written. */
100 size_t indent; /* current output indentation level */
101 int noindent; /* indent disabled by <pre> */
102 size_t col; /* current output byte position */
103 size_t bufcol; /* current buf byte position */
104 char buf[80]; /* output buffer */
105 struct tag *tag; /* last open tag */
106 struct rofftbl tbl; /* current table */
107 struct tag *tblt; /* current open table scope */
108 char *base_man1; /* bases for manpage href */
109 char *base_man2;
110 char *base_includes; /* base for include href */
111 char *style; /* style-sheet URI */
112 struct tag *metaf; /* current open font scope */
113 enum htmlfont metal; /* last used font */
114 enum htmlfont metac; /* current font mode */
115 int oflags; /* output options */
116 #define HTML_FRAGMENT (1 << 0) /* don't emit HTML/HEAD/BODY */
117 #define HTML_TOC (1 << 1) /* emit a table of contents */
118 };
119
120
121 struct roff_node;
122 struct tbl_span;
123 struct eqn_box;
124
125 void roff_html_pre(struct html *, const struct roff_node *);
126
127 void print_gen_comment(struct html *, struct roff_node *);
128 void print_gen_decls(struct html *);
129 void print_gen_head(struct html *);
130 void print_metaf(struct html *, enum mandoc_esc);
131 struct tag *print_otag(struct html *, enum htmltag, const char *, ...);
132 void print_tagq(struct html *, const struct tag *);
133 void print_stagq(struct html *, const struct tag *);
134 void print_text(struct html *, const char *);
135 void print_tblclose(struct html *);
136 void print_tbl(struct html *, const struct tbl_span *);
137 void print_eqn(struct html *, const struct eqn_box *);
138 void print_endline(struct html *);
139
140 void html_close_paragraph(struct html *);
141 enum roff_tok html_fillmode(struct html *, enum roff_tok);
142 char *html_make_id(const struct roff_node *, int);