aboutsummaryrefslogtreecommitdiffstats
path: root/bot/cogs/codeblock/parsing.py
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-05-06 13:30:51 -0700
committerGravatar MarkKoz <[email protected]>2020-06-13 11:21:05 -0700
commit2a7dcccf7a6b352e3f43b4248d00d9ec15af243e (patch)
tree5ff3902606e17150e2c3839fa58b5addd6007e9d /bot/cogs/codeblock/parsing.py
parentCode block: move parsing functions to a separate module (diff)
Code block: rework the instruction formatting functions
A new module, `instructions`, was created to house the functions. 4 ways in which code blocks can be incorrect are considered: 1. The code is not within a code block at all 2. Incorrect characters are used for back ticks 3. A language is not specified 4. A language is specified incorrectly Splitting it up into these 4 cases allows for more specific and relevant instructions to be shown to users. If a message has both incorrect back ticks and an issue with the language specifier, the instructions for fixing both issues are combined. The instructions show a generic code example rather than using the original code from the message. This circumvents any ambiguities when parsing their message and trying to fix it. The escaped code block also failed to preserve indentation. This was a problem because some users would copy it anyway and end up with poorly formatted code. By using a simple example that doesn't rely on indentation, it makes it clear the example is not meant to be copied. Finally, the new examples are shorter and thus make the embed not as giant.
Diffstat (limited to '')
-rw-r--r--bot/cogs/codeblock/parsing.py2
1 files changed, 0 insertions, 2 deletions
diff --git a/bot/cogs/codeblock/parsing.py b/bot/cogs/codeblock/parsing.py
index 7a096758b..d541441e0 100644
--- a/bot/cogs/codeblock/parsing.py
+++ b/bot/cogs/codeblock/parsing.py
@@ -7,8 +7,6 @@ import discord
log = logging.getLogger(__name__)
-RE_MARKDOWN = re.compile(r'([*_~`|>])')
-RE_CODE_BLOCK_LANGUAGE = re.compile(r"```(?:[^\W_]+)\n(.*?)```", re.DOTALL)
BACKTICK = "`"
TICKS = {
BACKTICK,