1*4d131170SRobert Mustacchi /* $Id: html.h,v 1.109 2021/09/09 14:47:24 schwarze Exp $ */ 295c635efSGarrett D'Amore /* 3*4d131170SRobert Mustacchi * Copyright (c) 2017, 2018, 2019, 2020 Ingo Schwarze <schwarze@openbsd.org> 4260e9a87SYuri Pankov * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> 595c635efSGarrett D'Amore * 695c635efSGarrett D'Amore * Permission to use, copy, modify, and distribute this software for any 795c635efSGarrett D'Amore * purpose with or without fee is hereby granted, provided that the above 895c635efSGarrett D'Amore * copyright notice and this permission notice appear in all copies. 995c635efSGarrett D'Amore * 1095c635efSGarrett D'Amore * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1195c635efSGarrett D'Amore * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1295c635efSGarrett D'Amore * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1395c635efSGarrett D'Amore * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1495c635efSGarrett D'Amore * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1595c635efSGarrett D'Amore * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1695c635efSGarrett D'Amore * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17*4d131170SRobert Mustacchi * 18*4d131170SRobert Mustacchi * Internal interfaces for mandoc(1) HTML formatters. 19*4d131170SRobert Mustacchi * For use by the individual HTML formatters only. 2095c635efSGarrett D'Amore */ 2195c635efSGarrett D'Amore 2295c635efSGarrett D'Amore enum htmltag { 2395c635efSGarrett D'Amore TAG_HTML, 2495c635efSGarrett D'Amore TAG_HEAD, 2595c635efSGarrett D'Amore TAG_META, 26*4d131170SRobert Mustacchi TAG_LINK, 27*4d131170SRobert Mustacchi TAG_STYLE, 2895c635efSGarrett D'Amore TAG_TITLE, 29*4d131170SRobert Mustacchi TAG_BODY, 3095c635efSGarrett D'Amore TAG_DIV, 31cec8643bSMichal Nowak TAG_SECTION, 3295c635efSGarrett D'Amore TAG_TABLE, 3395c635efSGarrett D'Amore TAG_TR, 3495c635efSGarrett D'Amore TAG_TD, 3595c635efSGarrett D'Amore TAG_LI, 3695c635efSGarrett D'Amore TAG_UL, 3795c635efSGarrett D'Amore TAG_OL, 3895c635efSGarrett D'Amore TAG_DL, 3995c635efSGarrett D'Amore TAG_DT, 4095c635efSGarrett D'Amore TAG_DD, 41*4d131170SRobert Mustacchi TAG_H1, 42*4d131170SRobert Mustacchi TAG_H2, 43cec8643bSMichal Nowak TAG_P, 4495c635efSGarrett D'Amore TAG_PRE, 45*4d131170SRobert Mustacchi TAG_A, 4695c635efSGarrett D'Amore TAG_B, 47*4d131170SRobert Mustacchi TAG_CITE, 4895c635efSGarrett D'Amore TAG_CODE, 49*4d131170SRobert Mustacchi TAG_I, 5095c635efSGarrett D'Amore TAG_SMALL, 51*4d131170SRobert Mustacchi TAG_SPAN, 52*4d131170SRobert Mustacchi TAG_VAR, 53*4d131170SRobert Mustacchi TAG_BR, 54*4d131170SRobert Mustacchi TAG_HR, 55*4d131170SRobert Mustacchi TAG_MARK, 56260e9a87SYuri Pankov TAG_MATH, 57260e9a87SYuri Pankov TAG_MROW, 58260e9a87SYuri Pankov TAG_MI, 59c66b8046SYuri Pankov TAG_MN, 60260e9a87SYuri Pankov TAG_MO, 61260e9a87SYuri Pankov TAG_MSUP, 62260e9a87SYuri Pankov TAG_MSUB, 63260e9a87SYuri Pankov TAG_MSUBSUP, 64260e9a87SYuri Pankov TAG_MFRAC, 65260e9a87SYuri Pankov TAG_MSQRT, 66260e9a87SYuri Pankov TAG_MFENCED, 67260e9a87SYuri Pankov TAG_MTABLE, 68260e9a87SYuri Pankov TAG_MTR, 69260e9a87SYuri Pankov TAG_MTD, 70260e9a87SYuri Pankov TAG_MUNDEROVER, 71260e9a87SYuri Pankov TAG_MUNDER, 72260e9a87SYuri Pankov TAG_MOVER, 7395c635efSGarrett D'Amore TAG_MAX 7495c635efSGarrett D'Amore }; 7595c635efSGarrett D'Amore 7695c635efSGarrett D'Amore struct tag { 7795c635efSGarrett D'Amore struct tag *next; 78cec8643bSMichal Nowak int refcnt; 79cec8643bSMichal Nowak int closed; 8095c635efSGarrett D'Amore enum htmltag tag; 8195c635efSGarrett D'Amore }; 8295c635efSGarrett D'Amore 8395c635efSGarrett D'Amore struct html { 8495c635efSGarrett D'Amore int flags; 8595c635efSGarrett D'Amore #define HTML_NOSPACE (1 << 0) /* suppress next space */ 8695c635efSGarrett D'Amore #define HTML_IGNDELIM (1 << 1) 8795c635efSGarrett D'Amore #define HTML_KEEP (1 << 2) 8895c635efSGarrett D'Amore #define HTML_PREKEEP (1 << 3) 8995c635efSGarrett D'Amore #define HTML_NONOSPACE (1 << 4) /* never add spaces */ 90698f87a4SGarrett D'Amore #define HTML_SKIPCHAR (1 << 6) /* skip the next character */ 91260e9a87SYuri Pankov #define HTML_NOSPLIT (1 << 7) /* do not break line before .An */ 92260e9a87SYuri Pankov #define HTML_SPLIT (1 << 8) /* break line before .An */ 93260e9a87SYuri Pankov #define HTML_NONEWLINE (1 << 9) /* No line break in nofill mode. */ 94a40ea1a7SYuri Pankov #define HTML_BUFFER (1 << 10) /* Collect a word to see if it fits. */ 95cec8643bSMichal Nowak #define HTML_TOCDONE (1 << 11) /* The TOC was already written. */ 96a40ea1a7SYuri Pankov size_t indent; /* current output indentation level */ 97a40ea1a7SYuri Pankov int noindent; /* indent disabled by <pre> */ 98a40ea1a7SYuri Pankov size_t col; /* current output byte position */ 99a40ea1a7SYuri Pankov size_t bufcol; /* current buf byte position */ 100a40ea1a7SYuri Pankov char buf[80]; /* output buffer */ 101a40ea1a7SYuri Pankov struct tag *tag; /* last open tag */ 10295c635efSGarrett D'Amore struct rofftbl tbl; /* current table */ 10395c635efSGarrett D'Amore struct tag *tblt; /* current open table scope */ 104cec8643bSMichal Nowak char *base_man1; /* bases for manpage href */ 105cec8643bSMichal Nowak char *base_man2; 10695c635efSGarrett D'Amore char *base_includes; /* base for include href */ 10795c635efSGarrett D'Amore char *style; /* style-sheet URI */ 10895c635efSGarrett D'Amore struct tag *metaf; /* current open font scope */ 109*4d131170SRobert Mustacchi enum mandoc_esc metal; /* last used font */ 110*4d131170SRobert Mustacchi enum mandoc_esc metac; /* current font mode */ 11195c635efSGarrett D'Amore int oflags; /* output options */ 11295c635efSGarrett D'Amore #define HTML_FRAGMENT (1 << 0) /* don't emit HTML/HEAD/BODY */ 113cec8643bSMichal Nowak #define HTML_TOC (1 << 1) /* emit a table of contents */ 11495c635efSGarrett D'Amore }; 11595c635efSGarrett D'Amore 116260e9a87SYuri Pankov 117c66b8046SYuri Pankov struct roff_node; 118260e9a87SYuri Pankov struct tbl_span; 119c66b8046SYuri Pankov struct eqn_box; 120c66b8046SYuri Pankov 121c66b8046SYuri Pankov void roff_html_pre(struct html *, const struct roff_node *); 122260e9a87SYuri Pankov 1236640c13bSYuri Pankov void print_gen_comment(struct html *, struct roff_node *); 12495c635efSGarrett D'Amore void print_gen_decls(struct html *); 12595c635efSGarrett D'Amore void print_gen_head(struct html *); 126a40ea1a7SYuri Pankov struct tag *print_otag(struct html *, enum htmltag, const char *, ...); 127*4d131170SRobert Mustacchi struct tag *print_otag_id(struct html *, enum htmltag, const char *, 128*4d131170SRobert Mustacchi struct roff_node *); 12995c635efSGarrett D'Amore void print_tagq(struct html *, const struct tag *); 13095c635efSGarrett D'Amore void print_stagq(struct html *, const struct tag *); 131*4d131170SRobert Mustacchi void print_tagged_text(struct html *, const char *, 132*4d131170SRobert Mustacchi struct roff_node *); 13395c635efSGarrett D'Amore void print_text(struct html *, const char *); 13495c635efSGarrett D'Amore void print_tblclose(struct html *); 13595c635efSGarrett D'Amore void print_tbl(struct html *, const struct tbl_span *); 136c66b8046SYuri Pankov void print_eqn(struct html *, const struct eqn_box *); 137a40ea1a7SYuri Pankov void print_endline(struct html *); 13895c635efSGarrett D'Amore 139cec8643bSMichal Nowak void html_close_paragraph(struct html *); 140cec8643bSMichal Nowak enum roff_tok html_fillmode(struct html *, enum roff_tok); 1416640c13bSYuri Pankov char *html_make_id(const struct roff_node *, int); 142*4d131170SRobert Mustacchi int html_setfont(struct html *, enum mandoc_esc); 143