Skip to content

Commit a5107d5

Browse files
authored
Kotlin: Added support for backticks in function names (#2489)
1 parent f217ab7 commit a5107d5

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

components/prism-kotlin.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
lookbehind: true
77
},
88
'function': [
9-
/\w+(?=\s*\()/,
109
{
11-
pattern: /(\.)\w+(?=\s*\{)/,
12-
lookbehind: true
10+
pattern: /(?:`[^\r\n`]+`|\w+)(?=\s*\()/,
11+
greedy: true
12+
},
13+
{
14+
pattern: /(\.)(?:`[^\r\n`]+`|\w+)(?=\s*\{)/,
15+
lookbehind: true,
16+
greedy: true
1317
}
1418
],
1519
'number': /\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/,

components/prism-kotlin.min.js

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

tests/languages/kotlin/function_feature.test

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
foo()
22
foo_Bar_42()
33
list.filter {}
4+
`function 1`()
5+
` !"#$%^&()*+,=?@{|}~-_`()
6+
list.`take 1` {}
7+
`make fun`()
48

59
----------------------------------------------------
610

711
[
812
["function", "foo"], ["punctuation", "("], ["punctuation", ")"],
913
["function", "foo_Bar_42"], ["punctuation", "("], ["punctuation", ")"],
1014
"\r\nlist", ["punctuation", "."],
11-
["function", "filter"], ["punctuation", "{"], ["punctuation", "}"]
15+
["function", "filter"], ["punctuation", "{"], ["punctuation", "}"],
16+
["function", "`function 1`"], ["punctuation", "("], ["punctuation", ")"],
17+
["function", "` !\"#$%^&()*+,=?@{|}~-_`"], ["punctuation", "("], ["punctuation", ")"],
18+
"\r\nlist", ["punctuation", "."],
19+
["function", "`take 1`"], ["punctuation", "{"], ["punctuation", "}"],
20+
["function", "`make fun`"], ["punctuation", "("], ["punctuation", ")"]
1221
]
1322

1423
----------------------------------------------------

0 commit comments

Comments
 (0)