fixed all markdown issues

This commit is contained in:
Linus E
2022-05-10 18:22:03 +02:00
parent 7b323595f3
commit a3172cc9c5
2 changed files with 29 additions and 15 deletions

View File

@@ -16,13 +16,13 @@ def contains_markdown_symbols(text):
:rtype: bool
"""
if text.find("_") != -1 or text.find("*") != -1 or text.find("~") != -1 or text.find("`") != -1: # check if text contains markdown symbols
if text.find("_") != -1 or text.find("*") != -1 or text.find("`") != -1: # check if text contains relevant markdown symbols
return True
return False
def make_markdown_proof(text):
def make_markdown_proof(text): # used to avoid errors related to markdown parsemode for telegram messaging
""" makes text markdown proof
:type text: string
@@ -37,11 +37,13 @@ def make_markdown_proof(text):
text = text.replace("_", "\\_")
text = text.replace("*", "\\*")
text = text.replace("~", "\\~")
text = text.replace("`", "\\`")
return text
if __name__ == '__main__':
print("this is a module for helper functions for the bot and should not be run directly")
print("this is a module for helper functions for the bot and should not be run directly")
print(make_markdown_proof("_test_"))
text = make_markdown_proof("_test_")
print(f"{text}")