Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
check-templates: Prevent excessive newlines.
Steve Howell6152bed37870
diff --git a/templates/zerver/for-companies.html b/templates/zerver/for-companies.htmlindex 62e307bce9f..26185353b15 100644--- a/templates/zerver/for-companies.html+++ b/templates/zerver/for-companies.html@@ -284,7 +284,6 @@</div>-<div class="feature-container"><div class="feature-half"><div class="feature-text">@@ -493,8 +492,6 @@</div></div>--<div class="feature-end"><div class="description"><h1>diff --git a/tools/lib/template_parser.py b/tools/lib/template_parser.pyindex 64b0a260126..071bdfbffbe 100644--- a/tools/lib/template_parser.py+++ b/tools/lib/template_parser.py@@ -493,10 +493,27 @@ def ensure_matching_indentation(fn: str, tokens: List[Token], lines: List[str]))+def prevent_extra_newlines(fn: str, tokens: List[Token]) -> None:+ count = 0++ for token in tokens:+ if token.kind != "newline":+ count = 0+ continue++ count += 1+ if count >= 4:+ raise TemplateParserException(+ f"""Please avoid so many blank lines near row {token.line} in {fn}."""+ )++def prevent_whitespace_violations(fn: str, tokens: List[Token]) -> None:if tokens[0].kind in ("indent", "whitespace"):raise TemplateParserException(f" Please remove the whitespace at the beginning of {fn}.")+ prevent_extra_newlines(fn, tokens)+for i in range(1, len(tokens) - 1):token = tokens[i]next_token = tokens[i + 1]