Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

check-templates: Remove prevent_dangling_tags.

Steve Howell0decfa8da0ed
diff --git a/tools/lib/template_parser.py b/tools/lib/template_parser.py
index 071bdfbffbe..b134365ca76 100644
--- a/tools/lib/template_parser.py
+++ b/tools/lib/template_parser.py
@@ -338,7 +338,6 @@ def validate(fn: Optional[str] = None, text: Optional[str] = None) -> None:
)
prevent_whitespace_violations(fn, tokens)
- prevent_dangling_tags(fn, tokens)
class State:
def __init__(self, func: Callable[[Token], None]) -> None:
@@ -555,48 +554,6 @@ def prevent_whitespace_violations(fn: str, tokens: List[Token]) -> None:
)
-def prevent_dangling_tags(fn: str, tokens: List[Token]) -> None:
- """
- Prevent this kind of HTML:
-
- <div attr attr
- attr attr>Stuff</div>
-
- We prefer:
- <div attr attr
- attr attr>
- Stuff
- </div>
-
- We may eventually have the pretty_printer code do this
- automatically, but there are some complications with
- legacy code.
- """
- min_row: Optional[int] = None
- for token in tokens:
- # We only apply this validation for a couple tag types, because
- # our existing templates may have some funny edge cases. We eventually
- # want to be more aggressive here. We may need to be extra careful
- # with tags like <pre> that have whitespace sensitivities.
- if token.tag not in ("div", "button", "p"):
- continue
- if min_row and token.line < min_row:
- raise TemplateParserException(
- f"""
-
- Please fix line {token.line} at {fn} (col {token.col})
- by moving this tag so that it closes the block at the
- same indentation level as its start tag:
-
- {token.s}
- """
- )
- else:
- min_row = None
- if token.line_span > 1:
- min_row = token.line + token.line_span
-
-
def is_django_block_tag(tag: str) -> bool:
return tag in [
"autoescape",