mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-03 19:34:43 +00:00
fixed #154, added test
This commit is contained in:
parent
736a03307f
commit
bec3623a4d
3 changed files with 10 additions and 1 deletions
|
|
@ -89,7 +89,7 @@ def condense_html(html: str, config: Config) -> str:
|
|||
# put short template tags back on one line
|
||||
html = re.sub(
|
||||
re.compile(
|
||||
rf"({{%-?[ ]*?({config.optional_single_line_template_tags})[^\n(?:%}})]*?%}})\s*([^%\n]*?)\s*?({{%-?[ ]+?end(\2)[ ]*?%}})",
|
||||
rf"({{%-?[ ]*?({config.optional_single_line_template_tags})[^\n(?:%}})]*?%}})\s*?([ ]*?[^%\n]*?[ ]*?)\s*?({{%-?[ ]+?end(\2)[ ]*?%}})",
|
||||
flags=re.IGNORECASE | re.MULTILINE | re.VERBOSE,
|
||||
),
|
||||
func,
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ def indent_html(rawcode: str, config: Config) -> str:
|
|||
elif is_block_raw is False:
|
||||
# get leading space, and attributes
|
||||
func = partial(format_attributes, config)
|
||||
|
||||
tmp = re.sub(
|
||||
re.compile(
|
||||
fr"(\s*?)(<(?:{config.indent_html_tags})\b)((?:\"[^\"]*\"|'[^']*'|{{[^}}]*}}|[^'\">{{}}])+?)(/?>)",
|
||||
|
|
|
|||
|
|
@ -41,6 +41,14 @@ def test_without_config(runner: CliRunner, tmp_file: TextIO) -> None:
|
|||
|
||||
assert output.exit_code == 0
|
||||
|
||||
output = reformat(
|
||||
tmp_file,
|
||||
runner,
|
||||
b'<a href="#"\n class="list-group-item{% if not is_allowed %} disabled{% endif %}">foo</a>\n',
|
||||
)
|
||||
|
||||
assert output.exit_code == 0
|
||||
|
||||
output = reformat(
|
||||
tmp_file,
|
||||
runner,
|
||||
|
|
|
|||
Loading…
Reference in a new issue