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:'AboutSyntaxHighlighterSyntaxHighlighterversion3.0.9(Thu,04Dec201412:32:21GMT)
http://alexgorbatchev.com/SyntaxHighlighter JavaScriptcodesyntaxhighlighter.
Copyright2004-2013AlexGorbatchev.
Ifyoulikethisscript,please
donateto
keepdevelopmentactive!