mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-16 13:13:08 +01:00
Check if spoiler was found before setting markdown
This commit is contained in:
parent
d1096f1f76
commit
e481980480
@ -14,6 +14,7 @@ import org.commonmark.node.HtmlInline;
|
|||||||
import org.commonmark.parser.Parser;
|
import org.commonmark.parser.Parser;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ public class SpoilerParserPlugin extends AbstractMarkwonPlugin {
|
|||||||
LinkedHashMap<Integer, Integer> spoilers = parse(markdownStringBuilder);
|
LinkedHashMap<Integer, Integer> spoilers = parse(markdownStringBuilder);
|
||||||
int offset = 2;
|
int offset = 2;
|
||||||
|
|
||||||
for (var entry : spoilers.entrySet()) {
|
for (Map.Entry<Integer, Integer> entry : spoilers.entrySet()) {
|
||||||
int spoilerStart = entry.getKey() - offset;
|
int spoilerStart = entry.getKey() - offset;
|
||||||
int spoilerEnd = entry.getValue() - offset;
|
int spoilerEnd = entry.getValue() - offset;
|
||||||
|
|
||||||
@ -98,9 +99,10 @@ public class SpoilerParserPlugin extends AbstractMarkwonPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(offset > 2) {
|
||||||
textView.setText(markdownStringBuilder);
|
textView.setText(markdownStringBuilder);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Very naive implementation, needs to be improved for efficiency and edge cases
|
// Very naive implementation, needs to be improved for efficiency and edge cases
|
||||||
// Don't allow more than one new line after every non-blank line
|
// Don't allow more than one new line after every non-blank line
|
||||||
|
Loading…
x
Reference in New Issue
Block a user