+ fputs (" <TR>\n", html->file);
+ for (x = 0; x < table_nc (t); )
+ {
+ const struct cell_contents *c;
+ struct table_cell cell;
+ const char *tag;
+ bool is_header;
+ int alignment, colspan, rowspan;
+ int top, left, right, bottom, n_borders;
+
+ table_get_cell (t, x, y, &cell);
+ if (x != cell.d[TABLE_HORZ][0] || y != cell.d[TABLE_VERT][0])
+ continue;
+
+ /* 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);
+
+ alignment = (cell.n_contents > 0
+ ? cell.contents[0].options & TAB_ALIGNMENT
+ : TAB_LEFT);
+ if (alignment != TAB_LEFT)
+ fprintf (html->file, " ALIGN=\"%s\"",
+ alignment == TAB_RIGHT ? "RIGHT" : "CENTER");
+
+ 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. */
+ n_borders = 0;
+
+ top = table_get_rule (t, TABLE_VERT, x, y);
+ if (top > TAL_GAP)
+ 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_GAP)
+ put_border (html->file, n_borders++, bottom, "bottom");
+ }
+
+ left = table_get_rule (t, TABLE_HORZ, x, y);
+ if (left > TAL_GAP)
+ 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_GAP)
+ put_border (html->file, n_borders++, right, "right");
+ }
+
+ if (n_borders > 0)
+ fputs ("\"", html->file);
+ }
+
+ putc ('>', html->file);
+
+ /* Output cell contents. */
+ for (c = cell.contents; c < &cell.contents[cell.n_contents]; c++)
+ {
+ if (c->text)
+ {
+ const char *s = c->text;
+ int i;
+
+ if (c->options & TAB_EMPH)
+ fputs ("<EM>", html->file);
+ if (c->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>");
+ }
+ if (c->options & TAB_EMPH)
+ fputs ("</EM>", html->file);
+
+ if (c->n_footnotes > 0)
+ {
+ fputs ("<SUP>", html->file);
+ for (i = 0; i < c->n_footnotes; i++)
+ {
+ char marker[16];
+
+ if (i > 0)
+ putc (',', html->file);
+ str_format_26adic (++footnote_idx, false,
+ marker, sizeof marker);
+ fputs (marker, html->file);
+ }
+ fputs ("</SUP>", html->file);
+ }
+ }
+ else
+ html_output_table (html, c->table);
+ }