mirror of
https://github.com/Hopiu/djLint.git
synced 2026-04-03 22:20:29 +00:00
fix(white space): prevent duplicate blank lines from being added
closes #297.
This commit is contained in:
parent
0bebf846d3
commit
67306b4cd1
3 changed files with 16 additions and 2 deletions
|
|
@ -94,7 +94,7 @@ def condense_html(html: str, config: Config) -> str:
|
|||
for tag in [x.strip() for x in config.blank_line_after_tag.split(",")]:
|
||||
html = re.sub(
|
||||
re.compile(
|
||||
rf"((?:{{%\s*?{tag}\b[^}}]+?%}}\n?)+)",
|
||||
rf"((?:{{%\s*?{tag}\b[^}}]+?%}}\n?)+)(?=[^\n])",
|
||||
re.IGNORECASE | re.MULTILINE | re.DOTALL,
|
||||
),
|
||||
func,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
{% extends nothing %}
|
||||
|
||||
<div></div>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
run::
|
||||
|
||||
pytest tests/test_config.py --cov=src/djlint --cov-branch \
|
||||
pytest tests/test_config/test_blank_lines_after_tag/test_config.py --cov=src/djlint --cov-branch \
|
||||
--cov-report xml:coverage.xml --cov-report term-missing
|
||||
|
||||
for a single test, run::
|
||||
|
|
@ -94,3 +94,14 @@ def test_blank_lines_after_tag(runner: CliRunner) -> None:
|
|||
["tests/test_config/test_blank_lines_after_tag/html_seven.html", "--check"],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
|
||||
# check that multiple blank lines are not added
|
||||
result = runner.invoke(
|
||||
djlint,
|
||||
[
|
||||
"tests/test_config/test_blank_lines_after_tag/html_eight.html",
|
||||
"--preserve-blank-lines",
|
||||
"--check",
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue