From 77c5468140c0f4bc1d4975679aa5c974451698ad Mon Sep 17 00:00:00 2001 From: hyee Date: Fri, 10 Nov 2017 21:06:34 +0800 Subject: [PATCH] fix --- chm.lua | 35 ++- htmlparser.lua | 212 +++++------------- htmlparser/ElementNode.lua | 424 ++++++++++++++++++------------------ htmlparser/voidelements.lua | 33 ++- 4 files changed, 310 insertions(+), 394 deletions(-) diff --git a/chm.lua b/chm.lua index 565dfab..f957e10 100644 --- a/chm.lua +++ b/chm.lua @@ -11,7 +11,7 @@ local target_doc_root='f:\\BM\\newdoc11\\' .hhc/.hhk/.hhp files are all created under the root path - .hhc => Content rules(buildJson): target.json + .hhc => Content rules(buildJson): target.db/target.json .hhk => Index rules(buildIdx): 1. Common books => index.htm:
-> content, @@ -39,6 +39,9 @@ local target_doc_root='f:\\BM\\newdoc11\\' a. Replace '.htm?' as '.htm' b. Caculate the based on the root path and replace '\' as '.', assign as the c. Final address is 'MS-ITS:.chm:://' + 5). For all links from 'a' that starts with 'http', set attribute target="_blank" + 6). For the content inside "
", if contains the prev/next navigation, then add the bottom bar + 7). For sections that after p="part", move as the children; for sections that p="appendix", move into appendix part Book list rules: all directories that contains 'toc.htm' --]] @@ -249,7 +252,7 @@ function builder:buildIdx() local function access_childs(li,level) if li.name~="li" or not li.nodes[1] then return end local content=li:getcontent():gsub('^%s+','') - local n={name=content:gsub('[%s,]+<.*>.*$',''),ref={}} + local n={name=content:gsub('[%s,]+<.+>.*$',''),ref={}} if n.name=="" then return end if level==1 then tree[#tree+1],sql_keys[n.name:upper()]=n,nil @@ -263,7 +266,9 @@ function builder:buildIdx() local lis=li:select("li") if li.nodes[1].name~="ul" then for _,a in ipairs(li:select("a")) do - n.ref[#n.ref+1]=a.attributes.href + if a.parent==li or (a.parent and a.parent.name=="span" and a.parent.parent==li) then + n.ref[#n.ref+1]=a.attributes.href + end end if level>1 and #n.ref==0 and #treenode[level-1].ref==0 then @@ -464,9 +469,20 @@ function builder:buildJson() for i=last,1,-1 do local node=root.docs[1].c[i] local p=node.p + if (node.t==node.seq or not node.t) and node.h then + local url=(self.full_dir..node.h):gsub("(html?)#.+$","%1") + txt=self.read(url) + if txt then + local title=txt:match("(.-)") + if title then + node.t=(node.seq and (node.seq.." ") or "")..title + end + end + end local t=node.t and node.t:lower() if t and p=="part" and (not node.c or #node.c==0) and last then node.c={p=node.p,n=node.n} + for j=last,i+1,-1 do local child=table.remove(root.docs[1].c,j) --print(node.t,child.t) @@ -555,6 +571,9 @@ function builder:processHTML(file,level) if not file:lower():find("%.html?$") then return end local prefix=string.rep("%.%./",level) local txt=self.read(file) + if not txt then + error('error on opening file: '..file) + end if self.is_javadoc then txt=txt:gsub('()',function(a,b,c) return a..b:gsub('<','>'):gsub('&','&'):gsub('>','<')..c @@ -601,7 +620,7 @@ function builder:processHTML(file,level) txt=txt:gsub('%s*
(.-)
%s*',function(s) if not s:find("nav%.gif") then return "" end local left,right,copy='#','#','' - for url,dir in s:gmatch(']*>]+/(%w+)nav.gif"') do + for url,dir in s:gmatch(']*>]+src="(.-/(%w+)nav.gif)"') do if dir=='left' then left=url else @@ -611,10 +630,10 @@ function builder:processHTML(file,level) copy=s:match("(Copyright[^<]+)") or ""; return ([[
- - - -
Go to previous page
Previous
Oracle
%s
Go to next page
Next
]]):format(left,copy,right) + Go to previous page
Prev
+ Oracle
%s + Go to next page
Next
+ ]]):format(left,dcommon_path,dcommon_path,copy,right,dcommon_path) end) txt=txt:gsub([[(%s*%s*)]],'') txt=txt:gsub('%s*%s*','') diff --git a/htmlparser.lua b/htmlparser.lua index c029eb5..1328887 100644 --- a/htmlparser.lua +++ b/htmlparser.lua @@ -1,161 +1,67 @@ --- vim: ft=lua ts=2 sw=2 - -local esc = function(s) return string.gsub(s, "([%^%$%(%)%%%.%[%]%*%+%-%?])", "%%" .. "%1") end -local str = tostring -local char = string.char -local err = function(s) io.stderr:write(s) end -local out = function(s) io.stdout:write(s) end - local ElementNode = require("htmlparser.ElementNode") local voidelements = require("htmlparser.voidelements") local HtmlParser = {} -local tpr = { - -- Here we're replacing confusing sequences - -- (things looking like tags, but appearing where tags can't) - -- with definitelly invalid utf sequence, and later we'll replace them back - ["<"] = char(208,209,208,209), - [">"] = char(209,208,209,208), -} - -local function parse(text,limit) - local text=str(text) - - local limit = limit or htmlparser_looplimit or 1000 - - local tpl = false - - local function g(id,...) - local arg={...} - arg[id]=tpr[arg[id]] - tpl=true - return table.concat(arg) - end - - text = text - :gsub( - "(<)".. - "([^>]-)".. - "(<)", - function(...)return g(3,...)end - ):gsub( - "("..tpr["<"]..")".. - "([^%w%s])".. - "([^%2]-)".. - "(%2)".. - "(>)".. - "([^>]-)".. - "(>)", - function(...)return g(5,...)end - ):gsub( - [=[(['"])]=].. - [=[([^'">%s]-)]=].. - "(>)".. - [=[([^'">%s]-)]=].. - [=[(['"])]=], - function(...)return g(3,...)end - ) - - local index = 0 - local root = ElementNode:new(index, str(text)) - - local node, descend, tpos, opentags = root, true, 1, {} - while true do - if index == limit then - err("[HTMLParser] [ERR] Main loop reached loop limit ("..limit.."). Please, consider increasing it or check the code for errors") - break - end - - local openstart, name - openstart, tpos, name = root._text:find( - "<" .. -- an uncaptured starting "<" - "([%w-]+)" .. -- name = the first word, directly following the "<" - "[^>]*>", -- include, but not capture everything up to the next ">" - tpos) - - if not name then break end - - index = index + 1 - - local tag = ElementNode:new(index, str(name), node, descend, openstart, tpos) - node = tag - - local tagloop - local tagst, apos = tag:gettext(), 1 - while true do - if tagloop == limit then - err("[HTMLParser] [ERR] tag parsing loop reached loop limit ("..limit.."). Please, consider increasing it or check the code for errors") - break - end - - local start, k, eq, quote, v - start, apos, k, eq, quote = tagst:find( - "%s+" .. -- some uncaptured space - "([^%s=/>]+)" .. -- k = an unspaced string up to an optional "=" or the "/" or ">" - "(=?)" .. -- eq = the optional; "=", else "" - "(['\"]?)", -- quote = an optional "'" or '"' following the "=", or "" - apos) - - if not k or k == "/>" or k == ">" then break end - - if eq == "=" then - pattern = "=([^%s>]*)" - if quote ~= "" then - pattern = quote .. "([^" .. quote .. "]*)" .. quote - end - start, apos, v = tagst:find(pattern, apos) - end - - v=v or "" - - if tpl then - for rk,rv in pairs(tpr) do - v = v:gsub(rv,rk) - end - end - - tag:addattribute(k, v) - tagloop = (tagloop or 0) + 1 - end - - if voidelements[tag.name:lower()] then - descend = false - tag:close() - else - opentags[tag.name] = opentags[tag.name] or {} - table.insert(opentags[tag.name], tag) - end - - local closeend = tpos - local closingloop - while true do - if closingloop == limit then - err("[HTMLParser] [ERR] tag closing loop reached loop limit ("..limit.."). Please, consider increasing it or check the code for errors") - break - end - - local closestart, closing, closename - closestart, closeend, closing, closename = root._text:find("[^<]*<(/?)([%w-]+)", closeend) - - if not closing or closing == "" then break end - - tag = table.remove(opentags[closename] or {}) or tag -- kludges for the cases of closing void or non-opened tags - closestart = root._text:find("<", closestart) - tag:close(closestart, closeend + 1) - node = tag.parent - descend = true - closingloop = (closingloop or 0) + 1 - end - end - - if tpl then - for k,v in pairs(tpr) do - root._text = root._text:gsub(v,k) - end - end - - return root +local function parse(text) + local index = 0 + local root = ElementNode:new(index, text) + + local node, descend, tpos, opentags = root, true, 1, {} + while true do + local openstart, name + openstart, tpos, name = string.find(root._text, + "<" .. -- an uncaptured starting "<" + "([%w-]+)" .. -- name = the first word, directly following the "<" + "[^>]*>", -- include, but not capture everything up to the next ">" + tpos) + if not name then break end + index = index + 1 + local tag = ElementNode:new(index, name, node, descend, openstart, tpos) + node = tag + + local tagst, apos = tag:gettext(), 1 + while true do + local start, k, eq, quote, v + start, apos, k, eq, quote = string.find(tagst, + "%s+" .. -- some uncaptured space + "([^%s=/>]+)" .. -- k = an unspaced string up to an optional "=" or the "/" or ">" + "(=?)" .. -- eq = the optional; "=", else "" + "(['\"]?)", -- quote = an optional "'" or '"' following the "=", or "" + apos) + if not k or k == "/>" or k == ">" then break end + if eq == "=" then + local pattern = "=([^%s>]*)" + if quote ~= "" then + pattern = quote .. "([^" .. quote .. "]*)" .. quote + end + start, apos, v = string.find(tagst, pattern, apos) + end + tag:addattribute(k, v or "") + end + + if voidelements[string.lower(tag.name)] then + descend = false + tag:close() + else + opentags[tag.name] = opentags[tag.name] or {} + table.insert(opentags[tag.name], tag) + end + + local closeend = tpos + while true do + local closestart, closing, closename + closestart, closeend, closing, closename = string.find(root._text, "[^<]*<(/?)([%w-]+)", closeend) + if not closing or closing == "" then break end + tag = table.remove(opentags[closename] or {}) or tag -- kludges for the cases of closing void or non-opened tags + closestart = string.find(root._text, "<", closestart) + tag:close(closestart, closeend + 1) + node = tag.parent + descend = true + end + end + + return root end HtmlParser.parse = parse diff --git a/htmlparser/ElementNode.lua b/htmlparser/ElementNode.lua index 381fb90..de21937 100644 --- a/htmlparser/ElementNode.lua +++ b/htmlparser/ElementNode.lua @@ -1,280 +1,272 @@ --- vim: ft=lua ts=2 +pcall(require, "luarocks.loader") local Set = {} Set.mt = {__index = Set} function Set:new(values) - local instance = {} - local isSet if getmetatable(values) == Set.mt then isSet = true end - if type(values) == "table" then - if not isSet and #values > 0 then - for _,v in ipairs(values) do - instance[v] = true - end - else - for k in pairs(values) do - instance[k] = true - end - end - elseif values ~= nil then - instance = {[values] = true} - end - return setmetatable(instance, Set.mt) + local instance = {} + local isSet if getmetatable(values) == Set.mt then isSet = true end + if type(values) == "table" then + if not isSet and #values > 0 then + for _,v in ipairs(values) do + instance[v] = true + end + else + for k in pairs(values) do + instance[k] = true + end + end + elseif values ~= nil then + instance = {[values] = true} + end + return setmetatable(instance, Set.mt) end function Set:add(e) - if e ~= nil then self[e] = true end - return self + if e ~= nil then self[e] = true end + return self end function Set:remove(e) - if e ~= nil then self[e] = nil end - return self + if e ~= nil then self[e] = nil end + return self end function Set:tolist() - local res = {} - for k in pairs(self) do - table.insert(res, k) - end - return res + local res = {} + for k in pairs(self) do + table.insert(res, k) + end + return res end Set.mt.__add = function (a, b) - local res, a, b = Set:new(), Set:new(a), Set:new(b) - for k in pairs(a) do res[k] = true end - for k in pairs(b) do res[k] = true end - return res + local res, a, b = Set:new(), Set:new(a), Set:new(b) + for k in pairs(a) do res[k] = true end + for k in pairs(b) do res[k] = true end + return res end -- Subtraction Set.mt.__sub = function (a, b) - local res, a, b = Set:new(), Set:new(a), Set:new(b) - for k in pairs(a) do res[k] = true end - for k in pairs(b) do res[k] = nil end - return res + local res, a, b = Set:new(), Set:new(a), Set:new(b) + for k in pairs(a) do res[k] = true end + for k in pairs(b) do res[k] = nil end + return res end -- Intersection Set.mt.__mul = function (a, b) - local res, a, b = Set:new(), Set:new(a), Set:new(b) - for k in pairs(a) do - res[k] = b[k] - end - return res + local res, a, b = Set:new(), Set:new(a), Set:new(b) + for k in pairs(a) do + res[k] = b[k] + end + return res end -- String representation Set.mt.__tostring = function (set) - local s = "{" - local sep = "" - for k in pairs(set) do - s = s .. sep .. tostring(k) - sep = ", " - end - return s .. "}" + local s = "{" + local sep = "" + for k in pairs(set) do + s = s .. sep .. tostring(k) + sep = ", " + end + return s .. "}" end local ElementNode = {} ElementNode.mt = {__index = ElementNode} function ElementNode:new(index, nameortext, node, descend, openstart, openend) - local instance = { - index = index, - name = nameortext, - level = 0, - parent = nil, - root = nil, - nodes = {}, - _openstart = openstart, _openend = openend, - _closestart = openstart, _closeend = openend, - attributes = {}, - id = nil, - classes = {}, - deepernodes = Set:new(), - deeperelements = {}, deeperattributes = {}, deeperids = {}, deeperclasses = {} - } - if not node then - instance.name = "root" - instance.root = instance - instance._text = nameortext - local length = string.len(nameortext) - instance._openstart, instance._openend = 1, length - instance._closestart, instance._closeend = 1, length - elseif descend then - instance.root = node.root - instance.parent = node - instance.level = node.level + 1 - table.insert(node.nodes, instance) - else - instance.root = node.root - instance.parent = node.parent - instance.level = node.level - table.insert(node.parent.nodes, instance) - end - return setmetatable(instance, ElementNode.mt) + local instance = { + index = index, + name = nameortext, + level = 0, + parent = nil, + root = nil, + nodes = {}, + _openstart = openstart, _openend = openend, + _closestart = openstart, _closeend = openend, + attributes = {}, + id = nil, + classes = {}, + deepernodes = Set:new(), + deeperelements = {}, deeperattributes = {}, deeperids = {}, deeperclasses = {} + } + if not node then + instance.name = "root" + instance.root = instance + instance._text = nameortext + local length = string.len(nameortext) + instance._openstart, instance._openend = 1, length + instance._closestart, instance._closeend = 1, length + elseif descend then + instance.root = node.root + instance.parent = node + instance.level = node.level + 1 + table.insert(node.nodes, instance) + else + instance.root = node.root + instance.parent = node.parent + instance.level = node.level + table.insert(node.parent.nodes, instance) + end + return setmetatable(instance, ElementNode.mt) end function ElementNode:gettext() - return string.sub(self.root._text, self._openstart, self._closeend) -end - -function ElementNode:settext(c) - self.root._text=c -end - -function ElementNode:textonly() - return (self:gettext():gsub("<[^>]*>","")) + return string.sub(self.root._text, self._openstart, self._closeend) end function ElementNode:getcontent() - return string.sub(self.root._text, self._openend + 1, self._closestart - 1) + return string.sub(self.root._text, self._openend + 1, self._closestart - 1) end function ElementNode:addattribute(k, v) - self.attributes[k] = v - if string.lower(k) == "id" then - self.id = v - -- class attribute contains "space-separated tokens", each of which we'd like quick access to - elseif string.lower(k) == "class" then - for class in string.gmatch(v, "%S+") do - table.insert(self.classes, class) - end - end + self.attributes[k] = v + if string.lower(k) == "id" then + self.id = v + -- class attribute contains "space-separated tokens", each of which we'd like quick access to + elseif string.lower(k) == "class" then + for class in string.gmatch(v, "%S+") do + table.insert(self.classes, class) + end + end end local function insert(table, name, node) - table[name] = table[name] or Set:new() - table[name]:add(node) + table[name] = table[name] or Set:new() + table[name]:add(node) end function ElementNode:close(closestart, closeend) - if closestart and closeend then - self._closestart, self._closeend = closestart, closeend - end - -- inform hihger level nodes about this element's existence in their branches - local node = self - while true do - node = node.parent - if not node then break end - node.deepernodes:add(self) - insert(node.deeperelements, self.name, self) - for k in pairs(self.attributes) do - insert(node.deeperattributes, k, self) - end - if self.id then - insert(node.deeperids, self.id, self) - end - for _,v in ipairs(self.classes) do - insert(node.deeperclasses, v, self) - end - end + if closestart and closeend then + self._closestart, self._closeend = closestart, closeend + end + -- inform hihger level nodes about this element's existence in their branches + local node = self + while true do + node = node.parent + if not node then break end + node.deepernodes:add(self) + insert(node.deeperelements, self.name, self) + for k in pairs(self.attributes) do + insert(node.deeperattributes, k, self) + end + if self.id then + insert(node.deeperids, self.id, self) + end + for _,v in ipairs(self.classes) do + insert(node.deeperclasses, v, self) + end + end end local function escape(s) - -- escape all ^, $, (, ), %, ., [, ], *, +, - , and ? with a % prefix - return string.gsub(s, "([%^%$%(%)%%%.%[%]%*%+%-%?])", "%%" .. "%1") + -- escape all ^, $, (, ), %, ., [, ], *, +, - , and ? with a % prefix + return string.gsub(s, "([%^%$%(%)%%%.%[%]%*%+%-%?])", "%%" .. "%1") end local function select(self, s) - if not s or type(s) ~= "string" or s == "" then return Set:new() end - local sets = {[""] = self.deeperelements, ["["] = self.deeperattributes, - ["#"] = self.deeperids, ["."] = self.deeperclasses} - local function match(t, w) - local m, e, v - if t == "[" then w, m, e, v = string.match(w, - "([^=|%*~%$!%^]+)" .. -- w = 1 or more characters up to a possible "=", "|", "*", "~", "$", "!", or "^" - "([|%*~%$!%^]?)" .. -- m = an optional "|", "*", "~", "$", "!", or "^", preceding the optional "=" - "(=?)" .. -- e = the optional "=" - "(.*)" -- v = anything following the "=", or else "" - ) - end - local matched = Set:new(sets[t][w]) - -- attribute value selectors - if e == "=" then - if #v < 2 then v = "'" .. v .. "'" end -- values should be quoted - v = string.sub(v, 2, #v - 1) -- strip quotes - if m == "!" then matched = Set:new(self.deepernodes) end -- include those without that attribute - for node in pairs(matched) do - local a = node.attributes[w] - -- equals - if m == "" and a ~= v then matched:remove(node) - -- not equals - elseif m == "!" and a == v then matched:remove(node) - -- prefix - elseif m =="|" and string.match(a, "^[^-]*") ~= v then matched:remove(node) - -- contains - elseif m =="*" and string.match(a, escape(v)) ~= v then matched:remove(node) - -- word - elseif m =="~" then matched:remove(node) - for word in string.gmatch(a, "%S+") do - if word == v then matched:add(node) break end - end - -- starts with - elseif m =="^" and string.match(a, "^" .. escape(v)) ~= v then matched:remove(node) - -- ends with - elseif m =="$" and string.match(a, escape(v) .. "$") ~= v then matched:remove(node) - end - end -- for node - end -- if v - return matched - end + if not s or type(s) ~= "string" or s == "" then return Set:new() end + local sets = {[""] = self.deeperelements, ["["] = self.deeperattributes, + ["#"] = self.deeperids, ["."] = self.deeperclasses} + local function match(t, w) + local m, e, v + if t == "[" then w, m, e, v = string.match(w, + "([^=|%*~%$!%^]+)" .. -- w = 1 or more characters up to a possible "=", "|", "*", "~", "$", "!", or "^" + "([|%*~%$!%^]?)" .. -- m = an optional "|", "*", "~", "$", "!", or "^", preceding the optional "=" + "(=?)" .. -- e = the optional "=" + "(.*)" -- v = anything following the "=", or else "" + ) + end + local matched = Set:new(sets[t][w]) + -- attribute value selectors + if e == "=" then + if #v < 2 then v = "'" .. v .. "'" end -- values should be quoted + v = string.sub(v, 2, #v - 1) -- strip quotes + if m == "!" then matched = Set:new(self.deepernodes) end -- include those without that attribute + for node in pairs(matched) do + local a = node.attributes[w] + -- equals + if m == "" and a ~= v then matched:remove(node) + -- not equals + elseif m == "!" and a == v then matched:remove(node) + -- prefix + elseif m =="|" and string.match(a, "^[^-]*") ~= v then matched:remove(node) + -- contains + elseif m =="*" and string.match(a, escape(v)) ~= v then matched:remove(node) + -- word + elseif m =="~" then matched:remove(node) + for word in string.gmatch(a, "%S+") do + if word == v then matched:add(node) break end + end + -- starts with + elseif m =="^" and string.match(a, "^" .. escape(v)) ~= v then matched:remove(node) + -- ends with + elseif m =="$" and string.match(a, escape(v) .. "$") ~= v then matched:remove(node) + end + end -- for node + end -- if v + return matched + end - local subjects, resultset, childrenonly = Set:new({self}) - for part in string.gmatch(s, "%S+") do + local subjects, resultset, childrenonly = Set:new({self}) + for part in string.gmatch(s, "%S+") do repeat - if part == ">" then childrenonly = true --[[goto nextpart]] break end - resultset = Set:new() - for subject in pairs(subjects) do - local star = subject.deepernodes - if childrenonly then star = Set:new(subject.nodes) end - resultset = resultset + star - end - childrenonly = false - if part == "*" then --[[goto nextpart]] break end - local excludes, filter = Set:new() - local start, pos = 0, 0 - while true do - local switch, stype, name, eq, quote - start, pos, switch, stype, name, eq, quote = string.find(part, - "(%(?%)?)" .. -- switch = a possible ( or ) switching the filter on or off - "([:%[#.]?)" .. -- stype = a possible :, [, #, or . - "([%w-_\\]+)" .. -- name = 1 or more alfanumeric chars (+ hyphen, reverse slash and uderscore) - "([|%*~%$!%^]?=?)" .. -- eq = a possible |=, *=, ~=, $=, !=, ^=, or = - "(['\"]?)", -- quote = a ' or " delimiting a possible attribute value - pos + 1 - ) - if not name then break end + if part == ">" then childrenonly = true --[[goto nextpart]] break end + resultset = Set:new() + for subject in pairs(subjects) do + local star = subject.deepernodes + if childrenonly then star = Set:new(subject.nodes) end + resultset = resultset + star + end + childrenonly = false + if part == "*" then --[[goto nextpart]] break end + local excludes, filter = Set:new() + local start, pos = 0, 0 + while true do + local switch, stype, name, eq, quote + start, pos, switch, stype, name, eq, quote = string.find(part, + "(%(?%)?)" .. -- switch = a possible ( or ) switching the filter on or off + "([:%[#.]?)" .. -- stype = a possible :, [, #, or . + "([%w-_\\]+)" .. -- name = 1 or more alfanumeric chars (+ hyphen, reverse slash and uderscore) + "([|%*~%$!%^]?=?)" .. -- eq = a possible |=, *=, ~=, $=, !=, ^=, or = + "(['\"]?)", -- quote = a ' or " delimiting a possible attribute value + pos + 1 + ) + if not name then break end repeat - if ":" == stype then - filter = name - --[[goto nextname]] break - end - if ")" == switch then - filter = nil - end - if "[" == stype and "" ~= quote then - local value - start, pos, value = string.find(part, "(%b" .. quote .. quote .. ")]", pos) - name = name .. eq .. value - end - local matched = match(stype, name) - if filter == "not" then - excludes = excludes + matched - else - resultset = resultset * matched - end - --::nextname:: + if ":" == stype then + filter = name + --[[goto nextname]] break + end + if ")" == switch then + filter = nil + end + if "[" == stype and "" ~= quote then + local value + start, pos, value = string.find(part, "(%b" .. quote .. quote .. ")]", pos) + name = name .. eq .. value + end + local matched = match(stype, name) + if filter == "not" then + excludes = excludes + matched + else + resultset = resultset * matched + end + --::nextname:: break until true - end - resultset = resultset - excludes - subjects = Set:new(resultset) - --::nextpart:: + end + resultset = resultset - excludes + subjects = Set:new(resultset) + --::nextpart:: break until true - end - resultset = resultset:tolist() - table.sort(resultset, function (a, b) return a.index < b.index end) - return resultset + end + resultset = resultset:tolist() + table.sort(resultset, function (a, b) return a.index < b.index end) + return resultset end function ElementNode:select(s) return select(self, s) end diff --git a/htmlparser/voidelements.lua b/htmlparser/voidelements.lua index 43dedf5..b95b010 100644 --- a/htmlparser/voidelements.lua +++ b/htmlparser/voidelements.lua @@ -1,19 +1,18 @@ --- vim: ft=lua ts=2 return { - area = true, - base = true, - br = true, - col = true, - command = true, - embed = true, - hr = true, - img = true, - input = true, - keygen = true, - link = true, - meta = true, - param = true, - source = true, - track = true, - wbr = true + area = true, + base = true, + br = true, + col = true, + command = true, + embed = true, + hr = true, + img = true, + input = true, + keygen = true, + link = true, + meta = true, + param = true, + source = true, + track = true, + wbr = true }