1
0
Fork 0

Added blockquote element to node_to_plaintext

This commit is contained in:
Casey 2023-05-10 12:33:33 +03:00
parent 277c32b09d
commit 1b3a0bbe0b
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
2 changed files with 14 additions and 2 deletions

View File

@ -27,7 +27,9 @@ from mastoposter.integrations import (
from mastoposter.types import Status from mastoposter.types import Status
__version__ = "0.1" __version__ = "0.1"
__description__ = "Configurable reposter from Mastodon-compatible Fediverse servers" __description__ = (
"Configurable reposter from Mastodon-compatible Fediverse servers"
)
logger = getLogger() logger = getLogger()

View File

@ -194,7 +194,7 @@ def node_to_markdown(el: PageElement) -> str:
% str.join( % str.join(
"\n", "\n",
( (
"%s" % part "\u258d%s" % part
for part in str.join( for part in str.join(
"", map(node_to_markdown, tag.children) "", map(node_to_markdown, tag.children)
).split("\n") ).split("\n")
@ -256,6 +256,16 @@ def node_to_plaintext(el: PageElement) -> str:
return str.join("", map(node_to_plaintext, el.children)) + "\n\n" return str.join("", map(node_to_plaintext, el.children)) + "\n\n"
elif el.name == "br": elif el.name == "br":
return "\n" return "\n"
elif el.name == "blockquote":
return str.join(
"\n",
(
"\u258d%s" % part
for part in str.join(
"", map(node_to_plaintext, el.children)
).split("\n")
),
)
elif el.name in ("ol", "ul"): elif el.name in ("ol", "ul"):
children = map(node_to_plaintext, el.children) children = map(node_to_plaintext, el.children)
return "\n%s\n" % str.join( return "\n%s\n" % str.join(