]>
git.cameronkatri.com Git - mandoc.git/blob - html.c
1 /* $Id: html.c,v 1.276 2022/06/24 11:15:53 schwarze Exp $ */
3 * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2011-2015, 2017-2021 Ingo Schwarze <schwarze@openbsd.org>
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.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS 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.
18 * Common functions for mandoc(1) HTML formatters.
19 * For use by individual formatters and by the main program.
23 #include <sys/types.h>
36 #include "mandoc_aux.h"
37 #include "mandoc_ohash.h"
48 #define HTML_INPHRASE (1 << 0) /* Can appear in phrasing context. */
49 #define HTML_TOPHRASE (1 << 1) /* Establishes phrasing context. */
50 #define HTML_NOSTACK (1 << 2) /* Does not have an end tag. */
51 #define HTML_NLBEFORE (1 << 3) /* Output line break before opening. */
52 #define HTML_NLBEGIN (1 << 4) /* Output line break after opening. */
53 #define HTML_NLEND (1 << 5) /* Output line break before closing. */
54 #define HTML_NLAFTER (1 << 6) /* Output line break after closing. */
55 #define HTML_NLAROUND (HTML_NLBEFORE | HTML_NLAFTER)
56 #define HTML_NLINSIDE (HTML_NLBEGIN | HTML_NLEND)
57 #define HTML_NLALL (HTML_NLAROUND | HTML_NLINSIDE)
58 #define HTML_INDENT (1 << 7) /* Indent content by two spaces. */
59 #define HTML_NOINDENT (1 << 8) /* Exception: never indent content. */
62 static const struct htmldata htmltags
[TAG_MAX
] = {
64 {"head", HTML_NLALL
| HTML_INDENT
},
65 {"meta", HTML_NOSTACK
| HTML_NLALL
},
66 {"link", HTML_NOSTACK
| HTML_NLALL
},
67 {"style", HTML_NLALL
| HTML_INDENT
},
68 {"title", HTML_NLAROUND
},
70 {"div", HTML_NLAROUND
},
71 {"section", HTML_NLALL
},
73 {"table", HTML_NLALL
| HTML_INDENT
},
74 {"tr", HTML_NLALL
| HTML_INDENT
},
75 {"td", HTML_NLAROUND
},
76 {"li", HTML_NLAROUND
| HTML_INDENT
},
77 {"ul", HTML_NLALL
| HTML_INDENT
},
78 {"ol", HTML_NLALL
| HTML_INDENT
},
79 {"dl", HTML_NLALL
| HTML_INDENT
},
80 {"dt", HTML_NLAROUND
},
81 {"dd", HTML_NLAROUND
| HTML_INDENT
},
82 {"h1", HTML_TOPHRASE
| HTML_NLAROUND
},
83 {"h2", HTML_TOPHRASE
| HTML_NLAROUND
},
84 {"p", HTML_TOPHRASE
| HTML_NLAROUND
| HTML_INDENT
},
85 {"pre", HTML_TOPHRASE
| HTML_NLAROUND
| HTML_NOINDENT
},
86 {"a", HTML_INPHRASE
| HTML_TOPHRASE
},
87 {"b", HTML_INPHRASE
| HTML_TOPHRASE
},
88 {"cite", HTML_INPHRASE
| HTML_TOPHRASE
},
89 {"code", HTML_INPHRASE
| HTML_TOPHRASE
},
90 {"i", HTML_INPHRASE
| HTML_TOPHRASE
},
91 {"small", HTML_INPHRASE
| HTML_TOPHRASE
},
92 {"span", HTML_INPHRASE
| HTML_TOPHRASE
},
93 {"var", HTML_INPHRASE
| HTML_TOPHRASE
},
94 {"br", HTML_INPHRASE
| HTML_NOSTACK
| HTML_NLALL
},
95 {"hr", HTML_INPHRASE
| HTML_NOSTACK
},
96 {"mark", HTML_INPHRASE
},
97 {"math", HTML_INPHRASE
| HTML_NLALL
| HTML_INDENT
},
116 /* Avoid duplicate HTML id= attributes. */
119 int ord
; /* Ordinal number of the latest occurrence. */
120 char id
[]; /* The id= attribute without any ordinal suffix. */
122 static struct ohash id_unique
;
124 static void html_reset_internal(struct html
*);
125 static void print_byte(struct html
*, char);
126 static void print_endword(struct html
*);
127 static void print_indent(struct html
*);
128 static void print_word(struct html
*, const char *);
130 static void print_ctag(struct html
*, struct tag
*);
131 static int print_escape(struct html
*, char);
132 static int print_encode(struct html
*, const char *, const char *, int);
133 static void print_href(struct html
*, const char *, const char *, int);
134 static void print_metaf(struct html
*);
138 html_alloc(const struct manoutput
*outopts
)
142 h
= mandoc_calloc(1, sizeof(struct html
));
145 h
->metac
= h
->metal
= ESCAPE_FONTROMAN
;
146 h
->style
= outopts
->style
;
147 if ((h
->base_man1
= outopts
->man
) == NULL
)
149 else if ((h
->base_man2
= strchr(h
->base_man1
, ';')) != NULL
)
150 *h
->base_man2
++ = '\0';
151 h
->base_includes
= outopts
->includes
;
152 if (outopts
->fragment
)
153 h
->oflags
|= HTML_FRAGMENT
;
155 h
->oflags
|= HTML_TOC
;
157 mandoc_ohash_init(&id_unique
, 4, offsetof(struct id_entry
, id
));
163 html_reset_internal(struct html
*h
)
166 struct id_entry
*entry
;
169 while ((tag
= h
->tag
) != NULL
) {
173 entry
= ohash_first(&id_unique
, &slot
);
174 while (entry
!= NULL
) {
176 entry
= ohash_next(&id_unique
, &slot
);
178 ohash_delete(&id_unique
);
184 html_reset_internal(p
);
185 mandoc_ohash_init(&id_unique
, 4, offsetof(struct id_entry
, id
));
191 html_reset_internal(p
);
196 print_gen_head(struct html
*h
)
200 print_otag(h
, TAG_META
, "?", "charset", "utf-8");
201 print_otag(h
, TAG_META
, "??", "name", "viewport",
202 "content", "width=device-width, initial-scale=1.0");
203 if (h
->style
!= NULL
) {
204 print_otag(h
, TAG_LINK
, "?h??", "rel", "stylesheet",
205 h
->style
, "type", "text/css", "media", "all");
210 * Print a minimal embedded style sheet.
213 t
= print_otag(h
, TAG_STYLE
, "");
214 print_text(h
, "table.head, table.foot { width: 100%; }");
216 print_text(h
, "td.head-rtitle, td.foot-os { text-align: right; }");
218 print_text(h
, "td.head-vol { text-align: center; }");
220 print_text(h
, ".Nd, .Bf, .Op { display: inline; }");
222 print_text(h
, ".Pa, .Ad { font-style: italic; }");
224 print_text(h
, ".Ms { font-weight: bold; }");
226 print_text(h
, ".Bl-diag ");
228 print_text(h
, " dt { font-weight: bold; }");
230 print_text(h
, "code.Nm, .Fl, .Cm, .Ic, code.In, .Fd, .Fn, .Cd "
231 "{ font-weight: bold; font-family: inherit; }");
236 html_setfont(struct html
*h
, enum mandoc_esc font
)
239 case ESCAPE_FONTPREV
:
242 case ESCAPE_FONTITALIC
:
243 case ESCAPE_FONTBOLD
:
245 case ESCAPE_FONTROMAN
:
251 font
= ESCAPE_FONTROMAN
;
262 print_metaf(struct html
*h
)
265 print_tagq(h
, h
->metaf
);
269 case ESCAPE_FONTITALIC
:
270 h
->metaf
= print_otag(h
, TAG_I
, "");
272 case ESCAPE_FONTBOLD
:
273 h
->metaf
= print_otag(h
, TAG_B
, "");
276 h
->metaf
= print_otag(h
, TAG_B
, "");
277 print_otag(h
, TAG_I
, "");
280 h
->metaf
= print_otag(h
, TAG_SPAN
, "c", "Li");
283 h
->metaf
= print_otag(h
, TAG_SPAN
, "c", "Li");
284 print_otag(h
, TAG_B
, "");
287 h
->metaf
= print_otag(h
, TAG_SPAN
, "c", "Li");
288 print_otag(h
, TAG_I
, "");
296 html_close_paragraph(struct html
*h
)
298 struct tag
*this, *next
;
304 flags
= htmltags
[this->tag
].flags
;
305 if (flags
& (HTML_INPHRASE
| HTML_TOPHRASE
))
307 if ((flags
& HTML_INPHRASE
) == 0)
314 * ROFF_nf switches to no-fill mode, ROFF_fi to fill mode.
315 * TOKEN_NONE does not switch. The old mode is returned.
318 html_fillmode(struct html
*h
, enum roff_tok want
)
323 for (t
= h
->tag
; t
!= NULL
; t
= t
->next
)
324 if (t
->tag
== TAG_PRE
)
327 had
= t
== NULL
? ROFF_fi
: ROFF_nf
;
335 html_close_paragraph(h
);
336 print_otag(h
, TAG_PRE
, "");
348 * Allocate a string to be used for the "id=" attribute of an HTML
349 * element and/or as a segment identifier for a URI in an <a> element.
350 * The function may fail and return NULL if the node lacks text data
351 * to create the attribute from.
352 * The caller is responsible for free(3)ing the returned string.
354 * If the "unique" argument is non-zero, the "id_unique" ohash table
355 * is used for de-duplication. If the "unique" argument is 1,
356 * it is the first time the function is called for this tag and
357 * location, so if an ordinal suffix is needed, it is incremented.
358 * If the "unique" argument is 2, it is the second time the function
359 * is called for this tag and location, so the ordinal suffix
363 html_make_id(const struct roff_node
*n
, int unique
)
365 const struct roff_node
*nch
;
366 struct id_entry
*entry
;
372 buf
= mandoc_strdup(n
->tag
);
380 for (nch
= n
->child
; nch
!= NULL
; nch
= nch
->next
)
381 if (nch
->type
!= ROFFT_TEXT
)
389 if (n
->child
== NULL
|| n
->child
->type
!= ROFFT_TEXT
)
391 buf
= mandoc_strdup(n
->child
->string
);
397 * In ID attributes, only use ASCII characters that are
398 * permitted in URL-fragment strings according to the
400 * https://url.spec.whatwg.org/#url-fragment-string
401 * In addition, reserve '~' for ordinal suffixes.
404 for (cp
= buf
; *cp
!= '\0'; cp
++)
405 if (isalnum((unsigned char)*cp
) == 0 &&
406 strchr("!$&'()*+,-./:;=?@_", *cp
) == NULL
)
412 /* Avoid duplicate HTML id= attributes. */
414 slot
= ohash_qlookup(&id_unique
, buf
);
415 if ((entry
= ohash_find(&id_unique
, slot
)) == NULL
) {
416 len
= strlen(buf
) + 1;
417 entry
= mandoc_malloc(sizeof(*entry
) + len
);
419 memcpy(entry
->id
, buf
, len
);
420 ohash_insert(&id_unique
, slot
, entry
);
421 } else if (unique
== 1)
424 if (entry
->ord
> 1) {
426 mandoc_asprintf(&buf
, "%s~%d", cp
, entry
->ord
);
433 print_escape(struct html
*h
, char c
)
438 print_word(h
, "<");
441 print_word(h
, ">");
444 print_word(h
, "&");
447 print_word(h
, """);
450 print_word(h
, " ");
464 print_encode(struct html
*h
, const char *p
, const char *pend
, int norecurse
)
469 int c
, len
, breakline
, nospace
;
471 static const char rejs
[10] = { ' ', '\\', '<', '>', '&', '"',
472 ASCII_NBRSP
, ASCII_HYPH
, ASCII_BREAK
, '\0' };
475 pend
= strchr(p
, '\0');
481 if (HTML_SKIPCHAR
& h
->flags
&& '\\' != *p
) {
482 h
->flags
&= ~HTML_SKIPCHAR
;
487 for (sz
= strcspn(p
, rejs
); sz
-- && p
< pend
; p
++)
491 (p
>= pend
|| *p
== ' ' || *p
== ASCII_NBRSP
)) {
492 print_otag(h
, TAG_BR
, "");
494 while (p
< pend
&& (*p
== ' ' || *p
== ASCII_NBRSP
))
508 if (print_escape(h
, *p
++))
511 esc
= mandoc_escape(&p
, &seq
, &len
);
514 case ESCAPE_FONTPREV
:
515 case ESCAPE_FONTBOLD
:
516 case ESCAPE_FONTITALIC
:
518 case ESCAPE_FONTROMAN
:
522 if (0 == norecurse
) {
523 h
->flags
|= HTML_NOSPACE
;
524 if (html_setfont(h
, esc
))
526 h
->flags
&= ~HTML_NOSPACE
;
529 case ESCAPE_SKIPCHAR
:
530 h
->flags
|= HTML_SKIPCHAR
;
538 if (h
->flags
& HTML_SKIPCHAR
) {
539 h
->flags
&= ~HTML_SKIPCHAR
;
545 /* Skip past "u" header. */
546 c
= mchars_num2uc(seq
+ 1, len
- 1);
548 case ESCAPE_NUMBERED
:
549 c
= mchars_num2char(seq
, len
);
554 c
= mchars_spec2cp(seq
, len
);
562 print_word(h
, "html");
571 case ESCAPE_OVERSTRIKE
:
579 if ((c
< 0x20 && c
!= 0x09) ||
580 (c
> 0x7E && c
< 0xA0))
583 (void)snprintf(numbuf
, sizeof(numbuf
), "&#x%.4X;", c
);
584 print_word(h
, numbuf
);
585 } else if (print_escape(h
, c
) == 0)
593 print_href(struct html
*h
, const char *name
, const char *sec
, int man
)
601 if (h
->base_man2
!= NULL
) {
602 mandoc_asprintf(&filename
, "%s.%s", name
, sec
);
603 if (stat(filename
, &sb
) == -1)
608 pp
= h
->base_includes
;
610 while ((p
= strchr(pp
, '%')) != NULL
) {
611 print_encode(h
, pp
, p
, 1);
612 if (man
&& p
[1] == 'S') {
616 print_encode(h
, sec
, NULL
, 1);
617 } else if ((man
&& p
[1] == 'N') ||
618 (man
== 0 && p
[1] == 'I'))
619 print_encode(h
, name
, NULL
, 1);
621 print_encode(h
, p
, p
+ 2, 1);
625 print_encode(h
, pp
, NULL
, 1);
629 print_otag(struct html
*h
, enum htmltag tag
, const char *fmt
, ...)
635 int style_written
, tflags
;
637 tflags
= htmltags
[tag
].flags
;
639 /* Flow content is not allowed in phrasing context. */
641 if ((tflags
& HTML_INPHRASE
) == 0) {
642 for (t
= h
->tag
; t
!= NULL
; t
= t
->next
) {
645 assert((htmltags
[t
->tag
].flags
& HTML_TOPHRASE
) == 0);
650 * Always wrap phrasing elements in a paragraph
651 * unless already contained in some flow container;
652 * never put them directly into a section.
655 } else if (tflags
& HTML_TOPHRASE
&& h
->tag
->tag
== TAG_SECTION
)
656 print_otag(h
, TAG_P
, "c", "Pp");
658 /* Push this tag onto the stack of open scopes. */
660 if ((tflags
& HTML_NOSTACK
) == 0) {
661 t
= mandoc_malloc(sizeof(struct tag
));
670 if (tflags
& HTML_NLBEFORE
)
674 else if ((h
->flags
& HTML_NOSPACE
) == 0) {
675 if (h
->flags
& HTML_KEEP
)
676 print_word(h
, " ");
678 if (h
->flags
& HTML_PREKEEP
)
679 h
->flags
|= HTML_KEEP
;
684 if ( ! (h
->flags
& HTML_NONOSPACE
))
685 h
->flags
&= ~HTML_NOSPACE
;
687 h
->flags
|= HTML_NOSPACE
;
689 /* Print out the tag name and attributes. */
692 print_word(h
, htmltags
[tag
].name
);
696 while (*fmt
!= '\0' && *fmt
!= 's') {
698 /* Parse attributes and arguments. */
700 arg1
= va_arg(ap
, char *);
717 arg1
= va_arg(ap
, char *);
723 arg2
= va_arg(ap
, char *);
727 /* Print the attributes. */
735 print_href(h
, arg1
, NULL
, 0);
739 print_href(h
, arg1
, arg2
, 1);
744 print_encode(h
, arg1
, NULL
, 1);
748 print_encode(h
, arg1
, NULL
, 1);
755 while (*fmt
++ == 's') {
756 arg1
= va_arg(ap
, char *);
757 arg2
= va_arg(ap
, char *);
761 if (style_written
== 0) {
762 print_word(h
, "style=\"");
776 /* Accommodate for "well-formed" singleton escaping. */
778 if (htmltags
[tag
].flags
& HTML_NOSTACK
)
783 if (tflags
& HTML_NLBEGIN
)
786 h
->flags
|= HTML_NOSPACE
;
788 if (tflags
& HTML_INDENT
)
790 if (tflags
& HTML_NOINDENT
)
797 * Print an element with an optional "id=" attribute.
798 * If the element has phrasing content and an "id=" attribute,
799 * also add a permalink: outside if it can be in phrasing context,
803 print_otag_id(struct html
*h
, enum htmltag elemtype
, const char *cattr
,
806 struct roff_node
*nch
;
812 if (n
->flags
& NODE_ID
)
813 id
= html_make_id(n
, 1);
814 if (n
->flags
& NODE_HREF
)
815 href
= id
== NULL
? html_make_id(n
, 2) : id
;
816 if (href
!= NULL
&& htmltags
[elemtype
].flags
& HTML_INPHRASE
)
817 ret
= print_otag(h
, TAG_A
, "chR", "permalink", href
);
818 t
= print_otag(h
, elemtype
, "ci", cattr
, id
);
821 if (href
!= NULL
&& (nch
= n
->child
) != NULL
) {
822 /* man(7) is safe, it tags phrasing content only. */
823 if (n
->tok
> MDOC_MAX
||
824 htmltags
[elemtype
].flags
& HTML_TOPHRASE
)
826 else /* For mdoc(7), beware of nested blocks. */
827 while (nch
!= NULL
&& nch
->type
== ROFFT_TEXT
)
830 print_otag(h
, TAG_A
, "chR", "permalink", href
);
840 print_ctag(struct html
*h
, struct tag
*tag
)
844 if (tag
->closed
== 0) {
851 tflags
= htmltags
[tag
->tag
].flags
;
852 if (tflags
& HTML_INDENT
)
854 if (tflags
& HTML_NOINDENT
)
856 if (tflags
& HTML_NLEND
)
861 print_word(h
, htmltags
[tag
->tag
].name
);
863 if (tflags
& HTML_NLAFTER
)
866 if (tag
->refcnt
== 0) {
873 print_gen_decls(struct html
*h
)
875 print_word(h
, "<!DOCTYPE html>");
880 print_gen_comment(struct html
*h
, struct roff_node
*n
)
884 print_word(h
, "<!-- This is an automatically generated file."
888 while (n
!= NULL
&& n
->type
== ROFFT_COMMENT
) {
889 if (strstr(n
->string
, "-->") == NULL
&&
890 (wantblank
|| *n
->string
!= '\0')) {
893 print_word(h
, n
->string
);
894 wantblank
= *n
->string
!= '\0';
900 print_word(h
, " -->");
906 print_text(struct html
*h
, const char *word
)
908 print_tagged_text(h
, word
, NULL
);
912 print_tagged_text(struct html
*h
, const char *word
, struct roff_node
*n
)
918 * Always wrap text in a paragraph unless already contained in
919 * some flow container; never put it directly into a section.
922 if (h
->tag
->tag
== TAG_SECTION
)
923 print_otag(h
, TAG_P
, "c", "Pp");
925 /* Output whitespace before this text? */
927 if (h
->col
&& (h
->flags
& HTML_NOSPACE
) == 0) {
928 if ( ! (HTML_KEEP
& h
->flags
)) {
929 if (HTML_PREKEEP
& h
->flags
)
930 h
->flags
|= HTML_KEEP
;
933 print_word(h
, " ");
937 * Optionally switch fonts, optionally write a permalink, then
938 * print the text, optionally surrounded by HTML whitespace.
941 assert(h
->metaf
== NULL
);
945 if (n
!= NULL
&& (href
= html_make_id(n
, 2)) != NULL
) {
946 t
= print_otag(h
, TAG_A
, "chR", "permalink", href
);
951 if ( ! print_encode(h
, word
, NULL
, 0)) {
952 if ( ! (h
->flags
& HTML_NONOSPACE
))
953 h
->flags
&= ~HTML_NOSPACE
;
954 h
->flags
&= ~HTML_NONEWLINE
;
956 h
->flags
|= HTML_NOSPACE
| HTML_NONEWLINE
;
958 if (h
->metaf
!= NULL
) {
959 print_tagq(h
, h
->metaf
);
961 } else if (t
!= NULL
)
964 h
->flags
&= ~HTML_IGNDELIM
;
968 print_tagq(struct html
*h
, const struct tag
*until
)
970 struct tag
*this, *next
;
972 for (this = h
->tag
; this != NULL
; this = next
) {
973 next
= this == until
? NULL
: this->next
;
979 * Close out all open elements up to but excluding suntil.
980 * Note that a paragraph just inside stays open together with it
981 * because paragraphs include subsequent phrasing content.
984 print_stagq(struct html
*h
, const struct tag
*suntil
)
986 struct tag
*this, *next
;
988 for (this = h
->tag
; this != NULL
; this = next
) {
990 if (this == suntil
|| (next
== suntil
&&
991 (this->tag
== TAG_P
|| this->tag
== TAG_PRE
)))
998 /***********************************************************************
999 * Low level output functions.
1000 * They implement line breaking using a short static buffer.
1001 ***********************************************************************/
1004 * Buffer one HTML output byte.
1005 * If the buffer is full, flush and deactivate it and start a new line.
1006 * If the buffer is inactive, print directly.
1009 print_byte(struct html
*h
, char c
)
1011 if ((h
->flags
& HTML_BUFFER
) == 0) {
1017 if (h
->col
+ h
->bufcol
< sizeof(h
->buf
)) {
1018 h
->buf
[h
->bufcol
++] = c
;
1027 fwrite(h
->buf
, h
->bufcol
, 1, stdout
);
1029 h
->col
= (h
->indent
+ 1) * 2 + h
->bufcol
+ 1;
1031 h
->flags
&= ~HTML_BUFFER
;
1035 * If something was printed on the current output line, end it.
1036 * Not to be called right after print_indent().
1039 print_endline(struct html
*h
)
1046 fwrite(h
->buf
, h
->bufcol
, 1, stdout
);
1051 h
->flags
|= HTML_NOSPACE
;
1052 h
->flags
&= ~HTML_BUFFER
;
1056 * Flush the HTML output buffer.
1057 * If it is inactive, activate it.
1060 print_endword(struct html
*h
)
1067 if ((h
->flags
& HTML_BUFFER
) == 0) {
1069 h
->flags
|= HTML_BUFFER
;
1070 } else if (h
->bufcol
) {
1072 fwrite(h
->buf
, h
->bufcol
, 1, stdout
);
1073 h
->col
+= h
->bufcol
+ 1;
1079 * If at the beginning of a new output line,
1080 * perform indentation and mark the line as containing output.
1081 * Make sure to really produce some output right afterwards,
1082 * but do not use print_otag() for producing it.
1085 print_indent(struct html
*h
)
1089 if (h
->col
|| h
->noindent
)
1092 h
->col
= h
->indent
* 2;
1093 for (i
= 0; i
< h
->col
; i
++)
1098 * Print or buffer some characters
1099 * depending on the current HTML output buffer state.
1102 print_word(struct html
*h
, const char *cp
)
1105 print_byte(h
, *cp
++);