diff options
author | Tatsuya Kinoshita <tats@debian.org> | 2020-08-30 00:57:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-30 00:57:45 +0000 |
commit | 6339dd9f13ec171765a139cf2ec3c7f669235ecd (patch) | |
tree | 7d9de0bb4df6ac6883de4ddb9fc83a371286ddd9 /file.c | |
parent | Merge pull request #145 from acli/20200824_zh_TW_CLEANED (diff) | |
parent | In HTML5 anchors should not be closed when encountering divs, for example, bu... (diff) | |
download | w3m-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.c | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -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; |