+style_end (struct css_style *cs)
+{
+ fputs ("\"", cs->file);
+ free (cs);
+}
+
+static void
+put_style (struct css_style *st, const char *name, const char *value)
+{
+ if (st->n_styles++ > 0)
+ fputs ("; ", st->file);
+ fprintf (st->file, "%s: %s", name, value);
+}
+
+static void
+put_border (struct css_style *st, int style, const char *border_name)
+{
+ const char *css = border_to_css (style);
+ if (css)
+ {
+ if (st->n_styles++ > 0)
+ fputs ("; ", st->file);
+ fprintf (st->file, "border-%s: %s", border_name, css);
+ }
+}
+
+static void
+put_tfoot (struct html_driver *html, const struct table *t, bool *tfoot)
+{
+ if (!*tfoot)
+ {
+ fputs ("<tfoot>\n", html->file);
+ fputs ("<tr>\n", html->file);
+ fprintf (html->file, "<td colspan=%d>\n", table_nc (t));
+ *tfoot = true;
+ }
+ else
+ fputs ("\n<br>", html->file);
+}
+
+static void
+html_put_footnote_markers (struct html_driver *html,
+ const struct footnote **footnotes,
+ size_t n_footnotes)
+{
+ if (n_footnotes > 0)
+ {
+ fputs ("<sup>", html->file);
+ for (size_t i = 0; i < n_footnotes; i++)
+ {
+ const struct footnote *f = footnotes[i];
+
+ if (i > 0)
+ putc (',', html->file);
+ escape_string (html->file, f->marker, " ", "<br>");
+ }
+ fputs ("</sup>", html->file);
+ }
+}
+
+static void
+html_put_table_item_text (struct html_driver *html,
+ const struct table_item_text *text)
+{
+ escape_string (html->file, text->content, " ", "<br>");
+ html_put_footnote_markers (html, text->footnotes, text->n_footnotes);
+}
+
+static void
+html_put_table_item_layers (struct html_driver *html,
+ const struct table_item_layers *layers)
+{
+ for (size_t i = 0; i < layers->n_layers; i++)
+ {
+ if (i)
+ fputs ("<br>\n", html->file);
+
+ const struct table_item_layer *layer = &layers->layers[i];
+ escape_string (html->file, layer->content, " ", "<br>");
+ html_put_footnote_markers (html, layer->footnotes, layer->n_footnotes);
+ }
+}
+
+static void
+html_output_table (struct html_driver *html, const struct table_item *item)