fixed #146, added test, updated version

This commit is contained in:
Christopher Pickering 2021-11-26 09:45:00 +01:00
parent ec60646b36
commit a053175663
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
7 changed files with 20 additions and 7 deletions

View file

@ -12,7 +12,7 @@
project = "djlint"
copyright = "2021, Riverside Healthcare"
author = "Christopher Pickering"
release = "0.6.2"
release = "0.6.3"
version = release
# -- General configuration ---------------------------------------------------

View file

@ -1,9 +1,10 @@
Changelog
=========
next release
------------
0.6.3
-----
- Added support for django `blocktrans` tag
- Bug fixes
0.6.2
-----

View file

@ -7,7 +7,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name="djlint"
version="0.6.2"
version="0.6.3"
description="HTML Template Linter and Formatter"
license="GPL-3.0-or-later"
authors=["Christopher Pickering <cpickering@rhc.net>"]

View file

@ -66,7 +66,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(
fr"((?:{{%\s*?{tag}[^}}]+?%}}\n?)+)",
fr"((?:{{%\s*?{tag}\b[^}}]+?%}}\n?)+)",
re.IGNORECASE | re.MULTILINE | re.DOTALL,
),
func,

View file

@ -0,0 +1,6 @@
{% blocktrans %}my words{% endblocktrans %}
{% block body %}
<div></div>
{% endblock body %}
{% block js %}{% endblock %}

View file

@ -1,3 +1,3 @@
[tool]
[tool.djlint]
blank_line_after_tag = "load, extends, include "
blank_line_after_tag = "load, extends, include ,endblock "

View file

@ -7,7 +7,7 @@ run::
for a single test, run::
pytest tests/test_config.py::test_exclude --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
"""
@ -153,6 +153,12 @@ def test_blank_lines_after_tag(runner: CliRunner) -> None:
)
assert result.exit_code == 0
# make sure endblock doesn't pick up endblocktrans :)
result = runner.invoke(
djlint, ["tests/config_blank_lines_after_tag/html_seven.html", "--check"]
)
assert result.exit_code == 0
def test_profile(runner: CliRunner) -> None:
result = runner.invoke(djlint, ["tests/config_profile/html.html"])