misc: added brush for SyntaxHighlighter JS script
authorAlexandre Terrasa <alexandre@moz-code.org>
Fri, 7 Feb 2014 05:35:22 +0000 (00:35 -0500)
committerAlexandre Terrasa <alexandre@moz-code.org>
Fri, 7 Feb 2014 05:35:22 +0000 (00:35 -0500)
SyntaxHighlighter is an open source Javascript client side code syntax hilighter.
More details on http://alexgorbatchev.com/SyntaxHighlighter/

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

misc/README
misc/syntaxhighlighter/shBrushNit.js [new file with mode: 0644]

index 5166943..6f19e2c 100644 (file)
@@ -1,6 +1,16 @@
 # gtksourceview (gedit and other GTK editors)
 To install in your home, just link (or copy) the language definition file in ~/.local/share/gtksourceview-2.0/language-specs
 
+# syntaxhighlighter
+
+Nit brush for the Alex Gorbatchev's JS syntaxhighlighter.
+
+To install the JS syntaxhighlighter, please refer to http://alexgorbatchev.com/SyntaxHighlighter/
+
+Then can add the brush to your html page:
+
+       <script type="text/javascript" src="shBrushNit.js"></script>
+
 # vim
 
 vim is a powerful text editor.
diff --git a/misc/syntaxhighlighter/shBrushNit.js b/misc/syntaxhighlighter/shBrushNit.js
new file mode 100644 (file)
index 0000000..e9d1f78
--- /dev/null
@@ -0,0 +1,52 @@
+/* This file is part of NIT ( http://www.nitlanguage.org ).
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Nit Brush for SyntaxHighlighter
+ * see http://alexgorbatchev.com/SyntaxHighlighter
+ */
+
+;(function()
+{
+       // CommonJS
+       typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;
+
+       function Brush()
+       {
+               var keywords =  'abort abstract and as assert break class continue do else end enum extern false for fun' +
+                                               'if import in init interface intrude is isa isset label loop module new null nullable not' +
+                                               'once or protected private redef return self super then type true universal var' +
+                                               'when while writable';
+               var builtins =  'exit sys args get_time getc getcwd gets print printn';
+
+               this.regexList = [
+                       { regex: SyntaxHighlighter.regexLib.singleLinePerlComments,     css: 'comments' },      // one line comments
+                       { regex: SyntaxHighlighter.regexLib.doubleQuotedString,         css: 'string' },        // double quoted strings
+                       { regex: SyntaxHighlighter.regexLib.singleQuotedString,         css: 'string' },        // single quoted strings
+                       { regex: /\b[A-Z0-9_]+\b/g,                                                                     css: 'constants' },     // types
+                       { regex: /[A-Z][A-Za-z0-9_]*/g,                                                         css: 'color2' },        // classes
+                       { regex: new RegExp(this.getKeywords(keywords), 'gm'),          css: 'keyword' },       // keywords
+                       { regex: new RegExp(this.getKeywords(builtins), 'gm'),          css: 'color3' }         // builtins
+               ];
+               this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
+       };
+
+       Brush.prototype = new SyntaxHighlighter.Highlighter();
+       Brush.aliases   = ['nit'];
+
+       SyntaxHighlighter.brushes.Nit = Brush;
+
+       // CommonJS
+       typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
+})();
+