mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-14 16:23:08 +00:00
fixed #35
This commit is contained in:
parent
324582c581
commit
92872bc53c
6 changed files with 25 additions and 5 deletions
|
|
@ -12,7 +12,7 @@
|
|||
project = "djlint"
|
||||
copyright = "2021, Riverside Healthcare"
|
||||
author = "Christopher Pickering"
|
||||
release = "0.4.8"
|
||||
release = "0.4.9"
|
||||
version = release
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
0.4.9
|
||||
-----
|
||||
- Fixed bug `#35 <https://github.com/Riverside-Healthcare/djLint/issues/35>`_
|
||||
|
||||
0.4.8
|
||||
-----
|
||||
- Fixed bug `#34 <https://github.com/Riverside-Healthcare/djLint/issues/34>`_
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ build-backend = "poetry.core.masonry.api"
|
|||
|
||||
[tool.poetry]
|
||||
name="djlint"
|
||||
version="0.4.8"
|
||||
version="0.4.9"
|
||||
description="HTML Template Linter and Formatter"
|
||||
license="GPL-3.0-or-later"
|
||||
authors=["Christopher Pickering <cpickering@rhc.net>"]
|
||||
|
|
|
|||
|
|
@ -174,10 +174,12 @@ def indent_html(rawcode: str, config: Config) -> str:
|
|||
if config.blank_line_after_tag:
|
||||
for tag in [x.strip() for x in config.blank_line_after_tag.split(",")]:
|
||||
beautified_code = re.sub(
|
||||
fr"((?:{{%\s*?{tag}[^}}]+?%}}\n?)+)",
|
||||
re.compile(
|
||||
fr"((?:^{{%\s*?{tag}[^}}]+?%}}\n?)+)",
|
||||
re.IGNORECASE | re.MULTILINE | re.DOTALL,
|
||||
),
|
||||
r"\1\n",
|
||||
beautified_code,
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
return beautified_code.strip() + "\n"
|
||||
|
|
|
|||
5
tests/config_blank_lines_after_tag/html_three.html
Normal file
5
tests/config_blank_lines_after_tag/html_three.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<div class="tab-cnt">
|
||||
<div class="tab-dta active" id="details">
|
||||
<div class="em-grid">{% include "pages/task/details_source.html.j2" %}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -7,7 +7,7 @@ run::
|
|||
|
||||
for a single test, run::
|
||||
|
||||
pytest tests/test_config.py::test_profile --cov=src/djlint \
|
||||
pytest tests/test_config.py::test_blank_lines_after_tag --cov=src/djlint \
|
||||
--cov-branch --cov-report xml:coverage.xml --cov-report term-missing
|
||||
|
||||
"""
|
||||
|
|
@ -91,6 +91,7 @@ def test_blank_lines_after_tag(runner: CliRunner) -> None:
|
|||
result = runner.invoke(
|
||||
djlint, ["tests/config_blank_lines_after_tag/html.html", "--check"]
|
||||
)
|
||||
|
||||
assert (
|
||||
"""+{% extends "nothing.html" %}
|
||||
+
|
||||
|
|
@ -117,6 +118,14 @@ def test_blank_lines_after_tag(runner: CliRunner) -> None:
|
|||
assert """1 file would be updated.""" in result.output
|
||||
assert result.exit_code == 1
|
||||
|
||||
# check blocks that do not start on a newline - they should be left as is.
|
||||
result = runner.invoke(
|
||||
djlint, ["tests/config_blank_lines_after_tag/html_three.html", "--check"]
|
||||
)
|
||||
|
||||
assert """0 files would be updated.""" in result.output
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_profile(runner: CliRunner) -> None:
|
||||
result = runner.invoke(djlint, ["tests/config_profile/html.html"])
|
||||
|
|
|
|||
Loading…
Reference in a new issue