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: not detecting tabs as a valid seperation between tags. #813

Merged
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
2 changes: 1 addition & 1 deletion src/djlint/formatter/condense.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def strip_space(config: Config, html: str, match: re.Match) -> str:
trailing_contents = r"\n \t"

if config.preserve_blank_lines:
line_contents = r"([^\n]+?)"
line_contents = r"([^\n]*?)"
trailing_contents = r" \t"

if not config.preserve_leading_space:
Expand Down
2 changes: 1 addition & 1 deletion src/djlint/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def __init__(
)
"""

self.break_before = r"(?<!\n[ ]*?)"
self.break_before = r"(?<!\n[ \t]*?)"

# if lines are longer than x
self.max_line_length = 120
Expand Down
7 changes: 6 additions & 1 deletion tests/test_config/test_preserve_blank_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,14 @@
({"preserve_blank_lines": True}),
id="whitespace test",
),
pytest.param(
("<div>\n\t\n\t<div>\n\t\n\t</div>\n\t\n</div>"),
("<div>\n\n <div></div>\n\n</div>\n"),
({"preserve_blank_lines": True}),
id="whitespace test with tabs",
),
]


@pytest.mark.parametrize(("source", "expected", "args"), test_data)
def test_base(source, expected, args):
output = formatter(config_builder(args), source)
Expand Down