diff options
Diffstat (limited to 'table.c')
-rw-r--r-- | table.c | 129 |
1 files changed, 70 insertions, 59 deletions
@@ -1,4 +1,4 @@ -/* $Id: table.c,v 1.49 2004/01/09 15:46:49 ukai Exp $ */ +/* $Id: table.c,v 1.55 2007/05/23 13:07:44 inu Exp $ */ /* * HTML table */ @@ -537,48 +537,18 @@ visible_length_plain(char *str) return len > max_len ? len : max_len; } -int -maximum_visible_length(char *str) +static int +maximum_visible_length(char *str, int offset) { - int maxlen, len; - - visible_length_offset = 0; - maxlen = visible_length(str); - - if (!strchr(str, '\t')) - return maxlen; - - for (visible_length_offset = 1; visible_length_offset < Tabstop; - visible_length_offset++) { - len = visible_length(str); - if (maxlen < len) { - maxlen = len; - break; - } - } - return maxlen; + visible_length_offset = offset; + return visible_length(str); } -int -maximum_visible_length_plain(char *str) +static int +maximum_visible_length_plain(char *str, int offset) { - int maxlen, len; - - visible_length_offset = 0; - maxlen = visible_length_plain(str); - - if (!strchr(str, '\t')) - return maxlen; - - for (visible_length_offset = 1; visible_length_offset < Tabstop; - visible_length_offset++) { - len = visible_length_plain(str); - if (maxlen < len) { - maxlen = len; - break; - } - } - return maxlen; + visible_length_offset = offset; + return visible_length_plain(str); } void @@ -1984,7 +1954,7 @@ renderTable(struct table *t, int max_width, struct html_feed_environ *h_env) break; } if (t->total_height == 0) { - renderbuf = Strnew(" "); + renderbuf = Strnew_charp(" "); t->total_height++; t->total_width = 1; push_render_image(renderbuf, 1, t->total_width, h_env); @@ -2465,11 +2435,16 @@ feed_table_tag(struct table *tbl, char *line, struct table_mode *mode, return TAG_ACTION_PLAIN; } if (mode->pre_mode & TBLM_INTXTA) { - if (mode->end_tag == cmd) { + switch (cmd) { + CASE_TABLE_TAG: + case HTML_N_TEXTAREA: table_close_textarea(tbl, mode, width); - return TAG_ACTION_NONE; + if (cmd == HTML_N_TEXTAREA) + return TAG_ACTION_NONE; + break; + default: + return TAG_ACTION_FEED; } - return TAG_ACTION_FEED; } if (mode->pre_mode & TBLM_SCRIPT) { if (mode->end_tag == cmd) { @@ -2950,33 +2925,69 @@ feed_table_tag(struct table *tbl, char *line, struct table_mode *mode, suspend_or_pushdata(tbl, line); break; case HTML_DEL: - if (displayInsDel) - feed_table_inline_tag(tbl, line, mode, 5); /* [DEL: */ - else + switch (displayInsDel) { + case DISPLAY_INS_DEL_SIMPLE: mode->pre_mode |= TBLM_DEL; + break; + case DISPLAY_INS_DEL_NORMAL: + feed_table_inline_tag(tbl, line, mode, 5); /* [DEL: */ + break; + case DISPLAY_INS_DEL_FONTIFY: + feed_table_inline_tag(tbl, line, mode, -1); + break; + } break; case HTML_N_DEL: - if (displayInsDel) - feed_table_inline_tag(tbl, line, mode, 5); /* :DEL] */ - else + switch (displayInsDel) { + case DISPLAY_INS_DEL_SIMPLE: mode->pre_mode &= ~TBLM_DEL; + break; + case DISPLAY_INS_DEL_NORMAL: + feed_table_inline_tag(tbl, line, mode, 5); /* :DEL] */ + break; + case DISPLAY_INS_DEL_FONTIFY: + feed_table_inline_tag(tbl, line, mode, -1); + break; + } break; case HTML_S: - if (displayInsDel) - feed_table_inline_tag(tbl, line, mode, 3); /* [S: */ - else + switch (displayInsDel) { + case DISPLAY_INS_DEL_SIMPLE: mode->pre_mode |= TBLM_S; + break; + case DISPLAY_INS_DEL_NORMAL: + feed_table_inline_tag(tbl, line, mode, 3); /* [S: */ + break; + case DISPLAY_INS_DEL_FONTIFY: + feed_table_inline_tag(tbl, line, mode, -1); + break; + } break; case HTML_N_S: - if (displayInsDel) - feed_table_inline_tag(tbl, line, mode, 3); /* :S] */ - else + switch (displayInsDel) { + case DISPLAY_INS_DEL_SIMPLE: mode->pre_mode &= ~TBLM_S; + break; + case DISPLAY_INS_DEL_NORMAL: + feed_table_inline_tag(tbl, line, mode, 3); /* :S] */ + break; + case DISPLAY_INS_DEL_FONTIFY: + feed_table_inline_tag(tbl, line, mode, -1); + break; + } break; case HTML_INS: case HTML_N_INS: - if (displayInsDel) + switch (displayInsDel) { + case DISPLAY_INS_DEL_SIMPLE: + break; + case DISPLAY_INS_DEL_NORMAL: feed_table_inline_tag(tbl, line, mode, 5); /* [INS:, :INS] */ + break; + case DISPLAY_INS_DEL_FONTIFY: + feed_table_inline_tag(tbl, line, mode, -1); + break; + } break; case HTML_SUP: case HTML_SUB: @@ -3200,7 +3211,7 @@ feed_table(struct table *tbl, char *line, struct table_mode *mode, check_rowcol(tbl, mode); if (mode->nobr_offset < 0) mode->nobr_offset = tbl->tabcontentssize; - addcontentssize(tbl, maximum_visible_length(line)); + addcontentssize(tbl, maximum_visible_length(line, tbl->tabcontentssize)); setwidth(tbl, mode); pushdata(tbl, tbl->row, tbl->col, line); } @@ -3229,9 +3240,9 @@ feed_table(struct table *tbl, char *line, struct table_mode *mode, line = ""; } if (mode->pre_mode & TBLM_PLAIN) - i = maximum_visible_length_plain(p); + i = maximum_visible_length_plain(p, tbl->tabcontentssize); else - i = maximum_visible_length(p); + i = maximum_visible_length(p, tbl->tabcontentssize); addcontentssize(tbl, i); setwidth(tbl, mode); if (nl) |