diff --git a/app/src/main/java/me/ash/reader/infrastructure/rss/RssHelper.kt b/app/src/main/java/me/ash/reader/infrastructure/rss/RssHelper.kt index 2d23dc9fc..e0251d7ec 100644 --- a/app/src/main/java/me/ash/reader/infrastructure/rss/RssHelper.kt +++ b/app/src/main/java/me/ash/reader/infrastructure/rss/RssHelper.kt @@ -36,6 +36,8 @@ import org.jsoup.Jsoup val enclosureRegex = """""".toRegex() val imgRegex = """img.*?src=(["'])((?!data).*?)\1""".toRegex(RegexOption.DOT_MATCHES_ALL) +const val substackLabelText = """Text within this block will maintain its original spacing when published""" + /** Some operations on RSS. */ class RssHelper @Inject @@ -105,6 +107,12 @@ constructor( if (h1Element != null && h1Element.hasText() && h1Element.text() == title) { h1Element.remove() } + if (link.contains("substack.com")) { + it.select("label:contains($substackLabelText)")?.remove() + it.select("pre")?.attr("style", "white-space: pre-wrap;") + // manually replace the pre tags to not mess up the formatting (like .tagName() does) + return@let it.toString().replace("