diff --git a/src/djlint/formatter/expand.py b/src/djlint/formatter/expand.py index 9363304..4ea2d32 100644 --- a/src/djlint/formatter/expand.py +++ b/src/djlint/formatter/expand.py @@ -61,13 +61,13 @@ def expand_html(html: str, config: Config) -> str: if inside_ignored_block(config, html, match): return match.group(1) - if not re.findall( r"\<(?:" + str(config.indent_html_tags) - + r")\b(?:[^>]|{%[^(?:%}]*?%}|{{[^(?:}}]*?}})*?" - + re.escape(match.group(1)) - + "$", + + r")\b(?:\"[^\"]*\"|'[^']*'|{{[^}]*}}|{%[^%]*%}|{\#[^\#]*\#}|[^>{}])*?" + # original + # + r")\b(?:[^>]|{%[^(?:%}]*?%}|{{[^(?:}}]*?}})*?" + + re.escape(match.group(1)) + "$", html[: match.end()], re.MULTILINE | re.VERBOSE, ): diff --git a/src/djlint/rules.yaml b/src/djlint/rules.yaml index d1d2f5c..42fac5e 100644 --- a/src/djlint/rules.yaml +++ b/src/djlint/rules.yaml @@ -185,7 +185,7 @@ message: Tag seems to be an orphan. flags: re.I|re.DOTALL patterns: - - <((/?(\w+))\b(\"[^\"]*\"|'[^']*'|{{[^}]*}}|{%[^%]*%}|{#[^%]*#}|[^'\">{}])*)(? + - <((/?(\w+))\b(\"[^\"]*\"|'[^']*'|{{[^}]*}}|{%[^%]*%}|{#[^#]*#}|[^'\">{}])*)(? - rule: name: H026 message: Empty id and class tags can be removed.