Ignore:
Timestamp:
Nov 1, 2008, 7:03:36 AM (11 years ago)
Author:
bsittler
Message:

output valid XHTML (it's valid HTML3 too); note that this drops the COLS=... attribute on the table, but that had previously been calculated incorrectly anyhow so i doubt it mattered

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/codec/export.c

    r3182 r3184  
    462462    int maxcols;
    463463
    464     /* The HTML table markup: less than 1000 bytes
    465      * A line: 10 chars for "<tr></tr>\n"
    466      * A glyph: 40 chars for "<td bgcolor=#xxxxxx><font color=#xxxxxx>"
    467      *          up to 36 chars for "<b><i><u><blink></blink></u></i></b>"
    468      *          up to 48 chars for "&#xxxxxx;", or "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" (\t); far less for pure ASCII
    469      *          12 chars for "</font></td>" */
    470     *bytes = 1000 + cv->height * (10 + cv->width * (40 + 36 + 48 + 12));
    471     cur = data = malloc(*bytes);
    472 
    473464    /* Table */
    474465    maxcols = 0;
     
    489480    }
    490481   
    491     cur += sprintf(cur, "<table border='0' cols='%d' cellpadding='0' cellspacing='0'>\n",
    492                         maxcols);
     482    /* The HTML table markup: less than 1000 bytes
     483     * A line: 10 chars for "<tr></tr>\n"
     484     * A glyph: up to 44 chars for "<td bgcolor=\"#xxxxxx\"><font color=\"#xxxxxx\">"
     485     *          up to 45 chars for "<tt><b><i><u><blink></blink></u></i></b></tt>"
     486     *          up to 9 chars for "&#xxxxxx;" (far less for pure ASCII)
     487     *          12 chars for "</font></td>" */
     488    *bytes = 1000 + cv->height * (10 + maxcols * (44 + 45 + 9 + 12));
     489    cur = data = malloc(*bytes);
     490
     491    cur += sprintf(cur, "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
    493492
    494493    for(y = 0; y < cv->height; y++)
     
    519518
    520519            if(caca_attr_to_ansi_bg(lineattr[x]) < 0x10)
    521                 cur += sprintf(cur, " bgcolor=#%.06lx", (unsigned long int)
     520                cur += sprintf(cur, " bgcolor=\"#%.06lx\"", (unsigned long int)
    522521                               _caca_attr_to_rgb24bg(lineattr[x]));
    523522
    524523            if((len + thistab) > 1)
    525                 cur += sprintf(cur, " colspan=%d", len + thistab);
     524                cur += sprintf(cur, " colspan=\"%d\"", len + thistab);
    526525
    527526            cur += sprintf(cur, ">");
     
    530529
    531530            if(needfont)
    532                 cur += sprintf(cur, "<font color=#%.06lx>", (unsigned long int)
     531                cur += sprintf(cur, "<font color=\"#%.06lx\">", (unsigned long int)
    533532                               _caca_attr_to_rgb24fg(lineattr[x]));
    534533
     534            cur += sprintf(cur, "<tt>");
    535535            if(lineattr[x] & CACA_BOLD)
    536536                cur += sprintf(cur, "<b>");
     
    582582            if(lineattr[x] & CACA_BOLD)
    583583                cur += sprintf(cur, "</b>");
     584            cur += sprintf(cur, "</tt>");
    584585
    585586            if(needfont)
Note: See TracChangeset for help on using the changeset viewer.