fix(css/js): fixed extra blank lines being appended to blank lines in css/js formatter

closes #451
This commit is contained in:
Christopher Pickering 2022-11-08 08:33:45 +01:00
parent 371f5c5d51
commit 10e593f623
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
4 changed files with 28 additions and 3 deletions

View file

@ -37,7 +37,7 @@ def format_css(html: str, config: Config) -> str:
line = line.lstrip()
ignore_indent = False
if ignore_indent is False:
if ignore_indent is False and line:
beautified += "\n" + inner_indent + line
else:

View file

@ -38,9 +38,9 @@ def format_js(html: str, config: Config) -> str:
line = line.lstrip()
ignore_indent = False
if ignore_indent is False:
if ignore_indent is False and line:
beautified += "\n" + inner_indent + line
else:
beautified += "\n" + line

View file

@ -0,0 +1,14 @@
<html>
<head>
<style>
body {}
div {}
</style>
</head>
<script>
let a;
let b;
</script>
</html>

View file

@ -35,3 +35,14 @@ def test_ignore(runner: CliRunner) -> None:
],
)
assert result.exit_code == 0
def text_blank_lines(runner: CliRunner) -> None:
result = runner.invoke(
djlint,
[
"tests/test_config/test_scripts_styles/blank_lines.html",
"--check",
],
)
assert result.exit_code == 0