Skip to content

Commit

Permalink
chore: Fix remaining stuff from conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
JCWasmx86 committed Nov 5, 2024
1 parent 2648723 commit cdb15e3
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions djlint/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def is_ignored_block_opening(config: Config, item: str) -> bool:
single line block.
"""
inline = _last_item(
re.finditer(config.ignored_blocks_inline, item, flags=RE_FLAGS_IMSX)
regex_utils.finditer(
config.ignored_blocks_inline, item, flags=RE_FLAGS_IMSX
)
)
last_index = (
inline.end() # get the last index. The ignored opening should start after this.
Expand All @@ -66,7 +68,9 @@ def is_script_style_block_opening(config: Config, item: str) -> bool:
single line block.
"""
inline = _last_item(
re.finditer(config.script_style_inline, item, flags=RE_FLAGS_IMSX)
regex_utils.finditer(
config.script_style_inline, item, flags=RE_FLAGS_IMSX
)
)
last_index = (
inline.end() # get the last index. The ignored opening should start after this.
Expand Down Expand Up @@ -99,19 +103,23 @@ def inside_protected_trans_block(
return False

non_trimmed = _last_item(
regex_utils.finditer(config.ignored_trans_blocks, html, flags=RE_FLAGS_ISX)
regex_utils.finditer(
config.ignored_trans_blocks, html, flags=RE_FLAGS_ISX
)
)

trimmed = _last_item(
regex_utils.finditer(config.trans_trimmed_blocks, html, flags=RE_FLAGS_ISX)
regex_utils.finditer(
config.trans_trimmed_blocks, html, flags=RE_FLAGS_ISX
)
)

# who is max?
if non_trimmed and (not trimmed or non_trimmed.end() > trimmed.end()):
# non trimmed!
# check that this is not an inline block.
non_trimmed_inline = bool(
re.search(
regex_utils.search(
config.ignored_trans_blocks, match.group(), flags=RE_FLAGS_ISX
)
)
Expand Down Expand Up @@ -155,7 +163,9 @@ def is_ignored_block_closing(config: Config, item: str) -> bool:
single line block.
"""
inline = _last_item(
re.finditer(config.ignored_inline_blocks, item, flags=RE_FLAGS_IX)
regex_utils.finditer(
config.ignored_inline_blocks, item, flags=RE_FLAGS_IX
)
)
last_index = (
inline.end() # get the last index. The ignored opening should start after this.
Expand All @@ -176,7 +186,9 @@ def is_script_style_block_closing(config: Config, item: str) -> bool:
single line block.
"""
inline = _last_item(
re.finditer(config.script_style_inline, item, flags=RE_FLAGS_IX)
regex_utils.finditer(
config.script_style_inline, item, flags=RE_FLAGS_IX
)
)
last_index = (
inline.end() # get the last index. The ignored opening should start after this.
Expand All @@ -197,7 +209,7 @@ def is_safe_closing_tag(config: Config, item: str) -> bool:
single line block.
"""
inline = _last_item(
re.finditer(
regex_utils.finditer(
config.ignored_inline_blocks + r" | " + config.ignored_blocks,
item,
flags=RE_FLAGS_IMSX,
Expand All @@ -220,7 +232,7 @@ def inside_template_block(
) -> bool:
"""Check if a re.Match is inside of a template block."""
match_start, match_end = match.span()
for ignored_match in re.finditer(
for ignored_match in regex_utils.finditer(
config.template_blocks, html, flags=RE_FLAGS_IMSX
):
ignored_match_start, ignored_match_end = ignored_match.span()
Expand All @@ -246,10 +258,9 @@ def inside_html_attribute(
config: Config, html: str, match: re.Match[str]
) -> bool:
"""Check if a re.Match is inside of an html attribute."""

match_start, match_end = match.span()
for ignored_match_start, ignored_match_end in _inside_html_attribute(
html, html_tag_regex=config.html_tag_regex
html, config.html_tag_regex
):
# span = (-1, -1) if no attributes are present
if (
Expand All @@ -265,7 +276,7 @@ def inside_ignored_linter_block(
) -> bool:
"""Check if a re.Match is inside of a ignored linter block."""
match_start, match_end = match.span()
for ignored_match in re.finditer(
for ignored_match in regex_utils.finditer(
config.ignored_linter_blocks, html, flags=RE_FLAGS_IMSX
):
ignored_match_start, ignored_match_end = ignored_match.span()
Expand Down Expand Up @@ -357,8 +368,10 @@ def _overlaps_ignored_block(
return tuple(
x.span()
for x in itertools.chain(
re.finditer(ignored_blocks, html, flags=RE_FLAGS_IMSX),
re.finditer(ignored_inline_blocks, html, flags=RE_FLAGS_IX),
regex_utils.finditer(ignored_blocks, html, flags=RE_FLAGS_IMSX),
regex_utils.finditer(
ignored_inline_blocks, html, flags=RE_FLAGS_IX
),
)
)

Expand Down Expand Up @@ -388,7 +401,9 @@ def inside_ignored_rule(
"""Check if match is inside an ignored pattern."""
match_start, match_end = match.span()
for rule_regex in config.ignored_rules:
for ignored_match in re.finditer(rule_regex, html, flags=RE_FLAGS_ISX):
for ignored_match in regex_utils.finditer(
rule_regex, html, flags=RE_FLAGS_ISX
):
ignored_match_start, ignored_match_end = ignored_match.span()
if (
(ignored_match_start <= match_start <= ignored_match_end)
Expand Down

0 comments on commit cdb15e3

Please sign in to comment.