From 84e0c01b237c59ebc05baef01e12ab86e30ca1aa Mon Sep 17 00:00:00 2001 From: Chris Heywood <31988069+cheywood@users.noreply.github.com> Date: Wed, 29 Jan 2025 16:02:04 +1000 Subject: [PATCH] fix: HTML formatter producing invalid HTML Resulting from lxml element tostring called with method using default "xml" value --- src/formatters/html.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/formatters/html.py b/src/formatters/html.py index 5557d20..9c21c73 100644 --- a/src/formatters/html.py +++ b/src/formatters/html.py @@ -27,7 +27,7 @@ def _format(self, text:str, indents:int): doc_root = html.fromstring(text) etree.indent(doc_root, space=indent_str) - return etree.tostring(doc_root, encoding='unicode', pretty_print=True) + return etree.tostring(doc_root, method='html', encoding='unicode', pretty_print=True) def is_correct(self, text:str) -> bool: if isinstance(text, str):