From 19425f9e0218926267505d8836ab00feab7d5c3d Mon Sep 17 00:00:00 2001 From: Christopher Pickering Date: Mon, 12 Jun 2023 14:21:06 -0500 Subject: [PATCH] fix(formatter): fixed isolated quotes being deleted from attributes closes #652 --- src/djlint/settings.py | 1 + tests/test_django/test_quoted.py | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/djlint/settings.py b/src/djlint/settings.py index 0a30ed70..8ad1f948 100644 --- a/src/djlint/settings.py +++ b/src/djlint/settings.py @@ -627,6 +627,7 @@ def __init__( | ({self.template_if_for_pattern} """ + r""" + | (?:\'|\") # allow random trailing quotes | {{.*?}} | {\#.*?\#} | {%.*?%}) diff --git a/tests/test_django/test_quoted.py b/tests/test_django/test_quoted.py index 9d3eb673..ce2b6487 100644 --- a/tests/test_django/test_quoted.py +++ b/tests/test_django/test_quoted.py @@ -1,6 +1,6 @@ """Test django quoted tags. -poetry run pytest tests/test_django/test_filter.py +poetry run pytest tests/test_django/test_quoted.py """ import pytest @@ -23,6 +23,28 @@ ), id="issue #640", ), + pytest.param( + ( + '\n" + " test\n" + " {% if piece.like_count %}{{ piece.like_count }}{% endif %}\n" + "\n" + ), + ( + '\n" + " test\n" + " {% if piece.like_count %}{{ piece.like_count }}{% endif %}\n" + "\n" + ), + id="issue #652", + ), ]