mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
5ef9679ca4
commit
7295a5ed89
@ -18,6 +18,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import me.ag2s.epublib.Constants;
|
import me.ag2s.epublib.Constants;
|
||||||
import me.ag2s.epublib.domain.EpubBook;
|
import me.ag2s.epublib.domain.EpubBook;
|
||||||
@ -42,6 +43,7 @@ public class PackageDocumentReader extends PackageDocumentBase {
|
|||||||
private static final String TAG = PackageDocumentReader.class.getName();
|
private static final String TAG = PackageDocumentReader.class.getName();
|
||||||
private static final String[] POSSIBLE_NCX_ITEM_IDS = new String[]{"toc",
|
private static final String[] POSSIBLE_NCX_ITEM_IDS = new String[]{"toc",
|
||||||
"ncx", "ncxtoc", "htmltoc"};
|
"ncx", "ncxtoc", "htmltoc"};
|
||||||
|
private static final Pattern namespaceRegex = Pattern.compile(" s?mlns=\"");
|
||||||
|
|
||||||
|
|
||||||
public static void read(
|
public static void read(
|
||||||
@ -49,9 +51,8 @@ public class PackageDocumentReader extends PackageDocumentBase {
|
|||||||
Resources resources)
|
Resources resources)
|
||||||
throws SAXException, IOException {
|
throws SAXException, IOException {
|
||||||
/*掌上书苑有很多自制书OPF的nameSpace格式不标准,强制修复成正确的格式*/
|
/*掌上书苑有很多自制书OPF的nameSpace格式不标准,强制修复成正确的格式*/
|
||||||
String string = new String(packageResource.getData())
|
String string = namespaceRegex.matcher(new String(packageResource.getData()))
|
||||||
.replace(" smlns=\"", " xmlns=\"")
|
.replaceAll(" xmlns=\"");
|
||||||
.replace(" mlns=\"", " xmlns=\"");
|
|
||||||
packageResource.setData(string.getBytes());
|
packageResource.setData(string.getBytes());
|
||||||
|
|
||||||
Document packageDocument = ResourceUtil.getAsDocument(packageResource);
|
Document packageDocument = ResourceUtil.getAsDocument(packageResource);
|
||||||
|
Loading…
Reference in New Issue
Block a user