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) {
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");
});
});