From 82ba2060db281850aea5e7a1cfbe4ae3fcf04b13 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 5 Jul 2022 12:12:07 +0100 Subject: [PATCH] Refator --- content.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/content.py b/content.py index e5b1af646..2f00f8bed 100644 --- a/content.py +++ b/content.py @@ -1008,6 +1008,17 @@ def _auto_tag(base_dir: str, nickname: str, domain: str, append_tags.append('#' + tag_name) +def _get_simplified_content(content: str) -> str: + """ + """ + content_simplified = \ + content.replace(',', ' ').replace(';', ' ').replace('- ', ' ') + content_simplified = content_simplified.replace('. ', ' ').strip() + if content_simplified.endswith('.'): + content_simplified = content_simplified[:len(content_simplified)-1] + return content_simplified + + def add_html_tags(base_dir: str, http_prefix: str, nickname: str, domain: str, content: str, recipients: [], hashtags: {}, @@ -1022,12 +1033,7 @@ def add_html_tags(base_dir: str, http_prefix: str, content = content.replace('\r', '') content = content.replace('\n', ' --linebreak-- ') content = _add_music_tag(content, 'nowplaying') - content_simplified = \ - content.replace(',', ' ').replace(';', ' ').replace('- ', ' ') - content_simplified = content_simplified.replace('. ', ' ').strip() - if content_simplified.endswith('.'): - content_simplified = content_simplified[:len(content_simplified)-1] - words = content_simplified.split(' ') + words = _get_simplified_content(content).split(' ') # remove . for words which are not mentions new_words = []