Skip to content

Commit

Permalink
feat: use discord expanded markdown for headers when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
onerandomusername committed Jun 8, 2023
1 parent 8ec3d46 commit 797738b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
7 changes: 7 additions & 0 deletions monty/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
__all__ = (
"Client",
"Colours",
"DiscordFeatures",
"Emojis",
"Icons",
"Stats",
Expand Down Expand Up @@ -104,6 +105,12 @@ class Colours:
gold = 0xE6C200


class DiscordFeatures:
"""Whether to embrace or ignore new features on Discord, in case they get rolled back."""

extended_markdown = True


class Emojis:
cross_mark = "\u274C"
star = "\u2B50"
Expand Down
23 changes: 17 additions & 6 deletions monty/utils/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,23 @@ def strikethrough(self, text: str) -> str:
"""Return crossed-out text."""
return f"~~{text}~~"

def heading(self, text: str, level: int) -> str:
"""Format the heading to be bold if its large enough, and underline it."""
if level in (1, 2, 3):
return f"**__{text}__**\n"
else:
return f"__{text}__\n"
if constants.DiscordFeatures.extended_markdown:

def heading(self, text: str, level: int) -> str:
"""Format the heading to be bold if its large enough, and underline it."""
if level in (1, 2, 3):
return "#" * (4 - level) + f" {text.strip()}\n"
else:
return f"__{text}__\n"

else:

def heading(self, text: str, level: int) -> str:
"""Format the heading to be bold if its large enough, and underline it."""
if level in (1, 2, 3):
return f"**__{text}__**\n"
else:
return f"__{text}__\n"

def newline(self) -> str:
"""No op."""
Expand Down

0 comments on commit 797738b

Please sign in to comment.