File tree Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -125,15 +125,15 @@ def fix_handlebars_template_tags(
125
125
re .search (
126
126
rf"""^(?:[^<\s].*?)? # start of a line, optionally with some text
127
127
(?:
128
- <({ slt_html } )(?:(?:>|\b[^>]+?>)(?:.*?)(?:</(?:\1)>)|\b[^>]*? />) # <span stuff-or-not>stuff</span> or <img stuff /> >>> match 1
128
+ <({ slt_html } )(?:(?:>|\b[^>]+?>)(?:.*?)(?:</(?:\1)>)|\b(?: [^>"']|"[^"]*"|'[^']*')*?\ />) # <span stuff-or-not>stuff</span> or <img stuff /> >>> match 1
129
129
|(?:<(?:{ always_self_closing_html } )\b[^>]*?/?>) # <img stuff />
130
130
|(?:{{%[ ]*?({ slt_template } )[ ]+?.*?%}})(?:.*?)(?:{{%[ ]+?end(?:\2)[ ]+?.*?%}}) # >>> match 2
131
131
|{ config .ignored_inline_blocks }
132
132
)[ \t]*?
133
133
(?:
134
134
.*? # anything
135
135
(?: # followed by another slt
136
- <({ slt_html } )(?:(?:>|\b[^>]+?>)(?:.*?)(?:</(?:\3)>)|\b[^>]*? />) # <span stuff-or-not>stuff</span> or <img stuff /> >>> match 3
136
+ <({ slt_html } )(?:(?:>|\b[^>]+?>)(?:.*?)(?:</(?:\3)>)|\b(?: [^>"']|"[^"]*"|'[^']*')*?\ />) # <span stuff-or-not>stuff</span> or <img stuff /> >>> match 3
137
137
|(?:<(?:{ always_self_closing_html } )\b[^>]*?/?>) # <img stuff />
138
138
|(?:{{%[ ]*?({ slt_template } )[ ]+?.*?%}})(?:.*?)(?:{{%[ ]+?end(?:\4)[ ]+?.*?%}}) # >>> match 4
139
139
|{ config .ignored_inline_blocks }
Original file line number Diff line number Diff line change
1
+ """Test for _hyperscript.
2
+
3
+ uv run pytest tests/test_html/test_hyperscript.py
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import TYPE_CHECKING
9
+
10
+ import pytest
11
+
12
+ from djlint .reformat import formatter
13
+ from tests .conftest import printer
14
+
15
+ if TYPE_CHECKING :
16
+ from djlint .settings import Config
17
+
18
+ test_data = [
19
+ pytest .param (
20
+ (
21
+ "<div _='on click increment :x then put it into the <output/> in me'>\n "
22
+ ' Clicks:\n '
23
+ ' <output>0</output>\n '
24
+ '</div>\n '
25
+ ),
26
+ (
27
+ "<div _='on click increment :x then put it into the <output/> in me'>\n "
28
+ ' Clicks:\n '
29
+ ' <output>0</output>\n '
30
+ '</div>\n '
31
+ ),
32
+ id = "html_tags_in_attributes" ,
33
+ ),
34
+ ]
35
+
36
+
37
+ @pytest .mark .parametrize (("source" , "expected" ), test_data )
38
+ def test_base (source : str , expected : str , basic_config : Config ) -> None :
39
+ output = formatter (basic_config , source )
40
+
41
+ printer (expected , source , output )
42
+ assert expected == output
You can’t perform that action at this time.
0 commit comments