Represent a comment element.
The comment tag does not support any standard attributes.
Represent a comment element.
The comment tag does not support any standard attributes.
Create a comment node.
def __init__(self, parent: str, content: str=' --- '):
"""Create a comment node.
:param parent: (str) Identifier of the parent node
:param content: (str) The comment message
"""
super(HTMLComment, self).__init__(parent, str(uuid.uuid1()))
self._value = str(content)
Serialize the comment into HTML.
def serialize(self, nbs: int=4) -> str:
"""Serialize the comment into HTML.
:param nbs: (int) Number of spaces for the indentation
:return: (str)
"""
indent = ' ' * nbs
html = '\n'
html += indent + '<!-- '
r = (70 - len(self._value)) // 2
if r > 0:
html += '-' * r
html += ' ' + self._value + ' '
if r > 0:
html += '-' * r
html += ' -->\n\n'
return html