From 46516fa4e6de946d98f8092110f7a6b9a491a825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=B1zgar=20Ozan?= Date: Sat, 10 Oct 2026 14:24:22 +0300 Subject: [PATCH] Replace continue statement in HTMLToMarkdown list handler (#1357) --- src/python/txtai/pipeline/data/htmltomd.py | 29 +++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/python/txtai/pipeline/data/htmltomd.py b/src/python/txtai/pipeline/data/htmltomd.py index 8286dce5..7f09025e 100644 --- a/src/python/txtai/pipeline/data/htmltomd.py +++ b/src/python/txtai/pipeline/data/htmltomd.py @@ -279,25 +279,24 @@ class HTMLToMarkdown(Pipeline): # Nested list that is a direct child of this list if element.name != "li": self.nested(element, article, elements) - continue + else: + # Unordered lists use dashes. Ordered lists use numbers. + count += 1 + prefix = "-" if node.name == "ul" else f"{count}." - # Unordered lists use dashes. Ordered lists use numbers. - count += 1 - prefix = "-" if node.name == "ul" else f"{count}." + # Detach nested lists, these are formatted separately + nested = [child.extract() for child in element.find_all(("ul", "ol"), recursive=False)] - # Detach nested lists, these are formatted separately - nested = [child.extract() for child in element.find_all(("ul", "ol"), recursive=False)] + # List item text + text = self.process(element, article) - # List item text - text = self.process(element, article) + # Add list element + if text: + elements.append(f"{prefix} {text}") - # Add list element - if text: - elements.append(f"{prefix} {text}") - - # Add nested lists - for child in nested: - self.nested(child, article, elements) + # Add nested lists + for child in nested: + self.nested(child, article, elements) # Join elements together as string return "\n".join(elements)