extract real TOC
This commit is contained in:
parent
4c6cc14c95
commit
3b64ebe942
1 changed files with 19 additions and 8 deletions
|
@ -151,8 +151,7 @@ public class TextConverter extends ConverterHelper {
|
||||||
if (!config.includeToc()){
|
if (!config.includeToc()){
|
||||||
extractRealTOC(onode);
|
extractRealTOC(onode);
|
||||||
}
|
}
|
||||||
|
//Split pages
|
||||||
//Split pages
|
|
||||||
onode = (Element) PageSplitter.splitSoftPageBreak(onode,ofr);
|
onode = (Element) PageSplitter.splitSoftPageBreak(onode,ofr);
|
||||||
// Convert content
|
// Convert content
|
||||||
hnode = (Element)traverseBlockText(onode,hnode);
|
hnode = (Element)traverseBlockText(onode,hnode);
|
||||||
|
@ -181,18 +180,30 @@ public class TextConverter extends ConverterHelper {
|
||||||
if (tocs == null){
|
if (tocs == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
System.out.println("extractRealTOC");
|
System.out.println("extractRealTOC " + tocs.getLength());
|
||||||
while (i < tocs.getLength()){
|
while (i < tocs.getLength()){
|
||||||
Node toc = tocs.item(i);
|
Node toc = tocs.item(i);
|
||||||
NodeList indexTitle = onode.getElementsByTagName(XMLString.TEXT_INDEX_TITLE);
|
NodeList indexBody = ((Element)toc).getElementsByTagName(XMLString.TEXT_INDEX_BODY);
|
||||||
if (indexTitle == null || indexTitle.item(0) == null){
|
if (indexBody == null || indexBody.item(0) == null){
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
while (indexTitle.item(0).hasChildNodes()){
|
while (indexBody.item(0).hasChildNodes()){
|
||||||
Node child = indexTitle.item(0).getFirstChild();
|
Node child = indexBody.item(0).getFirstChild();
|
||||||
|
if (child.getNodeType() == Node.ELEMENT_NODE
|
||||||
|
&&
|
||||||
|
((Element) child).getTagName().equals(XMLString.TEXT_INDEX_TITLE)
|
||||||
|
){
|
||||||
|
while(child.hasChildNodes()){
|
||||||
|
|
||||||
|
toc.getParentNode().insertBefore(child.getFirstChild(),toc);
|
||||||
|
}
|
||||||
|
//kamikadze
|
||||||
|
child.getParentNode().removeChild(child);
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
//Move childnodes before text:table-of-content
|
//Move childnodes before text:table-of-content
|
||||||
System.out.println("insertBefore");
|
|
||||||
toc.getParentNode().insertBefore(child, toc);
|
toc.getParentNode().insertBefore(child, toc);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
Loading…
Add table
Reference in a new issue