+ if (!text || !*text)
+ return;
+
+ fprintf (file, "<%s>", tag);
+ escape_string (file, text, space, newline);
+ fprintf (file, "</%s>", tag);
+}
+
+static const char *
+border_to_css (int border)
+{
+ switch (border)
+ {
+ case TABLE_STROKE_NONE:
+ return NULL;
+
+ case TABLE_STROKE_SOLID:
+ return "solid";
+
+ case TABLE_STROKE_DASHED:
+ return "dashed";
+
+ case TABLE_STROKE_THICK:
+ return "thick solid";
+
+ case TABLE_STROKE_THIN:
+ return "thin solid";
+
+ case TABLE_STROKE_DOUBLE:
+ return "double";
+
+ default:
+ return NULL;
+ }
+
+}
+
+struct css_style
+{
+ FILE *file;
+ int n_styles;
+};
+
+static struct css_style *
+style_start (FILE *file)
+{
+ struct css_style *cs = XMALLOC (struct css_style);
+ cs->file = file;
+ cs->n_styles = 0;
+ fputs (" style=\"", file);
+ return cs;
+}
+
+static void
+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);
+ }