|
|
|
@ -44,24 +44,10 @@ object HtmlFormatter { |
|
|
|
|
val matcher = imgPattern.matcher(keepImgHtml) |
|
|
|
|
var appendPos = 0 |
|
|
|
|
|
|
|
|
|
if(matcher.find()){ |
|
|
|
|
if(hasDataType || matcher.group(1)!!.indexOf(',') == -1) { //图片无参 |
|
|
|
|
|
|
|
|
|
do{ |
|
|
|
|
sb.append(keepImgHtml.substring(appendPos, matcher.start()).replace("\n","\n ")) //非图片部分换行缩进 |
|
|
|
|
sb.append( "<img src=\"${ |
|
|
|
|
NetworkUtils.getAbsoluteURL(redirectUrl,matcher.group(1)!!) |
|
|
|
|
}\">" ) |
|
|
|
|
appendPos = matcher.end() |
|
|
|
|
}while (matcher.find()) |
|
|
|
|
|
|
|
|
|
}else{ //图片有参 |
|
|
|
|
|
|
|
|
|
do{ |
|
|
|
|
while(matcher.find()){ |
|
|
|
|
val url = matcher.group(1)!! |
|
|
|
|
val urlBefore = url.substringBefore(',') |
|
|
|
|
val beforeStr = keepImgHtml.substring(appendPos, matcher.start()) |
|
|
|
|
sb.append( if(beforeStr == "\n") '\n' else beforeStr.replace("\n","\n ") ) //缩进换行下个非图片段落 |
|
|
|
|
sb.append( keepImgHtml.substring(appendPos, matcher.start()).replace("\n","\n ") ) //缩进换行下个非图片段落 |
|
|
|
|
sb.append( |
|
|
|
|
"<img src=\"${ |
|
|
|
|
NetworkUtils.getAbsoluteURL( |
|
|
|
@ -73,14 +59,10 @@ object HtmlFormatter { |
|
|
|
|
}\">" |
|
|
|
|
) |
|
|
|
|
appendPos = matcher.end() |
|
|
|
|
}while(matcher.find()) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (appendPos < keepImgHtml.length) { |
|
|
|
|
val beforeStr = keepImgHtml.substring(appendPos, keepImgHtml.length) |
|
|
|
|
sb.append( if(beforeStr == "\n") '\n' else beforeStr.replace("\n","\n ") ) //缩进换行下个非图片段落 |
|
|
|
|
sb.append( keepImgHtml.substring( appendPos, keepImgHtml.length ).replace("\n","\n ") ) //缩进换行下个非图片段落 |
|
|
|
|
} |
|
|
|
|
return sb.toString() |
|
|
|
|
} |
|
|
|
|