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.
This commit is contained in:
Ben Mactavsin 2023-06-01 21:32:44 +03:00 committed by GitHub
parent 271c509046
commit 24702d250a
Signed by: DevComp
GPG key ID: 4AEE18F83AFDEB23

View file

@ -108,15 +108,20 @@
function string(quote) { function string(quote) {
return function(stream, state) { return function(stream, state) {
var escaped = false, ch; var escaped = false, ignoreWhitespace = false, ch;
while ((ch = stream.next()) != null) { while ((ch = stream.next()) != null) {
if (ch == quote && !escaped) { if (ch == quote && !escaped) {
break; break;
} }
if (ch == "z" && escaped) {
ignoreWhitespace = true;
stream.eatSpace();
ignoreWhitespace = stream.eol();
}
escaped = !escaped && ch == "\\"; escaped = !escaped && ch == "\\";
} }
if (!escaped) { if (!ignoreWhitespace) {
state.cur = normal; state.cur = normal;
} }
return "string"; return "string";
@ -164,4 +169,4 @@
blockCommentEnd: "]]" blockCommentEnd: "]]"
}}); }});
CodeMirror.defineMIME("text/x-luau", "luau"); CodeMirror.defineMIME("text/x-luau", "luau");
}); });