Skip to content

Commit

Permalink
fix: max attribute length with longer regex custom html tags (#884)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverhaas authored Aug 28, 2024
1 parent 892dac1 commit a8e3835
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/djlint/formatter/indent.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def fix_handlebars_template_tags(html: str, match: re.Match) -> str:

tmp = re.sub(
re.compile(
rf"(\s*?)(<(?:{config.indent_html_tags})\b)((?:\"[^\"]*\"|'[^']*'|{{[^}}]*}}|[^'\">{{}}\/])+?)(\s?/?>)",
rf"(\s*?)(<(?:{config.indent_html_tags}))\s((?:\"[^\"]*\"|'[^']*'|{{[^}}]*}}|[^'\">{{}}\/])+?)(\s?/?>)",
re.VERBOSE | re.IGNORECASE,
),
func,
Expand Down
6 changes: 6 additions & 0 deletions tests/test_config/test_max_attribute_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@
({"max_attribute_length": 10000, "max_line_length": 1000}),
id="longest lines",
),
pytest.param(
("<tag-looooong></tag-looooong>\n"),
("<tag-looooong>\n</tag-looooong>\n"),
({"max_attribute_length": 3, "custom_html": "[\\w\\-]+"}),
id="long tag custom_html",
),
]


Expand Down

0 comments on commit a8e3835

Please sign in to comment.