diff options
author | scria1000 <91804886+scria1000@users.noreply.github.com> | 2021-12-05 19:15:59 +0000 |
---|---|---|
committer | scria1000 <91804886+scria1000@users.noreply.github.com> | 2021-12-05 19:15:59 +0000 |
commit | 281d6aec5012b0f291dd75253a877e7a8b62bc17 (patch) | |
tree | ece1c56ef51be29ef227ba7e103c736d8db2d7fc /app/src | |
parent | dea22c8f7e8da15019aaa5cb9e63b72486fae0a2 (diff) | |
download | infinity-for-reddit-281d6aec5012b0f291dd75253a877e7a8b62bc17.tar infinity-for-reddit-281d6aec5012b0f291dd75253a877e7a8b62bc17.tar.gz infinity-for-reddit-281d6aec5012b0f291dd75253a877e7a8b62bc17.tar.bz2 infinity-for-reddit-281d6aec5012b0f291dd75253a877e7a8b62bc17.tar.lz infinity-for-reddit-281d6aec5012b0f291dd75253a877e7a8b62bc17.tar.xz infinity-for-reddit-281d6aec5012b0f291dd75253a877e7a8b62bc17.tar.zst infinity-for-reddit-281d6aec5012b0f291dd75253a877e7a8b62bc17.zip |
Correct newline behaviour, again
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerParserPlugin.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerParserPlugin.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerParserPlugin.java index e399bece..3a05b71c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerParserPlugin.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerParserPlugin.java @@ -127,22 +127,19 @@ public class SpoilerParserPlugin extends AbstractMarkwonPlugin { for (int i = 0; i < length; i++) { if (markdown.charAt(i) == '\n') { new_lines++; - if (openSpoilerStack.size() >= 1 && new_lines > MAX_NEW_LINE) { + if (new_lines > MAX_NEW_LINE) { openSpoilerStack.clear(); new_lines = 0; } - continue; - } - if ((markdown.charAt(i) != '>') && (markdown.charAt(i) != '<') && (markdown.charAt(i) != '!')) { - continue; - } - if ((i + 1 < length) + } else if ((markdown.charAt(i) != '>') + && (markdown.charAt(i) != '<') + && (markdown.charAt(i) != '!')) { + new_lines = 0; + } else if ((i + 1 < length) && markdown.charAt(i) == '>' && markdown.charAt(i + 1) == '!') { openSpoilerStack.push(i + 2); - continue; - } - if ((i + 1 < length) && (i - 1 >= 0) + } else if ((i + 1 < length) && (i - 1 >= 0) && openSpoilerStack.size() > 0 && markdown.charAt(i - 1) != '>' && markdown.charAt(i) == '!' @@ -153,7 +150,11 @@ public class SpoilerParserPlugin extends AbstractMarkwonPlugin { && closedSpoilers.get(closedSpoilers.size() - 1).second < i) { 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; |