commit 6f78edf41feea447fd213163f663b45a9a6aa081
parent d8a59c3857c88a567c43f4d73053855ace69c2d0
Author: inu <inu>
Date: Sun, 10 Dec 2006 11:06:12 +0000
[w3m-dev 04185] display <em> and <i> elements with bold letters.
Diffstat:
M | ChangeLog | | | 6 | ++++++ |
M | file.c | | | 79 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------- |
M | fm.h | | | 8 | ++++++-- |
M | html.c | | | 62 | ++++++++++++++++++++++++++++++++++++-------------------------- |
M | html.h | | | 58 | +++++++++++++++++++++++++++++++--------------------------- |
M | tagtable.tab | | | 8 | ++++---- |
6 files changed, 147 insertions(+), 74 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-07 Hiroyuki Ito <ZXB01226@nifty.com>
+
+ * [w3m-dev 04185] Re: italic text
+ * file.c, fm.h, html.c, html.h, tagtable.tab:
+ display <em> and <i> elements with bold letters.
+
2006-12-07 Hideyuki SHIRAI <shirai@meadowy.org>
* [w3m-dev 04184] automatic uncompression in downloading
diff --git a/file.c b/file.c
@@ -2442,6 +2442,7 @@ set_breakpoint(struct readbuffer *obuf, int tag_length)
sizeof(obuf->anchor));
obuf->bp.img_alt = obuf->img_alt;
obuf->bp.in_bold = obuf->in_bold;
+ obuf->bp.in_italic = obuf->in_italic;
obuf->bp.in_under = obuf->in_under;
obuf->bp.nobr_level = obuf->nobr_level;
obuf->bp.prev_ctype = obuf->prev_ctype;
@@ -2456,6 +2457,7 @@ back_to_breakpoint(struct readbuffer *obuf)
sizeof(obuf->anchor));
obuf->img_alt = obuf->bp.img_alt;
obuf->in_bold = obuf->bp.in_bold;
+ obuf->in_italic = obuf->bp.in_italic;
obuf->in_under = obuf->bp.in_under;
obuf->prev_ctype = obuf->bp.prev_ctype;
obuf->pos = obuf->bp.pos;
@@ -2478,6 +2480,7 @@ append_tags(struct readbuffer *obuf)
case HTML_IMG_ALT:
case HTML_B:
case HTML_U:
+ case HTML_I:
push_link(obuf->tag_stack[i]->cmd, obuf->line->length, obuf->pos);
break;
}
@@ -2692,7 +2695,7 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,
FILE *f = h_env->f;
Str line = obuf->line, pass = NULL;
char *hidden_anchor = NULL, *hidden_img = NULL, *hidden_bold = NULL,
- *hidden_under = NULL, *hidden = NULL;
+ *hidden_under = NULL, *hidden_italic = NULL, *hidden = NULL;
#ifdef DEBUG
if (w3m_debug) {
@@ -2730,6 +2733,12 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,
hidden = hidden_bold;
}
}
+ if (obuf->in_italic) {
+ if ((hidden_italic = has_hidden_link(obuf, HTML_I)) != NULL) {
+ if (!hidden || hidden_italic < hidden)
+ hidden = hidden_italic;
+ }
+ }
if (obuf->in_under) {
if ((hidden_under = has_hidden_link(obuf, HTML_U)) != NULL) {
if (!hidden || hidden_under < hidden)
@@ -2759,6 +2768,8 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,
Strcat_charp(line, "</img_alt>");
if (obuf->in_bold && !hidden_bold)
Strcat_charp(line, "</b>");
+ if (obuf->in_italic && !hidden_italic)
+ Strcat_charp(line, "</i>");
if (obuf->in_under && !hidden_under)
Strcat_charp(line, "</u>");
@@ -2963,6 +2974,8 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,
}
if (!hidden_bold && obuf->in_bold)
push_tag(obuf, "<B>", HTML_B);
+ if (!hidden_italic && obuf->in_italic)
+ push_tag(obuf, "<I>", HTML_I);
if (!hidden_under && obuf->in_under)
push_tag(obuf, "<U>", HTML_U);
}
@@ -3075,6 +3088,8 @@ save_fonteffect(struct html_feed_environ *h_env, struct readbuffer *obuf)
obuf->fontstat_sp++;
if (obuf->in_bold)
push_tag(obuf, "</b>", HTML_N_B);
+ if (obuf->in_italic)
+ push_tag(obuf, "</i>", HTML_N_I);
if (obuf->in_under)
push_tag(obuf, "</u>", HTML_N_U);
bzero(obuf->fontstat, FONTSTAT_SIZE);
@@ -3090,6 +3105,8 @@ restore_fonteffect(struct html_feed_environ *h_env, struct readbuffer *obuf)
FONTSTAT_SIZE);
if (obuf->in_bold)
push_tag(obuf, "<b>", HTML_B);
+ if (obuf->in_italic)
+ push_tag(obuf, "<i>", HTML_I);
if (obuf->in_under)
push_tag(obuf, "<u>", HTML_U);
}
@@ -4245,6 +4262,20 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
return 0;
}
return 1;
+ case HTML_I:
+ obuf->in_italic++;
+ if (obuf->in_italic > 1)
+ return 1;
+ return 0;
+ case HTML_N_I:
+ if (obuf->in_italic == 1 && close_effect0(obuf, HTML_I))
+ obuf->in_italic = 0;
+ if (obuf->in_italic > 0) {
+ obuf->in_italic--;
+ if (obuf->in_italic == 0)
+ return 0;
+ }
+ return 1;
case HTML_U:
obuf->in_under++;
if (obuf->in_under > 1)
@@ -4260,9 +4291,15 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
}
return 1;
case HTML_EM:
- HTMLlineproc1("<b>", h_env);
+ HTMLlineproc1("<i>", h_env);
return 1;
case HTML_N_EM:
+ HTMLlineproc1("</i>", h_env);
+ return 1;
+ case HTML_STRONG:
+ HTMLlineproc1("<b>", h_env);
+ return 1;
+ case HTML_N_STRONG:
HTMLlineproc1("</b>", h_env);
return 1;
case HTML_Q:
@@ -5077,7 +5114,7 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
static int out_size = 0;
Anchor *a_href = NULL, *a_img = NULL, *a_form = NULL;
char *p, *q, *r, *s, *t, *str;
- Lineprop mode, effect;
+ Lineprop mode, effect, ex_effect;
int pos;
int nlines;
#ifdef DEBUG
@@ -5124,6 +5161,7 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
#endif
effect = 0;
+ ex_effect = 0;
nlines = 0;
while ((line = feed()) != NULL) {
#ifdef DEBUG
@@ -5148,7 +5186,7 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
while (str < endp) {
PSIZE;
mode = get_mctype(str);
- if (effect & PC_SYMBOL && *str != '<') {
+ if ((effect | ex_effect) & PC_SYMBOL && *str != '<') {
#ifdef USE_M17N
char **buf = set_symbol(symbol_width0);
int len;
@@ -5156,16 +5194,16 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
p = buf[(int)symbol];
len = get_mclen(p);
mode = get_mctype(p);
- PPUSH(mode | effect, *(p++));
+ PPUSH(mode | effect | ex_effect, *(p++));
if (--len) {
mode = (mode & ~PC_WCHAR1) | PC_WCHAR2;
while (len--) {
PSIZE;
- PPUSH(mode | effect, *(p++));
+ PPUSH(mode | effect | ex_effect, *(p++));
}
}
#else
- PPUSH(PC_ASCII | effect, SYMBOL_BASE + symbol);
+ PPUSH(PC_ASCII | effect | ex_effect, SYMBOL_BASE + symbol);
#endif
str += symbol_width;
}
@@ -5174,12 +5212,12 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
#else
else if (mode == PC_CTRL || IS_INTSPACE(*str)) {
#endif
- PPUSH(PC_ASCII | effect, ' ');
+ PPUSH(PC_ASCII | effect | ex_effect, ' ');
str++;
}
#ifdef USE_M17N
else if (mode & PC_UNKNOWN) {
- PPUSH(PC_ASCII | effect, ' ');
+ PPUSH(PC_ASCII | effect | ex_effect, ' ');
str += get_mclen(str);
}
#endif
@@ -5187,13 +5225,13 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
#ifdef USE_M17N
int len = get_mclen(str);
#endif
- PPUSH(mode | effect, *(str++));
+ PPUSH(mode | effect | ex_effect, *(str++));
#ifdef USE_M17N
if (--len) {
mode = (mode & ~PC_WCHAR1) | PC_WCHAR2;
while (len--) {
PSIZE;
- PPUSH(mode | effect, *(str++));
+ PPUSH(mode | effect | ex_effect, *(str++));
}
}
#endif
@@ -5211,12 +5249,12 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
#else
if (mode == PC_CTRL || IS_INTSPACE(*str)) {
#endif
- PPUSH(PC_ASCII | effect, ' ');
+ PPUSH(PC_ASCII | effect | ex_effect, ' ');
p++;
}
#ifdef USE_M17N
else if (mode & PC_UNKNOWN) {
- PPUSH(PC_ASCII | effect, ' ');
+ PPUSH(PC_ASCII | effect | ex_effect, ' ');
p += get_mclen(p);
}
#endif
@@ -5224,13 +5262,13 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
#ifdef USE_M17N
int len = get_mclen(p);
#endif
- PPUSH(mode | effect, *(p++));
+ PPUSH(mode | effect | ex_effect, *(p++));
#ifdef USE_M17N
if (--len) {
mode = (mode & ~PC_WCHAR1) | PC_WCHAR2;
while (len--) {
PSIZE;
- PPUSH(mode | effect, *(p++));
+ PPUSH(mode | effect | ex_effect, *(p++));
}
}
#endif
@@ -5249,6 +5287,12 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
case HTML_N_B:
effect &= ~PE_BOLD;
break;
+ case HTML_I:
+ ex_effect |= PE_EX_ITALIC;
+ break;
+ case HTML_N_I:
+ ex_effect &= ~PE_EX_ITALIC;
+ break;
case HTML_U:
effect |= PE_UNDER;
break;
@@ -6505,6 +6549,7 @@ init_henv(struct html_feed_environ *h_env, struct readbuffer *obuf,
bzero((void *)&obuf->anchor, sizeof(obuf->anchor));
obuf->img_alt = 0;
obuf->in_bold = 0;
+ obuf->in_italic = 0;
obuf->in_under = 0;
obuf->prev_ctype = PC_ASCII;
obuf->tag_sp = 0;
@@ -6540,6 +6585,10 @@ completeHTMLstream(struct html_feed_environ *h_env, struct readbuffer *obuf)
push_tag(obuf, "</b>", HTML_N_B);
obuf->in_bold = 0;
}
+ if (obuf->in_italic) {
+ push_tag(obuf, "</i>", HTML_N_I);
+ obuf->in_italic = 0;
+ }
if (obuf->in_under) {
push_tag(obuf, "</u>", HTML_N_U);
obuf->in_under = 0;
diff --git a/fm.h b/fm.h
@@ -166,6 +166,9 @@ void bzero(void *, int);
#define PE_ACTIVE 0x80
#define PE_VISITED 0x4000
+/* Extra effect */
+#define PE_EX_ITALIC PE_BOLD
+
#define CharType(c) ((c)&P_CHARTYPE)
#define CharEffect(c) ((c)&(P_EFFECT|PC_SYMBOL))
#define SetCharType(v,c) ((v)=(((v)&~P_CHARTYPE)|(c)))
@@ -536,7 +539,7 @@ typedef struct _DownloadList {
#define FONT_STACK_SIZE 5
-#define FONTSTAT_SIZE 4
+#define FONTSTAT_SIZE 5
#define _INIT_BUFFER_WIDTH (COLS - (showLineNum ? 6 : 1))
#define INIT_BUFFER_WIDTH ((_INIT_BUFFER_WIDTH > 0) ? _INIT_BUFFER_WIDTH : 0)
@@ -584,7 +587,8 @@ struct readbuffer {
#define in_bold fontstat[0]
#define in_under fontstat[1]
-#define in_stand fontstat[2]
+#define in_italic fontstat[2]
+#define in_stand fontstat[3]
#define RB_PRE 0x01
#define RB_SCRIPT 0x02
diff --git a/html.c b/html.c
@@ -231,34 +231,44 @@ TagInfo TagMAP[MAX_HTMLTAG] = {
{"/s", NULL, 0, TFLG_END}, /* 106 HTML_N_S */
{"q", NULL, 0, 0}, /* 107 HTML_Q */
{"/q", NULL, 0, TFLG_END}, /* 108 HTML_N_Q */
- {NULL, NULL, 0, 0}, /* 109 Undefined */
+ {"i", NULL, 0, 0}, /* 109 HTML_I */
+ {"/i", NULL, 0, TFLG_END}, /* 110 HTML_N_I */
+ {"strong", NULL, 0, 0}, /* 111 HTML_STRONG */
+ {"/strong", NULL, 0, TFLG_END}, /* 112 HTML_N_STRONG */
+ {NULL, NULL, 0, 0}, /* 113 Undefined */
+ {NULL, NULL, 0, 0}, /* 114 Undefined */
+ {NULL, NULL, 0, 0}, /* 115 Undefined */
+ {NULL, NULL, 0, 0}, /* 116 Undefined */
+ {NULL, NULL, 0, 0}, /* 117 Undefined */
+ {NULL, NULL, 0, 0}, /* 118 Undefined */
+ {NULL, NULL, 0, 0}, /* 119 Undefined */
/* pseudo tag */
- {"select_int", ALST_SELECT_INT, MAXA_SELECT_INT, TFLG_INT}, /* 110 HTML_SELECT_INT */
- {"/select_int", NULL, 0, TFLG_INT | TFLG_END}, /* 111 HTML_N_SELECT_INT */
- {"option_int", ALST_OPTION, MAXA_OPTION, TFLG_INT}, /* 112 HTML_OPTION_INT */
- {"textarea_int", ALST_TEXTAREA_INT, MAXA_TEXTAREA_INT, TFLG_INT}, /* 113 HTML_TEXTAREA_INT */
- {"/textarea_int", NULL, 0, TFLG_INT | TFLG_END}, /* 114 HTML_N_TEXTAREA_INT */
- {"table_alt", ALST_TABLE_ALT, MAXA_TABLE_ALT, TFLG_INT}, /* 115 HTML_TABLE_ALT */
- {"symbol", ALST_SYMBOL, MAXA_SYMBOL, TFLG_INT}, /* 116 HTML_SYMBOL */
- {"/symbol", NULL, 0, TFLG_INT | TFLG_END}, /* 117 HTML_N_SYMBOL */
- {"pre_int", NULL, 0, TFLG_INT}, /* 118 HTML_PRE_INT */
- {"/pre_int", NULL, 0, TFLG_INT | TFLG_END}, /* 119 HTML_N_PRE_INT */
- {"title_alt", ALST_TITLE_ALT, MAXA_TITLE_ALT, TFLG_INT}, /* 120 HTML_TITLE_ALT */
- {"form_int", ALST_FORM_INT, MAXA_FORM_INT, TFLG_INT}, /* 121 HTML_FORM_INT */
- {"/form_int", NULL, 0, TFLG_INT | TFLG_END}, /* 122 HTML_N_FORM_INT */
- {"dl_compact", NULL, 0, TFLG_INT}, /* 123 HTML_DL_COMPACT */
- {"input_alt", ALST_INPUT_ALT, MAXA_INPUT_ALT, TFLG_INT}, /* 124 HTML_INPUT_ALT */
- {"/input_alt", NULL, 0, TFLG_INT | TFLG_END}, /* 125 HTML_N_INPUT_ALT */
- {"img_alt", ALST_IMG_ALT, MAXA_IMG_ALT, TFLG_INT}, /* 126 HTML_IMG_ALT */
- {"/img_alt", NULL, 0, TFLG_INT | TFLG_END}, /* 127 HTML_N_IMG_ALT */
- {" ", ALST_NOP, MAXA_NOP, TFLG_INT}, /* 128 HTML_NOP */
- {"pre_plain", NULL, 0, TFLG_INT}, /* 129 HTML_PRE_PLAIN */
- {"/pre_plain", NULL, 0, TFLG_INT | TFLG_END}, /* 130 HTML_N_PRE_PLAIN */
- {"internal", NULL, 0, TFLG_INT}, /* 131 HTML_INTERNAL */
- {"/internal", NULL, 0, TFLG_INT | TFLG_END}, /* 132 HTML_N_INTERNAL */
- {"div_int", ALST_P, MAXA_P, TFLG_INT}, /* 133 HTML_DIV_INT */
- {"/div_int", NULL, 0, TFLG_INT | TFLG_END}, /* 134 HTML_N_DIV_INT */
+ {"select_int", ALST_SELECT_INT, MAXA_SELECT_INT, TFLG_INT}, /* 120 HTML_SELECT_INT */
+ {"/select_int", NULL, 0, TFLG_INT | TFLG_END}, /* 121 HTML_N_SELECT_INT */
+ {"option_int", ALST_OPTION, MAXA_OPTION, TFLG_INT}, /* 122 HTML_OPTION_INT */
+ {"textarea_int", ALST_TEXTAREA_INT, MAXA_TEXTAREA_INT, TFLG_INT}, /* 123 HTML_TEXTAREA_INT */
+ {"/textarea_int", NULL, 0, TFLG_INT | TFLG_END}, /* 124 HTML_N_TEXTAREA_INT */
+ {"table_alt", ALST_TABLE_ALT, MAXA_TABLE_ALT, TFLG_INT}, /* 125 HTML_TABLE_ALT */
+ {"symbol", ALST_SYMBOL, MAXA_SYMBOL, TFLG_INT}, /* 126 HTML_SYMBOL */
+ {"/symbol", NULL, 0, TFLG_INT | TFLG_END}, /* 127 HTML_N_SYMBOL */
+ {"pre_int", NULL, 0, TFLG_INT}, /* 128 HTML_PRE_INT */
+ {"/pre_int", NULL, 0, TFLG_INT | TFLG_END}, /* 129 HTML_N_PRE_INT */
+ {"title_alt", ALST_TITLE_ALT, MAXA_TITLE_ALT, TFLG_INT}, /* 130 HTML_TITLE_ALT */
+ {"form_int", ALST_FORM_INT, MAXA_FORM_INT, TFLG_INT}, /* 131 HTML_FORM_INT */
+ {"/form_int", NULL, 0, TFLG_INT | TFLG_END}, /* 132 HTML_N_FORM_INT */
+ {"dl_compact", NULL, 0, TFLG_INT}, /* 133 HTML_DL_COMPACT */
+ {"input_alt", ALST_INPUT_ALT, MAXA_INPUT_ALT, TFLG_INT}, /* 134 HTML_INPUT_ALT */
+ {"/input_alt", NULL, 0, TFLG_INT | TFLG_END}, /* 135 HTML_N_INPUT_ALT */
+ {"img_alt", ALST_IMG_ALT, MAXA_IMG_ALT, TFLG_INT}, /* 136 HTML_IMG_ALT */
+ {"/img_alt", NULL, 0, TFLG_INT | TFLG_END}, /* 137 HTML_N_IMG_ALT */
+ {" ", ALST_NOP, MAXA_NOP, TFLG_INT}, /* 138 HTML_NOP */
+ {"pre_plain", NULL, 0, TFLG_INT}, /* 139 HTML_PRE_PLAIN */
+ {"/pre_plain", NULL, 0, TFLG_INT | TFLG_END}, /* 140 HTML_N_PRE_PLAIN */
+ {"internal", NULL, 0, TFLG_INT}, /* 141 HTML_INTERNAL */
+ {"/internal", NULL, 0, TFLG_INT | TFLG_END}, /* 142 HTML_N_INTERNAL */
+ {"div_int", ALST_P, MAXA_P, TFLG_INT}, /* 143 HTML_DIV_INT */
+ {"/div_int", NULL, 0, TFLG_INT | TFLG_END}, /* 144 HTML_N_DIV_INT */
};
TagAttrInfo AttrMAP[MAX_TAGATTR] = {
diff --git a/html.h b/html.h
@@ -198,35 +198,39 @@ typedef struct {
#define HTML_N_S 106
#define HTML_Q 107
#define HTML_N_Q 108
+#define HTML_I 109
+#define HTML_N_I 110
+#define HTML_STRONG 111
+#define HTML_N_STRONG 112
/* pseudo tag */
-#define HTML_SELECT_INT 110
-#define HTML_N_SELECT_INT 111
-#define HTML_OPTION_INT 112
-#define HTML_TEXTAREA_INT 113
-#define HTML_N_TEXTAREA_INT 114
-#define HTML_TABLE_ALT 115
-#define HTML_SYMBOL 116
-#define HTML_N_SYMBOL 117
-#define HTML_PRE_INT 118
-#define HTML_N_PRE_INT 119
-#define HTML_TITLE_ALT 120
-#define HTML_FORM_INT 121
-#define HTML_N_FORM_INT 122
-#define HTML_DL_COMPACT 123
-#define HTML_INPUT_ALT 124
-#define HTML_N_INPUT_ALT 125
-#define HTML_IMG_ALT 126
-#define HTML_N_IMG_ALT 127
-#define HTML_NOP 128
-#define HTML_PRE_PLAIN 129
-#define HTML_N_PRE_PLAIN 130
-#define HTML_INTERNAL 131
-#define HTML_N_INTERNAL 132
-#define HTML_DIV_INT 133
-#define HTML_N_DIV_INT 134
-
-#define MAX_HTMLTAG 135
+#define HTML_SELECT_INT 120
+#define HTML_N_SELECT_INT 121
+#define HTML_OPTION_INT 122
+#define HTML_TEXTAREA_INT 123
+#define HTML_N_TEXTAREA_INT 124
+#define HTML_TABLE_ALT 125
+#define HTML_SYMBOL 126
+#define HTML_N_SYMBOL 127
+#define HTML_PRE_INT 128
+#define HTML_N_PRE_INT 129
+#define HTML_TITLE_ALT 130
+#define HTML_FORM_INT 131
+#define HTML_N_FORM_INT 132
+#define HTML_DL_COMPACT 133
+#define HTML_INPUT_ALT 134
+#define HTML_N_INPUT_ALT 135
+#define HTML_IMG_ALT 136
+#define HTML_N_IMG_ALT 137
+#define HTML_NOP 138
+#define HTML_PRE_PLAIN 139
+#define HTML_N_PRE_PLAIN 140
+#define HTML_INTERNAL 141
+#define HTML_N_INTERNAL 142
+#define HTML_DIV_INT 143
+#define HTML_N_DIV_INT 144
+
+#define MAX_HTMLTAG 145
/* Tag attribute */
diff --git a/tagtable.tab b/tagtable.tab
@@ -21,8 +21,8 @@ p HTML_P
br HTML_BR
b HTML_B
/b HTML_N_B
-i HTML_NOP
-/i HTML_NOP
+i HTML_I
+/i HTML_N_I
tt HTML_NOP
/tt HTML_NOP
ul HTML_UL
@@ -60,8 +60,8 @@ kbd HTML_NOP
/kbd HTML_NOP
samp HTML_NOP
/samp HTML_NOP
-strong HTML_EM
-/strong HTML_N_EM
+strong HTML_STRONG
+/strong HTML_N_STRONG
var HTML_NOP
/var HTML_NOP
address HTML_BR