mirror of
https://github.com/Hopiu/djLint.git
synced 2026-04-25 15:34:44 +00:00
fix tag indent for preserve whitespace option, preserve better text indenting
This commit is contained in:
parent
15ead700d1
commit
dc9a97d510
2 changed files with 14 additions and 1 deletions
|
|
@ -26,7 +26,15 @@ def condense_html(html: str, config: Config) -> str:
|
|||
func = partial(strip_space, config, html)
|
||||
|
||||
if not config.preserve_leading_space:
|
||||
# remove any leading/trailing space
|
||||
html = re.sub(re.compile(r"^[ \t]*(.*?)[\n \t]*$", re.M), func, html)
|
||||
else:
|
||||
# only remove leading space in front of tags
|
||||
# <, {%, {#, {{
|
||||
html = re.sub(
|
||||
re.compile(r"^[ \t]*((?:<|{%|{#|{{).*?)[\n \t]*$", re.M), func, html
|
||||
)
|
||||
html = re.sub(re.compile(r"^(.*?)[\n \t]*$", re.M), func, html)
|
||||
|
||||
def if_blank_line_after_match(config: Config, html: str) -> bool:
|
||||
"""Check if there should be a blank line after."""
|
||||
|
|
|
|||
|
|
@ -161,7 +161,12 @@ def indent_html(rawcode: str, config: Config) -> str:
|
|||
|
||||
# otherwise, just leave same level
|
||||
else:
|
||||
tmp = (indent * indent_level) + item + "\n"
|
||||
if not config.preserve_leading_space:
|
||||
# if we are not trying to preserve indenting
|
||||
# on text, the add it now.
|
||||
tmp = (indent * indent_level) + item + "\n"
|
||||
else:
|
||||
tmp = item + "\n"
|
||||
|
||||
# if a opening raw tag then start ignoring.. only if there is no closing tag
|
||||
# on the same line
|
||||
|
|
|
|||
Loading…
Reference in a new issue