Skip to content

Commit dfb6f17

Browse files
committed
C#: Fix wrong highlighting when three slashes appear inside string. Fix #1091
1 parent d6e068a commit dfb6f17

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

components/prism-csharp.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
Prism.languages.csharp = Prism.languages.extend('clike', {
22
'keyword': /\b(abstract|as|async|await|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|virtual|void|volatile|while|add|alias|ascending|async|await|descending|dynamic|from|get|global|group|into|join|let|orderby|partial|remove|select|set|value|var|where|yield)\b/,
33
'string': [
4-
/@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/,
5-
/("|')(\\?.)*?\1/
4+
{
5+
pattern: /@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/,
6+
greedy: true
7+
},
8+
{
9+
pattern: /("|')(\\?.)*?\1/,
10+
greedy: true
11+
}
612
],
713
'number': /\b-?(0x[\da-f]+|\d*\.?\d+f?)\b/i
814
});

components/prism-csharp.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/csharp/issue1091.test

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@"file:///"
2+
3+
----------------------------------------------------
4+
5+
[
6+
["string", "@\"file:///\""]
7+
]
8+
9+
----------------------------------------------------
10+
11+
Checks that three slashes inside a string do not break highlighting.
12+
See #1091.

0 commit comments

Comments
 (0)