1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-04-13 11:40:29 +02:00

JavaScript: String Single Character Escape Sequences (#415)

https://tc39.es/ecma262#table-string-single-character-escape-sequences
This commit is contained in:
Steven Penny 2020-10-24 20:48:00 -05:00 committed by GitHub
parent 4453913798
commit 639fa3adc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

View File

@ -49,6 +49,7 @@ var JavascriptRules = Rules{
{"`", LiteralStringBacktick, Pop(1)},
{`\\\\`, LiteralStringBacktick, nil},
{"\\\\`", LiteralStringBacktick, nil},
{"\\\\[^`\\\\]", LiteralStringBacktick, nil},
{`\$\{`, LiteralStringInterpol, Push("interp-inside")},
{`\$`, LiteralStringBacktick, nil},
{"[^`\\\\$]+", LiteralStringBacktick, nil},

View File

@ -1,2 +1,3 @@
sum = parseInt(num1) + parseInt(num2) // "+" means "add"
alert("Sum = " + sum) // "+" means combine into a string
alert("Sum = " + sum) // "+" means combine into a string
const filePath = String.raw`C:\Development\profile\aboutme.html`;

View File

@ -25,5 +25,17 @@
{"type":"NameOther","value":"sum"},
{"type":"Punctuation","value":")"},
{"type":"Text","value":" "},
{"type":"CommentSingle","value":"// \"+\" means combine into a string\n"}
{"type":"CommentSingle","value":"// \"+\" means combine into a string\n"},
{"type":"KeywordReserved","value":"const"},
{"type":"Text","value":" "},
{"type":"NameOther","value":"filePath"},
{"type":"Text","value":" "},
{"type":"Operator","value":"="},
{"type":"Text","value":" "},
{"type":"NameBuiltin","value":"String"},
{"type":"Punctuation","value":"."},
{"type":"NameOther","value":"raw"},
{"type":"LiteralStringBacktick","value":"`C:\\Development\\profile\\aboutme.html`"},
{"type":"Punctuation","value":";"},
{"type":"Text","value":"\n"}
]