aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2020-11-06 23:33:15 +0100
committerGravatar Sebastiaan Zeeff <[email protected]>2020-11-06 23:33:15 +0100
commitc99dc2e9faaa691d758e21d9edc4b9bb3c586ca3 (patch)
tree99b75eebd04a13904a263d63bcb711115130541b
parentMerge pull request #1271 from spacecraft1013/code_instructions (diff)
Detect codeblock language with special characters
The regex we use to detect codeblocks did not recognize language specifiers that use a dash, a plus, or a dot in their name. As there are valid language specifiers, such as python-repl and c++, that use those characters, I've changed the regex to reflect that. The character set used now reflects the characters used in language specifiers in highlight.js. Signed-off-by: Sebastiaan Zeeff <[email protected]>
-rw-r--r--bot/exts/info/codeblock/_parsing.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/bot/exts/info/codeblock/_parsing.py b/bot/exts/info/codeblock/_parsing.py
index 65a2272c8..e35fbca22 100644
--- a/bot/exts/info/codeblock/_parsing.py
+++ b/bot/exts/info/codeblock/_parsing.py
@@ -36,7 +36,7 @@ _RE_CODE_BLOCK = re.compile(
(?P<tick>[{''.join(_TICKS)}]) # Put all ticks into a character class within a group.
\2{{2}} # Match previous group 2 more times to ensure the same char.
)
- (?P<lang>[^\W_]+\n)? # Optionally match a language specifier followed by a newline.
+ (?P<lang>[A-Za-z0-9\+\-\.]+\n)? # Optionally match a language specifier followed by a newline.
(?P<code>.+?) # Match the actual code within the block.
\1 # Match the same 3 ticks used at the start of the block.
""",