Skip to content

Commit

Permalink
Indent contents of comment tag
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyGuthridge committed Sep 29, 2023
1 parent 7b1a07e commit 2b413e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pyhtml/__tag_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ def _render(self) -> list[str]:

return [
'<!--',
*util.escape_string(self.comment_data).splitlines(),
*util.increase_indent(
util.escape_string(self.comment_data).splitlines(),
# FIXME: Yucky magic number
2,
),
'-->'
]

Expand Down
9 changes: 8 additions & 1 deletion tests/basic_rendering_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_renders_properties():
def test_comment_renders():
assert str(Comment("Hello world")) == '\n'.join([
'<!--',
'Hello world',
' Hello world',
'-->',
])

Expand Down Expand Up @@ -115,3 +115,10 @@ def test_larger_page():
' </body>',
'</html>',
])


def test_format_through_repr():
"""Is HTML rendered through repr?"""
doc = html()

assert repr(doc) == "<html></html>"

0 comments on commit 2b413e0

Please sign in to comment.