diff --git a/mastoposter/utils.py b/mastoposter/utils.py index 115e364..9b2da47 100644 --- a/mastoposter/utils.py +++ b/mastoposter/utils.py @@ -210,5 +210,19 @@ def node_to_plaintext(el: PageElement) -> str: return str.join("", map(node_to_plaintext, el.children)) + "\n\n" elif el.name == "br": return "\n" + elif el.name in ("ol", "ul"): + children = map(node_to_plaintext, el.children) + return str.join( + "\n", + ( + " \u2022 %s" % li.replace("\n", "\n ").strip() + for li in children + ) + if el.name == "ol" + else ( + "%d. %s" % (i, li.replace("\n", "\n ").strip()) + for i, li in enumerate(children) + ), + ) return str.join("", map(node_to_plaintext, el.children)) return str(el)