Skip to content

Commit

Permalink
fix(formatter): don't add blank line to empty files
Browse files Browse the repository at this point in the history
closes #635
  • Loading branch information
christopherpickering committed May 18, 2023
1 parent 09a6ced commit 8ea5fd2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/djlint/reformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

def formatter(config: Config, rawcode: str) -> str:
"""Format a html string."""
if not rawcode:
return rawcode

# naturalize the line breaks
compressed = compress_html(("\n").join(rawcode.splitlines()), config)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_html/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
),
id="emtpy_doc",
),
pytest.param("", "\n", id="empty"),
pytest.param("", "", id="empty"),
pytest.param(
(
"<form>\n"
Expand Down

0 comments on commit 8ea5fd2

Please sign in to comment.