|
|
|
@ -22,8 +22,9 @@ object HtmlFormatter { |
|
|
|
|
|
|
|
|
|
fun formatKeepImg(html: String?, redirectUrl: URL?): String { |
|
|
|
|
html ?: return "" |
|
|
|
|
val keepImgHtml = formatKeepImg(html) |
|
|
|
|
val sb = StringBuffer() |
|
|
|
|
val matcher = AppPattern.imgPattern.matcher(formatKeepImg(html)) |
|
|
|
|
val matcher = AppPattern.imgPattern.matcher(keepImgHtml) |
|
|
|
|
var appendPos = 0 |
|
|
|
|
while (matcher.find()) { |
|
|
|
|
val urlArray = matcher.group(1)!!.split(AnalyzeUrl.splitUrlRegex) |
|
|
|
@ -31,12 +32,12 @@ object HtmlFormatter { |
|
|
|
|
if (urlArray.size > 1) { |
|
|
|
|
url = "$url,${urlArray[1]}" |
|
|
|
|
} |
|
|
|
|
sb.append(html.substring(appendPos, matcher.start())) |
|
|
|
|
sb.append(keepImgHtml.substring(appendPos, matcher.start())) |
|
|
|
|
sb.append("<img src=\"$url\" >") |
|
|
|
|
appendPos = matcher.end() |
|
|
|
|
} |
|
|
|
|
if (appendPos < html.length) { |
|
|
|
|
sb.append(html.substring(appendPos, html.length)) |
|
|
|
|
if (appendPos < keepImgHtml.length) { |
|
|
|
|
sb.append(keepImgHtml.substring(appendPos, keepImgHtml.length)) |
|
|
|
|
} |
|
|
|
|
return sb.toString() |
|
|
|
|
} |
|
|
|
|