From d3a879f2ed371ec0635a0e3052dc1b793778057f Mon Sep 17 00:00:00 2001 From: Dirk Jagdmann Date: Sun, 23 Oct 2022 20:32:45 -0700 Subject: [PATCH] fix some typos. remove trailing whitespace. --- XmlParser.lua | 2 +- xmlhandler/dom.lua | 65 +++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/XmlParser.lua b/XmlParser.lua index 2365f3a..3a7e86e 100755 --- a/XmlParser.lua +++ b/XmlParser.lua @@ -157,7 +157,7 @@ end --@param s String containing tag text --@return a {name, attrs} table -- where name is the name of the tag and attrs --- is a table containing the atributtes of the tag +-- is a table containing the attributes of the tag local function parseTag(self, s) local tag = { name = string.gsub(s, self._TAG, '%1'), diff --git a/xmlhandler/dom.lua b/xmlhandler/dom.lua index f2d643d..c317b98 100755 --- a/xmlhandler/dom.lua +++ b/xmlhandler/dom.lua @@ -7,14 +7,15 @@ local function init() end --- @module Handler to generate a DOM-like node tree structure with --- a single ROOT node parent - each node is a table comprising +-- a single ROOT node parent - each node is a table comprising -- the fields below. --- --- node = { _name = , +-- +-- node = { _name = , -- _type = ROOT|ELEMENT|TEXT|COMMENT|PI|DECL|DTD, +-- _text = , -- _attr = { Node attributes - see callback API }, --- _parent = --- _children = { List of child nodes - ROOT/NODE only } +-- _parent = , +-- _children = { List of child nodes - ROOT/ELEMENT only } -- } -- where: -- - PI = XML Processing Instruction tag. @@ -24,7 +25,7 @@ end -- -- Options -- ======= --- options.(comment|pi|dtd|decl)Node = bool +-- options.(comment|pi|dtd|decl)Node = bool -- - Include/exclude given node types -- -- License: @@ -52,15 +53,15 @@ end ---Parses a start tag. -- @param tag a {name, attrs} table --- where name is the name of the tag and attrs --- is a table containing the atributtes of the tag +-- where name is the name of the tag and attrs +-- is a table containing the attributes of the tag function dom:starttag(tag) - local node = { _type = 'ELEMENT', - _name = tag.name, - _attr = tag.attrs, - _children = {} + local node = { _type = 'ELEMENT', + _name = tag.name, + _attr = tag.attrs, + _children = {} } - + if self.root == nil then self.root = node end @@ -73,8 +74,8 @@ end ---Parses an end tag. -- @param tag a {name, attrs} table --- where name is the name of the tag and attrs --- is a table containing the atributtes of the tag +-- where name is the name of the tag and attrs +-- is a table containing the attributes of the tag function dom:endtag(tag, s) --Table representing the containing tag of the current tag local prev = self._stack[#self._stack] @@ -90,7 +91,7 @@ end ---Parses a tag content. -- @param text text to process function dom:text(text) - local node = { _type = "TEXT", + local node = { _type = "TEXT", _text = text } table.insert(self.current._children, node) @@ -100,8 +101,8 @@ end -- @param text comment text function dom:comment(text) if self.options.commentNode then - local node = { _type = "COMMENT", - _text = text + local node = { _type = "COMMENT", + _text = text } table.insert(self.current._children, node) end @@ -109,27 +110,27 @@ end --- Parses a XML processing instruction (PI) tag -- @param tag a {name, attrs} table --- where name is the name of the tag and attrs --- is a table containing the atributtes of the tag +-- where name is the name of the tag and attrs +-- is a table containing the attributes of the tag function dom:pi(tag) if self.options.piNode then - local node = { _type = "PI", + local node = { _type = "PI", _name = tag.name, - _attr = tag.attrs, - } + _attr = tag.attrs, + } table.insert(self.current._children, node) end end ---Parse the XML declaration line (the line that indicates the XML version). -- @param tag a {name, attrs} table --- where name is the name of the tag and attrs --- is a table containing the atributtes of the tag +-- where name is the name of the tag and attrs +-- is a table containing the attributes of the tag function dom:decl(tag) if self.options.declNode then - local node = { _type = "DECL", - _name = tag.name, - _attr = tag.attrs, + local node = { _type = "DECL", + _name = tag.name, + _attr = tag.attrs, } table.insert(self.current._children, node) end @@ -137,13 +138,13 @@ end ---Parses a DTD tag. -- @param tag a {name, attrs} table --- where name is the name of the tag and attrs --- is a table containing the atributtes of the tag +-- where name is the name of the tag and attrs +-- is a table containing the attributes of the tag function dom:dtd(tag) if self.options.dtdNode then - local node = { _type = "DTD", + local node = { _type = "DTD", _name = tag.name, - _attr = tag.attrs, + _attr = tag.attrs, } table.insert(self.current._children, node) end