Skip to content

Commit 2b413e0

Browse files
Indent contents of comment tag
1 parent 7b1a07e commit 2b413e0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

pyhtml/__tag_base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ def _render(self) -> list[str]:
111111

112112
return [
113113
'<!--',
114-
*util.escape_string(self.comment_data).splitlines(),
114+
*util.increase_indent(
115+
util.escape_string(self.comment_data).splitlines(),
116+
# FIXME: Yucky magic number
117+
2,
118+
),
115119
'-->'
116120
]
117121

tests/basic_rendering_test.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_renders_properties():
5353
def test_comment_renders():
5454
assert str(Comment("Hello world")) == '\n'.join([
5555
'<!--',
56-
'Hello world',
56+
' Hello world',
5757
'-->',
5858
])
5959

@@ -115,3 +115,10 @@ def test_larger_page():
115115
' </body>',
116116
'</html>',
117117
])
118+
119+
120+
def test_format_through_repr():
121+
"""Is HTML rendered through repr?"""
122+
doc = html()
123+
124+
assert repr(doc) == "<html></html>"

0 commit comments

Comments
 (0)