Permalink
Browse files

Release 1.0

  • Loading branch information...
0 parents commit be7edcd69e3328434d5ec25b5a5e36df97db7cc8 @ioquatix committed Feb 15, 2010

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,44 @@
+*** jQuery.Syntax ***
+
+jQuery.Syntax is a light weight client-side syntax highlighter, which dynamically loads external dependencies (js & css) when required. It uses jQuery to make it cross-browser compatible and to simplify integration.
+
+For more documentation, please see :
+ <http://www.oriontransfer.co.nz/software/jquery-syntax/>.
+
+For licensing details, please see the included LICENSE.txt.
+
+The jQuery name and logo is Copyright 2010 The jQuery Project.
+
+*** Compatibility ***
+
+jQuery.Syntax requires jQuery version 1.4.1+ <http://www.jquery.org>. It might work with earlier versions, but it hasn't been tested.
+
+Don't take my word for it... but it has been tested in
+ - IE6: Works fine, minor visual glitches, requires the html to be .clone(true) before it is inserted, or it doesn't show up.
+ - IE7: Not tested.
+ - IE8: Works fine.
+ - FF3.6: Works fine.
+ - Safari4: Works fine.
+
+If you can test in other browsers and let me know if it is successful, I'll add them to this list.
+
+*** Donations ***
+
+jQuery.Syntax is available as free software (under the license details given above). If you use it, please donate. It will help me to make more free projects in the future.
+
+For a negotiable fee, I am happy to:
+ - Write syntax brushes for other languages.
+ - Create custom themes for your website.
+ - Assist with integration into your website / CMS / blog.
+
+If you are a commercial entity, Orion Transfer Ltd sells commercial licenses for jQuery.Syntax.
+
+*** Credits ***
+
+I, Samuel Williams, developed the majority of this code. I was helped by a number of kind people on IRC when banging my head against bugs in Internet Explorer, and other such issues. Thanks to everyone who helped.
+
+Thanks to The jQuery Project for providing such a wonderful framework. It is easy to work with and makes life much easier when dealing with cross-browser issues.
+
+Thanks to Alex Gorbatchev whose SyntaxHighlighter project provided a lot of ideas and inspired me to work hard. I think he has contributed a great deal to the community.
+
+Thanks to Tadao Takaoka, my wise sensei, who has listened to me talk about algorithms for countless hours. jQuery.Syntax has a number of interesting and unique algorithms to solve highlighting problems efficiently. jQuery.Syntax is extremely fast because he helped me to think about the problem in new ways.
@@ -0,0 +1,5 @@
+.syntax .applescript {
+ font-family: Geneva, Helvetica, sans-serif; }
+ .syntax .applescript .keyword {
+ color: #00f;
+ font-weight: bold; }

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,8 @@
+.syntax .asm .register {
+ color: #3caa20;
+ font-style: italic; }
+.syntax .asm .label {
+ font-weight: bold;
+ color: #2a85b3; }
+.syntax .asm .directive {
+ color: #828a3d; }
@@ -0,0 +1,26 @@
+// brush: "asm" aliases: []
+
+// This file is part of the "jQuery.Syntax" project, and is licensed under the GNU AGPLv3.
+// Copyright 2010 Samuel Williams. All rights reserved.
+// See <jquery.syntax.js> for licensing details.
+
+Syntax.register('asm', function(brush) {
+ brush.push(Syntax.lib.cStyleComment);
+ brush.push(Syntax.lib.cppStyleComment);
+
+ brush.push({
+ pattern: /^\s+([a-zA-Z]+)/gm,
+ matches: Syntax.extractMatches({klass: 'function'})
+ });
+
+ brush.push({pattern: /\.[a-zA-Z_][a-zA-Z0-9_]*/gm, klass: 'directive'});
+
+ brush.push({pattern: /^[a-zA-Z_][a-zA-Z0-9_]*:/gm, klass: 'label'});
+
+ brush.push({pattern: /(-[0-9]+)|(\b[0-9]+)|(\$[0-9]+)/g, klass: 'constant'});
+ brush.push({pattern: /(\-|\b|\$)(0x[0-9a-f]+|[0-9]+)/g, klass: 'constant'});
+
+ brush.push({pattern: /%\w+/g, klass: 'register'});
+
+ brush.push(Syntax.lib.perlStyleComment);
+});
@@ -0,0 +1,2 @@
+.syntax .preprocessor {
+ text-decoration: underline; }
@@ -0,0 +1,55 @@
+// brush: "clang" aliases: ["cpp", "c++", "c", "objective-c"]
+
+// This file is part of the "jQuery.Syntax" project, and is licensed under the GNU AGPLv3.
+// Copyright 2010 Samuel Williams. All rights reserved.
+// See <jquery.syntax.js> for licensing details.
+
+Syntax.register('clang', function(brush) {
+ var keywords = ["@interface", "@implementation", "@protocol", "@end", "@try", "@throw", "@catch", "@finally", "@class", "@selector", "@encode", "@synchronized", "@property", "struct", "break", "continue", "else", "for", "switch", "case", "default", "enum", "goto", "register", "sizeof", "typedef", "volatile", "do", "extern", "if", "return", "static", "union", "while", "asm", "dynamic_cast", "namespace", "reinterpret_cast", "try", "explicit", "static_cast", "typeid", "catch", "operator", "template", "class", "const_cast", "inline", "throw", "virtual", "mutable", "wchar_t"];
+
+ var access = ["@private", "@protected", "@public", "private:", "protected:", "public:", "friend", "using"];
+
+ var types = ["auto", "const", "double", "float", "int", "short", "char", "long", "signed", "unsigned", "bool", "void", "typename", "id", "register"];
+ var operators = ["+", "*", "/", "-", "&", "|", "~", "!", "%", "<", "=", ">", "[", "]", "new", "delete"];
+ var values = ["this", "true", "false", /[0-9]+(\.[0-9]+)?/g];
+
+ brush.push(values, {klass: 'constant'});
+ brush.push(types, {klass: 'type'});
+ brush.push(keywords, {klass: 'keyword'});
+ brush.push(operators, {klass: 'operator'});
+ brush.push(access, {klass: 'access'});
+
+ // Objective-C classes
+ brush.push({pattern: /\b[A-Z_][\w]*\b/g, klass: 'type'});
+
+ brush.push({
+ pattern: /#.*$/gmi,
+ klass: 'preprocessor',
+ allow: ['string']
+ });
+
+ brush.push(Syntax.lib.cStyleComment);
+ brush.push(Syntax.lib.cppStyleComment);
+ brush.push(Syntax.lib.webLink);
+
+ // Objective-C style functions
+ brush.push({pattern: /\w+:(?=.*(\]|;|\{))/g, klass: 'function'});
+
+ brush.push({
+ pattern: /[^:\[]\s+(\w+)(?=\])/g,
+ matches: Syntax.extractMatches({klass: 'function'})
+ });
+
+ brush.push({
+ pattern: /-\s*(\(.+?\))?\s*(\w+)\s*\{/g,
+ matches: Syntax.extractMatches({index: 2, klass: 'function'})
+ });
+
+ // Strings
+ brush.push(Syntax.lib.singleQuotedString);
+ brush.push(Syntax.lib.doubleQuotedString);
+ brush.push(Syntax.lib.stringEscape);
+
+ brush.push(Syntax.lib.cStyleFunction);
+});
+
@@ -0,0 +1,6 @@
+.syntax .css .selector {
+ color: green; }
+.syntax .css .property {
+ color: red; }
+.syntax .css .value {
+ font-style: italic; }
@@ -0,0 +1,63 @@
+// brush: "css" aliases: []
+
+// This file is part of the "jQuery.Syntax" project, and is licensed under the GNU AGPLv3.
+// Copyright 2010 Samuel Williams. All rights reserved.
+// See <jquery.syntax.js> for licensing details.
+
+Syntax.register('css', function(brush) {
+ var colorNames = ["AliceBlue", "AntiqueWhite", "Aqua", "Aquamarine", "Azure", "Beige", "Bisque", "Black", "BlanchedAlmond", "Blue", "BlueViolet", "Brown", "BurlyWood", "CadetBlue", "Chartreuse", "Chocolate", "Coral", "CornflowerBlue", "Cornsilk", "Crimson", "Cyan", "DarkBlue", "DarkCyan", "DarkGoldenRod", "DarkGray", "DarkGreen", "DarkKhaki", "DarkMagenta", "DarkOliveGreen", "Darkorange", "DarkOrchid", "DarkRed", "DarkSalmon", "DarkSeaGreen", "DarkSlateBlue", "DarkSlateGray", "DarkTurquoise", "DarkViolet", "DeepPink", "DeepSkyBlue", "DimGray", "DodgerBlue", "FireBrick", "FloralWhite", "ForestGreen", "Fuchsia", "Gainsboro", "GhostWhite", "Gold", "GoldenRod", "Gray", "Green", "GreenYellow", "HoneyDew", "HotPink", "IndianRed", "Indigo", "Ivory", "Khaki", "Lavender", "LavenderBlush", "LawnGreen", "LemonChiffon", "LightBlue", "LightCoral", "LightCyan", "LightGoldenRodYellow", "LightGrey", "LightGreen", "LightPink", "LightSalmon", "LightSeaGreen", "LightSkyBlue", "LightSlateGray", "LightSteelBlue", "LightYellow", "Lime", "LimeGreen", "Linen", "Magenta", "Maroon", "MediumAquaMarine", "MediumBlue", "MediumOrchid", "MediumPurple", "MediumSeaGreen", "MediumSlateBlue", "MediumSpringGreen", "MediumTurquoise", "MediumVioletRed", "MidnightBlue", "MintCream", "MistyRose", "Moccasin", "NavajoWhite", "Navy", "OldLace", "Olive", "OliveDrab", "Orange", "OrangeRed", "Orchid", "PaleGoldenRod", "PaleGreen", "PaleTurquoise", "PaleVioletRed", "PapayaWhip", "PeachPuff", "Peru", "Pink", "Plum", "PowderBlue", "Purple", "Red", "RosyBrown", "RoyalBlue", "SaddleBrown", "Salmon", "SandyBrown", "SeaGreen", "SeaShell", "Sienna", "Silver", "SkyBlue", "SlateBlue", "SlateGray", "Snow", "SpringGreen", "SteelBlue", "Tan", "Teal", "Thistle", "Tomato", "Turquoise", "Violet", "Wheat", "White", "WhiteSmoke", "Yellow", "YellowGreen", "#[0-9a-f]{3,6}", "rgba?\\(.+?\\)", "hsla?\\(.+?\\)"];
+
+ var colorMatcher = new RegExp("(" + (colorNames.join(")|(")) + ")", "gi")
+
+ brush.push({
+ pattern: /\(.*?\)/g,
+ allow: '*',
+ disallow: ['property']
+ });
+
+ brush.push({
+ pattern: /\s*([\:\.\[\]\"\'\=\s\w#\.\-,]+)\s+\{/gm,
+ matches: Syntax.extractMatches({klass: 'selector', allow: ['string']})
+ });
+
+ brush.push({
+ pattern: colorMatcher,
+ klass: 'color'
+ });
+
+ brush.push(Syntax.lib.cStyleComment);
+ brush.push(Syntax.lib.webLink);
+
+ brush.push({
+ pattern: /\{(.|\n)*?\}/g,
+ klass: 'properties',
+ allow: '*'
+ });
+
+ brush.push({
+ pattern: /\:(.*?(?=\})|(.|\n)*?(?=(\}|\;)))/g,
+ matches: Syntax.extractMatches({klass: 'value', allow: ['color'], only: ['properties']})
+ });
+
+ brush.push({pattern: /[\-\w]+:/g, klass: 'property'});
+
+ // Strings
+ brush.push(Syntax.lib.singleQuotedString);
+ brush.push(Syntax.lib.doubleQuotedString);
+ brush.push(Syntax.lib.stringEscape);
+
+ brush.push(Syntax.lib.cStyleFunction);
+
+ brush.postprocess = function(options, html, container) {
+ if (options.showColors === true) {
+ $('.color', html).each(function() {
+ var text = $(this).text();
+ var colorBox = $('<span style="font-size: 0.5em; margin: 4px; border: 1px solid black">&nbsp;&nbsp;</span>').css('background-color', text);
+ $(this).append(colorBox);
+ });
+ }
+
+ return html;
+ };
+});
+
@@ -0,0 +1,16 @@
+.syntax .add {
+ color: green; }
+.syntax .del {
+ color: red; }
+.syntax .insert {
+ color: green;
+ background-color: #cfc;
+ display: block; }
+.syntax .remove {
+ color: red;
+ background-color: #fcc;
+ display: block; }
+.syntax .offset {
+ color: blue;
+ background-color: #ccf;
+ display: block; }
@@ -0,0 +1,16 @@
+// brush: "diff" aliases: ["patch"]
+
+// This file is part of the "jQuery.Syntax" project, and is licensed under the GNU AGPLv3.
+// Copyright 2010 Samuel Williams. All rights reserved.
+// See <jquery.syntax.js> for licensing details.
+
+Syntax.register('diff', function(brush) {
+ brush.push({pattern: /^\+\+\+.*$/gm, klass: 'add'});
+ brush.push({pattern: /^\-\-\-.*$/gm, klass: 'del'});
+
+ brush.push({pattern: /^@@.*@@/gm, klass: 'offset'});
+
+ brush.push({pattern: /^\+[^\+]{1}.*$/gm, klass: 'insert'});
+ brush.push({pattern: /^\-[^\-]{1}.*$/gm, klass: 'remove'});
+});
+
@@ -0,0 +1,19 @@
+.syntax .html .tag {
+ color: #00f;
+ font-weight: bold; }
+.syntax .html .attribute {
+ color: #00c; }
+.syntax .html .javascript, .syntax .html .css {
+ font-style: italic; }
+.syntax .html .instruction {
+ color: #532;
+ font-style: italic; }
+.syntax .html .doctype {
+ font-weight: bold;
+ color: #938; }
+.syntax .html .entity, .syntax .html .percent-escape {
+ color: #888;
+ font-size: 0.8em;
+ border: 1px solid #888;
+ margin: 1px;
+ padding: 1px; }
Oops, something went wrong.

0 comments on commit be7edcd

Please sign in to comment.