mirror of
https://github.com/Hopiu/djLint.git
synced 2026-04-02 05:30:24 +00:00
fix(custom attributes): custom attributes separated by hyphen were split up during format
closes #236
This commit is contained in:
parent
411c6cc1b2
commit
1ce378c43d
2 changed files with 10 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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"])
|
||||
|
|
|
|||
Loading…
Reference in a new issue