fix(custom attributes): custom attributes separated by hyphen were split up during format

closes #236
This commit is contained in:
Christopher Pickering 2022-05-02 09:03:35 -05:00
parent 411c6cc1b2
commit 1ce378c43d
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
2 changed files with 10 additions and 2 deletions

View file

@ -30,7 +30,7 @@ def compress_html(html: str, config: Config) -> str:
# put attributes on one line
html = re.sub(
re.compile(
rf"(<(?:{config.indent_html_tags})\b)((?:\"[^\"]*\"|'[^']*'|{{{{(?:(?!}}}}).)*}}}}|{{%(?:(?!%}}).)*%}}|[^'\">{{}}])+)(/?>)",
rf"(<(?:{config.indent_html_tags}))\s((?:\"[^\"]*\"|'[^']*'|{{{{(?:(?!}}}}).)*}}}}|{{%(?:(?!%}}).)*%}}|[^'\">{{}}])+)(/?>)",
flags=re.IGNORECASE | re.MULTILINE | re.VERBOSE,
),
_flatten_attributes,

View file

@ -13,10 +13,14 @@ for a single test, run::
"""
# pylint: disable=C0116
from typing import TextIO
from click.testing import CliRunner
from src.djlint import main as djlint
from .conftest import reformat
def test_custom_tags(runner: CliRunner) -> None:
result = runner.invoke(djlint, ["tests/config_custom_tags/html.html", "--check"])
@ -34,7 +38,7 @@ def test_custom_tags(runner: CliRunner) -> None:
assert result.exit_code == 1
def test_custom_html(runner: CliRunner) -> None:
def test_custom_html(runner: CliRunner, tmp_file: TextIO) -> None:
result = runner.invoke(djlint, ["tests/config_custom_html/html.html", "--check"])
print(result.output)
assert (
@ -49,6 +53,10 @@ def test_custom_html(runner: CliRunner) -> None:
)
assert result.exit_code == 1
# https://github.com/Riverside-Healthcare/djLint/issues/236
output = reformat(tmp_file, runner, b"<some-long-custom-element></some-long-custom-element>\n")
assert output.exit_code == 0
def test_extension(runner: CliRunner) -> None:
result = runner.invoke(djlint, ["tests/config_extension", "--check"])