Skip to content

Commit

Permalink
Merge pull request #638 from Riverside-Healthcare/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherpickering authored May 10, 2023
2 parents 2a0661f + e65558c commit c0d2db0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/djlint/formatter/indent.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def format_set(config, match):
# format set contents
beautified_code = re.sub(
re.compile(
r"([ ]*{%-?)[ ]*(set)((?:(?!%}).)*?)(-?%})",
r"([ ]*{%-?)[ ]*(set)[ ]+?((?:(?!%}).)*?)(-?%})",
flags=re.IGNORECASE | re.MULTILINE | re.VERBOSE | re.DOTALL,
),
func,
Expand Down
2 changes: 1 addition & 1 deletion src/djlint/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,4 @@
message: Duplicate attribute found.
flags: re.I
patterns:
- <\w[^>]*?\s\K([a-z][a-z-]*?)(?==[^>]+?\1=[^>]*?>)
- <\w[^>]*?\s\K([a-z-][a-z-]*?)(?==[^>]+?[^-]\1=[^>]*?>)
11 changes: 1 addition & 10 deletions tests/test_linter/test_django_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,7 @@
),
pytest.param(
('<form action="{% url \'something\' %}" data-action="xxx"></form>'),
(
[
{
"code": "H037",
"line": "1:6",
"match": "action",
"message": "Duplicate attribute found.",
}
]
),
([]),
id="DJ018_data_action",
),
pytest.param(
Expand Down
19 changes: 19 additions & 0 deletions tests/test_linter/test_h037.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@
([]),
id="mismatch names",
),
pytest.param(
('<svg -width="16" -width="2"></svg>'),
(
[
{
"code": "H037",
"line": "1:5",
"match": "-width",
"message": "Duplicate attribute found.",
}
]
),
id="leading hyphen names",
),
pytest.param(
('<svg width="16" stroke-width="2"></svg>'),
([]),
id="mismatch hyphen names",
),
pytest.param(
(
'<a href="" ></a><a href=""></a><a href=""></a><a href=""></a><a href=""></a><a href=""></a>'
Expand Down
6 changes: 6 additions & 0 deletions tests/test_nunjucks/test_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
({}),
id="set_with_sibling",
),
pytest.param(
('<title>{% set_title "My Title" %}</title>'),
('<title>{% set_title "My Title" %}</title>\n'),
({}),
id="don't break underscore stuff",
),
pytest.param(
(
"{% set schema=[\n"
Expand Down

0 comments on commit c0d2db0

Please sign in to comment.