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