|
|
@ -32,15 +32,48 @@ object HtmlFormatter { |
|
|
|
|
|
|
|
|
|
|
|
val matcher = imgPattern.matcher(keepImgHtml) |
|
|
|
val matcher = imgPattern.matcher(keepImgHtml) |
|
|
|
var appendPos = 0 |
|
|
|
var appendPos = 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(matcher.find()){ |
|
|
|
|
|
|
|
var url = matcher.group(1)!! |
|
|
|
|
|
|
|
var pos = url.indexOf(',') |
|
|
|
|
|
|
|
sb.append(keepImgHtml.substring(appendPos, matcher.start())) |
|
|
|
|
|
|
|
sb.append( |
|
|
|
|
|
|
|
"<img src=\"${ |
|
|
|
|
|
|
|
if (pos == -1) url else NetworkUtils.getAbsoluteURL( |
|
|
|
|
|
|
|
redirectUrl, |
|
|
|
|
|
|
|
url.substring(0, pos) |
|
|
|
|
|
|
|
) + url.substring(pos) |
|
|
|
|
|
|
|
}\">" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
appendPos = matcher.end() |
|
|
|
|
|
|
|
if(pos == -1) { |
|
|
|
while (matcher.find()) { |
|
|
|
while (matcher.find()) { |
|
|
|
sb.append(keepImgHtml.substring(appendPos, matcher.start())) |
|
|
|
sb.append(keepImgHtml.substring(appendPos, matcher.start())) |
|
|
|
sb.append("<img src=\"${ |
|
|
|
sb.append( "<img src=\"${ |
|
|
|
matcher.group(1)!!.replace("^\\s*([^,\\s]+)\\s*".toRegex()){ |
|
|
|
NetworkUtils.getAbsoluteURL(redirectUrl,matcher.group(1)!!) |
|
|
|
NetworkUtils.getAbsoluteURL(redirectUrl,it.groupValues[1]) |
|
|
|
}\">" ) |
|
|
|
|
|
|
|
appendPos = matcher.end() |
|
|
|
} |
|
|
|
} |
|
|
|
}\">") |
|
|
|
}else{ |
|
|
|
|
|
|
|
while (matcher.find()) { |
|
|
|
|
|
|
|
url = matcher.group(1)!! |
|
|
|
|
|
|
|
pos = url.indexOf(',') |
|
|
|
|
|
|
|
sb.append(keepImgHtml.substring(appendPos, matcher.start())) |
|
|
|
|
|
|
|
sb.append( |
|
|
|
|
|
|
|
"<img src=\"${ |
|
|
|
|
|
|
|
NetworkUtils.getAbsoluteURL( |
|
|
|
|
|
|
|
redirectUrl, |
|
|
|
|
|
|
|
url.substring(0, pos) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}${ |
|
|
|
|
|
|
|
url.substring(pos) |
|
|
|
|
|
|
|
}\">" |
|
|
|
|
|
|
|
) |
|
|
|
appendPos = matcher.end() |
|
|
|
appendPos = matcher.end() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (appendPos < keepImgHtml.length) { |
|
|
|
if (appendPos < keepImgHtml.length) { |
|
|
|
sb.append(keepImgHtml.substring(appendPos, keepImgHtml.length)) |
|
|
|
sb.append(keepImgHtml.substring(appendPos, keepImgHtml.length)) |
|
|
|
} |
|
|
|
} |
|
|
|