summary refs log tree commit diff stats
path: root/tests/stdlib/thtmlparser2814.nim
diff options
context:
space:
mode:
authorStephane Fontaine <stefont@gmail.com>2016-07-27 21:24:51 +0400
committerStephane Fontaine <stefont@gmail.com>2016-07-27 21:24:51 +0400
commitfa537ee3a480823a251ca4fdf5442d2afe7a5afe (patch)
tree43add765bc147c053f7c97601499173732962542 /tests/stdlib/thtmlparser2814.nim
parent5bac8cd8558048292bdc071fe09aa80191677719 (diff)
downloadNim-fa537ee3a480823a251ca4fdf5442d2afe7a5afe.tar.gz
htmlparser: Add test for paragraph inside <dd,li>
Diffstat (limited to 'tests/stdlib/thtmlparser2814.nim')
-rw-r--r--tests/stdlib/thtmlparser2814.nim38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/stdlib/thtmlparser2814.nim b/tests/stdlib/thtmlparser2814.nim
new file mode 100644
index 000000000..74c1a9556
--- /dev/null
+++ b/tests/stdlib/thtmlparser2814.nim
@@ -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>"