Skip to content

Commit

Permalink
C#: Remove duplicates in keywords + regexp optimisation + don't use c…
Browse files Browse the repository at this point in the history
…aptures if not needed
  • Loading branch information
Golmote committed Oct 22, 2017
1 parent d4b9003 commit 75b9b29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions components/prism-csharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ 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': [
{
pattern: /@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/,
pattern: /@("|')(?:\1\1|\\[\s\S]|(?!\1)[^\\])*\1/,
greedy: true
},
{
pattern: /("|')(\\?.)*?\1/,
pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*?\1/,
greedy: true
}
],
'number': /\b-?(0x[\da-f]+|\d*\.?\d+f?)\b/i
'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+f?)\b/i
});

Prism.languages.insertBefore('csharp', 'keyword', {
Expand All @@ -29,7 +29,7 @@ Prism.languages.insertBefore('csharp', 'keyword', {
inside: {
// highlight preprocessor directives as keywords
'directive': {
pattern: /(\s*#)\b(define|elif|else|endif|endregion|error|if|line|pragma|region|undef|warning)\b/,
pattern: /(\s*#)\b(?:define|elif|else|endif|endregion|error|if|line|pragma|region|undef|warning)\b/,
lookbehind: true,
alias: 'keyword'
}
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.

0 comments on commit 75b9b29

Please sign in to comment.