summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/luaxml/luaxml-mod-handler.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/generic/luaxml/luaxml-mod-handler.lua')
-rw-r--r--macros/luatex/generic/luaxml/luaxml-mod-handler.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/macros/luatex/generic/luaxml/luaxml-mod-handler.lua b/macros/luatex/generic/luaxml/luaxml-mod-handler.lua
index 5f12a92f71..1225b91314 100644
--- a/macros/luatex/generic/luaxml/luaxml-mod-handler.lua
+++ b/macros/luatex/generic/luaxml/luaxml-mod-handler.lua
@@ -253,7 +253,7 @@ M.simpleTreeHandler = simpleTreeHandler
local function domHandler()
local obj = {}
local decode = entities.decode
- obj.options = {commentNode=1,piNode=1,dtdNode=1,declNode=1}
+ obj.options = {commentNode=1,piNode=1,dtdNode=1,declNode=1, voidElements = {}}
obj.root = { _children = {n=0}, _type = "ROOT" }
obj.current = obj.root
obj.starttag = function(self,t,a)
@@ -270,13 +270,20 @@ local function domHandler()
_parent = self.current,
_children = {n=0} }
table.insert(self.current._children,node)
- self.current = node
+ -- close void element
+ if not self.options.voidElements[t] then
+ self.current = node
+ else
+ table.remove(self._xml._stack)
+ end
end
obj.endtag = function(self,t,s)
- if t ~= self.current._name then
+ if not self.options.voidElements[t] then
+ if t ~= self.current._name then
error("XML Error - Unmatched Tag ["..s..":"..t.."]\n")
+ end
+ self.current = self.current._parent
end
- self.current = self.current._parent
end
obj.text = function(self,t)
local node = { _type = "TEXT",