Moved some details to a function

... regarding [attribute=value] and other matching.
Also explained (in comments) the different matching patterns.
And fixed a bug where /> would be listed as an attribute.
And added a few more tests.
This commit is contained in:
Wouter Scherphof
2013-03-25 13:55:35 +01:00
parent de746865be
commit 64f3eb4df3
4 changed files with 52 additions and 30 deletions

View File

@@ -10,11 +10,8 @@ local root = htmlparser.parse(text)
local function p(n)
local space = string.rep(" ", n.level)
local s = space .. n.name
for i,v in ipairs(n.nodes) do
s = s .. " nodes[" .. i .. "]=" .. v.name
end
for k,v in pairs(n.attributes) do
s = s .. " " .. k .. "=[" .. v .. "]"
s = s .. " " .. k .. "=[[" .. v .. "]]"
end
print(s)
for i,v in ipairs(n.nodes) do
@@ -57,6 +54,11 @@ select("[itemscope]:not([itemprop])")
select("link[rel='alternate']")
select("[test2=\"val='2'\"]")
select("[test5='val5']")
select("[test6='val\"\"6']")
select("[itemscope='']")
select("[itemscope=]")
select("[itemscope]")
print("\nchapters")
local sel, chapters = root("ol.chapters > li"), {}