aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2021-02-13 16:26:30 +0000
committerbptato <nincsnevem662@gmail.com>2021-02-13 16:26:30 +0000
commit77ecf9b46b4b3ff7f1bafe3c0a914ba74527af47 (patch)
treecafb9dd5621eb34b4be674272710cef22a2827b8 /file.c
parent<dl> test (diff)
downloadw3m-77ecf9b46b4b3ff7f1bafe3c0a914ba74527af47.tar.gz
w3m-77ecf9b46b4b3ff7f1bafe3c0a914ba74527af47.zip
Fix <dl compact>
Diffstat (limited to 'file.c')
-rw-r--r--file.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/file.c b/file.c
index 0cf9b4e..9473993 100644
--- a/file.c
+++ b/file.c
@@ -4399,6 +4399,13 @@ process_idattr(struct readbuffer *obuf, int cmd, struct parsed_tag *tag)
envs[h_env->envc].indent = envs[h_env->envc - 1].indent; \
}
+#define PUSH_ENV_NOINDENT(cmd) \
+ if (++h_env->envc_real < h_env->nenv) { \
+ ++h_env->envc; \
+ envs[h_env->envc].env = cmd; \
+ envs[h_env->envc].count = 0; \
+ }
+
#define POP_ENV \
if (h_env->envc_real-- < h_env->nenv) \
h_env->envc--;
@@ -4662,6 +4669,7 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
do_blankline(h_env, obuf, envs[h_env->envc].indent, 0,
h_env->limit);
}
+ PUSH_ENV_NOINDENT(cmd);
if (parsedtag_exists(tag, ATTR_COMPACT))
envs[h_env->envc].env = HTML_DL_COMPACT;
obuf->flag |= RB_IGNORE_P;
@@ -4753,14 +4761,15 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
return 1;
case HTML_DT:
CLOSE_A;
- if (h_env->envc > 0 &&
- (envs[h_env->envc].env == HTML_DL ||
- envs[h_env->envc].env == HTML_DL_COMPACT)) {
- POP_ENV;
+ if (h_env->envc == 0 ||
+ (h_env->envc_real < h_env->nenv &&
+ envs[h_env->envc].env != HTML_DL &&
+ envs[h_env->envc].env != HTML_DL_COMPACT)) {
+ PUSH_ENV_NOINDENT(HTML_DL);
}
- if (h_env->envc >= 0) {
+ if (h_env->envc > 0) {
flushline(h_env, obuf,
- envs[h_env->envc].indent, 0, h_env->limit);
+ envs[h_env->envc - 1].indent, 0, h_env->limit);
}
if (!(obuf->flag & RB_IN_DT)) {
HTMLlineproc1("<b>", h_env);
@@ -4769,12 +4778,14 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
obuf->flag |= RB_IGNORE_P;
return 1;
case HTML_N_DT:
- if (!(obuf->flag & RB_IN_DT))
+ if (!(obuf->flag & RB_IN_DT)) {
return 1;
+ }
obuf->flag &= ~RB_IN_DT;
HTMLlineproc1("</b>", h_env);
- flushline(h_env, obuf, envs[h_env->envc].indent, 0,
- h_env->limit);
+ if (h_env->envc > 0 && envs[h_env->envc].env == HTML_DL)
+ flushline(h_env, obuf,
+ envs[h_env->envc - 1].indent, 0, h_env->limit);
return 1;
case HTML_DD:
CLOSE_A;
@@ -4785,6 +4796,11 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
envs[h_env->envc].env != HTML_DL_COMPACT)) {
PUSH_ENV(HTML_DL);
}
+ if (h_env->envc <= MAX_INDENT_LEVEL)
+ envs[h_env->envc].indent = envs[h_env->envc - 1].indent + INDENT_INCR;
+ else
+ envs[h_env->envc].indent = envs[h_env->envc - 1].indent;
+
if (envs[h_env->envc].env == HTML_DL_COMPACT) {
if (obuf->pos > envs[h_env->envc].indent)
flushline(h_env, obuf, envs[h_env->envc].indent, 0,
@@ -4797,12 +4813,12 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
/* obuf->flag |= RB_IGNORE_P; */
return 1;
case HTML_N_DD:
- if (h_env->envc > 0 &&
- (envs[h_env->envc].env == HTML_DL ||
- envs[h_env->envc].env == HTML_DL_COMPACT)) {
- POP_ENV;
- flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit);
- }
+ if (h_env->envc == 0 ||
+ (h_env->envc_real < h_env->nenv &&
+ envs[h_env->envc].env != HTML_DL &&
+ envs[h_env->envc].env != HTML_DL_COMPACT))
+ return 1;
+ envs[h_env->envc].indent = envs[h_env->envc - 1].indent - INDENT_INCR;
return 1;
case HTML_TITLE:
close_anchor(h_env, obuf);