mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-04 20:04:42 +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
|
# put attributes on one line
|
||||||
html = re.sub(
|
html = re.sub(
|
||||||
re.compile(
|
re.compile(
|
||||||
rf"(<(?:{config.indent_html_tags})\b)((?:\"[^\"]*\"|'[^']*'|{{{{(?:(?!}}}}).)*}}}}|{{%(?:(?!%}}).)*%}}|[^'\">{{}}])+)(/?>)",
|
rf"(<(?:{config.indent_html_tags}))\s((?:\"[^\"]*\"|'[^']*'|{{{{(?:(?!}}}}).)*}}}}|{{%(?:(?!%}}).)*%}}|[^'\">{{}}])+)(/?>)",
|
||||||
flags=re.IGNORECASE | re.MULTILINE | re.VERBOSE,
|
flags=re.IGNORECASE | re.MULTILINE | re.VERBOSE,
|
||||||
),
|
),
|
||||||
_flatten_attributes,
|
_flatten_attributes,
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,14 @@ for a single test, run::
|
||||||
"""
|
"""
|
||||||
# pylint: disable=C0116
|
# pylint: disable=C0116
|
||||||
|
|
||||||
|
from typing import TextIO
|
||||||
|
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
|
|
||||||
from src.djlint import main as djlint
|
from src.djlint import main as djlint
|
||||||
|
|
||||||
|
from .conftest import reformat
|
||||||
|
|
||||||
|
|
||||||
def test_custom_tags(runner: CliRunner) -> None:
|
def test_custom_tags(runner: CliRunner) -> None:
|
||||||
result = runner.invoke(djlint, ["tests/config_custom_tags/html.html", "--check"])
|
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
|
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"])
|
result = runner.invoke(djlint, ["tests/config_custom_html/html.html", "--check"])
|
||||||
print(result.output)
|
print(result.output)
|
||||||
assert (
|
assert (
|
||||||
|
|
@ -49,6 +53,10 @@ def test_custom_html(runner: CliRunner) -> None:
|
||||||
)
|
)
|
||||||
assert result.exit_code == 1
|
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:
|
def test_extension(runner: CliRunner) -> None:
|
||||||
result = runner.invoke(djlint, ["tests/config_extension", "--check"])
|
result = runner.invoke(djlint, ["tests/config_extension", "--check"])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue