mirror of
https://github.com/Hopiu/djLint.git
synced 2026-03-16 21:40:24 +00:00
fix(css/js): fixed extra blank lines being appended to blank lines in css/js formatter
closes #451
This commit is contained in:
parent
371f5c5d51
commit
10e593f623
4 changed files with 28 additions and 3 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
14
tests/test_config/test_scripts_styles/blank_lines.html
Normal file
14
tests/test_config/test_scripts_styles/blank_lines.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {}
|
||||
|
||||
div {}
|
||||
</style>
|
||||
</head>
|
||||
<script>
|
||||
let a;
|
||||
|
||||
let b;
|
||||
</script>
|
||||
</html>
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue