diff --git a/templates/zerver/for-open-source.html b/templates/zerver/for-open-source.html index 8120960152..91c8f4a6f3 100644 --- a/templates/zerver/for-open-source.html +++ b/templates/zerver/for-open-source.html @@ -442,8 +442,8 @@
  • Use topics to manage support workflows, answer - questions, and collaborate to investigate issues. Mark the topic ✓ + questions, and collaborate to investigate issues. + Mark the topic ✓ resolved when done!
  • diff --git a/templates/zerver/for-research.html b/templates/zerver/for-research.html index d73d4aad23..7d13b3b1c5 100644 --- a/templates/zerver/for-research.html +++ b/templates/zerver/for-research.html @@ -88,11 +88,9 @@ both the app and the website is extremely positive!
    - — Kevin - Buzzard, Professor of Pure Mathematics at Imperial College - London + — Kevin Buzzard, + Professor of Pure Mathematics at + Imperial College London
    How the Lean prover diff --git a/tools/lib/template_parser.py b/tools/lib/template_parser.py index cf558d7f9d..5d368c471c 100644 --- a/tools/lib/template_parser.py +++ b/tools/lib/template_parser.py @@ -223,6 +223,10 @@ HTML_VOID_TAGS = { } +def indent_level(s: str) -> int: + return len(s) - len(s.lstrip()) + + def validate( fn: Optional[str] = None, text: Optional[str] = None, check_indent: bool = True ) -> None: @@ -235,6 +239,8 @@ def validate( with open(fn) as f: text = f.read() + lines = text.split("\n") + try: tokens = tokenize(text) except FormattedException as e: @@ -294,6 +300,15 @@ def validate( elif check_indent and (end_line > start_line + max_lines): if end_col != start_col: problem = "Bad indentation." + + if end_line >= start_line + 2: + # We have 3+ lines in the tag's block. + start_row_text = lines[start_line - 1] + start_indent = indent_level(start_row_text) + if start_indent != start_col - 1 and start_row_text[start_indent] not in "<{": + junk = start_row_text[start_indent : start_col - 1] + problem = f"There is junk before the start tag: {junk}" + if problem: raise TemplateParserException( f""" diff --git a/tools/tests/test_pretty_print.py b/tools/tests/test_pretty_print.py index 271b84351f..b1a4e13b54 100644 --- a/tools/tests/test_pretty_print.py +++ b/tools/tests/test_pretty_print.py @@ -106,33 +106,7 @@ GOOD_HTML2 = """ """ -BAD_HTML3 = """ - - - {{# foobar area}} - foobarfoobar
    -

    - FOOBAR -

    -
    - {{/ foobar area}} - - -""" - -GOOD_HTML3 = """ - - - {{# foobar area}} - foobarfoobar
    -

    - FOOBAR -

    -
    - {{/ foobar area}} - - -""" +# The old GOOD_HTML3 test was flawed. BAD_HTML4 = """
    @@ -478,7 +452,6 @@ class TestPrettyPrinter(unittest.TestCase): self.compare(pretty_print_html(BAD_HTML), GOOD_HTML) self.compare(pretty_print_html(BAD_HTML1), GOOD_HTML1) self.compare(pretty_print_html(BAD_HTML2), GOOD_HTML2) - self.compare(pretty_print_html(BAD_HTML3), GOOD_HTML3) self.compare(pretty_print_html(BAD_HTML4), GOOD_HTML4) self.compare(pretty_print_html(BAD_HTML5), GOOD_HTML5) self.compare(pretty_print_html(BAD_HTML6), GOOD_HTML6)