Replace continue statement in HTMLToMarkdown list handler (#1357)

This commit is contained in:
Rızgar Ozan
2026-10-10 14:24:22 +03:00
parent 084a1eca4d
commit 46516fa4e6
+14 -15
View File
@@ -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)