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