From e78897229a24328aba343694d1004b1cc5c607dc Mon Sep 17 00:00:00 2001 From: Ben Mactavsin <69454747+BenMactavsin@users.noreply.github.com> Date: Tue, 6 Jun 2023 21:22:31 +0300 Subject: [PATCH] Fix website demo's string highlighting behaviour (#942) Fixes #935: * String literals that include `\z` escape sequence followed by newline characters are now correctly highlighted. * Unescaped backslash (`\`) character at the end of the line no longer acts like the `\z` escape sequence inside string literals when highlighting. --- docs/assets/js/luau_mode.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/assets/js/luau_mode.js b/docs/assets/js/luau_mode.js index 0a0b933a..1e53143f 100644 --- a/docs/assets/js/luau_mode.js +++ b/docs/assets/js/luau_mode.js @@ -108,15 +108,19 @@ 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) { + stream.eatSpace(); + ignoreWhitespace = stream.eol(); + } escaped = !escaped && ch == "\\"; } - if (!escaped) { + if (!ignoreWhitespace) { state.cur = normal; } return "string"; @@ -164,4 +168,4 @@ blockCommentEnd: "]]" }}); CodeMirror.defineMIME("text/x-luau", "luau"); -}); \ No newline at end of file +});