mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-04 03:44:43 +00:00
parent
3c1c125595
commit
4ac5fd0da8
2 changed files with 32 additions and 1 deletions
|
|
@ -101,6 +101,17 @@ def indent_html(rawcode: str, config: Config) -> str:
|
||||||
)
|
)
|
||||||
and is_block_raw is False
|
and is_block_raw is False
|
||||||
and not is_safe_closing_tag(config, item)
|
and not is_safe_closing_tag(config, item)
|
||||||
|
# and not ending in a slt like <span><strong></strong>.
|
||||||
|
and not re.findall(
|
||||||
|
rf"(<({slt_html})>)(.*?)(</(\2)>[^<]*?$)",
|
||||||
|
item,
|
||||||
|
re.IGNORECASE | re.VERBOSE | re.MULTILINE,
|
||||||
|
)
|
||||||
|
and not re.findall(
|
||||||
|
rf"(<({slt_html})\\b.+?>)(.*?)(</(\2)>[^<]*?$)",
|
||||||
|
item,
|
||||||
|
re.IGNORECASE | re.VERBOSE | re.MULTILINE,
|
||||||
|
)
|
||||||
):
|
):
|
||||||
# block to catch inline block followed by a non-break tag
|
# block to catch inline block followed by a non-break tag
|
||||||
if (
|
if (
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ run:
|
||||||
pytest tests/test_html/test_tag_span.py --cov=src/djlint --cov-branch \
|
pytest tests/test_html/test_tag_span.py --cov=src/djlint --cov-branch \
|
||||||
--cov-report xml:coverage.xml --cov-report term-missing
|
--cov-report xml:coverage.xml --cov-report term-missing
|
||||||
|
|
||||||
pytest tests/test_html/test_tag_span.py::test_span_tag
|
pytest tests/test_html/test_tag_span.py::test_nested_string
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
@ -45,3 +45,23 @@ def test_span_tag(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||||
</div>""",
|
</div>""",
|
||||||
) # noqa: E501
|
) # noqa: E501
|
||||||
assert output.exit_code == 0
|
assert output.exit_code == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_nested_string(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||||
|
write_to_file(
|
||||||
|
tmp_file.name,
|
||||||
|
b"""<p><p><span><strong>asdf</strong><br></span></p></p>""",
|
||||||
|
)
|
||||||
|
runner.invoke(djlint, [tmp_file.name, "--reformat"])
|
||||||
|
|
||||||
|
assert (
|
||||||
|
Path(tmp_file.name).read_text(encoding="utf8")
|
||||||
|
== """<p>
|
||||||
|
<p>
|
||||||
|
<span><strong>asdf</strong>
|
||||||
|
<br>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</p>
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue