mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-27 05:43:59 +00:00
simplified regex to improve speed
This commit is contained in:
parent
2029496854
commit
1c70ea624c
2 changed files with 3 additions and 3 deletions
|
|
@ -85,7 +85,7 @@ def compress_html(html: str, config: Config) -> str:
|
|||
# put short single line tags on one line
|
||||
html = re.sub(
|
||||
re.compile(
|
||||
fr"(<({config.single_line_html_tags})(?:[^<>])*>)\s*([^<\n]{{,80}})\s*?(</(\2)>)",
|
||||
fr"(<({config.single_line_html_tags})(?:\s(?:(?:{{%[^(?:%}}]*?%}})|(?:{{{{[^(?:}}}})]*?}}}})|[^<>])*)?>)\s*([^<\n]{{,80}})\s*?(</(\2)>)",
|
||||
re.IGNORECASE | re.MULTILINE | re.DOTALL | re.VERBOSE,
|
||||
),
|
||||
r"\1\3\4",
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ def expand_html(html: str, config: Config) -> str:
|
|||
# html tags - break before
|
||||
html = re.sub(
|
||||
re.compile(
|
||||
fr"{break_char}\K(</?(?:{html_tags})(?:[^<>])*>)",
|
||||
fr"{break_char}\K(</?(?:{html_tags})(?:\s((?:{{%[^(?:%}}]*?%}})|(?:{{{{[^(?:}}}})]*?}}}})|[^<>])*)?>)",
|
||||
flags=re.IGNORECASE | re.VERBOSE,
|
||||
),
|
||||
add_left,
|
||||
|
|
@ -79,7 +79,7 @@ def expand_html(html: str, config: Config) -> str:
|
|||
# html tags - break after
|
||||
html = re.sub(
|
||||
re.compile(
|
||||
fr"(</?(?:{html_tags})(?:[^<>])*>)(?=[^\n])",
|
||||
fr"(</?(?:{html_tags})(?:\s((?:{{%[^(?:%}}]*?%}})|(?:{{{{[^(?:}}}})]*?}}}})|[^<>])*)?>)(?=[^\n])",
|
||||
flags=re.IGNORECASE | re.VERBOSE,
|
||||
),
|
||||
add_right,
|
||||
|
|
|
|||
Loading…
Reference in a new issue