Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add syntax highlight for Kotlin #230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions syntaxhighlighter3/scripts/shBrushKotlin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* SyntaxHighlighter
* http://alexgorbatchev.com/SyntaxHighlighter
*
* SyntaxHighlighter is donationware. If you are using it, please donate.
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
*
* @version
* 3.0.83 (Wed, 16 Apr 2014 03:56:09 GMT)
*
* @copyright
* Copyright (C) 2004-2013 Alex Gorbatchev.
*
* @license
* Dual licensed under the MIT and GPL licenses.
*/
; (function ()
{
// CommonJS
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined' ? require('shCore').SyntaxHighlighter : null);

function Brush()
{
var keywords = 'as as? break class continue do else false for fun if in !in interface ' +
'is !is null object package return super this throw true ' +
'try typealias typeof val var when while by catch constructor ' +
'delegate dynamic field file finally get import init param property ' +
'receiver set setparam value where actual abstract annotation companion ' +
'const crossinline data enum expect external final infix inline ' +
'inner internal lateinit noinline open operator out override private ' +
'protected public reified sealed suspend tailrec vararg field it ';

this.regexList = [
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
{ regex: /\/\*([^\*][\s\S]*?)?\*\//gm, css: 'comments' }, // multiline comments
{ regex: /\/\*(?!\*\/)\*[\s\S]*?\*\//gm, css: 'preprocessor' }, // documentation comments
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
{ regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi, css: 'value' }, // numbers
{ regex: /(?!\@interface\b)\@[\$\w]+\b/g, css: 'color1' }, // annotation @anno
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // kotlin keyword
];

this.forHtmlScript({
left: /(&lt;|<)%[@!=]?/g,
right: /%(&gt;|>)/g
});
};

Brush.prototype = new SyntaxHighlighter.Highlighter();
Brush.aliases = ['kotlin'];

SyntaxHighlighter.brushes.Kotlin = Brush;

// CommonJS
typeof (exports) != 'undefined' ? exports.Brush = Brush : null;
})();