msva / lua-htmlparser

An HTML parser for lua.
234 stars 44 forks source link

Selecting by class fails for class names with hyphens #37

Closed SunsetTech closed 9 years ago

SunsetTech commented 10 years ago

Using Lua 5.2.3 and htmlparser 0.3.2-1 The following code demonstrates the issue.

htmlparser = require("htmlparser")
DOM = htmlparser.parse("<div class='te-st'></div><div class='test'></div>")
print(#DOM:select(".test"))
--1
print(#DOM:select(".te-st"))
--0
msva commented 9 years ago

I confirm that. I getting same behaviour even under LuaJIT 2.1 with HEAD.

msva commented 9 years ago

btw, patch would be like something like that on L158 in ElementNode.lua:

"([%w-_\\]+)"

or, to avoid \\:

[=[([%w-_\]+)]=]