From 091a8a525b668761f721cb51167a1bd8acf6b423 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Fri, 17 Oct 2014 15:49:57 +0200 Subject: Make the link to continue reading a parent of the main div, not at the cut-here level. --- org/madore/damlengine/TodoCutHere.java | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'org/madore/damlengine/TodoCutHere.java') diff --git a/org/madore/damlengine/TodoCutHere.java b/org/madore/damlengine/TodoCutHere.java index 51935e7..4438b5f 100644 --- a/org/madore/damlengine/TodoCutHere.java +++ b/org/madore/damlengine/TodoCutHere.java @@ -38,7 +38,23 @@ public final class TodoCutHere extends TodoDefaultElement { div.appendChild(ctx.doc.createComment(" EMPTY ")); node.getParentNode().replaceChild(div, node); } else { + // Remove every node that follows. + Node killPoint = node; + while ( ! killPoint.isSameNode(ctx.ent.mainDivNode) ) { + Node parent = killPoint.getParentNode(); + while ( killPoint.getNextSibling() != null ) + parent.removeChild(killPoint.getNextSibling()); + // FIXME: deleted node may already have found its way + // in the todo deque, which means it could cause a + // null pointer exception by trying to access its + // parent node. Do something about this! + killPoint = parent; + } + // Remove the cut-point node itself. + node.getParentNode().removeChild(node); + // Now add the link to the full content. Element p = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "p"); + ctx.ent.mainDivNode.appendChild(p); Element a = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "a"); p.appendChild(a); final String baseDir = ((ctx.gc.uriToTop==null)?"":(ctx.gc.uriToTop+"weblog/")); @@ -56,18 +72,6 @@ public final class TodoCutHere extends TodoDefaultElement { a.appendChild(ctx.doc.createTextNode("[Leger ultra\u2026]")); else a.appendChild(ctx.doc.createTextNode("[\u2026]")); - node.getParentNode().replaceChild(p, node); - Node killPoint = p; - while ( ! killPoint.isSameNode(ctx.ent.mainDivNode) ) { - Node parent = killPoint.getParentNode(); - while ( killPoint.getNextSibling() != null ) - parent.removeChild(killPoint.getNextSibling()); - // FIXME: deleted node may already have found its way - // in the todo deque, which means it could cause a - // null pointer exception by trying to access its - // parent node. Do something about this! - killPoint = parent; - } } } -- cgit v1.2.3