Skip to content

Commit 319aac4

Browse files
committed
xmltree: use the same code as in stdlib
1 parent 0ab9466 commit 319aac4

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

src/fusion/htmlparser/xmltree.nim

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,6 @@ type
6565
s: seq[XmlNode]
6666
fAttr: XmlAttributes
6767
fClientData: int ## for other clients
68-
# Is the Ending Slash Optional?
69-
# HTML5: the slash is optional.
70-
# HTML4: the slash is technically invalid. However, it's accepted by W3C's HTML validator.
71-
# XHTML: The slash is REQUIRED.
72-
const SingleTags = ["area", "base", "basefont",
73-
"br", "col","embed", "frame", "hr", "img",
74-
"input","source","track",
75-
"isindex", # obsolete HTML 4.01
76-
"link", "meta", "param", "wbr",
77-
"command", # obsolete
78-
"keygen", # obsolete
79-
]
8068

8169
const
8270
xmlHeader* = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
@@ -645,11 +633,8 @@ proc add*(result: var string, n: XmlNode, indent = 0, indWidth = 2,
645633
result.addEscapedAttr(val)
646634
result.add('"')
647635

648-
if n.len == 0 and n.fTag in SingleTags:
649-
result.add("/>")
650-
# result.add("</")
651-
# result.add(n.fTag)
652-
# result.add(">")
636+
if n.len == 0:
637+
result.add(" />")
653638
return
654639

655640
let

0 commit comments

Comments
 (0)