SimpleLogger.debug("Book is an exception - not creating index link (no stichwort.htm*)");
return;
}
Element indexLink = findFirstElement(Selector.TOC_HEADING_2).clone();
String fileExtension = ".htm";
Node ankerNode = null;
for (Node node : indexLink.childNodes()) {
if (node.hasAttr("href")) {
ankerNode = node.clone();
if (ankerNode.attr("href").contains(".html"))
fileExtension = ".html";
break;
}
}
if (ankerNode == null)
throw new RuntimeException(
"Cannot create index link because no cloneable TOC node has been found (should never happen)"
);
ankerNode.attr("href", "stichwort" + fileExtension);
((Element) ankerNode).text("Index");
bodyTag.appendChild(ankerNode);
}