aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2020-08-30 00:57:45 +0000
committerGitHub <noreply@github.com>2020-08-30 00:57:45 +0000
commit6339dd9f13ec171765a139cf2ec3c7f669235ecd (patch)
tree7d9de0bb4df6ac6883de4ddb9fc83a371286ddd9 /file.c
parentMerge pull request #145 from acli/20200824_zh_TW_CLEANED (diff)
parentIn HTML5 anchors should not be closed when encountering divs, for example, bu... (diff)
downloadw3m-6339dd9f13ec171765a139cf2ec3c7f669235ecd.tar.gz
w3m-6339dd9f13ec171765a139cf2ec3c7f669235ecd.zip
Merge pull request #146 from acli/20200821_a_CLEANED
Patch to make w3m’s handling of the a element HTML5 compatible (when the stream is HTML5)
Diffstat (limited to 'file.c')
-rw-r--r--file.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/file.c b/file.c
index 6011cf2..34e445c 100644
--- a/file.c
+++ b/file.c
@@ -1,4 +1,5 @@
/* $Id: file.c,v 1.266 2012/05/22 09:45:56 inu Exp $ */
+/* vi: set sw=4 ts=8 ai sm noet : */
#include "fm.h"
#include <sys/types.h>
#include "myctype.h"
@@ -4322,9 +4323,18 @@ process_idattr(struct readbuffer *obuf, int cmd, struct parsed_tag *tag)
obuf->flag &= ~RB_P;\
}
-#define CLOSE_A \
- CLOSE_P; \
- close_anchor(h_env, obuf);
+#define HTML5_CLOSE_A do { \
+ if (obuf->flag & RB_HTML5) { \
+ close_anchor(h_env, obuf); \
+ } \
+ } while (0)
+
+#define CLOSE_A do { \
+ CLOSE_P; \
+ if (!(obuf->flag & RB_HTML5)) { \
+ close_anchor(h_env, obuf); \
+ } \
+ } while (0)
#define CLOSE_DT \
if (obuf->flag & RB_IN_DT) { \
@@ -4948,6 +4958,8 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
close_anchor(h_env, obuf);
return 1;
case HTML_IMG:
+ if (parsedtag_exists(tag, ATTR_USEMAP))
+ HTML5_CLOSE_A;
tmp = process_img(tag, h_env->limit);
HTMLlineproc1(tmp->ptr, h_env);
return 1;
@@ -5143,6 +5155,7 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
HTMLlineproc1(tmp->ptr, h_env);
return 1;
case HTML_BUTTON:
+ HTML5_CLOSE_A;
tmp = process_button(tag);
if (tmp)
HTMLlineproc1(tmp->ptr, h_env);
@@ -5198,6 +5211,11 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
NULL);
HTMLlineproc1(tmp->ptr, h_env);
return 1;
+ case HTML_DOCTYPE:
+ if (!parsedtag_exists(tag, ATTR_PUBLIC)) {
+ obuf->flag |= RB_HTML5;
+ }
+ return 1;
case HTML_META:
p = q = r = NULL;
parsedtag_get_value(tag, ATTR_HTTP_EQUIV, &p);
@@ -5396,6 +5414,7 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
}
return 1;
case HTML_EMBED:
+ HTML5_CLOSE_A;
if (view_unseenobject) {
if (parsedtag_get_value(tag, ATTR_SRC, &p)) {
Str s;