Correct newline behaviour, again

This commit is contained in:
scria1000 2021-12-05 22:15:59 +03:00
parent dea22c8f7e
commit 281d6aec50

View File

@ -127,22 +127,19 @@ public class SpoilerParserPlugin extends AbstractMarkwonPlugin {
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
if (markdown.charAt(i) == '\n') { if (markdown.charAt(i) == '\n') {
new_lines++; new_lines++;
if (openSpoilerStack.size() >= 1 && new_lines > MAX_NEW_LINE) { if (new_lines > MAX_NEW_LINE) {
openSpoilerStack.clear(); openSpoilerStack.clear();
new_lines = 0; new_lines = 0;
} }
continue; } else if ((markdown.charAt(i) != '>')
} && (markdown.charAt(i) != '<')
if ((markdown.charAt(i) != '>') && (markdown.charAt(i) != '<') && (markdown.charAt(i) != '!')) { && (markdown.charAt(i) != '!')) {
continue; new_lines = 0;
} } else if ((i + 1 < length)
if ((i + 1 < length)
&& markdown.charAt(i) == '>' && markdown.charAt(i) == '>'
&& markdown.charAt(i + 1) == '!') { && markdown.charAt(i + 1) == '!') {
openSpoilerStack.push(i + 2); openSpoilerStack.push(i + 2);
continue; } else if ((i + 1 < length) && (i - 1 >= 0)
}
if ((i + 1 < length) && (i - 1 >= 0)
&& openSpoilerStack.size() > 0 && openSpoilerStack.size() > 0
&& markdown.charAt(i - 1) != '>' && markdown.charAt(i - 1) != '>'
&& markdown.charAt(i) == '!' && markdown.charAt(i) == '!'
@ -153,7 +150,11 @@ public class SpoilerParserPlugin extends AbstractMarkwonPlugin {
&& closedSpoilers.get(closedSpoilers.size() - 1).second < i) { && closedSpoilers.get(closedSpoilers.size() - 1).second < i) {
closedSpoilers.remove(closedSpoilers.size() - 1); closedSpoilers.remove(closedSpoilers.size() - 1);
} }
closedSpoilers.add(Pair.create(pos, i)); if (pos != i) {
closedSpoilers.add(Pair.create(pos, i));
}
} else {
new_lines = 0;
} }
} }
return closedSpoilers; return closedSpoilers;