diff --git a/caca/codec/export.c b/caca/codec/export.c
index 3cf644b..4edd433 100644
--- a/caca/codec/export.c
+++ b/caca/codec/export.c
@@ -481,11 +481,11 @@ static void *export_html3(caca_canvas_t const *cv, size_t *bytes)
/* The HTML table markup: less than 1000 bytes
* A line: 10 chars for "
\n"
- * A glyph: up to 44 chars for ""
- * up to 45 chars for ""
+ * A glyph: up to 48 chars for " | "
+ * up to 36 chars for ""
* up to 9 chars for "xxxxx;" (far less for pure ASCII)
- * 12 chars for " | " */
- *bytes = 1000 + cv->height * (10 + maxcols * (44 + 45 + 9 + 12));
+ * 17 chars for "" */
+ *bytes = 1000 + cv->height * (10 + maxcols * (48 + 36 + 9 + 17));
cur = data = malloc(*bytes);
cur += sprintf(cur, "\n");
@@ -500,13 +500,25 @@ static void *export_html3(caca_canvas_t const *cv, size_t *bytes)
for(x = 0; x < cv->width; x += len)
{
- int i, needfont;
+ int i, needfont = 0;
int thistab = 0;
/* Use colspan option to factor cells with same attributes
* (see below) */
len = 1;
- while((x + len < cv->width) && (lineattr[x + len] == lineattr[x]))
+ while((x + len < cv->width)
+ &&
+ (caca_attr_to_ansi_bg(lineattr[x + len])
+ ==
+ caca_attr_to_ansi_bg(lineattr[x]))
+ &&
+ ((caca_attr_to_ansi_bg(lineattr[x]) < 0x10)
+ ?
+ (_caca_attr_to_rgb24bg(lineattr[x + len])
+ &&
+ _caca_attr_to_rgb24bg(lineattr[x]))
+ :
+ 1))
len++;
for(i = 0; i < len; i++)
@@ -525,37 +537,47 @@ static void *export_html3(caca_canvas_t const *cv, size_t *bytes)
cur += sprintf(cur, ">");
- needfont = caca_attr_to_ansi_fg(lineattr[x]) < 0x10;
-
- if(needfont)
- cur += sprintf(cur, "", (unsigned long int)
- _caca_attr_to_rgb24fg(lineattr[x]));
-
cur += sprintf(cur, "");
- if(lineattr[x] & CACA_BOLD)
- cur += sprintf(cur, "");
- if(lineattr[x] & CACA_ITALICS)
- cur += sprintf(cur, "");
- if(lineattr[x] & CACA_UNDERLINE)
- cur += sprintf(cur, "");
- if(lineattr[x] & CACA_BLINK)
- cur += sprintf(cur, "");
- if(lineattr[x] & CACA_UNDERLINE)
- cur += sprintf(cur, "");
- if(lineattr[x] & CACA_ITALICS)
- cur += sprintf(cur, "");
- if(lineattr[x] & CACA_BOLD)
- cur += sprintf(cur, "");
cur += sprintf(cur, "");
-
- if(needfont)
- cur += sprintf(cur, "");
cur += sprintf(cur, "");
}
cur += sprintf(cur, "\n");