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.
This commit is contained in:
Ben Mactavsin 2023-06-06 21:22:31 +03:00 committed by GitHub
parent 4f82a77396
commit e78897229a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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