@@ -54,7 +54,7 @@ def _getChildNodes(self):
5454def testSerializer (element ):
5555 rv = []
5656 finalText = None
57- infosetFilter = ihatexml .InfosetFilter ()
57+ infosetFilter = ihatexml .InfosetFilter (preventDoubleDashComments = True )
5858
5959 def serializeElement (element , indent = 0 ):
6060 if not hasattr (element , "tag" ):
@@ -189,7 +189,7 @@ class TreeBuilder(_base.TreeBuilder):
189189
190190 def __init__ (self , namespaceHTMLElements , fullTree = False ):
191191 builder = etree_builders .getETreeModule (etree , fullTree = fullTree )
192- infosetFilter = self .infosetFilter = ihatexml .InfosetFilter ()
192+ infosetFilter = self .infosetFilter = ihatexml .InfosetFilter (preventDoubleDashComments = True )
193193 self .namespaceHTMLElements = namespaceHTMLElements
194194
195195 class Attributes (dict ):
@@ -257,7 +257,7 @@ def _getData(self):
257257 data = property (_getData , _setData )
258258
259259 self .elementClass = Element
260- self .commentClass = builder . Comment
260+ self .commentClass = Comment
261261 # self.fragmentClass = builder.DocumentFragment
262262 _base .TreeBuilder .__init__ (self , namespaceHTMLElements )
263263
@@ -344,7 +344,8 @@ def insertRoot(self, token):
344344
345345 # Append the initial comments:
346346 for comment_token in self .initial_comments :
347- root .addprevious (etree .Comment (comment_token ["data" ]))
347+ comment = self .commentClass (comment_token ["data" ])
348+ root .addprevious (comment ._element )
348349
349350 # Create the root document and add the ElementTree to it
350351 self .document = self .documentClass ()
0 commit comments