jcs
/wikipedia
/amendments
/20
wikipedia: Reset style counters when leaving <ref>
jcs made amendment 20 over 2 years ago
--- wikipedia.c Sat Sep 3 22:26:38 2022
+++ wikipedia.c Sun Sep 4 22:56:42 2022
@@ -225,7 +225,6 @@ parse_char:
last[0] == 'f') {
/* <ref */
wpr->in_ref = true;
- wpr->apostrophes = wpr->equals = wpr->brackets = wpr->curlys = 0;
dump = true;
wpr->buf_len -= 4;
} else if (last[-5] == '<' && last[-4] == '/' &&
@@ -233,6 +232,7 @@ parse_char:
last[0] == '>') {
/* </ref> */
wpr->in_ref = false;
+ wpr->apostrophes = wpr->equals = wpr->brackets = wpr->curlys = 0;
wpr->buf_len = 0;
} else if (wpr->in_ref) {
/* consume, obey */
@@ -288,8 +288,8 @@ parse_char:
}
if (c == '\n') {
- /* skip leading newlines */
- if (wpr->article_len == 0)
+ /* skip leading newlines and only allow 2 in a row */
+ if (wpr->article_len == 0 || (last[0] == '\r' && last[-1] == '\r'))
c = 0;
else
c = '\r';