From a8e38359c7cf7f16936bdb46348b74bd7e7a7ff8 Mon Sep 17 00:00:00 2001 From: Oliver Haas Date: Wed, 28 Aug 2024 15:10:46 +0200 Subject: [PATCH] fix: max attribute length with longer regex custom html tags (#884) --- src/djlint/formatter/indent.py | 2 +- tests/test_config/test_max_attribute_length.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/djlint/formatter/indent.py b/src/djlint/formatter/indent.py index f455c39c2..330ab10a5 100644 --- a/src/djlint/formatter/indent.py +++ b/src/djlint/formatter/indent.py @@ -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, diff --git a/tests/test_config/test_max_attribute_length.py b/tests/test_config/test_max_attribute_length.py index 7a4e1f949..4e58ce9bb 100644 --- a/tests/test_config/test_max_attribute_length.py +++ b/tests/test_config/test_max_attribute_length.py @@ -89,6 +89,12 @@ ({"max_attribute_length": 10000, "max_line_length": 1000}), id="longest lines", ), + pytest.param( + ("\n"), + ("\n\n"), + ({"max_attribute_length": 3, "custom_html": "[\\w\\-]+"}), + id="long tag custom_html", + ), ]