+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)
+{
+ const struct table *t = table_item_get_table (item);
+ bool tfoot = false;
+ int y;
+
+ fputs ("<TABLE>", html->file);
+
+ const struct table_item_text *caption = table_item_get_caption (item);
+ if (caption)
+ {
+ put_tfoot (html, t, &tfoot);
+ html_put_table_item_text (html, caption);
+ }
+ const struct footnote **f;
+ size_t n_footnotes = table_collect_footnotes (item, &f);
+
+ for (size_t i = 0; i < n_footnotes; i++)
+ {
+ put_tfoot (html, t, &tfoot);
+ escape_tag (html->file, "SUP", f[i]->marker, " ", "<BR>");
+ escape_string (html->file, f[i]->content, " ", "<BR>");
+ }
+ free (f);
+ if (tfoot)
+ fputs ("</TD></TR></TFOOT>\n", html->file);
+
+ fputs ("<TBODY VALIGN=\"TOP\">\n", html->file);
+
+ const struct table_item_text *title = table_item_get_title (item);
+ const struct table_item_layers *layers = table_item_get_layers (item);
+ if (title || layers)