From c99dc2e9faaa691d758e21d9edc4b9bb3c586ca3 Mon Sep 17 00:00:00 2001 From: Sebastiaan Zeeff Date: Fri, 6 Nov 2020 23:33:15 +0100 Subject: 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 --- bot/exts/info/codeblock/_parsing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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[{''.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[^\W_]+\n)? # Optionally match a language specifier followed by a newline. + (?P[A-Za-z0-9\+\-\.]+\n)? # Optionally match a language specifier followed by a newline. (?P.+?) # Match the actual code within the block. \1 # Match the same 3 ticks used at the start of the block. """, -- cgit v1.2.3