added script and style tags to single line tags. fixed #68 and added test

This commit is contained in:
Christopher Pickering 2021-10-07 08:16:04 +02:00
parent f4f6c32a04
commit 863efbf116
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
3 changed files with 22 additions and 2 deletions

View file

@ -102,5 +102,5 @@ def compress_html(html: str, config: Config) -> str:
r"\1\3\4",
html,
)
print(html)
return html

View file

@ -564,6 +564,8 @@ class Config:
| label
| div
| li
| script
| style
"""
self.always_single_line_html_tags: str = r"""

View file

@ -5,7 +5,7 @@ run::
pytest tests/test_html.py --cov=src/djlint --cov-branch \
--cov-report xml:coverage.xml --cov-report term-missing
pytest tests/test_html.py::test_long_attributes --cov=src/djlint --cov-branch \
pytest tests/test_html.py::test_style_tag --cov=src/djlint --cov-branch \
--cov-report xml:coverage.xml --cov-report term-missing
@ -53,6 +53,15 @@ console.log();
"""
)
# check script includes
output = reformat(
tmp_file,
runner,
b"""<script src="{% static 'common/js/foo.min.js' %}"></script>""",
)
assert output["exit_code"] == 0
def test_html_comments_tag(runner: CliRunner, tmp_file: TextIO) -> None:
write_to_file(
@ -343,3 +352,12 @@ def test_style_tag(runner: CliRunner, tmp_file: TextIO) -> None:
)
assert output["exit_code"] == 0
# check style includes
output = reformat(
tmp_file,
runner,
b"""<link href="{% static 'common/js/foo.min.js' %}" />""",
)
assert output["exit_code"] == 0