Remove unused characters before converting post to html

main
Bob Mottram 2022-05-09 18:20:05 +01:00
parent 2948264173
commit 9eaf4c4cdc
2 changed files with 16 additions and 10 deletions

View File

@ -302,17 +302,20 @@ def auto_translate_post(base_dir: str, post_json_object: {},
lang_list = \
libretranslate_languages(libretranslate_url, libretranslate_api_key)
for lang in lang_list:
content = None
if msg_object['contentMap'].get(lang):
content = msg_object['contentMap'][lang]
if not content:
continue
translated_text = \
libretranslate(libretranslate_url, content,
lang, system_language,
libretranslate_api_key)
if translated_text:
if remove_html(translated_text) == remove_html(content):
return content
translated_text = \
libretranslate(libretranslate_url, content,
lang, system_language,
libretranslate_api_key)
if translated_text:
if remove_html(translated_text) == remove_html(content):
return content
translated_text = \
'<p>' + translate['Translated'].upper() + '</p>' + \
translated_text
return translated_text
'<p>' + translate['Translated'].upper() + '</p>' + \
translated_text
return translated_text
return ''

View File

@ -2055,6 +2055,9 @@ def individual_post_as_html(signing_priv_key_pem: str,
if not is_pgp_encrypted(content_str):
if not is_patch:
# remove any tabs
content_str = \
content_str.replace('\t', '').replace('\r', '')
# Add bold text
if bold_reading and \
not displaying_ciphertext and \