From 58b762a53a5e64d6a6ea6999009d1899f7b6a4da Mon Sep 17 00:00:00 2001 From: Matthew Fennell Date: Sun, 23 Aug 2026 22:39:35 +0100 Subject: Add RSS feed plugins These are used to save each feed entry to a file. --- html2text2.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 html2text2.py (limited to 'html2text2.py') diff --git a/html2text2.py b/html2text2.py new file mode 100644 index 0000000..cd6e635 --- /dev/null +++ b/html2text2.py @@ -0,0 +1,29 @@ +# SPDX-FileCopyrightText: 2026 Matthew Fennell +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from __future__ import absolute_import, division, print_function + +import html2text + +class filter(object): + + def __init__(self, *args, feed=None, item=None, **kwargs): + if item.get('content'): + item['content_plain'] = ''.join([self.parse(x.value) + for x in item.get('content')]) + elif item.get('description') and item.get('description').strip(): + item['content_plain'] = self.parse(item.get('description')) + + @staticmethod + def parse(html=None): + if html is None: + return None + text_maker = html2text.HTML2Text() + text_maker.inline_links = False + text_maker.images_to_alt = True + text_maker.unicode_snob = True + text_maker.links_each_paragraph = True + text_maker.protect_links = True + text_maker.wrap_links = False + return text_maker.handle(html) -- cgit v1.2.3