Annotation of src/usr.bin/mandoc/html.h, Revision 1.70
1.70 ! schwarze 1: /* $OpenBSD: html.h,v 1.69 2020/03/13 00:31:04 schwarze Exp $ */
1.1 schwarze 2: /*
1.69 schwarze 3: * Copyright (c) 2017, 2018, 2019, 2020 Ingo Schwarze <schwarze@openbsd.org>
1.25 schwarze 4: * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
1.1 schwarze 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.
1.69 schwarze 17: *
18: * Internal interfaces for mandoc(1) HTML formatters.
19: * For use by the individual HTML formatters only.
1.1 schwarze 20: */
21:
22: enum htmltag {
23: TAG_HTML,
24: TAG_HEAD,
25: TAG_META,
1.66 schwarze 26: TAG_LINK,
27: TAG_STYLE,
1.1 schwarze 28: TAG_TITLE,
1.66 schwarze 29: TAG_BODY,
1.1 schwarze 30: TAG_DIV,
1.64 schwarze 31: TAG_SECTION,
1.1 schwarze 32: TAG_TABLE,
33: TAG_TR,
34: TAG_TD,
35: TAG_LI,
36: TAG_UL,
37: TAG_OL,
1.9 schwarze 38: TAG_DL,
39: TAG_DT,
40: TAG_DD,
1.66 schwarze 41: TAG_H1,
42: TAG_H2,
1.61 schwarze 43: TAG_P,
1.9 schwarze 44: TAG_PRE,
1.66 schwarze 45: TAG_A,
46: TAG_B,
1.44 schwarze 47: TAG_CITE,
1.66 schwarze 48: TAG_CODE,
1.10 schwarze 49: TAG_I,
1.11 schwarze 50: TAG_SMALL,
1.66 schwarze 51: TAG_SPAN,
52: TAG_VAR,
53: TAG_BR,
1.68 schwarze 54: TAG_MARK,
1.26 schwarze 55: TAG_MATH,
56: TAG_MROW,
57: TAG_MI,
1.48 schwarze 58: TAG_MN,
1.26 schwarze 59: TAG_MO,
60: TAG_MSUP,
61: TAG_MSUB,
62: TAG_MSUBSUP,
63: TAG_MFRAC,
64: TAG_MSQRT,
65: TAG_MFENCED,
66: TAG_MTABLE,
67: TAG_MTR,
68: TAG_MTD,
1.27 schwarze 69: TAG_MUNDEROVER,
70: TAG_MUNDER,
71: TAG_MOVER,
1.1 schwarze 72: TAG_MAX
73: };
74:
75: struct tag {
1.2 schwarze 76: struct tag *next;
1.63 schwarze 77: int refcnt;
78: int closed;
1.1 schwarze 79: enum htmltag tag;
80: };
81:
82: struct html {
83: int flags;
1.15 schwarze 84: #define HTML_NOSPACE (1 << 0) /* suppress next space */
1.7 schwarze 85: #define HTML_IGNDELIM (1 << 1)
86: #define HTML_KEEP (1 << 2)
87: #define HTML_PREKEEP (1 << 3)
1.15 schwarze 88: #define HTML_NONOSPACE (1 << 4) /* never add spaces */
1.19 schwarze 89: #define HTML_SKIPCHAR (1 << 6) /* skip the next character */
1.24 schwarze 90: #define HTML_NOSPLIT (1 << 7) /* do not break line before .An */
91: #define HTML_SPLIT (1 << 8) /* break line before .An */
1.32 schwarze 92: #define HTML_NONEWLINE (1 << 9) /* No line break in nofill mode. */
1.39 schwarze 93: #define HTML_BUFFER (1 << 10) /* Collect a word to see if it fits. */
1.56 schwarze 94: #define HTML_TOCDONE (1 << 11) /* The TOC was already written. */
1.39 schwarze 95: size_t indent; /* current output indentation level */
1.38 schwarze 96: int noindent; /* indent disabled by <pre> */
1.39 schwarze 97: size_t col; /* current output byte position */
98: size_t bufcol; /* current buf byte position */
99: char buf[80]; /* output buffer */
1.42 schwarze 100: struct tag *tag; /* last open tag */
1.13 schwarze 101: struct rofftbl tbl; /* current table */
1.14 schwarze 102: struct tag *tblt; /* current open table scope */
1.55 schwarze 103: char *base_man1; /* bases for manpage href */
104: char *base_man2;
1.13 schwarze 105: char *base_includes; /* base for include href */
106: char *style; /* style-sheet URI */
1.11 schwarze 107: struct tag *metaf; /* current open font scope */
1.65 schwarze 108: enum mandoc_esc metal; /* last used font */
109: enum mandoc_esc metac; /* current font mode */
1.18 schwarze 110: int oflags; /* output options */
111: #define HTML_FRAGMENT (1 << 0) /* don't emit HTML/HEAD/BODY */
1.56 schwarze 112: #define HTML_TOC (1 << 1) /* emit a table of contents */
1.1 schwarze 113: };
1.31 schwarze 114:
115:
1.46 schwarze 116: struct roff_node;
1.31 schwarze 117: struct tbl_span;
1.49 schwarze 118: struct eqn_box;
1.47 schwarze 119:
120: void roff_html_pre(struct html *, const struct roff_node *);
1.1 schwarze 121:
1.50 schwarze 122: void print_gen_comment(struct html *, struct roff_node *);
1.5 schwarze 123: void print_gen_decls(struct html *);
1.1 schwarze 124: void print_gen_head(struct html *);
1.36 schwarze 125: struct tag *print_otag(struct html *, enum htmltag, const char *, ...);
1.69 schwarze 126: struct tag *print_otag_id(struct html *, enum htmltag, const char *,
127: struct roff_node *);
1.1 schwarze 128: void print_tagq(struct html *, const struct tag *);
129: void print_stagq(struct html *, const struct tag *);
1.70 ! schwarze 130: void print_tagged_text(struct html *, const char *,
! 131: struct roff_node *);
1.1 schwarze 132: void print_text(struct html *, const char *);
1.14 schwarze 133: void print_tblclose(struct html *);
1.12 schwarze 134: void print_tbl(struct html *, const struct tbl_span *);
1.49 schwarze 135: void print_eqn(struct html *, const struct eqn_box *);
1.41 schwarze 136: void print_endline(struct html *);
1.3 schwarze 137:
1.61 schwarze 138: void html_close_paragraph(struct html *);
1.60 schwarze 139: enum roff_tok html_fillmode(struct html *, enum roff_tok);
1.52 schwarze 140: char *html_make_id(const struct roff_node *, int);
1.65 schwarze 141: int html_setfont(struct html *, enum mandoc_esc);