Annotation of mandoc/html.h, Revision 1.102
1.102 ! schwarze 1: /* $Id: html.h,v 1.101 2019/01/18 14:36:21 schwarze Exp $ */
1.1 kristaps 2: /*
1.66 schwarze 3: * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
1.99 schwarze 4: * Copyright (c) 2017, 2018, 2019 Ingo Schwarze <schwarze@openbsd.org>
1.1 kristaps 5: *
6: * Permission to use, copy, modify, and distribute this software for any
1.6 kristaps 7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
1.1 kristaps 9: *
1.6 kristaps 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.
1.1 kristaps 17: */
18:
1.6 kristaps 19: enum htmltag {
20: TAG_HTML,
21: TAG_HEAD,
22: TAG_BODY,
23: TAG_META,
24: TAG_TITLE,
25: TAG_DIV,
1.89 schwarze 26: TAG_IDIV,
1.102 ! schwarze 27: TAG_SECTION,
1.6 kristaps 28: TAG_H1,
29: TAG_H2,
30: TAG_SPAN,
31: TAG_LINK,
32: TAG_BR,
33: TAG_A,
34: TAG_TABLE,
35: TAG_TR,
36: TAG_TD,
37: TAG_LI,
38: TAG_UL,
39: TAG_OL,
1.28 kristaps 40: TAG_DL,
41: TAG_DT,
42: TAG_DD,
1.99 schwarze 43: TAG_P,
1.31 kristaps 44: TAG_PRE,
1.83 schwarze 45: TAG_VAR,
1.82 schwarze 46: TAG_CITE,
1.32 kristaps 47: TAG_B,
1.33 kristaps 48: TAG_I,
1.34 kristaps 49: TAG_CODE,
1.35 kristaps 50: TAG_SMALL,
1.56 kristaps 51: TAG_STYLE,
1.63 kristaps 52: TAG_MATH,
53: TAG_MROW,
54: TAG_MI,
1.86 schwarze 55: TAG_MN,
1.63 kristaps 56: TAG_MO,
57: TAG_MSUP,
58: TAG_MSUB,
59: TAG_MSUBSUP,
60: TAG_MFRAC,
61: TAG_MSQRT,
62: TAG_MFENCED,
63: TAG_MTABLE,
64: TAG_MTR,
65: TAG_MTD,
1.64 kristaps 66: TAG_MUNDEROVER,
67: TAG_MUNDER,
68: TAG_MOVER,
1.6 kristaps 69: TAG_MAX
70: };
71:
1.21 kristaps 72: enum htmlfont {
73: HTMLFONT_NONE = 0,
74: HTMLFONT_BOLD,
75: HTMLFONT_ITALIC,
1.49 schwarze 76: HTMLFONT_BI,
1.95 schwarze 77: HTMLFONT_CW,
1.21 kristaps 78: HTMLFONT_MAX
79: };
80:
1.6 kristaps 81: struct tag {
1.14 kristaps 82: struct tag *next;
1.101 schwarze 83: int refcnt;
84: int closed;
1.6 kristaps 85: enum htmltag tag;
86: };
87:
88: struct html {
89: int flags;
1.40 kristaps 90: #define HTML_NOSPACE (1 << 0) /* suppress next space */
1.25 kristaps 91: #define HTML_IGNDELIM (1 << 1)
92: #define HTML_KEEP (1 << 2)
93: #define HTML_PREKEEP (1 << 3)
1.40 kristaps 94: #define HTML_NONOSPACE (1 << 4) /* never add spaces */
1.48 schwarze 95: #define HTML_SKIPCHAR (1 << 6) /* skip the next character */
1.54 schwarze 96: #define HTML_NOSPLIT (1 << 7) /* do not break line before .An */
97: #define HTML_SPLIT (1 << 8) /* break line before .An */
1.70 schwarze 98: #define HTML_NONEWLINE (1 << 9) /* No line break in nofill mode. */
1.77 schwarze 99: #define HTML_BUFFER (1 << 10) /* Collect a word to see if it fits. */
1.94 schwarze 100: #define HTML_TOCDONE (1 << 11) /* The TOC was already written. */
1.77 schwarze 101: size_t indent; /* current output indentation level */
1.76 schwarze 102: int noindent; /* indent disabled by <pre> */
1.77 schwarze 103: size_t col; /* current output byte position */
104: size_t bufcol; /* current buf byte position */
105: char buf[80]; /* output buffer */
1.80 schwarze 106: struct tag *tag; /* last open tag */
1.38 kristaps 107: struct rofftbl tbl; /* current table */
1.39 kristaps 108: struct tag *tblt; /* current open table scope */
1.93 schwarze 109: char *base_man1; /* bases for manpage href */
110: char *base_man2;
1.38 kristaps 111: char *base_includes; /* base for include href */
112: char *style; /* style-sheet URI */
1.35 kristaps 113: struct tag *metaf; /* current open font scope */
114: enum htmlfont metal; /* last used font */
115: enum htmlfont metac; /* current font mode */
1.47 kristaps 116: int oflags; /* output options */
117: #define HTML_FRAGMENT (1 << 0) /* don't emit HTML/HEAD/BODY */
1.94 schwarze 118: #define HTML_TOC (1 << 1) /* emit a table of contents */
1.6 kristaps 119: };
1.69 schwarze 120:
121:
1.84 schwarze 122: struct roff_node;
1.69 schwarze 123: struct tbl_span;
1.87 schwarze 124: struct eqn_box;
1.85 schwarze 125:
126: void roff_html_pre(struct html *, const struct roff_node *);
1.12 kristaps 127:
1.88 schwarze 128: void print_gen_comment(struct html *, struct roff_node *);
1.22 kristaps 129: void print_gen_decls(struct html *);
1.6 kristaps 130: void print_gen_head(struct html *);
1.96 schwarze 131: void print_metaf(struct html *, enum mandoc_esc);
1.74 schwarze 132: struct tag *print_otag(struct html *, enum htmltag, const char *, ...);
1.6 kristaps 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.39 kristaps 136: void print_tblclose(struct html *);
1.37 kristaps 137: void print_tbl(struct html *, const struct tbl_span *);
1.87 schwarze 138: void print_eqn(struct html *, const struct eqn_box *);
1.79 schwarze 139: void print_endline(struct html *);
1.10 kristaps 140:
1.99 schwarze 141: void html_close_paragraph(struct html *);
1.98 schwarze 142: enum roff_tok html_fillmode(struct html *, enum roff_tok);
1.90 schwarze 143: char *html_make_id(const struct roff_node *, int);
CVSweb