summaryrefslogtreecommitdiffstats
path: root/org
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2011-08-26 17:28:05 +0200
committerDavid A. Madore <david+git@madore.org>2011-08-26 17:28:05 +0200
commitfc26fdba30e084a2e8a8278d09a1be08a83e0722 (patch)
tree5f2faf6413275a55683273e4fa3b9223f49967e4 /org
parent961bdfc66151b9aef46149e4730110ef409e5587 (diff)
downloaddamlengine-fc26fdba30e084a2e8a8278d09a1be08a83e0722.tar.gz
damlengine-fc26fdba30e084a2e8a8278d09a1be08a83e0722.tar.bz2
damlengine-fc26fdba30e084a2e8a8278d09a1be08a83e0722.zip
Handle d:img-a element.
Diffstat (limited to 'org')
-rw-r--r--org/madore/damlengine/TodoElement.java1
-rw-r--r--org/madore/damlengine/TodoImgAElement.java44
2 files changed, 45 insertions, 0 deletions
diff --git a/org/madore/damlengine/TodoElement.java b/org/madore/damlengine/TodoElement.java
index 95a22c4..c597430 100644
--- a/org/madore/damlengine/TodoElement.java
+++ b/org/madore/damlengine/TodoElement.java
@@ -59,6 +59,7 @@ public abstract class TodoElement extends TodoItem {
damlFactories.put("smiley-twisted", new TodoSmileyElement.Factory(TodoSmileyElement.Type.TWISTED));
damlFactories.put("smiley-cry", new TodoSmileyElement.Factory(TodoSmileyElement.Type.CRY));
damlFactories.put("smiley-evil", new TodoSmileyElement.Factory(TodoSmileyElement.Type.EVIL));
+ damlFactories.put("img-a", new TodoImgAElement.Factory());
}
protected final Element node;
diff --git a/org/madore/damlengine/TodoImgAElement.java b/org/madore/damlengine/TodoImgAElement.java
new file mode 100644
index 0000000..25a8263
--- /dev/null
+++ b/org/madore/damlengine/TodoImgAElement.java
@@ -0,0 +1,44 @@
+package org.madore.damlengine;
+
+import java.util.ArrayList;
+import org.w3c.dom.*;
+
+public final class TodoImgAElement extends TodoDefaultElement {
+
+ public static class Factory extends TodoElement.Factory {
+ @Override
+ public TodoImgAElement newItem(Element node,
+ Context ctx,
+ TodoItem caller) {
+ return new TodoImgAElement(node, ctx, caller);
+ }
+ }
+
+ public TodoImgAElement(Element node,
+ Context ctx,
+ TodoItem caller) {
+ super(node, ctx, caller);
+ }
+
+ @Override
+ public void handleNodeOnly() {
+ String explicitLang = LangHelper.getLangNorec(node);
+ Element a = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "a");
+ if ( explicitLang != null )
+ LangHelper.setLangNorec(node, explicitLang);
+ node.getParentNode().replaceChild(a, node);
+ Element img = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "img");
+ a.appendChild(img);
+ ArrayList<Attr> attrList = getAttrList(this.node);
+ for ( Attr attr : attrList ) {
+ if ( attr.getNamespaceURI() == null ) {
+ String attName = attr.getLocalName();
+ if ( attName == "src" )
+ a.setAttributeNS(null, "href", attr.getValue());
+ node.removeAttributeNode(attr);
+ img.setAttributeNodeNS(attr);
+ }
+ }
+ }
+
+}