From 1b3a0bbe0b932c9291f800fc3ffa4af42087ead1 Mon Sep 17 00:00:00 2001 From: hkc Date: Wed, 10 May 2023 12:33:33 +0300 Subject: [PATCH] Added blockquote element to node_to_plaintext --- mastoposter/__init__.py | 4 +++- mastoposter/utils.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mastoposter/__init__.py b/mastoposter/__init__.py index 944ab6c..6d7ee58 100644 --- a/mastoposter/__init__.py +++ b/mastoposter/__init__.py @@ -27,7 +27,9 @@ from mastoposter.integrations import ( from mastoposter.types import Status __version__ = "0.1" -__description__ = "Configurable reposter from Mastodon-compatible Fediverse servers" +__description__ = ( + "Configurable reposter from Mastodon-compatible Fediverse servers" +) logger = getLogger() diff --git a/mastoposter/utils.py b/mastoposter/utils.py index 391f630..4385b5d 100644 --- a/mastoposter/utils.py +++ b/mastoposter/utils.py @@ -194,7 +194,7 @@ def node_to_markdown(el: PageElement) -> str: % str.join( "\n", ( - "▍%s" % part + "\u258d%s" % part for part in str.join( "", map(node_to_markdown, tag.children) ).split("\n") @@ -256,6 +256,16 @@ 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 == "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"): children = map(node_to_plaintext, el.children) return "\n%s\n" % str.join(