diff options
Diffstat (limited to 'org')
-rw-r--r-- | org/madore/damlengine/TodoElement.java | 1 | ||||
-rw-r--r-- | org/madore/damlengine/TodoImgAElement.java | 44 |
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); + } + } + } + +} |