This commit is contained in:
Andreas Rumpf 2016-10-20 23:44:55 +02:00
commit 50d593787f
2 changed files with 20 additions and 15 deletions

View file

@ -636,12 +636,14 @@ proc rawGetTok(my: var XmlParser) =
proc getTok(my: var XmlParser) = proc getTok(my: var XmlParser) =
while true: while true:
let lastKind = my.kind
rawGetTok(my) rawGetTok(my)
case my.kind case my.kind
of xmlComment: of xmlComment:
if my.options.contains(reportComments): break if my.options.contains(reportComments): break
of xmlWhitespace: of xmlWhitespace:
if my.options.contains(reportWhitespace): break if my.options.contains(reportWhitespace) or lastKind in {xmlCharData, xmlComment, xmlEntity}:
break
else: break else: break
proc next*(my: var XmlParser) = proc next*(my: var XmlParser) =

View file

@ -164,3 +164,6 @@ when isMainModule:
var xml = loadXml(filePath, errors) var xml = loadXml(filePath, errors)
assert(errors.len == 0, "The file tests/testdata/doc1.xml should be parsed without errors.") assert(errors.len == 0, "The file tests/testdata/doc1.xml should be parsed without errors.")
block bug1518:
var err: seq[string] = @[]
assert $parsexml(newStringStream"<tag>One &amp; two</tag>", "temp.xml", err) == "<tag>One &amp; two</tag>"