Fix <dl compact>

This commit is contained in:
bptato
2021-02-13 17:26:30 +01:00
parent ef34bf837c
commit 77ecf9b46b
3 changed files with 72 additions and 17 deletions
+31 -15
View File
@@ -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; \ 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 \ #define POP_ENV \
if (h_env->envc_real-- < h_env->nenv) \ if (h_env->envc_real-- < h_env->nenv) \
h_env->envc--; 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, do_blankline(h_env, obuf, envs[h_env->envc].indent, 0,
h_env->limit); h_env->limit);
} }
PUSH_ENV_NOINDENT(cmd);
if (parsedtag_exists(tag, ATTR_COMPACT)) if (parsedtag_exists(tag, ATTR_COMPACT))
envs[h_env->envc].env = HTML_DL_COMPACT; envs[h_env->envc].env = HTML_DL_COMPACT;
obuf->flag |= RB_IGNORE_P; obuf->flag |= RB_IGNORE_P;
@@ -4753,14 +4761,15 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
return 1; return 1;
case HTML_DT: case HTML_DT:
CLOSE_A; CLOSE_A;
if (h_env->envc > 0 && if (h_env->envc == 0 ||
(envs[h_env->envc].env == HTML_DL || (h_env->envc_real < h_env->nenv &&
envs[h_env->envc].env == HTML_DL_COMPACT)) { envs[h_env->envc].env != HTML_DL &&
POP_ENV; 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, 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)) { if (!(obuf->flag & RB_IN_DT)) {
HTMLlineproc1("<b>", h_env); HTMLlineproc1("<b>", h_env);
@@ -4769,12 +4778,14 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
obuf->flag |= RB_IGNORE_P; obuf->flag |= RB_IGNORE_P;
return 1; return 1;
case HTML_N_DT: case HTML_N_DT:
if (!(obuf->flag & RB_IN_DT)) if (!(obuf->flag & RB_IN_DT)) {
return 1; return 1;
}
obuf->flag &= ~RB_IN_DT; obuf->flag &= ~RB_IN_DT;
HTMLlineproc1("</b>", h_env); HTMLlineproc1("</b>", h_env);
flushline(h_env, obuf, envs[h_env->envc].indent, 0, if (h_env->envc > 0 && envs[h_env->envc].env == HTML_DL)
h_env->limit); flushline(h_env, obuf,
envs[h_env->envc - 1].indent, 0, h_env->limit);
return 1; return 1;
case HTML_DD: case HTML_DD:
CLOSE_A; 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)) { envs[h_env->envc].env != HTML_DL_COMPACT)) {
PUSH_ENV(HTML_DL); 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 (envs[h_env->envc].env == HTML_DL_COMPACT) {
if (obuf->pos > envs[h_env->envc].indent) if (obuf->pos > envs[h_env->envc].indent)
flushline(h_env, obuf, envs[h_env->envc].indent, 0, 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; */ /* obuf->flag |= RB_IGNORE_P; */
return 1; return 1;
case HTML_N_DD: case HTML_N_DD:
if (h_env->envc > 0 && if (h_env->envc == 0 ||
(envs[h_env->envc].env == HTML_DL || (h_env->envc_real < h_env->nenv &&
envs[h_env->envc].env == HTML_DL_COMPACT)) { envs[h_env->envc].env != HTML_DL &&
POP_ENV; envs[h_env->envc].env != HTML_DL_COMPACT))
flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); return 1;
} envs[h_env->envc].indent = envs[h_env->envc - 1].indent - INDENT_INCR;
return 1; return 1;
case HTML_TITLE: case HTML_TITLE:
close_anchor(h_env, obuf); close_anchor(h_env, obuf);
+18 -1
View File
@@ -3,11 +3,27 @@ WWW wo miru
A pager with web browsing capabilities, A pager with web browsing capabilities,
maintained for Debian. maintained for Debian.
Firefox
(linebreak)
FF A free, open source, cross-platform,
graphical web browser developed by the
Mozilla Corporation and hundreds of
volunteers.
The Red Panda also known as the Lesser
Panda, Wah, Bear Cat or Firefox, is a
mostly herbivorous mammal, slightly larger
than a domestic cat (60 cm long).
Non-compact dl
w3m
WWW wo miru
A pager with web browsing capabilities,
maintained for Debian.
Firefox Firefox
(linebreak) (linebreak)
FF FF
.
A free, open source, cross-platform, A free, open source, cross-platform,
graphical web browser developed by the graphical web browser developed by the
Mozilla Corporation and hundreds of Mozilla Corporation and hundreds of
@@ -16,3 +32,4 @@ FF
Panda, Wah, Bear Cat or Firefox, is a Panda, Wah, Bear Cat or Firefox, is a
mostly herbivorous mammal, slightly larger mostly herbivorous mammal, slightly larger
than a domestic cat (60 cm long). than a domestic cat (60 cm long).
+23 -1
View File
@@ -1,4 +1,27 @@
<dl compact>
<dt>w3m</dt>
<dt>WWW wo miru</dt>
<dd>
A pager with web browsing capabilities,<br>
maintained for Debian.
</dd>
<dt><br>Firefox<br>(linebreak)</dt><br>
<dt>FF</dt>
<dd>
A free, open source, cross-platform,<br>
graphical web browser developed by the<br>
Mozilla Corporation and hundreds of<br>
volunteers.
</dd>
<dd>
The Red Panda also known as the Lesser<br>
Panda, Wah, Bear Cat or Firefox, is a<br>
mostly herbivorous mammal, slightly larger<br>
than a domestic cat (60 cm long).
</dd>
</dl>
<dl> <dl>
Non-compact dl
<dt>w3m</dt> <dt>w3m</dt>
<dt>WWW wo miru</dt> <dt>WWW wo miru</dt>
<dd> <dd>
@@ -7,7 +30,6 @@
</dd> </dd>
<dt><br>Firefox<br>(linebreak)</dt><br> <dt><br>Firefox<br>(linebreak)</dt><br>
<dt>FF</dt> <dt>FF</dt>
.
<dd> <dd>
A free, open source, cross-platform,<br> A free, open source, cross-platform,<br>
graphical web browser developed by the<br> graphical web browser developed by the<br>