User:Pyrospirit/syntaxhighlighter.js
// Code placed here to increase efficiency of User:Pyrospirit/monobook.js
/* Syntax highlighter */
if(document.title.indexOf(".js") == -1) // Ignore pages that end in .js
$(function () {
/* CSS syntax highlighting */
multicommentRE = new RegExp('(/\\*[\\s\\S]*?\\*/)', 'g');
ruleRE = new RegExp('([^\\{]+)\\{([^\\}]+)\\}', 'g');
idselectorRE = new RegExp('(#[a-zA-Z0-9\-\_]+)\\b', 'g');
classselectorRE = new RegExp('(\\.[a-zA-Z0-9\-\_]+)\\b', 'g');
pairRE = new RegExp('([a-zA-Z-]+):([^;]+);', 'g');
css = document.getElementsByTagName('pre');
for (i = 0; i < css.length; i++) {
c = css[i];
content = c.innerHTML;
content=content.replace(multicommentRE, '$1');
content = content.replace(ruleRE, function(text, selector, body) {
selector = selector.replace(idselectorRE, '$1');
selector = selector.replace(classselectorRE, '$1');
body = body.replace(pairRE, '$1:$2;');
return selector + '{' + body + '}';
});
c.innerHTML = content;
}
});
else { /* JS syntax highlighting */
//
/**
- Code Syntax Highlighter.
- Version 1.3.0
- Copyright (C) 2004 Alex Gorbatchev.
- http://www.dreamprojections.com/syntaxhighlighter/
- This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
- Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
- any later version.
- This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- details.
- You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
- the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- /
var dp={sh:{Brushes:{},Version:'1.3.0'}};dp.SyntaxHighlighter=dp.sh;dp.sh.Match=function(value,index,css){this.value=value;this.index=index,this.length=value.length,this.css=css};dp.sh.Highlighter=function(){this.addGutter=true,this.collapse=false,this.tabsToSpaces=true};dp.sh.Highlighter.SortCallback=function(m1,m2){if(m1.index
function(str,css){
var span=document.createElement('span');
str=str.replace(/&/g,'\&');
str=str.replace(/\&/g,'&');
str=str.replace(/\"/g,'"');
str=str.replace(/ |\t/g,' ').replace(/\n/gm,'
');
if(css!=null){var regex=new RegExp(' dp.sh.Brushes.JScript = function(){ var keywords = 'abstract boolean break byte case catch char class const continue debugger ' + 'default delete do double else enum export extends false final finally float ' + 'for function goto if implements import in instanceof int interface long native ' + 'new null package private protected public return short static super switch ' + 'synchronized this throw throws transient true try typeof var void volatile while with'; this.regexList = [ {regex: new RegExp('//.*$', 'gm'), css: 'comment' }, // one line comments {regex: new RegExp('/\\*[\\s\\S]*?\\*/', 'g'),css: 'comment' }, // multiline comments {regex: new RegExp('"(?:[^"\n]|[\"])*?".*?','g'),css: 'string' }, // double quoted strings {regex: new RegExp("'(?:[^'\n]|[\'])*?'.*?",'g'),css: 'string' }, // single quoted strings {regex: new RegExp('^\\s*#.*', 'gm'), css: 'preprocessor'},// preprocessor tags like #region and #endregion {regex: new RegExp(this.GetKeyw(keywords),'gm'),css: 'keyword'} // keywords ]; this.CssClass = 'dp-c'; } dp.sh.Brushes.JScript.prototype = new dp.sh.Highlighter(); $(dp.SyntaxHighlighter.HighlightAll); // }
','gi');if(regex.test(str)){var lines=str.split('
');str=;for(var i=0;i