Hi @msva, huge thanks for your parser! Found a small, but annoying bug.
Bug Description
Any tag listed in voidelements.lua casues the "Attempt to index a nil value" error if using a parent child selector.
Bug Reproduction
Shortest working example:
local htmlparser = require 'htmlparser'
local html = [[
<br><!-- ← This single tag causes nil index error. No error without it. -->
<div class="parent">
<div class="child">msva rulit, kogda ne spit!</div>
</div>
]]
local root = htmlparser.parse(html)
local bug = root('.parent .child') -- Error only if a pair. No error if single.
print(bug[1]:getcontent())
Temp Workaround
Until fixed, remove all unpaired tags that are listed in voidelements.lua from the html to be processed:
html = html:gsub('<br>', ''):gsub('<br />', ''):gsub('<hr>', ''):gsub('etc', '')
Hi @msva, huge thanks for your parser! Found a small, but annoying bug.
Bug Description
Any tag listed in
voidelements.lua
casues the "Attempt to index a nil value" error if using a parent child selector.Bug Reproduction
Shortest working example:
Temp Workaround
Until fixed, remove all unpaired tags that are listed in
voidelements.lua
from the html to be processed: