diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 02d63d3..18dbd97 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
- python-version: [3.7, 3.8, 3.9, '3.10']
+ python-version: [3.7, 3.8, 3.9, '3.10', 3.11-dev]
fail-fast: true
steps:
@@ -45,7 +45,7 @@ jobs:
# remove windows-latest, half tests seem to randomly pass
matrix:
os: [ubuntu-latest]
- python-version: [3.7, 3.8, 3.9, '3.10']
+ python-version: [3.7, 3.8, 3.9, '3.10', 3.11-dev]
node: [ 12, 14, 16 ]
fail-fast: true
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index e19ae09..16a879c 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -43,9 +43,3 @@ repos:
args: [--autofix]
- id: pretty-format-yaml
args: [--autofix, --indent, '2']
-repos:
- - repo: https://github.com/christopherpickering/pre-commit-hooks
- rev: 0.0.6
- hooks:
- - id: poetry-to-requirements
- args: [--output=requirements.txt]
\ No newline at end of file
diff --git a/docs/src/docs/linter.md b/docs/src/docs/linter.md
index 206098b..8a486fe 100644
--- a/docs/src/docs/linter.md
+++ b/docs/src/docs/linter.md
@@ -90,6 +90,7 @@ The first letter of a code follows the pattern:
| T027 | Unclosed string found in template syntax. |
| T028 | Consider using spaceless tags inside attribute values. {% raw %}`{%- if/for -%}`{% endraw %} |
| T032 | Extra whitespace found in template tags. |
+| T034 | Did you intend to use {% raw %}{% ... %} instead of {% ... }%? {% endraw %} |
### Adding Rules
diff --git a/docs/src/fr/docs/linter.md b/docs/src/fr/docs/linter.md
index 694ec8e..0cab56f 100644
--- a/docs/src/fr/docs/linter.md
+++ b/docs/src/fr/docs/linter.md
@@ -90,6 +90,7 @@ La première lettre d'un code suit le modèle :
| T027 | Chaîne non fermée trouvée dans la syntaxe du modèle. |
| T028 | Envisagez d'utiliser des balises sans espace à l'intérieur des valeurs d'attributs. {% raw %}`{%- if/for -%}`{% endraw %} |
| T032 | Espace blanc supplémentaire trouvé dans les balises du modèle. |
+| T034 | Aviez-vous l'intention d'utiliser {% raw %}{% ... %} au lieu de {% ... }% ? {% endraw %} |
### Ajout de règles
diff --git a/docs/src/ru/docs/linter.md b/docs/src/ru/docs/linter.md
index 12721f8..4582650 100644
--- a/docs/src/ru/docs/linter.md
+++ b/docs/src/ru/docs/linter.md
@@ -90,6 +90,7 @@ djlint /path/to/this.html.j2 --profile=jinja
| T027 | В синтаксисе шаблона найдена незакрытая строка. |
| T028 | Рассмотрите возможность использования тегов без пробелов внутри значений атрибутов. {% raw %}`{%- if/for -%}`{% endraw %} |
| T032 | В тегах шаблона обнаружены лишние пробелы. |
+| T034 | Вы намеревались использовать {% raw %}{% ... %} вместо {% ... }%? {% endraw %} |
### Добавление правил
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index 7fcc4dd..0000000
--- a/requirements.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-astroid==2.12.9; python_full_version >= "3.7.2"
-attrs==22.1.0; python_version >= "3.7"
-black==22.8.0; python_full_version >= "3.6.2"
-click==8.1.3; python_version >= "3.7"
-colorama==0.4.5; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
-coverage==6.4.4; python_version >= "3.7"
-cssbeautifier==1.14.6
-dill==0.3.5.1; python_full_version >= "3.7.2"
-distlib==0.3.6; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
-editorconfig==0.12.3
-execnet==1.9.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
-filelock==3.8.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-flake8==3.9.2; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-html-tag-names==0.1.2; python_version >= "3.7" and python_version < "4.0"
-html-void-elements==0.1.0; python_version >= "3.7" and python_version < "4.0"
-importlib-metadata==4.12.0; python_version >= "3.7"
-iniconfig==1.1.1; python_version >= "3.7"
-isort==5.10.1; python_full_version >= "3.6.1" and python_version < "4.0"
-jsbeautifier==1.14.6
-lazy-object-proxy==1.7.1; python_version >= "3.6" and python_full_version >= "3.7.2"
-mccabe==0.7.0; python_full_version >= "3.7.2" and python_version >= "3.7"
-mypy-extensions==0.4.3; python_full_version >= "3.6.2" and python_version >= "3.6"
-mypy==0.971; python_version >= "3.6"
-packaging==21.3; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-pathspec==0.10.1; python_version >= "3.7"
-pep8-naming==0.13.2; python_version >= "3.7"
-platformdirs==2.5.2; python_version >= "3.7" and python_full_version >= "3.7.2" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7")
-pluggy==1.0.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-py==1.11.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-pycodestyle==2.9.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-pyflakes==2.5.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-pylint==2.15.2; python_full_version >= "3.7.2"
-pyparsing==3.0.9; python_full_version >= "3.6.8" and python_version >= "3.7"
-pytest-cov==3.0.0; python_version >= "3.6"
-pytest-forked==1.4.0; python_version >= "3.6"
-pytest-xdist==2.5.0; python_version >= "3.6"
-pytest==7.1.3; python_version >= "3.7"
-pyyaml==6.0; python_version >= "3.6"
-regex==2022.9.11; python_version >= "3.6"
-six==1.16.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
-tomli==2.0.1; python_full_version <= "3.11.0a6" and python_full_version >= "3.7.2" and python_version >= "3.7" and python_version < "3.11" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0") or python_version < "3.11"
-tomlkit==0.11.4; python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.7.2"
-tox==3.26.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
-tqdm==4.64.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")
-typed-ast==1.5.4; python_version < "3.8" and implementation_name == "cpython" and python_full_version >= "3.7.2" and python_version >= "3.6"
-types-pyyaml==6.0.11
-typing-extensions==4.3.0; python_version < "3.8" and python_version >= "3.7" and python_full_version >= "3.7.2" and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.5.0" and python_version < "3.8" and python_version >= "3.7")
-virtualenv==20.16.5; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
-wrapt==1.14.1
-zipp==3.8.1; python_version < "3.8" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.5.0" and python_version < "3.8" and python_version >= "3.7")
diff --git a/src/djlint/formatter/indent.py b/src/djlint/formatter/indent.py
index de813d8..df2eaee 100644
--- a/src/djlint/formatter/indent.py
+++ b/src/djlint/formatter/indent.py
@@ -62,34 +62,24 @@ def indent_html(rawcode: str, config: Config) -> str:
# if a one-line, inline tag, just process it, only if line starts w/ it
elif (
- re.findall(
- rf"(^<({slt_html})>)(.*?)((\2)>[^<]*?$)",
- item,
- re.IGNORECASE | re.VERBOSE | re.MULTILINE,
- )
- or re.findall(
- re.compile(
- rf"(<({slt_html})\b.+?>)(.*?)((\2)>[^<]*?$)",
+ (
+ re.findall(
+ rf"""^ # start of a line
+ (?:
+ (?:<({slt_html})>)(?:.*?)(?:(?:\1)>[ \t]*?) # stuff >>>> match 1
+ |(?:<({slt_html})\b[^>]+?>)(?:.*?)(?:(?:\2)>[ \t]*?) # stuff >>> match 2
+ |(?:<(?:{always_self_closing_html})\b[^>]*?/?>[ \t]*?) #
+ |(?:<(?:{slt_html})\b[^>]*?/>[ \t]*?) #
+ |(?:{{%[ ]*?({slt_template})[ ]+?.*?%}})(?:.*?)(?:{{%[ ]+?end(\3)[ ]+?.*?%}}[ \t]*?) # >>> match 3
+ )
+ +?[^<]*?$ # with no other tags following until end of line
+ """,
+ item,
re.IGNORECASE | re.VERBOSE | re.MULTILINE,
- ),
- item,
+ )
)
- or re.findall(
- rf"^({{%[ ]*?({slt_template})[ ]+?.*?%}})(.*?)({{%[ ]+?end(\2)[ ]+?.*?%}})",
- item,
- re.IGNORECASE | re.MULTILINE | re.VERBOSE,
- )
- or re.findall(
- rf"(<({slt_html})\b.*?/>)", item, flags=re.IGNORECASE | re.VERBOSE
- )
- or re.findall(
- re.compile(
- rf"(<({always_self_closing_html})\b.*?/?>)",
- re.IGNORECASE | re.VERBOSE,
- ),
- item,
- )
- ) and is_block_raw is False:
+ and is_block_raw is False
+ ):
tmp = (indent * indent_level) + item + "\n"
# if unindent, move left
@@ -108,7 +98,7 @@ def indent_html(rawcode: str, config: Config) -> str:
re.IGNORECASE | re.VERBOSE | re.MULTILINE,
)
and not re.findall(
- rf"(<({slt_html})\\b.+?>)(.*?)((\2)>[^<]*?$)",
+ rf"(<({slt_html})\\b[^>]+?>)(.*?)((\2)>[^<]*?$)",
item,
re.IGNORECASE | re.VERBOSE | re.MULTILINE,
)
@@ -123,7 +113,7 @@ def indent_html(rawcode: str, config: Config) -> str:
)
or re.findall(
re.compile(
- rf"(^<({slt_html})\b.+?>)(.*?)((\2)>)",
+ rf"(^<({slt_html})\b[^>]+?>)(.*?)((\2)>)",
re.IGNORECASE | re.VERBOSE | re.MULTILINE,
),
item,
@@ -157,6 +147,17 @@ def indent_html(rawcode: str, config: Config) -> str:
),
item,
)
+ # # and not ending in a slt like .
+ # and not re.findall(
+ # rf"(<({slt_html})>)(.*?)((\2)>[^<]*?$)",
+ # item,
+ # re.IGNORECASE | re.VERBOSE | re.MULTILINE,
+ # )
+ # and not re.findall(
+ # rf"(<({slt_html})\\b.+?>)(.*?)((\2)>[^<]*?$)",
+ # item,
+ # re.IGNORECASE | re.VERBOSE | re.MULTILINE,
+ # )
and is_block_raw is False
):
tmp = (indent * indent_level) + item + "\n"
diff --git a/src/djlint/rules.yaml b/src/djlint/rules.yaml
index 884d8d7..bd9c779 100644
--- a/src/djlint/rules.yaml
+++ b/src/djlint/rules.yaml
@@ -26,7 +26,7 @@
message: Double quotes should be used in tags.
flags: re.DOTALL
patterns:
- - "{%[ \t]*?extends[ \t]+?'[^']*'"
+ - "{%[ \t]*?(?:trans(?:late)?|with|extends|include|now)?[ \t]+?(?:[^']+?=)?'[^']*'"
- rule:
name: T003
message: 'Endblock should have name. Ex: {% endblock body %}.'
@@ -251,3 +251,9 @@
patterns:
-