diff --git a/README.md b/README.md index ef762cc..3ac5825 100755 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ # Yash 3 C'est un fork avec des modifications mineures du plugin Yash de [Dotclear](https://fr.dotclear.org/ "dotclear") http://plugins.dotaddict.org/dc2/details/yash (By pep and contributors GNU/GPL v2) -# Etat du dev -reste un bug _ non fonctionnel tout de suite. +# Utilisation +///yash3 language +some->code->here; +/// # code tiers Minifier class was made by Tedious https://github.com/tedious/JShrink BSD License. diff --git a/inc/yash3.behaviors.php b/inc/yash3.behaviors.php index 92b08c7..c7776f7 100755 --- a/inc/yash3.behaviors.php +++ b/inc/yash3.behaviors.php @@ -29,7 +29,7 @@ class yash3Behaviors public static function coreInitWikiPost($wiki2xhtml) { - $wiki2xhtml->registerFunction('macro:yash3',array('yashBehaviors','transform')); + $wiki2xhtml->registerFunction('macro:yash3',array('yash3Behaviors','transform')); } public static function transform($text,$args) diff --git a/index.php b/index.php index ac0da1b..4579238 100755 --- a/index.php +++ b/index.php @@ -120,15 +120,12 @@ if (!empty($_POST['saveconfig'])) { } //concat js files and minify them - $fContent = yash3_minify_js( - file_get_contents(dirname(__FILE__)."/syntaxhighlighter/js/shCore.js"). - file_get_contents(dirname(__FILE__)."/syntaxhighlighter/js/shAutoloader.js"). - dcUtils::jsVar('yash_path',$core->blog->getPF('yash/syntaxhighlighter/js/')). + include_once(dirname(__FILE__).'/inc/Minifier.php'); $fContent = Minifier::minify( file_get_contents(dirname(__FILE__)."/syntaxhighlighter/js/shCore.js"). file_get_contents(dirname(__FILE__)."/syntaxhighlighter/js/shAutoloader.js"). - " var yash3_path=\"".$core->blog->getPF('yash/syntaxhighlighter/js/')."\"; ". + "\n var yash3_path=\"".$core->blog->getPF('yash3/syntaxhighlighter/js/')."\";\n". file_get_contents(dirname(__FILE__)."/js/public.js") ); //write the fiule diff --git a/js/post.js b/js/post.js index 092282e..b790299 100755 --- a/js/post.js +++ b/js/post.js @@ -37,7 +37,7 @@ jsToolBar.prototype.elements.yash3.fn.markdown = function() { }; jsToolBar.prototype.elements.yash3.fncall.wiki = function() { - var stag = '\n///yash3 ' + this.elements.yash.data.syntax + '\n'; + var stag = '\n///yash3 ' + this.elements.yash3.data.syntax + '\n'; var etag = '\n///\n'; this.encloseSelection(stag,etag); }; diff --git a/syntaxhighlighter/js/shConcatened.js b/syntaxhighlighter/js/shConcatened.js index 2eb1cea..7e6f332 100644 --- a/syntaxhighlighter/js/shConcatened.js +++ b/syntaxhighlighter/js/shConcatened.js @@ -1 +1,340 @@ -/***SyntaxHighlighter*http://alexgorbatchev.com/SyntaxHighlighter**SyntaxHighlighterisdonationware.Ifyouareusingit,pleasedonate.*http://alexgorbatchev.com/SyntaxHighlighter/donate.html**@version*3.0.9(Thu,04Dec201412:32:21GMT)**@copyright*Copyright(C)2004-2013AlexGorbatchev.**@license*DuallicensedundertheMITandGPLlicenses.*//*!*XRegExpv2.0.0*(c)2007-2012StevenLevithan*MITLicense*//***XRegExpprovidesaugmented,extensibleJavaScriptregularexpressions.Yougetnewsyntax,*flags,andmethodsbeyondwhatbrowserssupportnatively.XRegExpisalsoaregexutilitybelt*withtoolstomakeyourclient-sidegreppingsimplerandmorepowerful,whilefreeingyoufrom*worryingaboutpeskycross-browserinconsistenciesandthedubious`lastIndex`property.See*XRegExp'sdocumentation(http://xregexp.com/)formoredetails.*@modulexregexp*@requiresN/A*/varXRegExp;//Avoidrunningtwice;thatwouldresettokensandcouldbreakreferencestonativeglobalsXRegExp=XRegExp||(function(undef){"usestrict";/*--------------------------------------*Privatevariables*------------------------------------*/varself,addToken,add,//Optionalfeatures;canbeinstalledanduninstalledfeatures={natives:false,extensibility:false},//Storenativemethodstouseandrestore("native"isanES3reservedkeyword)nativ={exec:RegExp.prototype.exec,test:RegExp.prototype.test,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split},//Storageforfixed/extendednativemethodsfixed={},//Storageforcachedregexescache={},//Storageforaddontokenstokens=[],//TokenscopesdefaultScope="default",classScope="class",//RegexesthatmatchnativeregexsyntaxnativeTokens={//Anynativemulticharactertokenindefaultscope(includesoctals,excludescharacterclasses)"default":/^(?:\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S])|\(\?[:=!]|[?*+]\?|{\d+(?:,\d*)?}\??)/,//Anynativemulticharactertokenincharacterclassscope(includesoctals)"class":/^(?:\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S]))/},//AnybackreferenceinreplacementstringsreplacementToken=/\$(?:{([\w$]+)}|(\d\d?|[\s\S]))/g,//AnycharacterwithalaterinstanceinthestringduplicateFlags=/([\s\S])(?=[\s\S]*\1)/g,//Anygreedy/lazyquantifierquantifier=/^(?:[?*+]|{\d+(?:,\d*)?})\??/,//Checkforcorrect`exec`handlingofnonparticipatingcapturinggroupscompliantExecNpcg=nativ.exec.call(/()??/,"")[1]===undef,//Checkforflagysupport(Firefox3+)hasNativeY=RegExp.prototype.sticky!==undef,//UsedtokillinfiniterecursionduringXRegExpconstructionisInsideConstructor=false,//Storageforknownflags,includingaddonflagsregisteredFlags="gim"+(hasNativeY?"y":"");/*--------------------------------------*Privatehelperfunctions*------------------------------------*//***AttachesXRegExp.prototypepropertiesandnamedcapturesupportingdatatoaregexobject.*@private*@param{RegExp}regexRegextoaugment.*@param{Array}captureNamesArraywithcapturenames,ornull.*@param{Boolean}[isNative]Whethertheregexwascreatedby`RegExp`ratherthan`XRegExp`.*@returns{RegExp}Augmentedregex.*/functionaugment(regex,captureNames,isNative){varp;//Can'tauto-inheritthesesincetheXRegExpconstructorreturnsanonprimitivevaluefor(pinself.prototype){if(self.prototype.hasOwnProperty(p)){regex[p]=self.prototype[p];}}regex.xregexp={captureNames:captureNames,isNative:!!isNative};returnregex;}/***Returnsnative`RegExp`flagsusedbyaregexobject.*@private*@param{RegExp}regexRegextocheck.*@returns{String}Nativeflagsinuse.*/functiongetNativeFlags(regex){i,String(regex))[1];return(regex.global?"g":"")+(regex.ignoreCase?"i":"")+(regex.multiline?"m":"")+(regex.extended?"x":"")+//ProposedforES6,includedinAS3(regex.sticky?"y":"");//ProposedforES6,includedinFirefox3+}/***Copiesaregexobjectwhilepreservingspecialpropertiesfornamedcaptureandaugmentingwith*`XRegExp.prototype`methods.Thecopyhasafresh`lastIndex`property(settozero).Allows*addingandremovingflagswhilecopyingtheregex.*@private*@param{RegExp}regexRegextocopy.*@param{String}[addFlags]Flagstobeaddedwhilecopyingtheregex.*@param{String}[removeFlags]Flagstoberemovedwhilecopyingtheregex.*@returns{RegExp}Copyoftheprovidedregex,possiblywithmodifiedflags.*/functioncopy(regex,addFlags,removeFlags){if(!self.isRegExp(regex)){thrownewTypeError("typeRegExpexpected");}varflags=nativ.replace.call(getNativeFlags(regex)+(addFlags||""),duplicateFlags,"");if(removeFlags){//Wouldneedtoescape`removeFlags`ifthiswaspublicflags=nativ.replace.call(flags,newRegExp("["+removeFlags+"]+","g"),"");}if(regex.xregexp&&!regex.xregexp.isNative){//Compilingthecurrent(ratherthanprecompilation)sourcepreservestheeffectsofnonnativesourceflagsregex=augment(self(regex.source,flags),regex.xregexp.captureNames?regex.xregexp.captureNames.slice(0):null);}else{//Augmentwith`XRegExp.prototype`methods,butusenative`RegExp`(avoidsearchingforspecialtokens)regex=augment(newRegExp(regex.source,flags),null,true);}returnregex;}/**Returnsthelastindexatwhichagivenvaluecanbefoundinanarray,or`-1`ifit'snot*present.Thearrayissearchedbackwards.*@private*@param{Array}arrayArraytosearch.*@param{*}valueValuetolocateinthearray.*@returns{Number}Lastzero-basedindexatwhichtheitemisfound,or-1.*/functionlastIndexOf(array,value){vari=array.length;if(Array.prototype.lastIndexOf){returnarray.lastIndexOf(value);//Usethenativemethodifavailable}while(i--){if(array[i]===value){returni;}}return-1;}/***Determineswhetheranobjectisofthespecifiedtype.*@private*@param{*}valueObjecttocheck.*@param{String}typeTypetocheckfor,inlowercase.*@returns{Boolean}Whethertheobjectmatchesthetype.*/functionisType(value,type){returnObject.prototype.toString.call(value).toLowerCase()==="[object"+type+"]";}/***Preparesanoptionsobjectfromthegivenvalue.*@private*@param{String|Object}valueValuetoconverttoanoptionsobject.*@returns{Object}Optionsobject.*/functionprepareOptions(value){value=value||{};if(value==="all"||value.all){value={natives:true,extensibility:true};}elseif(isType(value,"string")){value=self.forEach(value,/[^\s,]+/,function(m){this[m]=true;},{});}returnvalue;}/***Runsbuilt-in/customtokensinreverseinsertionorder,untilamatchisfound.*@private*@param{String}patternOriginalpatternfromwhichanXRegExpobjectisbeingbuilt.*@param{Number}posPositiontosearchfortokenswithin`pattern`.*@param{Number}scopeCurrentregexscope.*@param{Object}contextContextobjectassignedtotokenhandlerfunctions.*@returns{Object}Objectwithproperties`output`(thesubstitutionstringreturnedbythe*successfultokenhandler)and`match`(thetoken'smatcharray),ornull.*/functionrunTokens(pattern,pos,scope,context){vari=tokens.length,result=null,match,t;//ProtectagainstconstructingXRegExpswithintokenhandlerandtriggerfunctionsisInsideConstructor=true;//Mustreset`isInsideConstructor`,evenifa`trigger`or`handler`throwstry{while(i--){//Runinreverseordert=tokens[i];if((t.scope==="all"||t.scope===scope)&&(!t.trigger||t.trigger.call(context))){t.pattern.lastIndex=pos;match=fixed.exec.call(t.pattern,pattern);//Fixed`exec`hereallowsuseofnamedbackreferences,etc.if(match&&match.index===pos){result={output:t.handler.call(context,match,scope),match:match};break;}}}}catch(err){throwerr;}finally{isInsideConstructor=false;}returnresult;}/***EnablesordisablesXRegExpsyntaxandflagextensibility.*@private*@param{Boolean}on`true`toenable;`false`todisable.*/functionsetExtensibility(on){self.addToken=addToken[on?"on":"off"];features.extensibility=on;}/***Enablesordisablesnativemethodoverrides.*@private*@param{Boolean}on`true`toenable;`false`todisable.*/functionsetNatives(on){RegExp.prototype.exec=(on?fixed:nativ).exec;RegExp.prototype.test=(on?fixed:nativ).test;String.prototype.match=(on?fixed:nativ).match;String.prototype.replace=(on?fixed:nativ).replace;String.prototype.split=(on?fixed:nativ).split;features.natives=on;}/*--------------------------------------*Constructor*------------------------------------*//***Createsanextendedregularexpressionobjectformatchingtextwithapattern.Differsfroma*nativeregularexpressioninthatadditionalsyntaxandflagsaresupported.Thereturnedobject*isinfactanative`RegExp`andworkswithallnativemethods.*@classXRegExp*@constructor*@param{String|RegExp}patternRegexpatternstring,oranexisting`RegExp`objecttocopy.*@param{String}[flags]Anycombinationofflags:*
  • `g`-global*
  • `i`-ignorecase*
  • `m`-multilineanchors*
  • `n`-explicitcapture*
  • `s`-dotmatchesall(akasingleline)*
  • `x`-free-spacingandlinecomments(akaextended)*
  • `y`-sticky(Firefox3+only)*Flagscannotbeprovidedwhenconstructingone`RegExp`fromanother.*@returns{RegExp}Extendedregularexpressionobject.*@example**//Withnamedcaptureandflagx*date=XRegExp('(?[0-9]{4})-?#year\n\*(?[0-9]{2})-?#month\n\*(?[0-9]{2})#day','x');**//Passingaregexobjecttocopyit.Thecopymaintainsspecialpropertiesfornamedcapture,*//isaugmentedwith`XRegExp.prototype`methods,andhasafresh`lastIndex`property(setto*//zero).NativeregexesarenotrecompiledusingXRegExpsyntax.*XRegExp(/regex/);*/self=function(pattern,flags){if(self.isRegExp(pattern)){if(flags!==undef){thrownewTypeError("can'tsupplyflagswhenconstructingoneRegExpfromanother");}returncopy(pattern);}//Tokensbecomepartoftheregexconstructionprocess,soprotectagainstinfiniterecursion//whenanXRegExpisconstructedwithinatokenhandlerfunctionif(isInsideConstructor){thrownewError("can'tcalltheXRegExpconstructorwithintokendefinitionfunctions");}varoutput=[],scope=defaultScope,tokenContext={hasNamedCapture:false,captureNames:[],hasFlag:function(flag){returnflags.indexOf(flag)>-1;}},pos=0,tokenResult,match,chr;pattern=pattern===undef?"":String(pattern);flags=flags===undef?"":String(flags);if(nativ.match.call(flags,duplicateFlags)){//Don'tusetest/execbecausetheywouldupdatelastIndexthrownewSyntaxError("invalidduplicateregularexpressionflag");}//Strip/applyleadingmodemodifierwithanycombinationofflagsexceptgory:(?imnsx)pattern=nativ.replace.call(pattern,/^\(\?([\w$]+)\)/,function($0,$1){if(nativ.test.call(/[gy]/,$1)){thrownewSyntaxError("can'tuseflaggoryinmodemodifier");}flags=nativ.replace.call(flags+$1,duplicateFlags,"");return"";});self.forEach(flags,/[\s\S]/,function(m){if(registeredFlags.indexOf(m[0])<0){thrownewSyntaxError("invalidregularexpressionflag"+m[0]);}});while(posThematcharray,withnamedbackreferenceproperties.*
  • Theregexscopewherethematchwasfound.*@param{Object}[options]Optionsobjectwithoptionalproperties:*
  • `scope`{String}Scopeswherethetokenapplies:'default','class',or'all'.*
  • `trigger`{Function}Functionthatreturns`true`whenthetokenshouldbeapplied;e.g.,*ifaflagisset.If`false`isreturned,thematchedstringcanbematchedbyothertokens.*Hasaccesstopersistentpropertiesoftheregexbeingbuilt,through`this`(including*function`this.hasFlag`).*
  • `customFlags`{String}Nonnativeflagsusedbythetoken'shandlerortriggerfunctions.*PreventsXRegExpfromthrowinganinvalidflagerrorwhenthespecifiedflagsareused.*@example**//Basicusage:Adds\aforALERTcharacter*XRegExp.addToken(*/\\a/,*function(){return'\\x07';},*{scope:'all'}*);*XRegExp('\\a[\\a-\\n]+').test('\x07\n\x07');//->true*/self.addToken=addToken.off;/***Cachesandreturnstheresultofcalling`XRegExp(pattern,flags)`.Onanysubsequentcallwith*thesamepatternandflagcombination,thecachedcopyisreturned.*@memberOfXRegExp*@param{String}patternRegexpatternstring.*@param{String}[flags]AnycombinationofXRegExpflags.*@returns{RegExp}CachedXRegExpobject.*@example**while(match=XRegExp.cache('.','gs').exec(str)){*//Theregexiscompiledonceonly*}*/self.cache=function(pattern,flags){varkey=pattern+"/"+(flags||"");returncache[key]||(cache[key]=self(pattern,flags));};/***Escapesanyregularexpressionmetacharacters,forusewhenmatchingliteralstrings.Theresult*cansafelybeusedatanypointwithinaregexthatusesanyflags.*@memberOfXRegExp*@param{String}strStringtoescape.*@returns{String}Stringwithregexmetacharactersescaped.*@example**XRegExp.escape('Escaped?<.>');*//->'Escaped\?\<\.>'*/self.escape=function(str){returnnativ.replace.call(str,/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");};/***Executesaregexsearchinaspecifiedstring.Returnsamatcharrayor`null`.Iftheprovided*regexusesnamedcapture,namedbackreferencepropertiesareincludedonthematcharray.*Optional`pos`and`sticky`argumentsspecifythesearchstartposition,andwhetherthematch*muststartatthespecifiedpositiononly.The`lastIndex`propertyoftheprovidedregexisnot*used,butisupdatedforcompatibility.Alsofixesbrowserbugscomparedtothenative*`RegExp.prototype.exec`andcanbeusedreliablycross-browser.*@memberOfXRegExp*@param{String}strStringtosearch.*@param{RegExp}regexRegextosearchwith.*@param{Number}[pos=0]Zero-basedindexatwhichtostartthesearch.*@param{Boolean|String}[sticky=false]Whetherthematchmuststartatthespecifiedposition*only.Thestring`'sticky'`isacceptedasanalternativeto`true`.*@returns{Array}Matcharraywithnamedbackreferenceproperties,ornull.*@example**//Basicuse,withnamedbackreference*varmatch=XRegExp.exec('U+2620',XRegExp('U\\+(?[0-9A-F]{4})'));*match.hex;//->'2620'**//Withposandsticky,inaloop*varpos=2,result=[],match;*while(match=XRegExp.exec('<1><2><3><4>5<6>',/<(\d)>/,pos,'sticky')){*result.push(match[1]);*pos=match.index+match[0].length;*}*//result->['2','3','4']*/self.exec=function(str,regex,pos,sticky){varr2=copy(regex,"g"+(sticky&&hasNativeY?"y":""),(sticky===false?"y":"")),match;r2.lastIndex=pos=pos||0;match=fixed.exec.call(r2,str);//Fixed`exec`requiredfor`lastIndex`fix,etc.if(sticky&&match&&match.index!==pos){match=null;}if(regex.global){regex.lastIndex=match?r2.lastIndex:0;}returnmatch;};/***Executesaprovidedfunctiononceperregexmatch.*@memberOfXRegExp*@param{String}strStringtosearch.*@param{RegExp}regexRegextosearchwith.*@param{Function}callbackFunctiontoexecuteforeachmatch.Invokedwithfourarguments:*
  • Thematcharray,withnamedbackreferenceproperties.*
  • Thezero-basedmatchindex.*
  • Thestringbeingtraversed.*
  • Theregexobjectbeingusedtotraversethestring.*@param{*}[context]Objecttouseas`this`whenexecuting`callback`.*@returns{*}Provided`context`object.*@example**//Extractseveryotherdigitfromastring*XRegExp.forEach('1a2345',/\d/,function(match,i){*if(i%2)this.push(+match[0]);*},[]);*//->[2,4]*/self.forEach=function(str,regex,callback,context){varpos=0,i=-1,match;while((match=self.exec(str,regex,pos))){callback.call(context,match,++i,str,regex);pos=match.index+(match[0].length||1);}returncontext;};/***Copiesaregexobjectandaddsflag`g`.Thecopymaintainsspecialpropertiesfornamed*capture,isaugmentedwith`XRegExp.prototype`methods,andhasafresh`lastIndex`property*(settozero).NativeregexesarenotrecompiledusingXRegExpsyntax.*@memberOfXRegExp*@param{RegExp}regexRegextoglobalize.*@returns{RegExp}Copyoftheprovidedregexwithflag`g`added.*@example**varglobalCopy=XRegExp.globalize(/regex/);*globalCopy.global;//->true*/self.globalize=function(regex){returncopy(regex,"g");};/***Installsoptionalfeaturesaccordingtothespecifiedoptions.*@memberOfXRegExp*@param{Object|String}optionsOptionsobjectorstring.*@example**//Withanoptionsobject*XRegExp.install({*//Overridesnativeregexmethodswithfixed/extendedversionsthatsupportnamed*//backreferencesandfixnumerouscross-browserbugs*natives:true,**//EnablesextensibilityofXRegExpsyntaxandflags*extensibility:true*});**//Withanoptionsstring*XRegExp.install('nativesextensibility');**//Usingashortcuttoinstallalloptionalfeatures*XRegExp.install('all');*/self.install=function(options){options=prepareOptions(options);if(!features.natives&&options.natives){setNatives(true);}if(!features.extensibility&&options.extensibility){setExtensibility(true);}};/***Checkswhetheranindividualoptionalfeatureisinstalled.*@memberOfXRegExp*@param{String}featureNameofthefeaturetocheck.Oneof:*
  • `natives`*
  • `extensibility`*@returns{Boolean}Whetherthefeatureisinstalled.*@example**XRegExp.isInstalled('natives');*/self.isInstalled=function(feature){return!!(features[feature]);};/***Returns`true`ifanobjectisaregex;`false`ifitisn't.Thisworkscorrectlyforregexes*createdinanotherframe,when`instanceof`and`constructor`checkswouldfail.*@memberOfXRegExp*@param{*}valueObjecttocheck.*@returns{Boolean}Whethertheobjectisa`RegExp`object.*@example**XRegExp.isRegExp('string');//->false*XRegExp.isRegExp(/regex/i);//->true*XRegExp.isRegExp(RegExp('^','m'));//->true*XRegExp.isRegExp(XRegExp('(?s).'));//->true*/self.isRegExp=function(value){returnisType(value,"regexp");};/***Retrievesthematchesfromsearchingastringusingachainofregexesthatsuccessivelysearch*withinpreviousmatches.Theprovided`chain`arraycancontainregexesandobjectswith`regex`*and`backref`properties.Whenabackreferenceisspecified,thenamedornumberedbackreference*ispassedforwardtothenextregexorreturned.*@memberOfXRegExp*@param{String}strStringtosearch.*@param{Array}chainRegexesthateachsearchformatcheswithinprecedingresults.*@returns{Array}Matchesbythelastregexinthechain,oranemptyarray.*@example**//Basicusage;matchesnumberswithintags*XRegExp.matchChain('1234a56',[*XRegExp('(?is).*?'),*/\d+/*]);*//->['2','4','56']**//Passingforwardandreturningspecificbackreferences*html='XRegExp\*Google';*XRegExp.matchChain(html,[*{regex://i,backref:1},*{regex:XRegExp('(?i)^https?://(?[^/?#]+)'),backref:'domain'}*]);*//->['xregexp.com','www.google.com']*/self.matchChain=function(str,chain){return(functionrecurseChain(values,level){varitem=chain[level].regex?chain[level]:{regex:chain[level]},matches=[],addMatch=function(match){matches.push(item.backref?(match[item.backref]||""):match[0]);},i;for(i=0;i$$-Insertsaliteral'$'.*
  • $&,$0-Insertsthematchedsubstring.*
  • $`-Insertsthestringthatprecedesthematchedsubstring(leftcontext).*
  • $'-Insertsthestringthatfollowsthematchedsubstring(rightcontext).*
  • $n,$nn-Wheren/nnaredigitsreferencinganexistentcapturinggroup,inserts*backreferencen/nn.*
  • ${n}-Wherenisanameoranynumberofdigitsthatreferenceanexistentcapturing*group,insertsbackreferencen.*Replacementfunctionsareinvokedwiththreeormorearguments:*
  • Thematchedsubstring(correspondsto$&above).Namedbackreferencesareaccessibleas*propertiesofthisfirstargument.*
  • 0..narguments,oneforeachbackreference(correspondingto$1,$2,etc.above).*
  • Thezero-basedindexofthematchwithinthetotalsearchstring.*
  • Thetotalstringbeingsearched.*@param{String}[scope='one']Use'one'toreplacethefirstmatchonly,or'all'.Ifnot*explicitlyspecifiedandusingaregexwithflag`g`,`scope`is'all'.*@returns{String}Newstringwithoneorallmatchesreplaced.*@example**//Regexsearch,usingnamedbackreferencesinreplacementstring*varname=XRegExp('(?\\w+)(?\\w+)');*XRegExp.replace('JohnSmith',name,'${last},${first}');*//->'Smith,John'**//Regexsearch,usingnamedbackreferencesinreplacementfunction*XRegExp.replace('JohnSmith',name,function(match){*returnmatch.last+','+match.first;*});*//->'Smith,John'**//Globalstringsearch/replacement*XRegExp.replace('RegExpbuildsRegExps','RegExp','XRegExp','all');*//->'XRegExpbuildsXRegExps'*/self.replace=function(str,search,replacement,scope){varisRegex=self.isRegExp(search),search2=search,result;if(isRegex){if(scope===undef&&search.global){scope="all";//Followflaggwhen`scope`isn'texplicit}//Notethatsinceacopyisused,`search`'s`lastIndex`isn'tupdated*during*replacementiterationssearch2=copy(search,scope==="all"?"g":"",scope==="all"?"":"g");}elseif(scope==="all"){search2=newRegExp(self.escape(String(search)),"g");}result=fixed.replace.call(String(str),search2,replacement);//Fixed`replace`requiredfornamedbackreferences,etc.if(isRegex&&search.global){search.lastIndex=0;//FixesIE,Safaribug(lasttestedIE9,Safari5.1)}returnresult;};/***Splitsastringintoanarrayofstringsusingaregexorstringseparator.Matchesofthe*separatorarenotincludedintheresultarray.However,if`separator`isaregexthatcontains*capturinggroups,backreferencesaresplicedintotheresulteachtime`separator`ismatched.*Fixesbrowserbugscomparedtothenative`String.prototype.split`andcanbeusedreliably*cross-browser.*@memberOfXRegExp*@param{String}strStringtosplit.*@param{RegExp|String}separatorRegexorstringtouseforseparatingthestring.*@param{Number}[limit]Maximumnumberofitemstoincludeintheresultarray.*@returns{Array}Arrayofsubstrings.*@example**//Basicuse*XRegExp.split('abc','');*//->['a','b','c']**//Withlimit*XRegExp.split('abc','',2);*//->['a','b']**//Backreferencesinresultarray*XRegExp.split('..word1..',/([a-z]+)(\d+)/i);*//->['..','word','1','..']*/self.split=function(str,separator,limit){returnfixed.split.call(str,separator,limit);};/***Executesaregexsearchinaspecifiedstring.Returns`true`or`false`.Optional`pos`and*`sticky`argumentsspecifythesearchstartposition,andwhetherthematchmuststartatthe*specifiedpositiononly.The`lastIndex`propertyoftheprovidedregexisnotused,butis*updatedforcompatibility.Alsofixesbrowserbugscomparedtothenative*`RegExp.prototype.test`andcanbeusedreliablycross-browser.*@memberOfXRegExp*@param{String}strStringtosearch.*@param{RegExp}regexRegextosearchwith.*@param{Number}[pos=0]Zero-basedindexatwhichtostartthesearch.*@param{Boolean|String}[sticky=false]Whetherthematchmuststartatthespecifiedposition*only.Thestring`'sticky'`isacceptedasanalternativeto`true`.*@returns{Boolean}Whethertheregexmatchedtheprovidedvalue.*@example**//Basicuse*XRegExp.test('abc',/c/);//->true**//Withposandsticky*XRegExp.test('abc',/c/,0,'sticky');//->false*/self.test=function(str,regex,pos,sticky){//Dothistheeasyway:-)return!!self.exec(str,regex,pos,sticky);};/***Uninstallsoptionalfeaturesaccordingtothespecifiedoptions.*@memberOfXRegExp*@param{Object|String}optionsOptionsobjectorstring.*@example**//Withanoptionsobject*XRegExp.uninstall({*//Restoresnativeregexmethods*natives:true,**//Disablesadditionalsyntaxandflagextensions*extensibility:true*});**//Withanoptionsstring*XRegExp.uninstall('nativesextensibility');**//Usingashortcuttouninstallalloptionalfeatures*XRegExp.uninstall('all');*/self.uninstall=function(options){options=prepareOptions(options);if(features.natives&&options.natives){setNatives(false);}if(features.extensibility&&options.extensibility){setExtensibility(false);}};/***ReturnsanXRegExpobjectthatistheunionofthegivenpatterns.Patternscanbeprovidedas*regexobjectsorstrings.Metacharactersareescapedinpatternsprovidedasstrings.*Backreferencesinprovidedregexobjectsareautomaticallyrenumberedtoworkcorrectly.Native*flagsusedbyprovidedregexesareignoredinfavorofthe`flags`argument.*@memberOfXRegExp*@param{Array}patternsRegexesandstringstocombine.*@param{String}[flags]AnycombinationofXRegExpflags.*@returns{RegExp}Unionoftheprovidedregexesandstrings.*@example**XRegExp.union(['a+b*c',/(dogs)\1/,/(cats)\1/],'i');*i**XRegExp.union([XRegExp('(?dogs)\\k'),XRegExp('(?cats)\\k')]);*//->XRegExp('(?dogs)\\k|(?cats)\\k')*/self.union=function(patterns,flags){varparts=/(\()(?!\?)|\\([1-9]\d*)|\\[\s\S]|\[(?:[^\\\]]|\\[\s\S])*]/g,numCaptures=0,numPriorCaptures,captureNames,rewrite=function(match,paren,backref){varname=captureNames[numCaptures-numPriorCaptures];if(paren){//Capturinggroup++numCaptures;if(name){//Ifthecurrentcapturehasanamereturn"(?<"+name+">";}}elseif(backref){//Backreferencereturn"\\"+(+backref+numPriorCaptures);}returnmatch;},output=[],pattern,i;if(!(isType(patterns,"array")&&patterns.length)){thrownewTypeError("patternsmustbeanonemptyarray");}for(i=0;i1&&lastIndexOf(match,"")>-1){r2=newRegExp(this.source,nativ.replace.call(getNativeFlags(this),"g",""));//Using`str.slice(match.index)`ratherthan`match[0]`incaselookaheadallowed//matchingduetocharactersoutsidethematchnativ.replace.call(String(str).slice(match.index),r2,function(){vari;for(i=1;imatch.index)){this.lastIndex=match.index;}}if(!this.global){this.lastIndex=origLastIndex;//FixesIE,Operabug(lasttestedIE9,Opera11.6)}returnmatch;};/***Fixesbrowserbugsinthenative`RegExp.prototype.test`.Calling`XRegExp.install('natives')`*usesthistooverridethenativemethod.*@private*@param{String}strStringtosearch.*@returns{Boolean}Whethertheregexmatchedtheprovidedvalue.*/fixed.test=function(str){//Dothistheeasyway:-)return!!fixed.exec.call(this,str);};/***Addsnamedcapturesupport(withbackreferencesreturnedas`result.name`),andfixesbrowser*bugsinthenative`String.prototype.match`.Calling`XRegExp.install('natives')`usesthisto*overridethenativemethod.*@private*@param{RegExp}regexRegextosearchwith.*@returns{Array}If`regex`usesflagg,anarrayofmatchstringsornull.Withoutflagg,the*resultofcalling`regex.exec(this)`.*/fixed.match=function(regex){if(!self.isRegExp(regex)){regex=newRegExp(regex);//Usenative`RegExp`}elseif(regex.global){varresult=nativ.match.apply(this,arguments);regex.lastIndex=0;//FixesIEbugreturnresult;}returnfixed.exec.call(regex,this);};/***Addssupportfor`${n}`tokensfornamedandnumberedbackreferencesinreplacementtext,and*providesnamedbackreferencestoreplacementfunctionsas`arguments[0].name`.Alsofixes*browserbugsinreplacementtextsyntaxwhenperformingareplacementusinganonregexsearch*value,andthevalueofareplacementregex's`lastIndex`propertyduringreplacementiterations*anduponcompletion.Notethatthisdoesn'tsupportSpiderMonkey'sproprietarythird(`flags`)*argument.Calling`XRegExp.install('natives')`usesthistooverridethenativemethod.Usevia*`XRegExp.replace`withoutoverridingnatives.*@private*@param{RegExp|String}searchSearchpatterntobereplaced.*@param{String|Function}replacementReplacementstringorafunctioninvokedtocreateit.*@returns{String}Newstringwithoneorallmatchesreplaced.*/fixed.replace=function(search,replacement){varisRegex=self.isRegExp(search),captureNames,result,str,origLastIndex;if(isRegex){if(search.xregexp){captureNames=search.xregexp.captureNames;}if(!search.global){origLastIndex=search.lastIndex;}}else{search+="";}if(isType(replacement,"function")){result=nativ.replace.call(String(this),search,function(){varargs=arguments,i;if(captureNames){//Changethe`arguments[0]`stringprimitivetoa`String`objectthatcanstorepropertiesargs[0]=newString(args[0]);//Storenamedbackreferencesonthefirstargumentfor(i=0;iargs.length-3){thrownewSyntaxError("backreferencetoundefinedgroup"+$0);}returnargs[$2]||"";}thrownewSyntaxError("invalidtoken"+$0);});});}if(isRegex){if(search.global){search.lastIndex=0;//FixesIE,Safaribug(lasttestedIE9,Safari5.1)}else{search.lastIndex=origLastIndex;//FixesIE,Operabug(lasttestedIE9,Opera11.6)}}returnresult;};/***Fixesbrowserbugsinthenative`String.prototype.split`.Calling`XRegExp.install('natives')`*usesthistooverridethenativemethod.Usevia`XRegExp.split`withoutoverridingnatives.*@private*@param{RegExp|String}separatorRegexorstringtouseforseparatingthestring.*@param{Number}[limit]Maximumnumberofitemstoincludeintheresultarray.*@returns{Array}Arrayofsubstrings.*/fixed.split=function(separator,limit){if(!self.isRegExp(separator)){returnnativ.split.apply(this,arguments);//usefasternativemethod}varstr=String(this),origLastIndex=separator.lastIndex,output=[],lastLastIndex=0,lastLength;/*Valuesfor`limit`,perthespec:*Ifundefined:pow(2,32)-1*If0,Infinity,orNaN:0*Ifpositivenumber:limit=floor(limit);if(limit>=pow(2,32))limit-=pow(2,32);*Ifnegativenumber:pow(2,32)-floor(abs(limit))*Ifother:Type-convert,thenusetheaboverules*/limit=(limit===undef?-1:limit)>>>0;self.forEach(str,separator,function(match){if((match.index+match[0].length)>lastLastIndex){//!=`if(match[0].length)`output.push(str.slice(lastLastIndex,match.index));if(match.length>1&&match.indexlimit?output.slice(0,limit):output;};/*--------------------------------------*Built-intokens*------------------------------------*///Shortcutadd=addToken.on;/*Letteridentityescapesthatnativelymatchliteralcharacters:\p,\P,etc.*ShouldbeSyntaxErrorsbutareallowedinwebreality.XRegExpmakesthemerrorsforcross-*browserconsistencyandtoreservetheirsyntax,butletsthembesupersededbyXRegExpaddons.*/add(/\\([ABCE-RTUVXYZaeg-mopqyz]|c(?![A-Za-z])|u(?![\dA-Fa-f]{4})|x(?![\dA-Fa-f]{2}))/,function(match,scope){//\Bisallowedindefaultscopeonlyif(match[1]==="B"&&scope===defaultScope){returnmatch[0];}thrownewSyntaxError("invalidescape"+match[0]);},{scope:"all"});/*Emptycharacterclass:[]or[^]*Fixesacriticalcross-browsersyntaxinconsistency.Unlessthisisstandardized(perthespec),*regexsyntaxcan'tbeaccuratelyparsedbecausecharacterclassendingscan'tbedetermined.*/add(/\[(\^?)]/,function(match){//Forcross-browsercompatibilitywithES3,convert[]to\b\Band[^]to[\s\S].//(?!)shouldworklike\b\B,butisunreliableinFirefoxreturnmatch[1]?"[\\s\\S]":"\\b\\B";});/*Commentpattern:(?#)*Inlinecommentsareanalternativetothelinecommentsallowedinfree-spacingmode(flagx).*/add(/(?:\(\?#[^)]*\))+/,function(match){//Keeptokensseparatedunlessthefollowingtokenisaquantifierreturnnativ.test.call(quantifier,match.input.slice(match.index+match[0].length))?"":"(?:)";});/*Namedbackreference:\k*BackreferencenamescanusethecharactersA-Z,a-z,0-9,_,and$only.*/add(/\\k<([\w$]+)>/,function(match){varindex=isNaN(match[1])?(lastIndexOf(this.captureNames,match[1])+1):+match[1],endIndex=match.index+match[0].length;if(!index||index>this.captureNames.length){thrownewSyntaxError("backreferencetoundefinedgroup"+match[0]);}//Keepbackreferencesseparatefromsubsequentliteralnumbersreturn"\\"+index+(endIndex===match.input.length||isNaN(match.input.charAt(endIndex))?"":"(?:)");});/*Whitespaceandlinecomments,infree-spacingmode(akaextendedmode,flagx)only.*/add(/(?:\s+|#.*)+/,function(match){//Keeptokensseparatedunlessthefollowingtokenisaquantifierreturnnativ.test.call(quantifier,match.input.slice(match.index+match[0].length))?"":"(?:)";},{trigger:function(){returnthis.hasFlag("x");},customFlags:"x"});/*Dot,indotallmode(akasinglelinemode,flags)only.*/add(/\./,function(){return"[\\s\\S]";},{trigger:function(){returnthis.hasFlag("s");},customFlags:"s"});/*Namedcapturinggroup;matchtheopeningdelimiteronly:(?*CapturenamescanusethecharactersA-Z,a-z,0-9,_,and$only.Namescan'tbeintegers.*SupportsPython-style(?PasanalternatesyntaxtoavoidissuesinrecentOpera(which*nativelysupportsthePython-stylesyntax).Otherwise,XRegExpmighttreatnumbered*backreferencestoPython-stylenamedcaptureasoctals.*/add(/\(\?P?<([\w$]+)>/,function(match){if(!isNaN(match[1])){//Avoidincorrectlookups,sincenamedbackreferencesareaddedtomatcharraysthrownewSyntaxError("can'tuseintegerascapturename"+match[0]);}this.captureNames.push(match[1]);this.hasNamedCapture=true;return"(";});/*Numberedbackreferenceoroctal,plusanyfollowingdigits:\0,\11,etc.*Octalsexcept\0notfollowedby0-9andbackreferencestounopenedcapturegroupsthrowan*error.Othermatchesarereturnedunaltered.IE<=8doesn'tsupportbackreferencesgreaterthan*\99inregexsyntax.*/add(/\\(\d+)/,function(match,scope){if(!(scope===defaultScope&&/^[1-9]/.test(match[1])&&+match[1]<=this.captureNames.length)&&match[1]!=="0"){thrownewSyntaxError("can'tuseoctalescapeorbackreferencetoundefinedgroup"+match[0]);}returnmatch[0];},{scope:"all"});/*Capturinggroup;matchtheopeningparenthesisonly.*Requiredforsupportofnamedcapturinggroups.Alsoaddsexplicitcapturemode(flagn).*/add(/\((?!\?)/,function(){if(this.hasFlag("n")){return"(?:";}this.captureNames.push(null);return"(";},{customFlags:"n"});/*--------------------------------------*ExposeXRegExp*------------------------------------*///ForCommonJSenviromentsif(typeofexports!=="undefined"){exports.XRegExp=self;}returnself;}());////Beginanonymousfunction.Thisisusedtocontainlocalscopevariableswithoutpoluttingglobalscope.//if(typeof(SyntaxHighlighter)=='undefined')varSyntaxHighlighter=function(){//CommonJSif(typeof(require)!='undefined'&&typeof(XRegExp)=='undefined'){XRegExp=require('xregexp').XRegExp;}//ShortcutobjectwhichwillbeassignedtotheSyntaxHighlightervariable.//Thisisashorthandforlocalreferenceinordertoavoidlongnamespace//referencestoSyntaxHighlighter.whatever...varsh={defaults:{/**AdditionalCSSclassnamestobeaddedtohighlighterelements.*/'class-name':'',/**Firstlinenumber.*/'first-line':1,/***Padslinenumbers.Possiblevaluesare:**false-don'tpadlinenumbers.*true-automaticalypadnumberswithminimumrequirednumberofleadingzeroes.*[int]-lengthuptowhichpadlinenumbers.*/'pad-line-numbers':false,/**Linestohighlight.*/'highlight':null,/**Titletobedisplayedabovethecodeblock.*/'title':null,/**Enablesordisablessmarttabs.*/'smart-tabs':true,/**Getsorsetstabsize.*/'tab-size':4,/**Enablesordisablesgutter.*/'gutter':true,/**Enablesordisablestoolbar.*/'toolbar':true,/**Enablesquickcodecopyandpastefromdoubleclick.*/'quick-code':true,/**Forcescodeviewtobecollapsed.*/'collapse':false,/**Enablesordisablesautomaticlinks.*/'auto-links':true,/**Getsorsetslightmode.Equavalenttoturningoffgutterandtoolbar.*/'light':false,unindent:true,'html-script':false},config:{space:' ',/**Enablesuseoftags.*/useScriptTags:true,/**Bloggermodeflag.*/bloggerMode:false,stripBrs:false,/**NameofthetagthatSyntaxHighlighterwillautomaticallylookfor.*/tagName:'pre',strings:{expandSource:'expandsource',help:'?',alert:'SyntaxHighlighter\n\n',noBrush:'Can\'tfindbrushfor:',brushNotHtmlScript:'Brushwasn\'tconfiguredforhtml-scriptoption:',//thisispopulatedbythebuildscriptaboutDialog:'AboutSyntaxHighlighterSyntaxHighlighter
    version3.0.9(Thu,04Dec201412:32:21GMT)
    http://alexgorbatchev.com/SyntaxHighlighter
    JavaScriptcodesyntaxhighlighter.
    Copyright2004-2013AlexGorbatchev.
    Ifyoulikethisscript,pleasedonateto
    keepdevelopmentactive!
    '}},/**Internal'global'variables.*/vars:{highlighters:{}},/**Thisobjectispopulatedbyuserincludedexternalbrushfiles.*/brushes:{},/**Commonregularexpressions.*/regexLib:{multiLineCComments:XRegExp('/\\*.*?\\*/','gs'),singleLineCComments:/\/\/.*$/gm,singleLinePerlComments:/#.*$/gm,doubleQuotedString:/"([^\\"\n]|\\.)*"/g,singleQuotedString:/'([^\\'\n]|\\.)*'/g,multiLineDoubleQuotedString:XRegExp('"([^\\\\"]|\\\\.)*"','gs'),multiLineSingleQuotedString:XRegExp("'([^\\\\']|\\\\.)*'",'gs'),xmlComments:XRegExp('(<|<)!--.*?--(>|>)','gs'),url:/\w+:\/\/[\w-.\/?%&=:@;#]*/g,phpScriptTags:{left:/(<|<)\?(?:=|php)?/g,right:/\?(>|>)/g,eof:true},aspScriptTags:{left:/(<|<)%=?/g,right:/%(>|>)/g},scriptScriptTags:{left:/(<|<)\s*script.*?(>|>)/gi,right:/(<|<)\/\s*script\s*(>|>)/gi}},toolbar:{/***GeneratesHTMLmarkupforthetoolbar.*@param{Highlighter}highlighterHighlighterinstance.*@return{String}ReturnsHTMLmarkup.*/getHtml:function(highlighter){varhtml='',items=sh.toolbar.items,list=items.list;functiondefaultGetHtml(highlighter,name){returnsh.toolbar.getButtonHtml(highlighter,name,sh.config.strings[name]);}for(vari=0,l=list.length;i';returnhtml;},/***GeneratesHTMLmarkupforaregularbuttoninthetoolbar.*@param{Highlighter}highlighterHighlighterinstance.*@param{String}commandNameCommandnamethatwouldbeexecuted.*@param{String}labelLabeltexttodisplay.*@return{String}ReturnsHTMLmarkup.*/getButtonHtml:function(highlighter,commandName,label){commandName=escapeHtml(commandName);return''+escapeHtml(label)+'';},/***Eventhandlerforatoolbaranchor.*/handler:function(e){vartarget=e.target,className=target.className||'';functiongetValue(name){varr=newRegExp(name+'_(\\w+)'),match=r.exec(className);returnmatch?match[1]:null;}varhighlighter=getHighlighterById(findParentElement(target,'.syntaxhighlighter').id),commandName=getValue('command');//executethetoolbarcommandif(highlighter&&commandName)sh.toolbar.items[commandName].execute(highlighter);//disabledefaultAclickbehavioure.preventDefault();},/**Collectionoftoolbaritems.*/items:{//Orderedlisofitemsinthetoolbar.Can'texpect`for(varninitems)`tobeconsistent.list:['expandSource','help'],expandSource:{getHtml:function(highlighter){if(highlighter.getParam('collapse')!=true)return'';vartitle=highlighter.getParam('title');returnsh.toolbar.getButtonHtml(highlighter,'expandSource',title?title:sh.config.strings.expandSource);},execute:function(highlighter){vardiv=getHighlighterDivById(highlighter.id);removeClass(div,'collapsed');}},/**Commandtodisplaytheaboutdialogwindow.*/help:{execute:function(highlighter){varwnd=popup('','_blank',500,250,'scrollbars=0'),doc=wnd.document;doc.write(sh.config.strings.aboutDialog);doc.close();wnd.focus();}}}},/***FindsallelementsonthepagewhichshouldbeprocessesbySyntaxHighlighter.**@param{Object}globalParamsOptionalparameterswhichoverrideelement's*parameters.Onlyusedifelementisspecified.**@param{Object}elementOptionalelementtohighlight.Ifnoneis*provided,allelementsinthecurrentdocument*arereturnedwhichqualify.**@return{Array}Returnslistof{target:DOMElement,params:Object}objects.*/findElements:function(globalParams,element){varelements=element?[element]:toArray(document.getElementsByTagName(sh.config.tagName)),conf=sh.config,result=[];//supportforfeatureif(conf.useScriptTags)elements=elements.concat(getSyntaxHighlighterScriptTags());if(elements.length===0)returnresult;for(vari=0,l=elements.length;itagsifit'spresentif(conf.useScriptTags)code=stripCData(code);//Injecttitleiftheattributeispresentif((target.title||'')!='')params.title=target.title;params.brush=brushName;highlighter.init(params);element=highlighter.getDiv(code);//carryoverIDif((target.id||'')!='')element.id=target.id;target.parentNode.replaceChild(element,target);}},/***MainentrypointfortheSyntaxHighlighter.*@param{Object}paramsOptionalparamstoapplytoallhighlightedelements.*/all:function(params){attachEvent(window,'load',function(){sh.highlight(params);});}};//endofshfunctionescapeHtml(html){returndocument.createElement('div').appendChild(document.createTextNode(html)).parentNode.innerHTML.replace(/"/g,'"');};/***ChecksiftargetDOMelementshasspecifiedCSSclass.*@param{DOMElement}targetTargetDOMelementtocheck.*@param{String}classNameNameoftheCSSclasstocheckfor.*@return{Boolean}Returnstrueifclassnameispresent,falseotherwise.*/functionhasClass(target,className){returntarget.className.indexOf(className)!=-1;};/***AddsCSSclassnametothetargetDOMelement.*@param{DOMElement}targetTargetDOMelement.*@param{String}classNameNewCSSclasstoadd.*/functionaddClass(target,className){if(!hasClass(target,className))target.className+=''+className;};/***RemovesCSSclassnamefromthetargetDOMelement.*@param{DOMElement}targetTargetDOMelement.*@param{String}classNameCSSclasstoremove.*/functionremoveClass(target,className){target.className=target.className.replace(className,'');};/***Convertsthesourcetoarrayobject.Mostlyusedforfunctionargumentsand*listsreturnedbygetElementsByTagName()whicharen'tArrayobjects.*@param{List}sourceSourcelist.*@return{Array}Returnsarray.*/functiontoArray(source){varresult=[];for(vari=0,l=source.length;ifindElement(container,className,true).*@param{Element}targetTargetelement.*@param{String}classNameClassnametolookfor.*@return{Element}Returnsfoundparentelementonnull.*/functionfindParentElement(target,className){returnfindElement(target,className,true);};/***Findsanindexofelementinthearray.*@ignore*@param{Object}searchElement*@param{Number}fromIndex*@return{Number}Returnsindexofelementiffound;-1otherwise.*/functionindexOf(array,searchElement,fromIndex){fromIndex=Math.max(fromIndex||0,0);for(vari=fromIndex,l=array.length;i(.*?))\\]$"),pos=0,regex=XRegExp("(?[\\w-]+)"+"\\s*:\\s*"+"(?"+"[\\w%#-]+|"+//word"\\[.*?\\]|"+//[]array'".*?"|'+//""string"'.*?'"+//''string")\\s*;?","g");while((match=XRegExp.exec(str,regex,pos))!=null){varvalue=match.value.replace(/^['"]|['"]$/g,'')//stripquotesfromendofstrings;//trytoparsearrayvalueif(value!=null&&arrayRegex.test(value)){varm=XRegExp.exec(value,arrayRegex);value=m.values.length>0?m.values.split(/\s*,\s*/):[];}result[match.name]=value;pos=match.index+match[0].length;}returnresult;};/***Wrapseachlineofthestringintotagwithgivenstyleappliedtoit.**@param{String}strInputstring.*@param{String}cssStylenametoapplytothestring.*@return{String}Returnsinputstringwitheachlinesurroundedbytag.*/functionwrapLinesWithCode(str,css){if(str==null||str.length==0||str=='\n')returnstr;str=str.replace(/...tothemsothat//leadingspacesaren'tincluded.if(css!=null)str=eachLine(str,function(line){if(line.length==0)return'';varspaces='';line=line.replace(/^( | )+/,function(s){spaces=s;return'';});if(line.length==0)returnspaces;returnspaces+''+line+'';});returnstr;};/***Padsnumberwithzerosuntilit'slengthisthesameasgivenlength.**@param{Number}numberNumbertopad.*@param{Number}lengthMaxstringlengthwith.*@return{String}Returnsastringpaddedwithproperamountof'0'.*/functionpadNumber(number,length){varresult=number.toString();while(result.length|<br\s*\/?>/gi;if(sh.config.bloggerMode==true)str=str.replace(br,'\n');if(sh.config.stripBrs==true)str=str.replace(br,'');returnstr;};/***Removesallwhitespaceatthebeginingandendofastring.**@param{String}strStringtotrim.*@return{String}Returnsstringwithoutleadingandfollowingwhitespacecharacters.*/functiontrim(str){returnstr.replace(/^\s+|\s+$/g,'');};/***Unindentsablockoftextbythelowestcommonindentamount.*@param{String}strTexttounindent.*@return{String}Returnsunindentedtextblock.*/functionunindent(str){varlines=splitLines(fixInputString(str)),indents=newArray(),regex=/^\s*/,min=1000;//gothrougheverylineandcheckforcommonnumberofindentsfor(vari=0,l=lines.length;i0;i++){varline=lines[i];if(trim(line).length==0)continue;varmatches=regex.exec(line);//Intheeventthatjustonelinedoesn'thaveleadingwhitespace//wecan'tunindentanything,sobailcompletely.if(matches==null)returnstr;min=Math.min(matches[0].length,min);}//trimminimumcommonnumberofwhitespacefromthebeginingofeverylineif(min>0)for(vari=0,l=lines.length;im2.index)return1;else{//ifindexisthesame,sortbylengthif(m1.lengthm2.length)return1;}return0;};/***Executesgivenregularexpressiononprovidedcodeandreturnsall*matchesthatarefound.**@param{String}codeCodetoexecuteregularexpressionon.*@param{Object}regexRegularexpressioniteminfofromregexListcollection.*@return{Array}ReturnsalistofMatchobjects.*/functiongetMatches(code,regexInfo){functiondefaultAdd(match,regexInfo){returnmatch[0];};varindex=0,match=null,matches=[],func=regexInfo.func?regexInfo.func:defaultAddpos=0;while((match=XRegExp.exec(code,regexInfo.regex,pos))!=null){varresultMatch=func(match,regexInfo);if(typeof(resultMatch)=='string')resultMatch=[newsh.Match(resultMatch,match.index,regexInfo.css)];matches=matches.concat(resultMatch);pos=match.index+match[0].length;}returnmatches;};/***TurnsallURLsinthecodeintotags.*@param{String}codeInputcode.*@return{String}Returnscodewithtags.*/functionprocessUrls(code){vargt=/(.*)((>|<).*)/;returncode.replace(sh.regexLib.url,function(m){varsuffix='',match=null;google.com>google.com>//Whereas>easilylookslikepartoftheURLstring.if(match=gt.exec(m)){m=match[1];suffix=match[2];}return''+m+''+suffix;});};/***Findsallelementss.*@return{Array}ReturnsarrayofallfoundSyntaxHighlightertags.*/functiongetSyntaxHighlighterScriptTags(){vartags=document.getElementsByTagName('script'),result=[];for(vari=0,l=tags.length;ifromfunctionshGetPath(){varargs=arguments,result=[];for(vari=0;i + * MIT License + */ +var XRegExp;XRegExp=XRegExp||(function(undef){"use strict";var self,addToken,add,features={natives:false,extensibility:false},nativ={exec:RegExp.prototype.exec,test:RegExp.prototype.test,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split},fixed={},cache={},tokens=[],defaultScope="default",classScope="class",nativeTokens={"default":/^(?:\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S])|\(\?[:=!]|[?*+]\?|{\d+(?:,\d*)?}\??)/,"class":/^(?:\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S]))/},replacementToken=/\$(?:{([\w$]+)}|(\d\d?|[\s\S]))/g,duplicateFlags=/([\s\S])(?=[\s\S]*\1)/g,quantifier=/^(?:[?*+]|{\d+(?:,\d*)?})\??/,compliantExecNpcg=nativ.exec.call(/()??/,"")[1]===undef,hasNativeY=RegExp.prototype.sticky!==undef,isInsideConstructor=false,registeredFlags="gim"+(hasNativeY?"y":"");function augment(regex,captureNames,isNative){var p;for(p in self.prototype){if(self.prototype.hasOwnProperty(p)){regex[p]=self.prototype[p];}} +regex.xregexp={captureNames:captureNames,isNative:!!isNative};return regex;} +function getNativeFlags(regex){return(regex.global?"g":"")+ +(regex.ignoreCase?"i":"")+ +(regex.multiline?"m":"")+ +(regex.extended?"x":"")+ +(regex.sticky?"y":"");} +function copy(regex,addFlags,removeFlags){if(!self.isRegExp(regex)){throw new TypeError("type RegExp expected");} +var flags=nativ.replace.call(getNativeFlags(regex)+(addFlags||""),duplicateFlags,"");if(removeFlags){flags=nativ.replace.call(flags,new RegExp("["+removeFlags+"]+","g"),"");} +if(regex.xregexp&&!regex.xregexp.isNative){regex=augment(self(regex.source,flags),regex.xregexp.captureNames?regex.xregexp.captureNames.slice(0):null);}else{regex=augment(new RegExp(regex.source,flags),null,true);} +return regex;} +function lastIndexOf(array,value){var i=array.length;if(Array.prototype.lastIndexOf){return array.lastIndexOf(value);} +while(i--){if(array[i]===value){return i;}} +return-1;} +function isType(value,type){return Object.prototype.toString.call(value).toLowerCase()==="[object "+type+"]";} +function prepareOptions(value){value=value||{};if(value==="all"||value.all){value={natives:true,extensibility:true};}else if(isType(value,"string")){value=self.forEach(value,/[^\s,]+/,function(m){this[m]=true;},{});} +return value;} +function runTokens(pattern,pos,scope,context){var i=tokens.length,result=null,match,t;isInsideConstructor=true;try{while(i--){t=tokens[i];if((t.scope==="all"||t.scope===scope)&&(!t.trigger||t.trigger.call(context))){t.pattern.lastIndex=pos;match=fixed.exec.call(t.pattern,pattern);if(match&&match.index===pos){result={output:t.handler.call(context,match,scope),match:match};break;}}}}catch(err){throw err;}finally{isInsideConstructor=false;} +return result;} +function setExtensibility(on){self.addToken=addToken[on?"on":"off"];features.extensibility=on;} +function setNatives(on){RegExp.prototype.exec=(on?fixed:nativ).exec;RegExp.prototype.test=(on?fixed:nativ).test;String.prototype.match=(on?fixed:nativ).match;String.prototype.replace=(on?fixed:nativ).replace;String.prototype.split=(on?fixed:nativ).split;features.natives=on;} +self=function(pattern,flags){if(self.isRegExp(pattern)){if(flags!==undef){throw new TypeError("can't supply flags when constructing one RegExp from another");} +return copy(pattern);} +if(isInsideConstructor){throw new Error("can't call the XRegExp constructor within token definition functions");} +var output=[],scope=defaultScope,tokenContext={hasNamedCapture:false,captureNames:[],hasFlag:function(flag){return flags.indexOf(flag)>-1;}},pos=0,tokenResult,match,chr;pattern=pattern===undef?"":String(pattern);flags=flags===undef?"":String(flags);if(nativ.match.call(flags,duplicateFlags)){throw new SyntaxError("invalid duplicate regular expression flag");} +pattern=nativ.replace.call(pattern,/^\(\?([\w$]+)\)/,function($0,$1){if(nativ.test.call(/[gy]/,$1)){throw new SyntaxError("can't use flag g or y in mode modifier");} +flags=nativ.replace.call(flags+$1,duplicateFlags,"");return"";});self.forEach(flags,/[\s\S]/,function(m){if(registeredFlags.indexOf(m[0])<0){throw new SyntaxError("invalid regular expression flag "+m[0]);}});while(pos";}}else if(backref){return"\\"+(+backref+numPriorCaptures);} +return match;},output=[],pattern,i;if(!(isType(patterns,"array")&&patterns.length)){throw new TypeError("patterns must be a nonempty array");} +for(i=0;i1&&lastIndexOf(match,"")>-1){r2=new RegExp(this.source,nativ.replace.call(getNativeFlags(this),"g",""));nativ.replace.call(String(str).slice(match.index),r2,function(){var i;for(i=1;imatch.index)){this.lastIndex=match.index;}} +if(!this.global){this.lastIndex=origLastIndex;} +return match;};fixed.test=function(str){return!!fixed.exec.call(this,str);};fixed.match=function(regex){if(!self.isRegExp(regex)){regex=new RegExp(regex);}else if(regex.global){var result=nativ.match.apply(this,arguments);regex.lastIndex=0;return result;} +return fixed.exec.call(regex,this);};fixed.replace=function(search,replacement){var isRegex=self.isRegExp(search),captureNames,result,str,origLastIndex;if(isRegex){if(search.xregexp){captureNames=search.xregexp.captureNames;} +if(!search.global){origLastIndex=search.lastIndex;}}else{search+="";} +if(isType(replacement,"function")){result=nativ.replace.call(String(this),search,function(){var args=arguments,i;if(captureNames){args[0]=new String(args[0]);for(i=0;iargs.length-3){throw new SyntaxError("backreference to undefined group "+$0);} +return args[$2]||"";} +throw new SyntaxError("invalid token "+$0);});});} +if(isRegex){if(search.global){search.lastIndex=0;}else{search.lastIndex=origLastIndex;}} +return result;};fixed.split=function(separator,limit){if(!self.isRegExp(separator)){return nativ.split.apply(this,arguments);} +var str=String(this),origLastIndex=separator.lastIndex,output=[],lastLastIndex=0,lastLength;limit=(limit===undef?-1:limit)>>>0;self.forEach(str,separator,function(match){if((match.index+match[0].length)>lastLastIndex){output.push(str.slice(lastLastIndex,match.index));if(match.length>1&&match.indexlimit?output.slice(0,limit):output;};add=addToken.on;add(/\\([ABCE-RTUVXYZaeg-mopqyz]|c(?![A-Za-z])|u(?![\dA-Fa-f]{4})|x(?![\dA-Fa-f]{2}))/,function(match,scope){if(match[1]==="B"&&scope===defaultScope){return match[0];} +throw new SyntaxError("invalid escape "+match[0]);},{scope:"all"});add(/\[(\^?)]/,function(match){return match[1]?"[\\s\\S]":"\\b\\B";});add(/(?:\(\?#[^)]*\))+/,function(match){return nativ.test.call(quantifier,match.input.slice(match.index+match[0].length))?"":"(?:)";});add(/\\k<([\w$]+)>/,function(match){var index=isNaN(match[1])?(lastIndexOf(this.captureNames,match[1])+1):+match[1],endIndex=match.index+match[0].length;if(!index||index>this.captureNames.length){throw new SyntaxError("backreference to undefined group "+match[0]);} +return"\\"+index+(endIndex===match.input.length||isNaN(match.input.charAt(endIndex))?"":"(?:)");});add(/(?:\s+|#.*)+/,function(match){return nativ.test.call(quantifier,match.input.slice(match.index+match[0].length))?"":"(?:)";},{trigger:function(){return this.hasFlag("x");},customFlags:"x"});add(/\./,function(){return"[\\s\\S]";},{trigger:function(){return this.hasFlag("s");},customFlags:"s"});add(/\(\?P?<([\w$]+)>/,function(match){if(!isNaN(match[1])){throw new SyntaxError("can't use integer as capture name "+match[0]);} +this.captureNames.push(match[1]);this.hasNamedCapture=true;return"(";});add(/\\(\d+)/,function(match,scope){if(!(scope===defaultScope&&/^[1-9]/.test(match[1])&&+match[1]<=this.captureNames.length)&&match[1]!=="0"){throw new SyntaxError("can't use octal escape or backreference to undefined group "+match[0]);} +return match[0];},{scope:"all"});add(/\((?!\?)/,function(){if(this.hasFlag("n")){return"(?:";} +this.captureNames.push(null);return"(";},{customFlags:"n"});if(typeof exports!=="undefined"){exports.XRegExp=self;} +return self;}());if(typeof(SyntaxHighlighter)=='undefined')var SyntaxHighlighter=function(){if(typeof(require)!='undefined'&&typeof(XRegExp)=='undefined') +{XRegExp=require('xregexp').XRegExp;} +var sh={defaults:{'class-name':'','first-line':1,'pad-line-numbers':false,'highlight':null,'title':null,'smart-tabs':true,'tab-size':4,'gutter':true,'toolbar':true,'quick-code':true,'collapse':false,'auto-links':true,'light':false,'unindent':true,'html-script':false},config:{space:' ',useScriptTags:true,bloggerMode:false,stripBrs:false,tagName:'pre',strings:{expandSource:'expand source',help:'?',alert:'SyntaxHighlighter\n\n',noBrush:'Can\'t find brush for: ',brushNotHtmlScript:'Brush wasn\'t configured for html-script option: ',aboutDialog:'About SyntaxHighlighter
    SyntaxHighlighter
    version 3.0.9 (Thu, 04 Dec 2014 12:32:21 GMT)
    JavaScript code syntax highlighter.
    Copyright 2004-2013 Alex Gorbatchev.
    If you like this script, please donate to
    keep development active!
    '}},vars:{highlighters:{}},brushes:{},regexLib:{multiLineCComments:XRegExp('/\\*.*?\\*/','gs'),singleLineCComments:/\/\/.*$/gm,singleLinePerlComments:/#.*$/gm,doubleQuotedString:/"([^\\"\n]|\\.)*"/g,singleQuotedString:/'([^\\'\n]|\\.)*'/g,multiLineDoubleQuotedString:XRegExp('"([^\\\\"]|\\\\.)*"','gs'),multiLineSingleQuotedString:XRegExp("'([^\\\\']|\\\\.)*'",'gs'),xmlComments:XRegExp('(<|<)!--.*?--(>|>)','gs'),url:/\w+:\/\/[\w-.\/?%&=:@;#]*/g,phpScriptTags:{left:/(<|<)\?(?:=|php)?/g,right:/\?(>|>)/g,'eof':true},aspScriptTags:{left:/(<|<)%=?/g,right:/%(>|>)/g},scriptScriptTags:{left:/(<|<)\s*script.*?(>|>)/gi,right:/(<|<)\/\s*script\s*(>|>)/gi}},toolbar:{getHtml:function(highlighter) +{var html='
    ',items=sh.toolbar.items,list=items.list;function defaultGetHtml(highlighter,name) +{return sh.toolbar.getButtonHtml(highlighter,name,sh.config.strings[name]);} +for(var i=0,l=list.length;i'+escapeHtml(label)+'';},handler:function(e) +{var target=e.target,className=target.className||'';function getValue(name) +{var r=new RegExp(name+'_(\\w+)'),match=r.exec(className);return match?match[1]:null;} +var highlighter=getHighlighterById(findParentElement(target,'.syntaxhighlighter').id),commandName=getValue('command');if(highlighter&&commandName) +sh.toolbar.items[commandName].execute(highlighter);e.preventDefault();},items:{list:['expandSource','help'],expandSource:{getHtml:function(highlighter) +{if(highlighter.getParam('collapse')!=true) +return'';var title=highlighter.getParam('title');return sh.toolbar.getButtonHtml(highlighter,'expandSource',title?title:sh.config.strings.expandSource);},execute:function(highlighter) +{var div=getHighlighterDivById(highlighter.id);removeClass(div,'collapsed');}},help:{execute:function(highlighter) +{var wnd=popup('','_blank',500,250,'scrollbars=0'),doc=wnd.document;doc.write(sh.config.strings.aboutDialog);doc.close();wnd.focus();}}}},findElements:function(globalParams,element) +{var elements=element?[element]:toArray(document.getElementsByTagName(sh.config.tagName)),conf=sh.config,result=[];if(conf.useScriptTags) +elements=elements.concat(getSyntaxHighlighterScriptTags());if(elements.length===0) +return result;for(var i=0,l=elements.length;i(.*?))\\]$"),pos=0,regex=XRegExp("(?[\\w-]+)"+"\\s*:\\s*"+"(?"+"[\\w%#-]+|"+"\\[.*?\\]|"+'".*?"|'+"'.*?'"+")\\s*;?","g");while((match=XRegExp.exec(str,regex,pos))!=null) +{var value=match.value.replace(/^['"]|['"]$/g,'');if(value!=null&&arrayRegex.test(value)) +{var m=XRegExp.exec(value,arrayRegex);value=m.values.length>0?m.values.split(/\s*,\s*/):[];} +result[match.name]=value;pos=match.index+match[0].length;} +return result;};function wrapLinesWithCode(str,css) +{if(str==null||str.length==0||str=='\n') +return str;str=str.replace(/'+line+'';});return str;};function padNumber(number,length) +{var result=number.toString();while(result.length|<br\s*\/?>/gi;if(sh.config.bloggerMode==true) +str=str.replace(br,'\n');if(sh.config.stripBrs==true) +str=str.replace(br,'');return str;};function trim(str) +{return str.replace(/^\s+|\s+$/g,'');};function unindent(str) +{var lines=splitLines(fixInputString(str)),indents=new Array(),regex=/^\s*/,min=1000;for(var i=0,l=lines.length;i0;i++) +{var line=lines[i];if(trim(line).length==0) +continue;var matches=regex.exec(line);if(matches==null) +return str;min=Math.min(matches[0].length,min);} +if(min>0) +for(var i=0,l=lines.length;im2.index) +return 1;else +{if(m1.lengthm2.length) +return 1;} +return 0;};function getMatches(code,regexInfo) +{function defaultAdd(match,regexInfo) +{return match[0];};var index=0,match=null,matches=[],func=regexInfo.func?regexInfo.func:defaultAdd +pos=0;while((match=XRegExp.exec(code,regexInfo.regex,pos))!=null) +{var resultMatch=func(match,regexInfo);if(typeof(resultMatch)=='string') +resultMatch=[new sh.Match(resultMatch,match.index,regexInfo.css)];matches=matches.concat(resultMatch);pos=match.index+match[0].length;} +return matches;};function processUrls(code) +{var gt=/(.*)((>|<).*)/;return code.replace(sh.regexLib.url,function(m) +{var suffix='',match=null;if(match=gt.exec(m)) +{m=match[1];suffix=match[2];} +return''+m+''+suffix;});};function getSyntaxHighlighterScriptTags() +{var tags=document.getElementsByTagName('script'),result=[];for(var i=0,l=tags.length;iitemIEndPos) +break;else if(itemJ.index==itemI.index&&itemJ.length>itemI.length) +matches[i]=null;else if(itemJ.index>=itemI.index&&itemJ.index'+code+'
    ';},getLineNumbersHtml:function(code,lineNumbers) +{var html='',count=splitLines(code).length,firstLine=parseInt(this.getParam('first-line')),pad=this.getParam('pad-line-numbers');if(pad==true) +pad=(firstLine+count-1).toString().length;else if(isNaN(pad)==true) +pad=0;for(var i=0;i'+spaces+'':'')+line);} +return html;},getTitleHtml:function(title) +{return title?''+escapeHtml(title)+'':'';},getMatchesHtml:function(code,matches) +{var pos=0,result='',brushName=this.getParam('brush','');function getBrushNameCss(match) +{var result=match?(match.brushName||brushName):brushName;return result?result+' ':'';};for(var i=0,l=matches.length;i' ++(this.getParam('toolbar')?sh.toolbar.getHtml(this):'') ++'' ++this.getTitleHtml(this.getParam('title')) ++'' ++'' ++(gutter?'':'') ++'' ++'' ++'' ++'
    '+this.getLineNumbersHtml(code)+'' ++'
    ' ++html ++'
    ' ++'
    ' ++'';return html;},getDiv:function(code) +{if(code===null) +code='';this.code=code;var div=this.create('div');div.innerHTML=this.getHtml(code);if(this.getParam('toolbar')) +attachEvent(findElement(div,'.toolbar'),'click',sh.toolbar.handler);if(this.getParam('quick-code')) +attachEvent(findElement(div,'.code'),'dblclick',quickCodeHandler);return div;},init:function(params) +{this.id=guid();storeHighlighter(this);this.params=merge(sh.defaults,params||{}) +if(this.getParam('light')==true) +this.params.toolbar=this.params.gutter=false;},getKeywords:function(str) +{str=str.replace(/^\s+|\s+$/g,'').replace(/\s+/g,'|');return'\\b(?:'+str+')\\b';},forHtmlScript:function(regexGroup) +{var regex={'end':regexGroup.right.source};if(regexGroup.eof) +regex.end="(?:(?:"+regex.end+")|$)";this.htmlScript={left:{regex:regexGroup.left,css:'script'},right:{regex:regexGroup.right,css:'script'},code:XRegExp("(?"+regexGroup.left.source+")"+"(?.*?)"+"(?"+regex.end+")","sgi")};}};return sh;}();typeof(exports)!='undefined'?exports.SyntaxHighlighter=SyntaxHighlighter:null;(function(){var sh=SyntaxHighlighter;sh.autoloader=function() +{var list=arguments,elements=sh.findElements(),brushes={},scripts={},all=SyntaxHighlighter.all,allCalled=false,allParams=null,i;SyntaxHighlighter.all=function(params) +{allParams=params;allCalled=true;};function addBrush(aliases,url) +{for(var i=0;i