html规则优化

pull/274/head
gedoor 4 years ago
parent 5f052184d1
commit acb44a1a55
  1. 2
      app/src/main/java/io/legado/app/utils/StringExtensions.kt

@ -33,7 +33,7 @@ fun String?.isJsonArray(): Boolean =
} ?: false } ?: false
fun String?.htmlFormat(): String = fun String?.htmlFormat(): String =
this?.replace("(?i)<(br[\\s/]*|/*p\\b.*?|/*div\\b.*?)>".toRegex(), "\n") this?.replace("</?(?:div|p|b|br|hr|h\\d|article|dd|dl|span)[^>]*>".toRegex(), "\n")
?.replace("<[script>]*.*?>|&nbsp;".toRegex(), "") ?.replace("<[script>]*.*?>|&nbsp;".toRegex(), "")
?.replace("\\s*\\n+\\s*".toRegex(), "\n  ") ?.replace("\\s*\\n+\\s*".toRegex(), "\n  ")
?.replace("^[\\n\\s]+".toRegex(), "  ") ?.replace("^[\\n\\s]+".toRegex(), "  ")

Loading…
Cancel
Save