tabs -> spaces and remove trailing whitespace

This commit is contained in:
Sami Samhuri 2010-12-19 18:58:12 -08:00
parent beb7c0fa71
commit 72cb12cf75
6 changed files with 433 additions and 433 deletions

View file

@ -1,77 +1,77 @@
/* Unobtrustive Code Highlighter By Dan Webb 11/2005 /* Unobtrustive Code Highlighter By Dan Webb 11/2005
Version: 0.4 Version: 0.4
Usage: Usage:
Add a script tag for this script and any stylesets you need to use Add a script tag for this script and any stylesets you need to use
to the page in question, add correct class names to CODE elements, to the page in question, add correct class names to CODE elements,
define CSS styles for elements. That's it! define CSS styles for elements. That's it!
Known to work on: Known to work on:
IE 5.5+ PC IE 5.5+ PC
Firefox/Mozilla PC/Mac Firefox/Mozilla PC/Mac
Opera 7.23 + PC Opera 7.23 + PC
Safari 2 Safari 2
Known to degrade gracefully on: Known to degrade gracefully on:
IE5.0 PC IE5.0 PC
Note: IE5.0 fails due to the use of lookahead in some stylesets. To avoid script errors Note: IE5.0 fails due to the use of lookahead in some stylesets. To avoid script errors
in older browsers use expressions that use lookahead in string format when defining stylesets. in older browsers use expressions that use lookahead in string format when defining stylesets.
This script is inspired by star-light by entirely cunning Dean Edwards This script is inspired by star-light by entirely cunning Dean Edwards
http://dean.edwards.name/star-light/. http://dean.edwards.name/star-light/.
*/ */
// replace callback support for safari. // replace callback support for safari.
if ("a".replace(/a/, function() {return "b"}) != "b") (function(){ if ("a".replace(/a/, function() {return "b"}) != "b") (function(){
var default_replace = String.prototype.replace; var default_replace = String.prototype.replace;
String.prototype.replace = function(search,replace){ String.prototype.replace = function(search,replace){
// replace is not function // replace is not function
if(typeof replace != "function"){ if(typeof replace != "function"){
return default_replace.apply(this,arguments) return default_replace.apply(this,arguments)
} }
var str = "" + this; var str = "" + this;
var callback = replace; var callback = replace;
// search string is not RegExp // search string is not RegExp
if(!(search instanceof RegExp)){ if(!(search instanceof RegExp)){
var idx = str.indexOf(search); var idx = str.indexOf(search);
return ( return (
idx == -1 ? str : idx == -1 ? str :
default_replace.apply(str,[search,callback(search, idx, str)]) default_replace.apply(str,[search,callback(search, idx, str)])
) )
} }
var reg = search; var reg = search;
var result = []; var result = [];
var lastidx = reg.lastIndex; var lastidx = reg.lastIndex;
var re; var re;
while((re = reg.exec(str)) != null){ while((re = reg.exec(str)) != null){
var idx = re.index; var idx = re.index;
var args = re.concat(idx, str); var args = re.concat(idx, str);
result.push( result.push(
str.slice(lastidx,idx), str.slice(lastidx,idx),
callback.apply(null,args).toString() callback.apply(null,args).toString()
); );
if(!reg.global){ if(!reg.global){
lastidx += RegExp.lastMatch.length; lastidx += RegExp.lastMatch.length;
break break
}else{ }else{
lastidx = reg.lastIndex; lastidx = reg.lastIndex;
} }
} }
result.push(str.slice(lastidx)); result.push(str.slice(lastidx));
return result.join("") return result.join("")
} }
})(); })();
var CodeHighlighter = { styleSets : new Array }; var CodeHighlighter = { styleSets : new Array };
CodeHighlighter.addStyle = function(name, rules) { CodeHighlighter.addStyle = function(name, rules) {
// using push test to disallow older browsers from adding styleSets // using push test to disallow older browsers from adding styleSets
if ([].push) this.styleSets.push({ if ([].push) this.styleSets.push({
name : name, name : name,
rules : rules, rules : rules,
ignoreCase : arguments[2] || false ignoreCase : arguments[2] || false
}) })
// function setEvent() { // function setEvent() {
// // set highlighter to run on load (use LowPro if present) // // set highlighter to run on load (use LowPro if present)
@ -95,300 +95,300 @@ CodeHighlighter.addStyle = function(name, rules) {
} }
CodeHighlighter.init = function() { CodeHighlighter.init = function() {
if (!document.getElementsByTagName) return; if (!document.getElementsByTagName) return;
if ("a".replace(/a/, function() {return "b"}) != "b") return; // throw out Safari versions that don't support replace function if ("a".replace(/a/, function() {return "b"}) != "b") return; // throw out Safari versions that don't support replace function
// throw out older browsers // throw out older browsers
// var codeEls = document.getElementsByTagName("CODE"); // var codeEls = document.getElementsByTagName("CODE");
// HACK: // HACK:
var codeEls = [$('code')]; var codeEls = [$('code')];
// collect array of all pre elements // collect array of all pre elements
codeEls.filter = function(f) { codeEls.filter = function(f) {
var a = new Array; var a = new Array;
for (var i = 0; i < this.length; i++) for (var i = 0; i < this.length; i++)
if (f(this[i])) if (f(this[i]))
a[a.length] = this[i]; a[a.length] = this[i];
return a; return a;
} }
var rules = new Array; var rules = new Array;
rules.toString = function() { rules.toString = function() {
// joins regexes into one big parallel regex // joins regexes into one big parallel regex
var exps = new Array; var exps = new Array;
for (var i = 0; i < this.length; i++) exps.push(this[i].exp); for (var i = 0; i < this.length; i++) exps.push(this[i].exp);
return exps.join("|"); return exps.join("|");
} }
function addRule(className, rule) { function addRule(className, rule) {
// add a replace rule // add a replace rule
var exp = (typeof rule.exp != "string")?String(rule.exp).substr(1, String(rule.exp).length-2):rule.exp; var exp = (typeof rule.exp != "string")?String(rule.exp).substr(1, String(rule.exp).length-2):rule.exp;
// converts regex rules to strings and chops of the slashes // converts regex rules to strings and chops of the slashes
rules.push({ rules.push({
className : className, className : className,
exp : "(" + exp + ")", exp : "(" + exp + ")",
length : (exp.match(/(^|[^\\])\([^?]/g) || "").length + 1, // number of subexps in rule length : (exp.match(/(^|[^\\])\([^?]/g) || "").length + 1, // number of subexps in rule
replacement : rule.replacement || null replacement : rule.replacement || null
}); });
} }
function parse(text, ignoreCase) { function parse(text, ignoreCase) {
// main text parsing and replacement // main text parsing and replacement
return text.replace(new RegExp(rules, (ignoreCase)?"gi":"g"), function() { return text.replace(new RegExp(rules, (ignoreCase)?"gi":"g"), function() {
var i = 0, j = 1, rule; var i = 0, j = 1, rule;
while (rule = rules[i++]) { while (rule = rules[i++]) {
if (arguments[j]) { if (arguments[j]) {
// if no custom replacement defined do the simple replacement // if no custom replacement defined do the simple replacement
if (!rule.replacement) return "<span class=\"" + rule.className + "\">" + arguments[0] + "</span>"; if (!rule.replacement) return "<span class=\"" + rule.className + "\">" + arguments[0] + "</span>";
else { else {
// replace $0 with the className then do normal replaces // replace $0 with the className then do normal replaces
var str = rule.replacement.replace("$0", rule.className); var str = rule.replacement.replace("$0", rule.className);
for (var k = 1; k <= rule.length - 1; k++) str = str.replace("$" + k, arguments[j + k]); for (var k = 1; k <= rule.length - 1; k++) str = str.replace("$" + k, arguments[j + k]);
return str; return str;
} }
} else j+= rule.length; } else j+= rule.length;
} }
}); });
} }
function highlightCode(styleSet) { function highlightCode(styleSet) {
// clear rules array // clear rules array
var parsed, clsRx = new RegExp("(\\s|^)" + styleSet.name + "(\\s|$)"); var parsed, clsRx = new RegExp("(\\s|^)" + styleSet.name + "(\\s|$)");
rules.length = 0; rules.length = 0;
// // get stylable elements by filtering out all code elements without the correct className // // get stylable elements by filtering out all code elements without the correct className
var stylableEls = codeEls.filter(function(item) { return clsRx.test(item.className) }); var stylableEls = codeEls.filter(function(item) { return clsRx.test(item.className) });
// var stylableEls = codeEls; // var stylableEls = codeEls;
// add style rules to parser // add style rules to parser
for (var className in styleSet.rules) addRule(className, styleSet.rules[className]); for (var className in styleSet.rules) addRule(className, styleSet.rules[className]);
// replace for all elements // replace for all elements
for (var i = 0; i < stylableEls.length; i++) { for (var i = 0; i < stylableEls.length; i++) {
// EVIL hack to fix IE whitespace badness if it's inside a <pre> // EVIL hack to fix IE whitespace badness if it's inside a <pre>
if (/MSIE/.test(navigator.appVersion) && stylableEls[i].parentNode.nodeName == 'PRE') { if (/MSIE/.test(navigator.appVersion) && stylableEls[i].parentNode.nodeName == 'PRE') {
stylableEls[i] = stylableEls[i].parentNode; stylableEls[i] = stylableEls[i].parentNode;
parsed = stylableEls[i].innerHTML.replace(/(<code[^>]*>)([^<]*)<\/code>/i, function() { parsed = stylableEls[i].innerHTML.replace(/(<code[^>]*>)([^<]*)<\/code>/i, function() {
return arguments[1] + parse(arguments[2], styleSet.ignoreCase) + "</code>" return arguments[1] + parse(arguments[2], styleSet.ignoreCase) + "</code>"
}); });
parsed = parsed.replace(/\n( *)/g, function() { parsed = parsed.replace(/\n( *)/g, function() {
var spaces = ""; var spaces = "";
for (var i = 0; i < arguments[1].length; i++) spaces+= "&nbsp;"; for (var i = 0; i < arguments[1].length; i++) spaces+= "&nbsp;";
return "\n" + spaces; return "\n" + spaces;
}); });
parsed = parsed.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;"); parsed = parsed.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;");
parsed = parsed.replace(/\n(<\/\w+>)?/g, "<br />$1").replace(/<br \/>[\n\r\s]*<br \/>/g, "<p><br></p>"); parsed = parsed.replace(/\n(<\/\w+>)?/g, "<br />$1").replace(/<br \/>[\n\r\s]*<br \/>/g, "<p><br></p>");
} else parsed = parse(stylableEls[i].innerHTML, styleSet.ignoreCase); } else parsed = parse(stylableEls[i].innerHTML, styleSet.ignoreCase);
stylableEls[i].innerHTML = parsed; stylableEls[i].innerHTML = parsed;
} }
} }
// run highlighter on all stylesets // run highlighter on all stylesets
for (var i=0; i < this.styleSets.length; i++) { for (var i=0; i < this.styleSets.length; i++) {
highlightCode(this.styleSets[i]); highlightCode(this.styleSets[i]);
} }
} }
CodeHighlighter.addStyle("css", { CodeHighlighter.addStyle("css", {
comment : { comment : {
exp : /\/\*[^*]*\*+([^\/][^*]*\*+)*\// exp : /\/\*[^*]*\*+([^\/][^*]*\*+)*\//
}, },
keywords : { keywords : {
exp : /@\w[\w\s]*/ exp : /@\w[\w\s]*/
}, },
selectors : { selectors : {
exp : "([\\w-:\\[.#][^{};>]*)(?={)" exp : "([\\w-:\\[.#][^{};>]*)(?={)"
}, },
properties : { properties : {
exp : "([\\w-]+)(?=\\s*:)" exp : "([\\w-]+)(?=\\s*:)"
}, },
units : { units : {
exp : /([0-9])(em|en|px|%|pt)\b/, exp : /([0-9])(em|en|px|%|pt)\b/,
replacement : "$1<span class=\"$0\">$2</span>" replacement : "$1<span class=\"$0\">$2</span>"
}, },
urls : { urls : {
exp : /url\([^\)]*\)/ exp : /url\([^\)]*\)/
} }
}); });
CodeHighlighter.addStyle("ruby",{ CodeHighlighter.addStyle("ruby",{
comment : { comment : {
exp : /#[^\n]*/ exp : /#[^\n]*/
}, },
brackets : { brackets : {
exp : /\(|\)/ exp : /\(|\)/
}, },
string : { string : {
exp : /'[^'\\]*(\\.[^'\\]*)*'|"[^"\\]*(\\.[^"\\]*)*"|\%w\(.*\)|`[^`\\]*(\\.[^`\\]*)*`/ exp : /'[^'\\]*(\\.[^'\\]*)*'|"[^"\\]*(\\.[^"\\]*)*"|\%w\(.*\)|`[^`\\]*(\\.[^`\\]*)*`/
}, },
keywords : { keywords : {
exp : /\b(do|end|self|class|def|if|module|yield|then|else|for|until|unless|while|elsif|case|when|break|retry|redo|rescue|require|raise|extend)\b/ exp : /\b(do|end|self|class|def|if|module|yield|then|else|for|until|unless|while|elsif|case|when|break|retry|redo|rescue|require|raise|extend)\b/
}, },
/* Added by Shelly Fisher (shelly@agileevolved.com) */ /* Added by Shelly Fisher (shelly@agileevolved.com) */
symbol : { symbol : {
exp : /([^:])(:[A-Za-z0-9_!?]+)/ exp : /([^:])(:[A-Za-z0-9_!?]+)/
} }
}); });
CodeHighlighter.addStyle("html", { CodeHighlighter.addStyle("html", {
comment : { comment : {
exp: /<!\s*(--([^-]|[\r\n]|-[^-])*--\s*)>/ exp: /<!\s*(--([^-]|[\r\n]|-[^-])*--\s*)>/
}, },
tag : { tag : {
exp: /(<\/?)([a-zA-Z1-9]+\s?)/, exp: /(<\/?)([a-zA-Z1-9]+\s?)/,
replacement: "$1<span class=\"$0\">$2" replacement: "$1<span class=\"$0\">$2"
}, },
string : { string : {
exp : /'[^']*'|"[^"]*"/ exp : /'[^']*'|"[^"]*"/
}, },
attribute : { attribute : {
exp: /\b([a-zA-Z-:]+)(=)/, exp: /\b([a-zA-Z-:]+)(=)/,
replacement: "<span class=\"$0\">$1$2" replacement: "<span class=\"$0\">$1$2"
}, },
doctype : { doctype : {
exp: /<!DOCTYPE([^&]|&[^g]|&g[^t])*>/ exp: /<!DOCTYPE([^&]|&[^g]|&g[^t])*>/
} }
}); });
CodeHighlighter.addStyle("javascript",{ CodeHighlighter.addStyle("javascript",{
comment : { comment : {
exp : /(\/\/[^\n]*(\n|$))|(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)/ exp : /(\/\/[^\n]*(\n|$))|(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)/
}, },
parameter: { parameter: {
exp: /\bfunction\s?\((.+)\)/ exp: /\bfunction\s?\((.+)\)/
// ,replacement: "<span class='parameter'>$1</span>" // ,replacement: "<span class='parameter'>$1</span>"
}, },
brackets : { brackets : {
exp : /\(|\)/ exp : /\(|\)/
}, },
string : { string : {
exp : /'[^']*'|"[^"]*"/ exp : /'[^']*'|"[^"]*"/
}, },
keywords : { keywords : {
exp : /\b(arguments|break|case|continue|default|delete|do|else|false|for|function|if|in|instanceof|new|null|return|switch|this|true|typeof|var|void|while|with)\b/ exp : /\b(arguments|break|case|continue|default|delete|do|else|false|for|function|if|in|instanceof|new|null|return|switch|this|true|typeof|var|void|while|with)\b/
}, },
global : { global : {
exp : /\b(toString|valueOf|window|element|prototype|constructor|document|escape|unescape|parseInt|parseFloat|setTimeout|clearTimeout|setInterval|clearInterval|NaN|isNaN|Infinity|String|Numeric|Array)\b/ exp : /\b(toString|valueOf|window|element|prototype|constructor|document|escape|unescape|parseInt|parseFloat|setTimeout|clearTimeout|setInterval|clearInterval|NaN|isNaN|Infinity|String|Numeric|Array)\b/
} }
}); });
CodeHighlighter.addStyle("yaml", { CodeHighlighter.addStyle("yaml", {
keyword : { keyword : {
exp : /\/\*[^*]*\*+([^\/][^*]*\*+)*\// exp : /\/\*[^*]*\*+([^\/][^*]*\*+)*\//
}, },
value : { value : {
exp : /@\w[\w\s]*/ exp : /@\w[\w\s]*/
} }
}); });
CodeHighlighter.addStyle("python",{ CodeHighlighter.addStyle("python",{
comment : { comment : {
exp : /#[^\n]+/ exp : /#[^\n]+/
}, },
brackets : { brackets : {
exp : /\(|\)/ exp : /\(|\)/
}, },
string : { string : {
exp : /'[^'\\]*(\\.[^'\\]*)*'|"[^"\\]*(\\.[^"\\]*)*"|""".*"""/ exp : /'[^'\\]*(\\.[^'\\]*)*'|"[^"\\]*(\\.[^"\\]*)*"|""".*"""/
}, },
keywords : { keywords : {
exp : /\b(and|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while|yield|as|None)\b/ exp : /\b(and|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while|yield|as|None)\b/
} }
}); });
CodeHighlighter.addStyle("applescript",{ CodeHighlighter.addStyle("applescript",{
comment : { comment : {
exp : /--[^\n]+|#![^\n]+/ exp : /--[^\n]+|#![^\n]+/
}, },
brackets : { brackets : {
exp : /\(|\)/ exp : /\(|\)/
}, },
string : { string : {
exp : /"[^"\\]*(\\.[^"\\]*)*"/ exp : /"[^"\\]*(\\.[^"\\]*)*"/
}, },
keywords : { keywords : {
exp : /\b(about|above|after|against|and|apart[\s]+from|around|as|aside[\s]+from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|contain|contains|contains|continue|copy|div|does|eighth|else|end|equal|equals|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead[\s]+of|into|is|it|its|last|local|me|middle|mod|my|ninth|not|of|on|onto|or|out[\s]+of|over|prop|property|put|ref|reference|repeat|return|returning|script|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/ exp : /\b(about|above|after|against|and|apart[\s]+from|around|as|aside[\s]+from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|contain|contains|contains|continue|copy|div|does|eighth|else|end|equal|equals|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead[\s]+of|into|is|it|its|last|local|me|middle|mod|my|ninth|not|of|on|onto|or|out[\s]+of|over|prop|property|put|ref|reference|repeat|return|returning|script|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/
}, },
global : { global : {
exp : /\b(AppleScript('s)?|current[\s]+application|missing[\s]+value|false|pi|true|version)\b/ exp : /\b(AppleScript('s)?|current[\s]+application|missing[\s]+value|false|pi|true|version)\b/
} }
}); });
CodeHighlighter.addStyle("cpp",{ CodeHighlighter.addStyle("cpp",{
comment : { comment : {
exp : /(\/\/[^\n]*(\n|$))|(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)/ exp : /(\/\/[^\n]*(\n|$))|(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)/
}, },
brackets : { brackets : {
exp : /\(|\)/ exp : /\(|\)/
}, },
string : { string : {
exp : /"[^"\\]*(\\.[^"\\]*)*"/ exp : /"[^"\\]*(\\.[^"\\]*)*"/
}, },
keywords : { keywords : {
exp : /\b(break|case|catch|class|const|__finally|__exception|__try|const_cast|continue|private|public|protected|__declspec|default|delete|deprecated|dllexport|dllimport|do|dynamic_cast|else|enum|explicit|extern|if|for|friend|goto|inline|mutable|naked|namespace|new|noinline|noreturn|nothrow|register|reinterpret_cast|return|selectany|sizeof|static|static_cast|struct|switch|template|this|thread|throw|true|false|try|typedef|typeid|typename|union|using|uuid|virtual|void|volatile|whcar_t|while)\b/ exp : /\b(break|case|catch|class|const|__finally|__exception|__try|const_cast|continue|private|public|protected|__declspec|default|delete|deprecated|dllexport|dllimport|do|dynamic_cast|else|enum|explicit|extern|if|for|friend|goto|inline|mutable|naked|namespace|new|noinline|noreturn|nothrow|register|reinterpret_cast|return|selectany|sizeof|static|static_cast|struct|switch|template|this|thread|throw|true|false|try|typedef|typeid|typename|union|using|uuid|virtual|void|volatile|whcar_t|while)\b/
}, },
datatype: { datatype: {
exp : /\b(ATOM|BOOL|BOOLEAN|BYTE|CHAR|COLORREF|DWORD|DWORDLONG|DWORD_PTR|DWORD32|DWORD64|FLOAT|HACCEL|HALF_PTR|HANDLE|HBITMAP|HBRUSH|HCOLORSPACE|HCONV|HCONVLIST|HCURSOR|HDC|HDDEDATA|HDESK|HDROP|HDWP|HENHMETAFILE|HFILE|HFONT|HGDIOBJ|HGLOBAL|HHOOK|HICON|HINSTANCE|HKEY|HKL|HLOCAL|HMENU|HMETAFILE|HMODULE|HMONITOR|HPALETTE|HPEN|HRESULT|HRGN|HRSRC|HSZ|HWINSTA|HWND|INT|INT_PTR|INT32|INT64|LANGID|LCID|LCTYPE|LGRPID|LONG|LONGLONG|LONG_PTR|LONG32|LONG64|LPARAM|LPBOOL|LPBYTE|LPCOLORREF|LPCSTR|LPCTSTR|LPCVOID|LPCWSTR|LPDWORD|LPHANDLE|LPINT|LPLONG|LPSTR|LPTSTR|LPVOID|LPWORD|LPWSTR|LRESULT|PBOOL|PBOOLEAN|PBYTE|PCHAR|PCSTR|PCTSTR|PCWSTR|PDWORDLONG|PDWORD_PTR|PDWORD32|PDWORD64|PFLOAT|PHALF_PTR|PHANDLE|PHKEY|PINT|PINT_PTR|PINT32|PINT64|PLCID|PLONG|PLONGLONG|PLONG_PTR|PLONG32|PLONG64|POINTER_32|POINTER_64|PSHORT|PSIZE_T|PSSIZE_T|PSTR|PTBYTE|PTCHAR|PTSTR|PUCHAR|PUHALF_PTR|PUINT|PUINT_PTR|PUINT32|PUINT64|PULONG|PULONGLONG|PULONG_PTR|PULONG32|PULONG64|PUSHORT|PVOID|PWCHAR|PWORD|PWSTR|SC_HANDLE|SC_LOCK|SERVICE_STATUS_HANDLE|SHORT|SIZE_T|SSIZE_T|TBYTE|TCHAR|UCHAR|UHALF_PTR|UINT|UINT_PTR|UINT32|UINT64|ULONG|ULONGLONG|ULONG_PTR|ULONG32|ULONG64|USHORT|USN|VOID|WCHAR|WORD|WPARAM|WPARAM|WPARAM|char|bool|short|int|__int32|__int64|__int8|__int16|long|float|double|__wchar_t|clock_t|_complex|_dev_t|_diskfree_t|div_t|ldiv_t|_exception|_EXCEPTION_POINTERS|FILE|_finddata_t|_finddatai64_t|_wfinddata_t|_wfinddatai64_t|__finddata64_t|__wfinddata64_t|_FPIEEE_RECORD|fpos_t|_HEAPINFO|_HFILE|lconv|intptr_t|jmp_buf|mbstate_t|_off_t|_onexit_t|_PNH|ptrdiff_t|_purecall_handler|sig_atomic_t|size_t|_stat|__stat64|_stati64|terminate_function|time_t|__time64_t|_timeb|__timeb64|tm|uintptr_t|_utimbuf|va_list|wchar_t|wctrans_t|wctype_t|wint_t|signed)\b/ exp : /\b(ATOM|BOOL|BOOLEAN|BYTE|CHAR|COLORREF|DWORD|DWORDLONG|DWORD_PTR|DWORD32|DWORD64|FLOAT|HACCEL|HALF_PTR|HANDLE|HBITMAP|HBRUSH|HCOLORSPACE|HCONV|HCONVLIST|HCURSOR|HDC|HDDEDATA|HDESK|HDROP|HDWP|HENHMETAFILE|HFILE|HFONT|HGDIOBJ|HGLOBAL|HHOOK|HICON|HINSTANCE|HKEY|HKL|HLOCAL|HMENU|HMETAFILE|HMODULE|HMONITOR|HPALETTE|HPEN|HRESULT|HRGN|HRSRC|HSZ|HWINSTA|HWND|INT|INT_PTR|INT32|INT64|LANGID|LCID|LCTYPE|LGRPID|LONG|LONGLONG|LONG_PTR|LONG32|LONG64|LPARAM|LPBOOL|LPBYTE|LPCOLORREF|LPCSTR|LPCTSTR|LPCVOID|LPCWSTR|LPDWORD|LPHANDLE|LPINT|LPLONG|LPSTR|LPTSTR|LPVOID|LPWORD|LPWSTR|LRESULT|PBOOL|PBOOLEAN|PBYTE|PCHAR|PCSTR|PCTSTR|PCWSTR|PDWORDLONG|PDWORD_PTR|PDWORD32|PDWORD64|PFLOAT|PHALF_PTR|PHANDLE|PHKEY|PINT|PINT_PTR|PINT32|PINT64|PLCID|PLONG|PLONGLONG|PLONG_PTR|PLONG32|PLONG64|POINTER_32|POINTER_64|PSHORT|PSIZE_T|PSSIZE_T|PSTR|PTBYTE|PTCHAR|PTSTR|PUCHAR|PUHALF_PTR|PUINT|PUINT_PTR|PUINT32|PUINT64|PULONG|PULONGLONG|PULONG_PTR|PULONG32|PULONG64|PUSHORT|PVOID|PWCHAR|PWORD|PWSTR|SC_HANDLE|SC_LOCK|SERVICE_STATUS_HANDLE|SHORT|SIZE_T|SSIZE_T|TBYTE|TCHAR|UCHAR|UHALF_PTR|UINT|UINT_PTR|UINT32|UINT64|ULONG|ULONGLONG|ULONG_PTR|ULONG32|ULONG64|USHORT|USN|VOID|WCHAR|WORD|WPARAM|WPARAM|WPARAM|char|bool|short|int|__int32|__int64|__int8|__int16|long|float|double|__wchar_t|clock_t|_complex|_dev_t|_diskfree_t|div_t|ldiv_t|_exception|_EXCEPTION_POINTERS|FILE|_finddata_t|_finddatai64_t|_wfinddata_t|_wfinddatai64_t|__finddata64_t|__wfinddata64_t|_FPIEEE_RECORD|fpos_t|_HEAPINFO|_HFILE|lconv|intptr_t|jmp_buf|mbstate_t|_off_t|_onexit_t|_PNH|ptrdiff_t|_purecall_handler|sig_atomic_t|size_t|_stat|__stat64|_stati64|terminate_function|time_t|__time64_t|_timeb|__timeb64|tm|uintptr_t|_utimbuf|va_list|wchar_t|wctrans_t|wctype_t|wint_t|signed)\b/
}, },
preprocessor : { preprocessor : {
exp : /^ *#.*/gm exp : /^ *#.*/gm
} }
}); });
// http://www.undermyhat.org/blog/wp-content/uploads/2009/09/shBrushClojure.js // http://www.undermyhat.org/blog/wp-content/uploads/2009/09/shBrushClojure.js
CodeHighlighter.addStyle("clojure",{ CodeHighlighter.addStyle("clojure",{
comment : { comment : {
exp : /;[^\]]+$/ exp : /;[^\]]+$/
}, },
string : { string : {
exp : /"[^"\\]*(\\.[^"\\]*)*"/m exp : /"[^"\\]*(\\.[^"\\]*)*"/m
}, },
functions : { functions : {
exp : /\b(:arglists|:doc|:file|:line|:macro|:name|:ns|:private|:tag|:test|new|alias|alter|and|apply|assert|class|cond|conj|count|def|defmacro|defn|defstruct|deref|do|doall|dorun|doseq|dosync|eval|filter|finally|find|first|fn|gen-class|gensym|if|import|inc|keys|let|list|loop|map|ns|or|print|println|quote|rand|recur|reduce|ref|repeat|require|rest|send|seq|set|sort|str|struct|sync|take|test|throw|trampoline|try|type|use|var|vec|when|while)\b/gmi exp : /\b(:arglists|:doc|:file|:line|:macro|:name|:ns|:private|:tag|:test|new|alias|alter|and|apply|assert|class|cond|conj|count|def|defmacro|defn|defstruct|deref|do|doall|dorun|doseq|dosync|eval|filter|finally|find|first|fn|gen-class|gensym|if|import|inc|keys|let|list|loop|map|ns|or|print|println|quote|rand|recur|reduce|ref|repeat|require|rest|send|seq|set|sort|str|struct|sync|take|test|throw|trampoline|try|type|use|var|vec|when|while)\b/gmi
}, },
keyword : { keyword : {
exp : /\[|\]/g exp : /\[|\]/g
}, },
symbols : { symbols : {
exp : /'[a-z][A-Za-z0-9_]*/g exp : /'[a-z][A-Za-z0-9_]*/g
}, },
keywords: { keywords: {
exp: /(:[a-z][A-Za-z0-9_]*)/g exp: /(:[a-z][A-Za-z0-9_]*)/g
} }
}); });
CodeHighlighter.addStyle("haskell",{ CodeHighlighter.addStyle("haskell",{
comment : { comment : {
exp : /(\-\-.*$)|(\{\-[\s\S]*?\-\})/gm exp : /(\-\-.*$)|(\{\-[\s\S]*?\-\})/gm
}, },
keywords : { keywords : {
exp : /\b(as|case|of|class|data|datafamily|data instance|default|deriving|deriving instance|do|forall|foreign|hiding|if|then|else|import|infix|infixl|infixr|instance|let|in|mdo|module|newtype|proc|qualified|rec|type|type family|type instance|where)\b/ exp : /\b(as|case|of|class|data|datafamily|data instance|default|deriving|deriving instance|do|forall|foreign|hiding|if|then|else|import|infix|infixl|infixr|instance|let|in|mdo|module|newtype|proc|qualified|rec|type|type family|type instance|where)\b/
}, },
string : { string : {
exp : /'[^']*'|"[^"]*"/ exp : /'[^']*'|"[^"]*"/
} }
}); });