1
0
Fork 0

Forgot about plaintext

This commit is contained in:
Casey 2023-01-13 10:47:23 +03:00
parent bbc5053cf6
commit 3753c6a342
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 14 additions and 0 deletions

View File

@ -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)