mirror of
https://github.com/msva/lua-htmlparser.git
synced 2024-11-04 23:34:20 +00:00
added a kludge for cases of closing non-opened tags
Signed-off-by: Vadim A. Misbakh-Soloviov <git@mva.name>
This commit is contained in:
parent
74e189b9e8
commit
2a876887d2
26
htmlparser-scm-0.rockspec
Normal file
26
htmlparser-scm-0.rockspec
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package = "htmlparser"
|
||||||
|
version = "scm-0"
|
||||||
|
source = {
|
||||||
|
url = "git://github.com/wscherphof/lua-htmlparser.git",
|
||||||
|
branch = "master"
|
||||||
|
}
|
||||||
|
description = {
|
||||||
|
summary = "Parse HTML text into a tree of elements with selectors",
|
||||||
|
detailed = [[
|
||||||
|
Call parse() to build up a tree of element nodes. Each node in the tree, including the root node that is returned by parse(), supports a basic set of jQuery-like selectors. Or you could walk the tree by hand.
|
||||||
|
]],
|
||||||
|
homepage = "http://msva.github.io/lua-htmlparser/",
|
||||||
|
license = "LGPL+"
|
||||||
|
}
|
||||||
|
dependencies = {
|
||||||
|
"lua >= 5.2"
|
||||||
|
}
|
||||||
|
build = {
|
||||||
|
type = "builtin",
|
||||||
|
copy_directories = {"doc", "tst"},
|
||||||
|
modules = {
|
||||||
|
htmlparser = "src/htmlparser.lua",
|
||||||
|
["htmlparser.ElementNode"] = "src/htmlparser/ElementNode.lua",
|
||||||
|
["htmlparser.voidelements"] = "src/htmlparser/voidelements.lua"
|
||||||
|
}
|
||||||
|
}
|
@ -53,7 +53,7 @@ local function parse(text)
|
|||||||
local closestart, closing, closename
|
local closestart, closing, closename
|
||||||
closestart, closeend, closing, closename = string.find(root._text, "[^<]*<(/?)(%w+)", closeend)
|
closestart, closeend, closing, closename = string.find(root._text, "[^<]*<(/?)(%w+)", closeend)
|
||||||
if not closing or closing == "" then break end
|
if not closing or closing == "" then break end
|
||||||
tag = table.remove(opentags[closename])
|
tag = table.remove(opentags[closename]) or tag -- kludge for cases of closing tag that wasn't opened
|
||||||
closestart = string.find(root._text, "<", closestart)
|
closestart = string.find(root._text, "<", closestart)
|
||||||
tag:close(closestart, closeend + 1)
|
tag:close(closestart, closeend + 1)
|
||||||
node = tag.parent
|
node = tag.parent
|
||||||
|
Loading…
Reference in New Issue
Block a user