From 4880c642fe7386d1c1aaf05fad242b30335d920f Mon Sep 17 00:00:00 2001 From: sk Date: Wed, 30 Nov 2022 00:09:08 +0100 Subject: [PATCH] render markdown lists correctly closes mastodon#152 --- .../joinmastodon/android/ui/text/HtmlParser.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java b/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java index fdd976983..000b70969 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java @@ -3,6 +3,7 @@ package org.joinmastodon.android.ui.text; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.TextUtils; +import android.text.style.BulletSpan; import android.widget.TextView; import com.twitter.twittertext.Regex; @@ -15,7 +16,6 @@ import org.jsoup.Jsoup; import org.jsoup.nodes.Element; import org.jsoup.nodes.Node; import org.jsoup.nodes.TextNode; -import org.jsoup.safety.Cleaner; import org.jsoup.safety.Safelist; import org.jsoup.select.NodeVisitor; @@ -29,6 +29,8 @@ import java.util.stream.Collectors; import androidx.annotation.NonNull; +import me.grishka.appkit.utils.V; + public class HtmlParser{ private static final String TAG="HtmlParser"; private static final String VALID_URL_PATTERN_STRING = @@ -89,6 +91,12 @@ public class HtmlParser{ ssb.append(textNode.text()); }else if(node instanceof Element el){ switch(el.nodeName()){ + case "p" -> { + Node sib=el.previousSibling(); + // compensate for missing empty line after to match the empty + // line added by the

before