Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(H016): Allow attributes on <title> #830

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/djlint/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@
message: Missing title tag in html.
flags: re.DOTALL|re.I
patterns:
- <html[^>]*?>(?:(?!<title>).)*</html>
# Title allow a list of global attributes.
# https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#list_of_global_attributes
- <html[^>]*?>(?:(?!<title(\s+(class|data-[\-\._0-9a-zA-Z:]+|dir|id|lang|translate)=\"[^"]*\")*>).)*</html>
- rule:
name: H017
message: Void tags should be self closing.
Expand Down
10 changes: 10 additions & 0 deletions tests/test_linter/test_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ def test_H016(runner: CliRunner, tmp_file: TextIO) -> None:
result = runner.invoke(djlint, [tmp_file.name])
assert "H016" not in result.output

write_to_file(
tmp_file.name,
b"""\
<html>
<title id="title-reload-with-htmx" data-foo="bar">stuff</title>
</html>""",
)
result = runner.invoke(djlint, [tmp_file.name])
assert "H016" not in result.output


def test_H017(runner: CliRunner, tmp_file: TextIO) -> None:
write_to_file(tmp_file.name, b"<img this >")
Expand Down