Skip to content

Commit

Permalink
enh(csharp) highlight generics in more cases (highlightjs#2599)
Browse files Browse the repository at this point in the history
  • Loading branch information
TupikovVladimir authored and Himura2la committed Aug 5, 2020
1 parent 2a04835 commit 55ee668
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/languages/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ function(hljs) {
]
};

var GENERIC_MODIFIER = {
begin: "<",
end: ">",
contains: [
{ beginKeywords: "in out"},
hljs.TITLE_MODE
]
};
var TYPE_IDENT_RE = hljs.IDENT_RE + '(<' + hljs.IDENT_RE + '(\\s*,\\s*' + hljs.IDENT_RE + ')*>)?(\\[\\])?';

return {
Expand Down Expand Up @@ -161,13 +169,16 @@ function(hljs) {
},
{
className: 'function',
begin: '(' + TYPE_IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*\\(', returnBegin: true,
begin: '(' + TYPE_IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*(\\<.+\\>)?\\s*\\(', returnBegin: true,
end: /\s*[{;=]/, excludeEnd: true,
keywords: KEYWORDS,
contains: [
{
begin: hljs.IDENT_RE + '\\s*\\(', returnBegin: true,
contains: [hljs.TITLE_MODE],
begin: hljs.IDENT_RE + '\\s*(\\<.+\\>)?\\s*\\(', returnBegin: true,
contains: [
hljs.TITLE_MODE,
GENERIC_MODIFIER
],
relevance: 0
},
{
Expand Down

0 comments on commit 55ee668

Please sign in to comment.