fixed html tags showing up on Feeds

Added test for RSS feed with html elements
This commit is contained in:
Ace 2020-12-02 01:00:28 +01:00
parent 5b8f7473d0
commit b6a64681a0
2 changed files with 14 additions and 1 deletions

View File

@ -5,6 +5,7 @@
RSS module for InkyCal Project
Copyright by aceisace
"""
import re
from inkycal.modules.template import inkycal_module
from inkycal.custom import *
@ -111,7 +112,9 @@ class Feeds(inkycal_module):
for feeds in self.feed_urls:
text = feedparser.parse(feeds)
for posts in text.entries:
parsed_feeds.append(f'{posts.title}: {posts.summary}')
summary = posts.summary
parsed_feeds.append(
f"{posts.title}: {re.sub('<[^<]+?>', '', posts.summary)}")
self._parsed_feeds = parsed_feeds

View File

@ -22,6 +22,16 @@ tests = [
"padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en"
}
},
{
"position": 1,
"name": "Feeds",
"config": {
"size": [400,100],
"feed_urls": "https://www.anekdot.ru/rss/export_top.xml",
"shuffle_feeds": False,
"padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en"
}
},
]
class module_test(unittest.TestCase):