From 24702d250a36606af8cbed428929f053e6c0c4df Mon Sep 17 00:00:00 2001 From: Ben Mactavsin <69454747+BenMactavsin@users.noreply.github.com> Date: Thu, 1 Jun 2023 21:32:44 +0300 Subject: [PATCH] Fix website demo's string highlighting behaviour Fixes the highlighting behaviour of website demo when: * String includes `\z` escape sequence followed by newline characters. * String includes just a single backslash (`\`) character at the end of the line. --- docs/assets/js/luau_mode.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/assets/js/luau_mode.js b/docs/assets/js/luau_mode.js index 0a0b933a..363f1b3a 100644 --- a/docs/assets/js/luau_mode.js +++ b/docs/assets/js/luau_mode.js @@ -108,15 +108,20 @@ function string(quote) { return function(stream, state) { - var escaped = false, ch; + var escaped = false, ignoreWhitespace = false, ch; while ((ch = stream.next()) != null) { if (ch == quote && !escaped) { break; } + if (ch == "z" && escaped) { + ignoreWhitespace = true; + stream.eatSpace(); + ignoreWhitespace = stream.eol(); + } escaped = !escaped && ch == "\\"; } - if (!escaped) { + if (!ignoreWhitespace) { state.cur = normal; } return "string"; @@ -164,4 +169,4 @@ blockCommentEnd: "]]" }}); CodeMirror.defineMIME("text/x-luau", "luau"); -}); \ No newline at end of file +});