+ 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);
+ }