From 83b71b830402db198393970c2e75f1dc9a434d6f Mon Sep 17 00:00:00 2001 From: Docile-Alligator Date: Wed, 30 Mar 2022 07:27:41 +0800 Subject: Fix spoiler not rendering last two characters. --- .../infinityforreddit/markdown/SpoilerParserPlugin.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/src/main/java/ml') 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 90e439b0..d1dde6f2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerParserPlugin.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerParserPlugin.java @@ -89,7 +89,7 @@ public class SpoilerParserPlugin extends AbstractMarkwonPlugin { int offset = 2; for (Pair spoiler : spoilers) { int spoilerStart = spoiler.first - offset; - int spoilerEnd = spoiler.second - offset; + int spoilerEnd = spoiler.second - offset + 2; // Try not to set a spoiler span if it's inside a CodeSpan CodeSpan[] codeSpans = markdownStringBuilder.getSpans(spoilerStart, spoilerEnd, CodeSpan.class); @@ -99,7 +99,7 @@ public class SpoilerParserPlugin extends AbstractMarkwonPlugin { markdownStringBuilder.delete(spoilerEnd, spoilerEnd + 2); markdownStringBuilder.delete(spoilerStart, spoilerStart + 2); SpoilerSpan spoilerSpan = new SpoilerSpan(textColor, backgroundColor); - markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd - 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); offset += 4; continue; } @@ -111,7 +111,7 @@ public class SpoilerParserPlugin extends AbstractMarkwonPlugin { markdownStringBuilder.delete(spoilerEnd, spoilerEnd + 2); markdownStringBuilder.delete(spoilerStart, spoilerStart + 2); SpoilerSpan spoilerSpan = new SpoilerSpan(textColor, backgroundColor); - markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd - 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); offset += 4; } else { break; @@ -125,7 +125,7 @@ public class SpoilerParserPlugin extends AbstractMarkwonPlugin { markdownStringBuilder.delete(spoilerEnd, spoilerEnd + 2); markdownStringBuilder.delete(spoilerStart, spoilerStart + 2); SpoilerSpan spoilerSpan = new SpoilerSpan(textColor, backgroundColor); - markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd - 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); offset += 4; } else { break; -- cgit v1.2.3