mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 13:00:38 +00:00
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:
parent
4f82a77396
commit
e78897229a
1 changed files with 7 additions and 3 deletions
|
@ -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");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue