Skip to content

Commit

Permalink
C#: Fix wrong highlighting when three slashes appear inside string. Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Feb 7, 2017
1 parent d6e068a commit dfb6f17
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
10 changes: 8 additions & 2 deletions components/prism-csharp.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
Prism.languages.csharp = Prism.languages.extend('clike', {
'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/,
'string': [
/@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/,
/("|')(\\?.)*?\1/
{
pattern: /@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/,
greedy: true
},
{
pattern: /("|')(\\?.)*?\1/,
greedy: true
}
],
'number': /\b-?(0x[\da-f]+|\d*\.?\d+f?)\b/i
});
Expand Down
2 changes: 1 addition & 1 deletion components/prism-csharp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions tests/languages/csharp/issue1091.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@"file:///"

----------------------------------------------------

[
["string", "@\"file:///\""]
]

----------------------------------------------------

Checks that three slashes inside a string do not break highlighting.
See #1091.

0 comments on commit dfb6f17

Please sign in to comment.