summary refs log tree commit diff stats
path: root/tests/stdlib/thtmlparser2814.nim
blob: 968d390f13dc0050e8ff720c7845d9a6899d0be8 (plain) (blame)
1
2
3
4
5
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Gene
discard """
  output: true
"""
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)

  if $parseH.findAll(ltype[1])[0].child("p") != "<p>that</p>":
    echo "case " & ltype[0] & " failed !"
    quit(2)


echo "true"