mirror of https://gitlab.com/bashrc2/epicyon
Remove unused characters before converting post to html
parent
2948264173
commit
9eaf4c4cdc
23
languages.py
23
languages.py
|
@ -302,17 +302,20 @@ def auto_translate_post(base_dir: str, post_json_object: {},
|
||||||
lang_list = \
|
lang_list = \
|
||||||
libretranslate_languages(libretranslate_url, libretranslate_api_key)
|
libretranslate_languages(libretranslate_url, libretranslate_api_key)
|
||||||
for lang in lang_list:
|
for lang in lang_list:
|
||||||
|
content = None
|
||||||
if msg_object['contentMap'].get(lang):
|
if msg_object['contentMap'].get(lang):
|
||||||
content = msg_object['contentMap'][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 = \
|
translated_text = \
|
||||||
libretranslate(libretranslate_url, content,
|
'<p>' + translate['Translated'].upper() + '</p>' + \
|
||||||
lang, system_language,
|
translated_text
|
||||||
libretranslate_api_key)
|
return translated_text
|
||||||
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
|
|
||||||
return ''
|
return ''
|
||||||
|
|
|
@ -2055,6 +2055,9 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
|
|
||||||
if not is_pgp_encrypted(content_str):
|
if not is_pgp_encrypted(content_str):
|
||||||
if not is_patch:
|
if not is_patch:
|
||||||
|
# remove any tabs
|
||||||
|
content_str = \
|
||||||
|
content_str.replace('\t', '').replace('\r', '')
|
||||||
# Add bold text
|
# Add bold text
|
||||||
if bold_reading and \
|
if bold_reading and \
|
||||||
not displaying_ciphertext and \
|
not displaying_ciphertext and \
|
||||||
|
|
Loading…
Reference in New Issue