Merge pull request #32 from matthiask/mk/no-source-indent

Do not indent the <source> element, it does not permit content
This commit is contained in:
sur.la.route 2021-09-30 14:29:54 +02:00 committed by GitHub
commit 6fc9cf45d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View file

@ -227,7 +227,6 @@ class Config:
| path
| script
| style
| source
| details
| summary
)
@ -287,7 +286,6 @@ class Config:
| path
| script
| style
| source
| details
| summary
)
@ -445,6 +443,7 @@ class Config:
link
| img
| meta
| source
"""
self.single_line_template_tags: str = r"""

View file

@ -199,3 +199,21 @@ def test_ignored_attributes(runner: CliRunner, tmp_file: TextIO) -> None:
json-data='{"menu":{"header":"SVG Viewer","items":[{"id":"Open"}]}}'></div>
"""
)
def test_picture_source_img_tags(runner: CliRunner, tmp_file: TextIO) -> None:
write_to_file(
tmp_file.name,
b"""\
<picture><source media="(max-width:640px)"
srcset="image.jpg"><img src="image.jpg" alt="image"></picture>""",
)
runner.invoke(djlint, [tmp_file.name, "--reformat"])
assert (
Path(tmp_file.name).read_text()
== """<picture>
<source media="(max-width:640px)" srcset="image.jpg">
<img src="image.jpg" alt="image">
</picture>
"""
)