Initial import of 4.x module.
This commit is contained in:
parent
af67f93887
commit
b4d2df93d3
8 changed files with 193 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
node_modules
|
||||
bower_components
|
5
.travis.yml
Normal file
5
.travis.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- "4"
|
||||
- "5"
|
11
README.md
Normal file
11
README.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# brush-kotlin
|
||||
|
||||
Kotlin brush module for [SyntaxHighlighter](https://github.com/syntaxhighlighter/syntaxhighlighter).
|
||||
|
||||
## Usage
|
||||
|
||||
Please see [Building Instructions](https://github.com/syntaxhighlighter/syntaxhighlighter/wiki/Building) on the [SyntaxHighlighter Wiki](https://github.com/syntaxhighlighter/syntaxhighlighter/wiki) for details.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
70
brush.js
Normal file
70
brush.js
Normal file
|
@ -0,0 +1,70 @@
|
|||
var BrushBase = require('brush-base');
|
||||
var regexLib = require('syntaxhighlighter-regex').commonRegExp;
|
||||
|
||||
function Brush() {
|
||||
var keywords = 'abstract annotation as break by catch class companion const constructor continue' +
|
||||
' crossinline data do dynamic else enum external false 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 tailrec this throw trait true try type val var vararg when where while' +
|
||||
' String Array Unit Int';
|
||||
|
||||
this.regexList = [
|
||||
{
|
||||
// line comment
|
||||
regex: regexLib.singleLineCComments,
|
||||
css: 'comments'
|
||||
},
|
||||
{
|
||||
// block comment
|
||||
regex: /\/\*([^\*][\s\S]*?)?\*\//gm,
|
||||
css: 'comments'
|
||||
},
|
||||
{
|
||||
// javadoc
|
||||
regex: /\/\*(?!\*\/)\*[\s\S]*?\*\//gm,
|
||||
css: 'preprocessor'
|
||||
},
|
||||
{
|
||||
regex: regexLib.doubleQuotedString,
|
||||
css: 'string'
|
||||
},
|
||||
{
|
||||
regex: regexLib.singleQuotedString,
|
||||
css: 'string'
|
||||
},
|
||||
{
|
||||
// numbers
|
||||
regex: /\b([\d]+(\.[\d]+)?f?|[\d]+l?|0x[a-f0-9]+)\b/gi,
|
||||
css: 'value'
|
||||
},
|
||||
{
|
||||
// annotations
|
||||
regex: /\@(Target|Retention|Repeatable|MustBeDocumented|Test|Deprecated)/g,
|
||||
css: 'color2'
|
||||
},
|
||||
{
|
||||
// User-site targets
|
||||
regex: /\@(file|property|field|get|set|receiver|param|setparam|delegate):/g,
|
||||
css: 'color2'
|
||||
},
|
||||
{
|
||||
// @Inject annotation
|
||||
regex: /\@(Inject)\b/g,
|
||||
css: 'color3'
|
||||
},
|
||||
{
|
||||
regex: new RegExp(this.getKeywords(keywords), 'gm'),
|
||||
css: 'keyword'
|
||||
}
|
||||
];
|
||||
|
||||
this.forHtmlScript({
|
||||
left: /(<|<)%[@!=]?/g,
|
||||
right: /%(>|>)/g
|
||||
});
|
||||
};
|
||||
|
||||
Brush.prototype = new BrushBase();
|
||||
Brush.aliases = ['kotlin'];
|
||||
module.exports = Brush;
|
4
mocha.opts
Normal file
4
mocha.opts
Normal file
|
@ -0,0 +1,4 @@
|
|||
--recursive
|
||||
--reporter spec
|
||||
--ui bdd
|
||||
--timeout 3000
|
46
package.json
Normal file
46
package.json
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "brush-kotlin",
|
||||
"version": "0.2.0",
|
||||
"description": "Kotlin brush module for SyntaxHighlighter.",
|
||||
"keywords": [
|
||||
"syntaxhighlighter",
|
||||
"brush",
|
||||
"kotlin"
|
||||
],
|
||||
"homepage": "https://github.com/ethauvin/brush-kotlin",
|
||||
"bugs": "https://github.com/syntaxhighlighter/brush-kotlin/issues",
|
||||
"author": {
|
||||
"name": "Erik C. Thauvin",
|
||||
"url": "https://github.com/ethauvin"
|
||||
},
|
||||
"main": "brush.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/syntaxhighlighter/brush-kotlin.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "babel-node --only='syntaxhighlighter-*,brush-*' node_modules/.bin/_mocha --opts mocha.opts test.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"brush-base": "^4.0.0",
|
||||
"syntaxhighlighter-regex": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.4.5",
|
||||
"babel-core": "^6.1.21",
|
||||
"babel-preset-es2015": "^6.1.18",
|
||||
"chai": "^3.4.1",
|
||||
"mocha": "^2.3.4",
|
||||
"syntaxhighlighter-match": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4",
|
||||
"npm": ">=2"
|
||||
},
|
||||
"license": "MIT",
|
||||
"babel": {
|
||||
"presets": [
|
||||
"es2015"
|
||||
]
|
||||
}
|
||||
}
|
20
sample.txt
Normal file
20
sample.txt
Normal file
|
@ -0,0 +1,20 @@
|
|||
package demo
|
||||
|
||||
/**
|
||||
* This class supports greeting people by name.
|
||||
*
|
||||
* @property name The name of the person to be greeted.
|
||||
*/
|
||||
class Greeter(val name: String) {
|
||||
|
||||
/**
|
||||
* Prints the greeting to the standard output.
|
||||
*/
|
||||
fun greet() {
|
||||
println("Hello $name!")
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
Greeter(args[0]).greet()
|
||||
}
|
35
test.js
Normal file
35
test.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
var chai = require('chai');
|
||||
var expect = chai.expect;
|
||||
var match = require('syntaxhighlighter-match');
|
||||
var Brush = require('./brush');
|
||||
var sample = require('fs').readFileSync(`${__dirname}/sample.txt`, 'utf8');
|
||||
|
||||
describe('brush-java', function() {
|
||||
var instance = null;
|
||||
|
||||
before(function() {
|
||||
instance = new Brush();
|
||||
});
|
||||
|
||||
it('has populated code sample', function() {
|
||||
expect(sample).to.not.match(/^Populate/);
|
||||
});
|
||||
|
||||
describe('instance', function() {
|
||||
it('has `regexList`', function() {
|
||||
expect(instance).to.have.property('regexList');
|
||||
});
|
||||
});
|
||||
|
||||
describe('parsing', function() {
|
||||
var matches = null;
|
||||
|
||||
before(function() {
|
||||
matches = match.applyRegexList(sample, instance.regexList);
|
||||
});
|
||||
|
||||
it('can parse', function() {
|
||||
expect(matches).to.have.length.above(0);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue