Improve pretty printed comments

This commit is contained in:
Chris Mayo 2019-10-05 19:38:57 +01:00
parent 607328d5c5
commit 30df69c158
2 changed files with 13 additions and 13 deletions

View file

@ -87,7 +87,7 @@ class HtmlPrettyPrinter (object):
@type data: string
@return: None
"""
self.fd.write("<!--%s-->" % data)
self.fd.write("<!-- %s -->" % data)
def start_element (self, tag, attrs, element_text=None):
"""

View file

@ -72,23 +72,23 @@ parsetests = [
("""<br/>""", """<br/>"""),
("""<a b="50%"><br>""", """<a b="50%"><br/></a>"""),
# comments
("""<!---->< 1>""", """<!-- -->< 1>"""),
("""<!---->< 1>""", """<!-- -->< 1>"""),
("""<!-- a - b -->< 2>""", """<!-- a - b -->< 2>"""),
("""<!----->< 3>""", """<!----->< 3>"""),
("""<!------>< 4>""", """<!------>< 4>"""),
("""<!------->< 5>""", """<!------->< 5>"""),
("""<!-- -->< 7>""", """<!-- -->< 7>"""),
("""<!---- />-->""", """<!---- />-->"""),
("""<!----->< 3>""", """<!-- - -->< 3>"""),
("""<!------>< 4>""", """<!-- -- -->< 4>"""),
("""<!------->< 5>""", """<!-- --- -->< 5>"""),
("""<!-- -->< 7>""", """<!-- -->< 7>"""),
("""<!---- />-->""", """<!-- -- /> -->"""),
("""<!-- a-2 -->< 9>""", """<!-- a-2 -->< 9>"""),
("""<!-- --- -->< 10>""", """<!-- --- -->< 10>"""),
("""<!>""", """<!-- -->"""), # empty comment
("""<!>""", """<!-- -->"""), # empty comment
# invalid comments
("""<!-- -- >< 8>""", """<!-- -->< 8>"""),
("""<!---- >< 6>""", """<!-- -->< 6>"""),
("""<!- blubb ->""", """<!--- blubb --->"""),
("""<! -- blubb -->""", """<!-- -- blubb ---->"""),
("""<!-- -- >< 8>""", """<!-- -->< 8>"""),
("""<!---- >< 6>""", """<!-- -->< 6>"""),
("""<!- blubb ->""", """<!-- - blubb - -->"""),
("""<! -- blubb -->""", """<!-- -- blubb -- -->"""),
("""<!-- blubb -- >""", """<!-- blubb -->"""),
("""<! blubb !>< a>""", """<!-- blubb !-->< a>"""),
("""<! blubb !>< a>""", """<!-- blubb ! -->< a>"""),
("""<! blubb >< a>""", """<!-- blubb -->< a>"""),
# end tags
("""</a>""", """"""),