htmlparser: Add test for paragraph inside <dd,li>
This commit is contained in:
parent
5bac8cd855
commit
fa537ee3a4
1 changed files with 38 additions and 0 deletions
38
tests/stdlib/thtmlparser2814.nim
Normal file
38
tests/stdlib/thtmlparser2814.nim
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
discard """
|
||||||
|
output: "@[]"
|
||||||
|
"""
|
||||||
|
import htmlparser
|
||||||
|
import xmltree
|
||||||
|
import strutils
|
||||||
|
from streams import newStringStream
|
||||||
|
|
||||||
|
|
||||||
|
## builds the two cases below and test that
|
||||||
|
## ``//[dd,li]`` has "<p>that</p>" as children
|
||||||
|
##
|
||||||
|
## <dl>
|
||||||
|
## <dt>this</dt>
|
||||||
|
## <dd>
|
||||||
|
## <p>that</p>
|
||||||
|
## </dd>
|
||||||
|
## </dl>
|
||||||
|
|
||||||
|
##
|
||||||
|
## <ul>
|
||||||
|
## <li>
|
||||||
|
## <p>that</p>
|
||||||
|
## </li>
|
||||||
|
## </ul>
|
||||||
|
|
||||||
|
for ltype in [["dl","dd"], ["ul","li"]]:
|
||||||
|
let desc_item = if ltype[0]=="dl": "<dt>this</dt>" else: ""
|
||||||
|
let item = "$1<$2><p>that</p></$2>" % [desc_item, ltype[1]]
|
||||||
|
let list = """ <$1>
|
||||||
|
$2
|
||||||
|
</$1> """ % [ltype[0], item]
|
||||||
|
|
||||||
|
var errors : seq[string] = @[]
|
||||||
|
|
||||||
|
let parseH = parseHtml(newStringStream(list),"statichtml", errors =errors)
|
||||||
|
|
||||||
|
echo $parseH.findAll(ltype[1])[0].child("p") == "<p>that</p>"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue