mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化图片排版
This commit is contained in:
parent
296f839f7c
commit
eee6570f32
@ -207,7 +207,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
//set css
|
//set css
|
||||||
epubBook.resources.add(
|
epubBook.resources.add(
|
||||||
Resource(
|
Resource(
|
||||||
"body{background:white;margin:0;}h2{color:#005a9c;text-align:left;}p{text-indent:2em;text-align:justify;}img{width:100%;height:100%;max-width: 100%;max-height:100%;}".encodeToByteArray(),
|
"body,div{background:white;margin:0 auto;}padding:0;outline:none;width:100%;}h2{color:#005a9c;text-align:left;}p{text-indent:2em;text-align:justify;}img{display:inline-block;width:100%;height:100%;max-width: 100%;max-height:100%;}".encodeToByteArray(),
|
||||||
"css/style.css"
|
"css/style.css"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -60,9 +60,15 @@ public class ResourceUtil {
|
|||||||
private static String createHtml(String title, String txt) {
|
private static String createHtml(String title, String txt) {
|
||||||
StringBuilder body = new StringBuilder();
|
StringBuilder body = new StringBuilder();
|
||||||
for (String s : txt.split("\\r?\\n")) {
|
for (String s : txt.split("\\r?\\n")) {
|
||||||
s = s.trim();
|
s=StringUtil.FixTrim(s);
|
||||||
if (s.length() != 0) {
|
if (s.length() != 0) {
|
||||||
body.append("<p>").append(s).append("</p>");
|
if(s.contains("<img")){
|
||||||
|
//body.append("<div class=\"duokan-image-single img-note\">")
|
||||||
|
body.append(s);//.append("</div>");
|
||||||
|
}else {
|
||||||
|
body.append("<p>").append(s).append("</p>");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ package me.ag2s.epublib.util;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Various String utility functions.
|
* Various String utility functions.
|
||||||
@ -271,4 +273,18 @@ public class StringUtil {
|
|||||||
}
|
}
|
||||||
return text.substring(cPos + 1);
|
return text.substring(cPos + 1);
|
||||||
}
|
}
|
||||||
|
public static String FixTrim(String s) {
|
||||||
|
if (s==null){
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
Pattern r = Pattern.compile("^[\\s]{1,9}(.*?)[\\s]{1,9}$");
|
||||||
|
Matcher m = r.matcher(s);
|
||||||
|
if (m.find()) {
|
||||||
|
s= m.group(1);
|
||||||
|
}
|
||||||
|
//移除GBK中文全角空格
|
||||||
|
s = s.replace(" ", "");
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user