mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 03:38:53 -05:00
[Utils] Markdown helpers escape special chars (#2182)
Escaping italics (`*`) that get passed to `italics()` doesn't work, the string still won't show up properly.
This commit is contained in:
parent
fdf3f86ab0
commit
03892f5ef1
@ -67,6 +67,7 @@ def bold(text: str) -> str:
|
|||||||
The marked up text.
|
The marked up text.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
text = escape(text, formatting=True)
|
||||||
return "**{}**".format(text)
|
return "**{}**".format(text)
|
||||||
|
|
||||||
|
|
||||||
@ -104,7 +105,10 @@ def inline(text: str) -> str:
|
|||||||
The marked up text.
|
The marked up text.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return "`{}`".format(text)
|
if "`" in text:
|
||||||
|
return "``{}``".format(text)
|
||||||
|
else:
|
||||||
|
return "`{}`".format(text)
|
||||||
|
|
||||||
|
|
||||||
def italics(text: str) -> str:
|
def italics(text: str) -> str:
|
||||||
@ -121,6 +125,7 @@ def italics(text: str) -> str:
|
|||||||
The marked up text.
|
The marked up text.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
text = escape(text, formatting=True)
|
||||||
return "*{}*".format(text)
|
return "*{}*".format(text)
|
||||||
|
|
||||||
|
|
||||||
@ -276,6 +281,7 @@ def strikethrough(text: str) -> str:
|
|||||||
The marked up text.
|
The marked up text.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
text = escape(text, formatting=True)
|
||||||
return "~~{}~~".format(text)
|
return "~~{}~~".format(text)
|
||||||
|
|
||||||
|
|
||||||
@ -293,6 +299,7 @@ def underline(text: str) -> str:
|
|||||||
The marked up text.
|
The marked up text.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
text = escape(text, formatting=True)
|
||||||
return "__{}__".format(text)
|
return "__{}__".format(text)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user