mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	refactor: Move logic for HTML_VOID_TAGS.
This sets up for the next commit.
This commit is contained in:
		@@ -384,10 +384,23 @@ def validate(fn: Optional[str] = None, text: Optional[str] = None) -> None:
 | 
				
			|||||||
        kind = token.kind
 | 
					        kind = token.kind
 | 
				
			||||||
        tag = token.tag
 | 
					        tag = token.tag
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if not state.foreign:
 | 
				
			||||||
 | 
					            if kind == "html_start":
 | 
				
			||||||
 | 
					                if tag in HTML_VOID_TAGS:
 | 
				
			||||||
 | 
					                    raise TemplateParserException(
 | 
				
			||||||
 | 
					                        f"Tag must be self-closing: {tag} at {fn} line {token.line}, col {token.col}"
 | 
				
			||||||
 | 
					                    )
 | 
				
			||||||
 | 
					            elif kind == "html_singleton":
 | 
				
			||||||
 | 
					                if not state.foreign and tag not in HTML_VOID_TAGS:
 | 
				
			||||||
 | 
					                    raise TemplateParserException(
 | 
				
			||||||
 | 
					                        f"Tag must not be self-closing: {tag} at {fn} line {token.line}, col {token.col}"
 | 
				
			||||||
 | 
					                    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if kind in (
 | 
					        if kind in (
 | 
				
			||||||
            "django_comment",
 | 
					            "django_comment",
 | 
				
			||||||
            "handlebar_comment",
 | 
					            "handlebar_comment",
 | 
				
			||||||
            "handlebars_singleton",
 | 
					            "handlebars_singleton",
 | 
				
			||||||
 | 
					            "html_singleton",
 | 
				
			||||||
            "indent",
 | 
					            "indent",
 | 
				
			||||||
            "template_var",
 | 
					            "template_var",
 | 
				
			||||||
            "html_comment",
 | 
					            "html_comment",
 | 
				
			||||||
@@ -399,16 +412,7 @@ def validate(fn: Optional[str] = None, text: Optional[str] = None) -> None:
 | 
				
			|||||||
            continue
 | 
					            continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if kind == "html_start":
 | 
					        if kind == "html_start":
 | 
				
			||||||
            if not state.foreign and tag in HTML_VOID_TAGS:
 | 
					 | 
				
			||||||
                raise TemplateParserException(
 | 
					 | 
				
			||||||
                    f"Tag must be self-closing: {tag} at {fn} line {token.line}, col {token.col}"
 | 
					 | 
				
			||||||
                )
 | 
					 | 
				
			||||||
            start_tag_matcher(token)
 | 
					            start_tag_matcher(token)
 | 
				
			||||||
        elif kind == "html_singleton":
 | 
					 | 
				
			||||||
            if not state.foreign and tag not in HTML_VOID_TAGS:
 | 
					 | 
				
			||||||
                raise TemplateParserException(
 | 
					 | 
				
			||||||
                    f"Tag must not be self-closing: {tag} at {fn} line {token.line}, col {token.col}"
 | 
					 | 
				
			||||||
                )
 | 
					 | 
				
			||||||
        elif kind == "html_end":
 | 
					        elif kind == "html_end":
 | 
				
			||||||
            state.matcher(token)
 | 
					            state.matcher(token)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user