+ for (y = 0; y < table_nr (t); y++)
+ {
+ int x;
+
+ fputs (" <TR>\n", html->file);
+ for (x = 0; x < table_nc (t); )
+ {
+ struct table_cell cell;
+ const char *tag;
+ bool is_header;
+ 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])
+ goto next_1;
+
+ /* Output <TD> or <TH> tag. */
+ is_header = (y < table_ht (t)
+ || y >= table_nr (t) - table_hb (t)
+ || x < table_hl (t)
+ || x >= table_nc (t) - table_hr (t));
+ tag = is_header ? "TH" : "TD";
+ fprintf (html->file, " <%s", tag);
+
+ enum table_halign halign = table_halign_interpret (
+ cell.style->cell_style.halign, cell.options & TAB_NUMERIC);
+ if (halign != TABLE_HALIGN_LEFT)
+ {
+ fprintf (html->file, " ALIGN=\"%s\"",
+ (halign == TABLE_HALIGN_RIGHT ? "RIGHT"
+ : halign == TABLE_HALIGN_CENTER ? "CENTER"
+ : "CHAR"));
+ if (cell.style->cell_style.decimal_char)
+ fprintf (html->file, " CHAR=\"%c\"",
+ cell.style->cell_style.decimal_char);
+ }
+
+ if (cell.style->cell_style.valign != TABLE_VALIGN_TOP)
+ fprintf (html->file, " ALIGN=\"%s\"",
+ (cell.style->cell_style.valign == TABLE_VALIGN_BOTTOM
+ ? "BOTTOM" : "MIDDLE"));
+
+ colspan = table_cell_colspan (&cell);
+ if (colspan > 1)
+ fprintf (html->file, " COLSPAN=\"%d\"", colspan);
+
+ rowspan = table_cell_rowspan (&cell);
+ if (rowspan > 1)
+ fprintf (html->file, " ROWSPAN=\"%d\"", rowspan);
+
+ if (html->borders)
+ {
+ /* Cell borders. */
+ int n_borders = 0;
+
+ struct cell_color color;
+ top = table_get_rule (t, TABLE_VERT, x, y, &color);
+ put_border (html->file, &n_borders, top, "top");
+
+ if (y + rowspan == table_nr (t))
+ {
+ bottom = table_get_rule (t, TABLE_VERT, x, y + rowspan,
+ &color);
+ put_border (html->file, &n_borders, bottom, "bottom");
+ }
+
+ left = table_get_rule (t, TABLE_HORZ, x, y, &color);
+ put_border (html->file, &n_borders, left, "left");
+
+ if (x + colspan == table_nc (t))
+ {
+ right = table_get_rule (t, TABLE_HORZ, x + colspan, y,
+ &color);
+ put_border (html->file, &n_borders, right, "right");
+ }
+
+ if (n_borders > 0)
+ fputs ("\"", html->file);
+ }
+
+ putc ('>', html->file);
+
+ /* Output cell contents. */
+ const char *s = cell.text;
+ if (cell.options & TAB_FIX)
+ {
+ fputs ("<TT>", html->file);
+ escape_string (html->file, s, strlen (s), " ", "<BR>");
+ fputs ("</TT>", html->file);
+ }
+ else
+ {
+ s += strspn (s, CC_SPACES);
+ escape_string (html->file, s, strlen (s), " ", "<BR>");
+ }
+
+ html_put_footnote_markers (html, cell.footnotes, cell.n_footnotes);
+
+ /* Output </TH> or </TD>. */
+ fprintf (html->file, "</%s>\n", tag);
+
+ next_1:
+ x = cell.d[TABLE_HORZ][1];
+ table_cell_free (&cell);
+ }
+ fputs (" </TR>\n", html->file);
+ }