Skip to content

Commit

Permalink
Kotlin: add backticks support
Browse files Browse the repository at this point in the history
  • Loading branch information
osipxd committed Jul 28, 2020
1 parent 49a96e9 commit 1475d0e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions components/prism-kotlin.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
(function (Prism) {

var functionName = /(?:`[\w !"#$%^&()*+,=?@{|}~\-]+`|\w+)/.source;

Prism.languages.kotlin = Prism.languages.extend('clike', {
'keyword': {
// The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get
pattern: /(^|[^.])\b(?:abstract|actual|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|dynamic|else|enum|expect|external|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|operator|out|override|package|private|protected|public|reified|return|sealed|set|super|suspend|tailrec|this|throw|to|try|typealias|val|var|vararg|when|where|while)\b/,
lookbehind: true
},
'function': [
/\w+(?=\s*\()/,
RegExp(/<name>(?=\s*\()/.source.replace('<name>', functionName)),
{
pattern: /(\.)\w+(?=\s*\{)/,
pattern: RegExp(/(\.)<name>(?=\s*\{)/.source.replace('<name>', functionName)),
lookbehind: true
}
],
Expand Down

0 comments on commit 1475d0e

Please sign in to comment.