From 102094a8900d26e36515777a5638e32249c8eac4 Mon Sep 17 00:00:00 2001 From: Locked-chess-official <13140752715@163.com> Date: Wed, 22 Oct 2025 19:23:32 +0800 Subject: [PATCH] Prevent multilines in Python string patterns in non-thrice quotes Added 'illegal' property to string patterns to prevent newlines. --- src/languages/python.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/languages/python.js b/src/languages/python.js index 2604889790..5e68ac78d7 100644 --- a/src/languages/python.js +++ b/src/languages/python.js @@ -216,24 +216,29 @@ export default function(hljs) { { begin: /([uU]|[rR])'/, end: /'/, + illegal: /\n/, relevance: 10 }, { begin: /([uU]|[rR])"/, end: /"/, + illegal: /\n/, relevance: 10 }, { begin: /([bB]|[bB][rR]|[rR][bB])'/, - end: /'/ + end: /'/, + illegal: /\n/ }, { begin: /([bB]|[bB][rR]|[rR][bB])"/, - end: /"/ + end: /"/, + illegal: /\n/ }, { begin: /([fF][rR]|[rR][fF]|[fF])'/, end: /'/, + illegal: /\n/, contains: [ hljs.BACKSLASH_ESCAPE, LITERAL_BRACKET, @@ -243,6 +248,7 @@ export default function(hljs) { { begin: /([fF][rR]|[rR][fF]|[fF])"/, end: /"/, + illegal: /\n/, contains: [ hljs.BACKSLASH_ESCAPE, LITERAL_BRACKET,