mirror of
https://github.com/TangentFoxy/lua-htmlparser.git
synced 2025-07-28 19:12:18 +00:00
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:
10
test.lua
10
test.lua
@@ -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"), {}
|
||||
|
Reference in New Issue
Block a user