- commit
- 81ced4023704dc0086098738512a841dfdaac45b
- parent
- 5fafa14acfea42f24913782381c1a635c50b9099
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-07-02 07:59
add lineabreaks to plain text content
Diffstat
| M | plutopluto/__init__.py | 11 | +++++++++++ |
1 files changed, 11 insertions, 0 deletions
diff --git a/plutopluto/__init__.py b/plutopluto/__init__.py
@@ -19,6 +19,15 @@ __version__ = '1.2.0' 19 19 app = Flask(__name__) 20 20 21 21 -1 22 def linebreaks(text): -1 23 html = ( -1 24 text -1 25 .replace('\n\n', '</p><p>') -1 26 .replace('\n', '<br>') -1 27 ) -1 28 return '<p>' + html + '</p>' -1 29 -1 30 22 31 @functools.lru_cache 23 32 def parse(url): 24 33 """Get feed and convert to JSON.""" @@ -39,6 +48,8 @@ def parse(url): 39 48 d['source'] = feed.feed.get('title') 40 49 d['source_link'] = feed.feed.get('link') 41 50 d['content'] = item.get('description', '') -1 51 if '<' not in d['content']: -1 52 d['content'] = linebreaks(d['content']) 42 53 if 'youtube' in url: 43 54 thumbnail = '<a href="%s"><img alt="" src="%s" /></a>' % ( 44 55 d['link'],