}
}
+static const char *
+border_to_css (int border)
+{
+ switch (border)
+ {
+ case TAL_NONE:
+ return NULL;
+
+ case TAL_SOLID:
+ return "solid";
+
+ case TAL_DASHED:
+ return "dashed";
+
+ case TAL_THICK:
+ return "thick solid";
+
+ case TAL_THIN:
+ return "thin solid";
+
+ case TAL_DOUBLE:
+ return "double";
+
+ default:
+ return NULL;
+ }
+
+}
+
static void
-put_border (FILE *file, int n_borders, int style, const char *border_name)
+put_border (FILE *file, int *n_borders, int style, const char *border_name)
{
- fprintf (file, "%sborder-%s: %s",
- n_borders == 0 ? " STYLE=\"" : "; ",
- border_name,
- style == TAL_1 ? "thin solid" : "double");
+ const char *css = border_to_css (style);
+ if (css)
+ {
+ fprintf (file, "%sborder-%s: %s",
+ (*n_borders)++ == 0 ? " STYLE=\"" : "; ",
+ border_name, css);
+ }
}
static void
struct table_cell cell;
const char *tag;
bool is_header;
- int alignment, colspan, rowspan;
- int top, left, right, bottom, n_borders;
+ int colspan, rowspan;
+ int top, left, right, bottom;
table_get_cell (t, x, y, &cell);
if (x != cell.d[TABLE_HORZ][0] || y != cell.d[TABLE_VERT][0])
tag = is_header ? "TH" : "TD";
fprintf (html->file, " <%s", tag);
- alignment = (cell.n_contents > 0
- ? cell.contents[0].options & TAB_ALIGNMENT
- : TAB_LEFT);
- if (alignment != TAB_LEFT)
+ int halign = (cell.n_contents > 0
+ ? cell.contents[0].options & TAB_HALIGN
+ : TAB_LEFT);
+ if (halign != TAB_LEFT)
+ fprintf (html->file, " ALIGN=\"%s\"",
+ halign == TAB_RIGHT ? "RIGHT" : "CENTER");
+
+ int valign = (cell.n_contents > 0
+ ? cell.contents[0].options & TAB_VALIGN
+ : TAB_LEFT);
+ if (valign != TAB_TOP)
fprintf (html->file, " ALIGN=\"%s\"",
- alignment == TAB_RIGHT ? "RIGHT" : "CENTER");
+ valign == TAB_BOTTOM ? "BOTTOM" : "MIDDLE");
colspan = table_cell_colspan (&cell);
if (colspan > 1)
if (html->borders)
{
/* Cell borders. */
- n_borders = 0;
+ int n_borders = 0;
top = table_get_rule (t, TABLE_VERT, x, y);
- if (top > TAL_0)
- put_border (html->file, n_borders++, top, "top");
+ put_border (html->file, &n_borders, top, "top");
if (y + rowspan == table_nr (t))
{
bottom = table_get_rule (t, TABLE_VERT, x, y + rowspan);
- if (bottom > TAL_0)
- put_border (html->file, n_borders++, bottom, "bottom");
+ put_border (html->file, &n_borders, bottom, "bottom");
}
left = table_get_rule (t, TABLE_HORZ, x, y);
- if (left > TAL_0)
- put_border (html->file, n_borders++, left, "left");
+ put_border (html->file, &n_borders, left, "left");
if (x + colspan == table_nc (t))
{
right = table_get_rule (t, TABLE_HORZ, x + colspan, y);
- if (right > TAL_0)
- put_border (html->file, n_borders++, right, "right");
+ put_border (html->file, &n_borders, right, "right");
}
if (n_borders > 0)