shCore.js 156KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656
  1. // XRegExp 1.5.1
  2. // (c) 2007-2012 Steven Levithan
  3. // MIT License
  4. // <http://xregexp.com>
  5. // Provides an augmented, extensible, cross-browser implementation of regular expressions,
  6. // including support for additional syntax, flags, and methods
  7. var XRegExp;
  8. if (XRegExp) {
  9. // Avoid running twice, since that would break references to native globals
  10. throw Error("can't load XRegExp twice in the same frame");
  11. }
  12. // Run within an anonymous function to protect variables and avoid new globals
  13. (function (undefined) {
  14. //---------------------------------
  15. // Constructor
  16. //---------------------------------
  17. // Accepts a pattern and flags; returns a new, extended `RegExp` object. Differs from a native
  18. // regular expression in that additional syntax and flags are supported and cross-browser
  19. // syntax inconsistencies are ameliorated. `XRegExp(/regex/)` clones an existing regex and
  20. // converts to type XRegExp
  21. XRegExp = function (pattern, flags) {
  22. var output = [],
  23. currScope = XRegExp.OUTSIDE_CLASS,
  24. pos = 0,
  25. context, tokenResult, match, chr, regex;
  26. if (XRegExp.isRegExp(pattern)) {
  27. if (flags !== undefined)
  28. throw TypeError("can't supply flags when constructing one RegExp from another");
  29. return clone(pattern);
  30. }
  31. // Tokens become part of the regex construction process, so protect against infinite
  32. // recursion when an XRegExp is constructed within a token handler or trigger
  33. if (isInsideConstructor)
  34. throw Error("can't call the XRegExp constructor within token definition functions");
  35. flags = flags || "";
  36. context = { // `this` object for custom tokens
  37. hasNamedCapture: false,
  38. captureNames: [],
  39. hasFlag: function (flag) {return flags.indexOf(flag) > -1;},
  40. setFlag: function (flag) {flags += flag;}
  41. };
  42. while (pos < pattern.length) {
  43. // Check for custom tokens at the current position
  44. tokenResult = runTokens(pattern, pos, currScope, context);
  45. if (tokenResult) {
  46. output.push(tokenResult.output);
  47. pos += (tokenResult.match[0].length || 1);
  48. } else {
  49. // Check for native multicharacter metasequences (excluding character classes) at
  50. // the current position
  51. if (match = nativ.exec.call(nativeTokens[currScope], pattern.slice(pos))) {
  52. output.push(match[0]);
  53. pos += match[0].length;
  54. } else {
  55. chr = pattern.charAt(pos);
  56. if (chr === "[")
  57. currScope = XRegExp.INSIDE_CLASS;
  58. else if (chr === "]")
  59. currScope = XRegExp.OUTSIDE_CLASS;
  60. // Advance position one character
  61. output.push(chr);
  62. pos++;
  63. }
  64. }
  65. }
  66. regex = RegExp(output.join(""), nativ.replace.call(flags, flagClip, ""));
  67. regex._xregexp = {
  68. source: pattern,
  69. captureNames: context.hasNamedCapture ? context.captureNames : null
  70. };
  71. return regex;
  72. };
  73. //---------------------------------
  74. // Public properties
  75. //---------------------------------
  76. XRegExp.version = "1.5.1";
  77. // Token scope bitflags
  78. XRegExp.INSIDE_CLASS = 1;
  79. XRegExp.OUTSIDE_CLASS = 2;
  80. //---------------------------------
  81. // Private variables
  82. //---------------------------------
  83. var replacementToken = /\$(?:(\d\d?|[$&`'])|{([$\w]+)})/g,
  84. flagClip = /[^gimy]+|([\s\S])(?=[\s\S]*\1)/g, // Nonnative and duplicate flags
  85. quantifier = /^(?:[?*+]|{\d+(?:,\d*)?})\??/,
  86. isInsideConstructor = false,
  87. tokens = [],
  88. // Copy native globals for reference ("native" is an ES3 reserved keyword)
  89. nativ = {
  90. exec: RegExp.prototype.exec,
  91. test: RegExp.prototype.test,
  92. match: String.prototype.match,
  93. replace: String.prototype.replace,
  94. split: String.prototype.split
  95. },
  96. compliantExecNpcg = nativ.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
  97. compliantLastIndexIncrement = function () {
  98. var x = /^/g;
  99. nativ.test.call(x, "");
  100. return !x.lastIndex;
  101. }(),
  102. hasNativeY = RegExp.prototype.sticky !== undefined,
  103. nativeTokens = {};
  104. // `nativeTokens` match native multicharacter metasequences only (including deprecated octals,
  105. // excluding character classes)
  106. nativeTokens[XRegExp.INSIDE_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]))/;
  107. nativeTokens[XRegExp.OUTSIDE_CLASS] = /^(?:\\(?: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*)?}\??)/;
  108. //---------------------------------
  109. // Public methods
  110. //---------------------------------
  111. // Lets you extend or change XRegExp syntax and create custom flags. This is used internally by
  112. // the XRegExp library and can be used to create XRegExp plugins. This function is intended for
  113. // users with advanced knowledge of JavaScript's regular expression syntax and behavior. It can
  114. // be disabled by `XRegExp.freezeTokens`
  115. XRegExp.addToken = function (regex, handler, scope, trigger) {
  116. tokens.push({
  117. pattern: clone(regex, "g" + (hasNativeY ? "y" : "")),
  118. handler: handler,
  119. scope: scope || XRegExp.OUTSIDE_CLASS,
  120. trigger: trigger || null
  121. });
  122. };
  123. // Accepts a pattern and flags; returns an extended `RegExp` object. If the pattern and flag
  124. // combination has previously been cached, the cached copy is returned; otherwise the newly
  125. // created regex is cached
  126. XRegExp.cache = function (pattern, flags) {
  127. var key = pattern + "/" + (flags || "");
  128. return XRegExp.cache[key] || (XRegExp.cache[key] = XRegExp(pattern, flags));
  129. };
  130. // Accepts a `RegExp` instance; returns a copy with the `/g` flag set. The copy has a fresh
  131. // `lastIndex` (set to zero). If you want to copy a regex without forcing the `global`
  132. // property, use `XRegExp(regex)`. Do not use `RegExp(regex)` because it will not preserve
  133. // special properties required for named capture
  134. XRegExp.copyAsGlobal = function (regex) {
  135. return clone(regex, "g");
  136. };
  137. // Accepts a string; returns the string with regex metacharacters escaped. The returned string
  138. // can safely be used at any point within a regex to match the provided literal string. Escaped
  139. // characters are [ ] { } ( ) * + ? - . , \ ^ $ | # and whitespace
  140. XRegExp.escape = function (str) {
  141. return str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  142. };
  143. // Accepts a string to search, regex to search with, position to start the search within the
  144. // string (default: 0), and an optional Boolean indicating whether matches must start at-or-
  145. // after the position or at the specified position only. This function ignores the `lastIndex`
  146. // of the provided regex in its own handling, but updates the property for compatibility
  147. XRegExp.execAt = function (str, regex, pos, anchored) {
  148. var r2 = clone(regex, "g" + ((anchored && hasNativeY) ? "y" : "")),
  149. match;
  150. r2.lastIndex = pos = pos || 0;
  151. match = r2.exec(str); // Run the altered `exec` (required for `lastIndex` fix, etc.)
  152. if (anchored && match && match.index !== pos)
  153. match = null;
  154. if (regex.global)
  155. regex.lastIndex = match ? r2.lastIndex : 0;
  156. return match;
  157. };
  158. // Breaks the unrestorable link to XRegExp's private list of tokens, thereby preventing
  159. // syntax and flag changes. Should be run after XRegExp and any plugins are loaded
  160. XRegExp.freezeTokens = function () {
  161. XRegExp.addToken = function () {
  162. throw Error("can't run addToken after freezeTokens");
  163. };
  164. };
  165. // Accepts any value; returns a Boolean indicating whether the argument is a `RegExp` object.
  166. // Note that this is also `true` for regex literals and regexes created by the `XRegExp`
  167. // constructor. This works correctly for variables created in another frame, when `instanceof`
  168. // and `constructor` checks would fail to work as intended
  169. XRegExp.isRegExp = function (o) {
  170. return Object.prototype.toString.call(o) === "[object RegExp]";
  171. };
  172. // Executes `callback` once per match within `str`. Provides a simpler and cleaner way to
  173. // iterate over regex matches compared to the traditional approaches of subverting
  174. // `String.prototype.replace` or repeatedly calling `exec` within a `while` loop
  175. XRegExp.iterate = function (str, regex, callback, context) {
  176. var r2 = clone(regex, "g"),
  177. i = -1, match;
  178. while (match = r2.exec(str)) { // Run the altered `exec` (required for `lastIndex` fix, etc.)
  179. if (regex.global)
  180. regex.lastIndex = r2.lastIndex; // Doing this to follow expectations if `lastIndex` is checked within `callback`
  181. callback.call(context, match, ++i, str, regex);
  182. if (r2.lastIndex === match.index)
  183. r2.lastIndex++;
  184. }
  185. if (regex.global)
  186. regex.lastIndex = 0;
  187. };
  188. // Accepts a string and an array of regexes; returns the result of using each successive regex
  189. // to search within the matches of the previous regex. The array of regexes can also contain
  190. // objects with `regex` and `backref` properties, in which case the named or numbered back-
  191. // references specified are passed forward to the next regex or returned. E.g.:
  192. // var xregexpImgFileNames = XRegExp.matchChain(html, [
  193. // {regex: /<img\b([^>]+)>/i, backref: 1}, // <img> tag attributes
  194. // {regex: XRegExp('(?ix) \\s src=" (?<src> [^"]+ )'), backref: "src"}, // src attribute values
  195. // {regex: XRegExp("^http://xregexp\\.com(/[^#?]+)", "i"), backref: 1}, // xregexp.com paths
  196. // /[^\/]+$/ // filenames (strip directory paths)
  197. // ]);
  198. XRegExp.matchChain = function (str, chain) {
  199. return function recurseChain (values, level) {
  200. var item = chain[level].regex ? chain[level] : {regex: chain[level]},
  201. regex = clone(item.regex, "g"),
  202. matches = [], i;
  203. for (i = 0; i < values.length; i++) {
  204. XRegExp.iterate(values[i], regex, function (match) {
  205. matches.push(item.backref ? (match[item.backref] || "") : match[0]);
  206. });
  207. }
  208. return ((level === chain.length - 1) || !matches.length) ?
  209. matches : recurseChain(matches, level + 1);
  210. }([str], 0);
  211. };
  212. //---------------------------------
  213. // New RegExp prototype methods
  214. //---------------------------------
  215. // Accepts a context object and arguments array; returns the result of calling `exec` with the
  216. // first value in the arguments array. the context is ignored but is accepted for congruity
  217. // with `Function.prototype.apply`
  218. RegExp.prototype.apply = function (context, args) {
  219. return this.exec(args[0]);
  220. };
  221. // Accepts a context object and string; returns the result of calling `exec` with the provided
  222. // string. the context is ignored but is accepted for congruity with `Function.prototype.call`
  223. RegExp.prototype.call = function (context, str) {
  224. return this.exec(str);
  225. };
  226. //---------------------------------
  227. // Overriden native methods
  228. //---------------------------------
  229. // Adds named capture support (with backreferences returned as `result.name`), and fixes two
  230. // cross-browser issues per ES3:
  231. // - Captured values for nonparticipating capturing groups should be returned as `undefined`,
  232. // rather than the empty string.
  233. // - `lastIndex` should not be incremented after zero-length matches.
  234. RegExp.prototype.exec = function (str) {
  235. var match, name, r2, origLastIndex;
  236. if (!this.global)
  237. origLastIndex = this.lastIndex;
  238. match = nativ.exec.apply(this, arguments);
  239. if (match) {
  240. // Fix browsers whose `exec` methods don't consistently return `undefined` for
  241. // nonparticipating capturing groups
  242. if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
  243. r2 = RegExp(this.source, nativ.replace.call(getNativeFlags(this), "g", ""));
  244. // Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed
  245. // matching due to characters outside the match
  246. nativ.replace.call((str + "").slice(match.index), r2, function () {
  247. for (var i = 1; i < arguments.length - 2; i++) {
  248. if (arguments[i] === undefined)
  249. match[i] = undefined;
  250. }
  251. });
  252. }
  253. // Attach named capture properties
  254. if (this._xregexp && this._xregexp.captureNames) {
  255. for (var i = 1; i < match.length; i++) {
  256. name = this._xregexp.captureNames[i - 1];
  257. if (name)
  258. match[name] = match[i];
  259. }
  260. }
  261. // Fix browsers that increment `lastIndex` after zero-length matches
  262. if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
  263. this.lastIndex--;
  264. }
  265. if (!this.global)
  266. this.lastIndex = origLastIndex; // Fix IE, Opera bug (last tested IE 9.0.5, Opera 11.61 on Windows)
  267. return match;
  268. };
  269. // Fix browser bugs in native method
  270. RegExp.prototype.test = function (str) {
  271. // Use the native `exec` to skip some processing overhead, even though the altered
  272. // `exec` would take care of the `lastIndex` fixes
  273. var match, origLastIndex;
  274. if (!this.global)
  275. origLastIndex = this.lastIndex;
  276. match = nativ.exec.call(this, str);
  277. // Fix browsers that increment `lastIndex` after zero-length matches
  278. if (match && !compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
  279. this.lastIndex--;
  280. if (!this.global)
  281. this.lastIndex = origLastIndex; // Fix IE, Opera bug (last tested IE 9.0.5, Opera 11.61 on Windows)
  282. return !!match;
  283. };
  284. // Adds named capture support and fixes browser bugs in native method
  285. String.prototype.match = function (regex) {
  286. if (!XRegExp.isRegExp(regex))
  287. regex = RegExp(regex); // Native `RegExp`
  288. if (regex.global) {
  289. var result = nativ.match.apply(this, arguments);
  290. regex.lastIndex = 0; // Fix IE bug
  291. return result;
  292. }
  293. return regex.exec(this); // Run the altered `exec`
  294. };
  295. // Adds support for `${n}` tokens for named and numbered backreferences in replacement text,
  296. // and provides named backreferences to replacement functions as `arguments[0].name`. Also
  297. // fixes cross-browser differences in replacement text syntax when performing a replacement
  298. // using a nonregex search value, and the value of replacement regexes' `lastIndex` property
  299. // during replacement iterations. Note that this doesn't support SpiderMonkey's proprietary
  300. // third (`flags`) parameter
  301. String.prototype.replace = function (search, replacement) {
  302. var isRegex = XRegExp.isRegExp(search),
  303. captureNames, result, str, origLastIndex;
  304. // There are too many combinations of search/replacement types/values and browser bugs that
  305. // preclude passing to native `replace`, so don't try
  306. //if (...)
  307. // return nativ.replace.apply(this, arguments);
  308. if (isRegex) {
  309. if (search._xregexp)
  310. captureNames = search._xregexp.captureNames; // Array or `null`
  311. if (!search.global)
  312. origLastIndex = search.lastIndex;
  313. } else {
  314. search = search + ""; // Type conversion
  315. }
  316. if (Object.prototype.toString.call(replacement) === "[object Function]") {
  317. result = nativ.replace.call(this + "", search, function () {
  318. if (captureNames) {
  319. // Change the `arguments[0]` string primitive to a String object which can store properties
  320. arguments[0] = new String(arguments[0]);
  321. // Store named backreferences on `arguments[0]`
  322. for (var i = 0; i < captureNames.length; i++) {
  323. if (captureNames[i])
  324. arguments[0][captureNames[i]] = arguments[i + 1];
  325. }
  326. }
  327. // Update `lastIndex` before calling `replacement` (fix browsers)
  328. if (isRegex && search.global)
  329. search.lastIndex = arguments[arguments.length - 2] + arguments[0].length;
  330. return replacement.apply(null, arguments);
  331. });
  332. } else {
  333. str = this + ""; // Type conversion, so `args[args.length - 1]` will be a string (given nonstring `this`)
  334. result = nativ.replace.call(str, search, function () {
  335. var args = arguments; // Keep this function's `arguments` available through closure
  336. return nativ.replace.call(replacement + "", replacementToken, function ($0, $1, $2) {
  337. // Numbered backreference (without delimiters) or special variable
  338. if ($1) {
  339. switch ($1) {
  340. case "$": return "$";
  341. case "&": return args[0];
  342. case "`": return args[args.length - 1].slice(0, args[args.length - 2]);
  343. case "'": return args[args.length - 1].slice(args[args.length - 2] + args[0].length);
  344. // Numbered backreference
  345. default:
  346. // What does "$10" mean?
  347. // - Backreference 10, if 10 or more capturing groups exist
  348. // - Backreference 1 followed by "0", if 1-9 capturing groups exist
  349. // - Otherwise, it's the string "$10"
  350. // Also note:
  351. // - Backreferences cannot be more than two digits (enforced by `replacementToken`)
  352. // - "$01" is equivalent to "$1" if a capturing group exists, otherwise it's the string "$01"
  353. // - There is no "$0" token ("$&" is the entire match)
  354. var literalNumbers = "";
  355. $1 = +$1; // Type conversion; drop leading zero
  356. if (!$1) // `$1` was "0" or "00"
  357. return $0;
  358. while ($1 > args.length - 3) {
  359. literalNumbers = String.prototype.slice.call($1, -1) + literalNumbers;
  360. $1 = Math.floor($1 / 10); // Drop the last digit
  361. }
  362. return ($1 ? args[$1] || "" : "$") + literalNumbers;
  363. }
  364. // Named backreference or delimited numbered backreference
  365. } else {
  366. // What does "${n}" mean?
  367. // - Backreference to numbered capture n. Two differences from "$n":
  368. // - n can be more than two digits
  369. // - Backreference 0 is allowed, and is the entire match
  370. // - Backreference to named capture n, if it exists and is not a number overridden by numbered capture
  371. // - Otherwise, it's the string "${n}"
  372. var n = +$2; // Type conversion; drop leading zeros
  373. if (n <= args.length - 3)
  374. return args[n];
  375. n = captureNames ? indexOf(captureNames, $2) : -1;
  376. return n > -1 ? args[n + 1] : $0;
  377. }
  378. });
  379. });
  380. }
  381. if (isRegex) {
  382. if (search.global)
  383. search.lastIndex = 0; // Fix IE, Safari bug (last tested IE 9.0.5, Safari 5.1.2 on Windows)
  384. else
  385. search.lastIndex = origLastIndex; // Fix IE, Opera bug (last tested IE 9.0.5, Opera 11.61 on Windows)
  386. }
  387. return result;
  388. };
  389. // A consistent cross-browser, ES3 compliant `split`
  390. String.prototype.split = function (s /* separator */, limit) {
  391. // If separator `s` is not a regex, use the native `split`
  392. if (!XRegExp.isRegExp(s))
  393. return nativ.split.apply(this, arguments);
  394. var str = this + "", // Type conversion
  395. output = [],
  396. lastLastIndex = 0,
  397. match, lastLength;
  398. // Behavior for `limit`: if it's...
  399. // - `undefined`: No limit
  400. // - `NaN` or zero: Return an empty array
  401. // - A positive number: Use `Math.floor(limit)`
  402. // - A negative number: No limit
  403. // - Other: Type-convert, then use the above rules
  404. if (limit === undefined || +limit < 0) {
  405. limit = Infinity;
  406. } else {
  407. limit = Math.floor(+limit);
  408. if (!limit)
  409. return [];
  410. }
  411. // This is required if not `s.global`, and it avoids needing to set `s.lastIndex` to zero
  412. // and restore it to its original value when we're done using the regex
  413. s = XRegExp.copyAsGlobal(s);
  414. while (match = s.exec(str)) { // Run the altered `exec` (required for `lastIndex` fix, etc.)
  415. if (s.lastIndex > lastLastIndex) {
  416. output.push(str.slice(lastLastIndex, match.index));
  417. if (match.length > 1 && match.index < str.length)
  418. Array.prototype.push.apply(output, match.slice(1));
  419. lastLength = match[0].length;
  420. lastLastIndex = s.lastIndex;
  421. if (output.length >= limit)
  422. break;
  423. }
  424. if (s.lastIndex === match.index)
  425. s.lastIndex++;
  426. }
  427. if (lastLastIndex === str.length) {
  428. if (!nativ.test.call(s, "") || lastLength)
  429. output.push("");
  430. } else {
  431. output.push(str.slice(lastLastIndex));
  432. }
  433. return output.length > limit ? output.slice(0, limit) : output;
  434. };
  435. //---------------------------------
  436. // Private helper functions
  437. //---------------------------------
  438. // Supporting function for `XRegExp`, `XRegExp.copyAsGlobal`, etc. Returns a copy of a `RegExp`
  439. // instance with a fresh `lastIndex` (set to zero), preserving properties required for named
  440. // capture. Also allows adding new flags in the process of copying the regex
  441. function clone (regex, additionalFlags) {
  442. if (!XRegExp.isRegExp(regex))
  443. throw TypeError("type RegExp expected");
  444. var x = regex._xregexp;
  445. regex = XRegExp(regex.source, getNativeFlags(regex) + (additionalFlags || ""));
  446. if (x) {
  447. regex._xregexp = {
  448. source: x.source,
  449. captureNames: x.captureNames ? x.captureNames.slice(0) : null
  450. };
  451. }
  452. return regex;
  453. }
  454. function getNativeFlags (regex) {
  455. return (regex.global ? "g" : "") +
  456. (regex.ignoreCase ? "i" : "") +
  457. (regex.multiline ? "m" : "") +
  458. (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
  459. (regex.sticky ? "y" : "");
  460. }
  461. function runTokens (pattern, index, scope, context) {
  462. var i = tokens.length,
  463. result, match, t;
  464. // Protect against constructing XRegExps within token handler and trigger functions
  465. isInsideConstructor = true;
  466. // Must reset `isInsideConstructor`, even if a `trigger` or `handler` throws
  467. try {
  468. while (i--) { // Run in reverse order
  469. t = tokens[i];
  470. if ((scope & t.scope) && (!t.trigger || t.trigger.call(context))) {
  471. t.pattern.lastIndex = index;
  472. match = t.pattern.exec(pattern); // Running the altered `exec` here allows use of named backreferences, etc.
  473. if (match && match.index === index) {
  474. result = {
  475. output: t.handler.call(context, match, scope),
  476. match: match
  477. };
  478. break;
  479. }
  480. }
  481. }
  482. } catch (err) {
  483. throw err;
  484. } finally {
  485. isInsideConstructor = false;
  486. }
  487. return result;
  488. }
  489. function indexOf (array, item, from) {
  490. if (Array.prototype.indexOf) // Use the native array method if available
  491. return array.indexOf(item, from);
  492. for (var i = from || 0; i < array.length; i++) {
  493. if (array[i] === item)
  494. return i;
  495. }
  496. return -1;
  497. }
  498. //---------------------------------
  499. // Built-in tokens
  500. //---------------------------------
  501. // Augment XRegExp's regular expression syntax and flags. Note that when adding tokens, the
  502. // third (`scope`) argument defaults to `XRegExp.OUTSIDE_CLASS`
  503. // Comment pattern: (?# )
  504. XRegExp.addToken(
  505. /\(\?#[^)]*\)/,
  506. function (match) {
  507. // Keep tokens separated unless the following token is a quantifier
  508. return nativ.test.call(quantifier, match.input.slice(match.index + match[0].length)) ? "" : "(?:)";
  509. }
  510. );
  511. // Capturing group (match the opening parenthesis only).
  512. // Required for support of named capturing groups
  513. XRegExp.addToken(
  514. /\((?!\?)/,
  515. function () {
  516. this.captureNames.push(null);
  517. return "(";
  518. }
  519. );
  520. // Named capturing group (match the opening delimiter only): (?<name>
  521. XRegExp.addToken(
  522. /\(\?<([$\w]+)>/,
  523. function (match) {
  524. this.captureNames.push(match[1]);
  525. this.hasNamedCapture = true;
  526. return "(";
  527. }
  528. );
  529. // Named backreference: \k<name>
  530. XRegExp.addToken(
  531. /\\k<([\w$]+)>/,
  532. function (match) {
  533. var index = indexOf(this.captureNames, match[1]);
  534. // Keep backreferences separate from subsequent literal numbers. Preserve back-
  535. // references to named groups that are undefined at this point as literal strings
  536. return index > -1 ?
  537. "\\" + (index + 1) + (isNaN(match.input.charAt(match.index + match[0].length)) ? "" : "(?:)") :
  538. match[0];
  539. }
  540. );
  541. // Empty character class: [] or [^]
  542. XRegExp.addToken(
  543. /\[\^?]/,
  544. function (match) {
  545. // For cross-browser compatibility with ES3, convert [] to \b\B and [^] to [\s\S].
  546. // (?!) should work like \b\B, but is unreliable in Firefox
  547. return match[0] === "[]" ? "\\b\\B" : "[\\s\\S]";
  548. }
  549. );
  550. // Mode modifier at the start of the pattern only, with any combination of flags imsx: (?imsx)
  551. // Does not support x(?i), (?-i), (?i-m), (?i: ), (?i)(?m), etc.
  552. XRegExp.addToken(
  553. /^\(\?([imsx]+)\)/,
  554. function (match) {
  555. this.setFlag(match[1]);
  556. return "";
  557. }
  558. );
  559. // Whitespace and comments, in free-spacing (aka extended) mode only
  560. XRegExp.addToken(
  561. /(?:\s+|#.*)+/,
  562. function (match) {
  563. // Keep tokens separated unless the following token is a quantifier
  564. return nativ.test.call(quantifier, match.input.slice(match.index + match[0].length)) ? "" : "(?:)";
  565. },
  566. XRegExp.OUTSIDE_CLASS,
  567. function () {return this.hasFlag("x");}
  568. );
  569. // Dot, in dotall (aka singleline) mode only
  570. XRegExp.addToken(
  571. /\./,
  572. function () {return "[\\s\\S]";},
  573. XRegExp.OUTSIDE_CLASS,
  574. function () {return this.hasFlag("s");}
  575. );
  576. //---------------------------------
  577. // Backward compatibility
  578. //---------------------------------
  579. // Uncomment the following block for compatibility with XRegExp 1.0-1.2:
  580. /*
  581. XRegExp.matchWithinChain = XRegExp.matchChain;
  582. RegExp.prototype.addFlags = function (s) {return clone(this, s);};
  583. RegExp.prototype.execAll = function (s) {var r = []; XRegExp.iterate(s, this, function (m) {r.push(m);}); return r;};
  584. RegExp.prototype.forEachExec = function (s, f, c) {return XRegExp.iterate(s, this, f, c);};
  585. RegExp.prototype.validate = function (s) {var r = RegExp("^(?:" + this.source + ")$(?!\\s)", getNativeFlags(this)); if (this.global) this.lastIndex = 0; return s.search(r) === 0;};
  586. */
  587. })();
  588. //
  589. // Begin anonymous function. This is used to contain local scope variables without polutting global scope.
  590. //
  591. if (typeof(SyntaxHighlighter) == 'undefined') var SyntaxHighlighter = function() {
  592. // CommonJS
  593. if (typeof(require) != 'undefined' && typeof(XRegExp) == 'undefined')
  594. {
  595. XRegExp = require('XRegExp').XRegExp;
  596. }
  597. // Shortcut object which will be assigned to the SyntaxHighlighter variable.
  598. // This is a shorthand for local reference in order to avoid long namespace
  599. // references to SyntaxHighlighter.whatever...
  600. var sh = {
  601. defaults : {
  602. /** Additional CSS class names to be added to highlighter elements. */
  603. 'class-name' : '',
  604. /** First line number. */
  605. 'first-line' : 1,
  606. /**
  607. * Pads line numbers. Possible values are:
  608. *
  609. * false - don't pad line numbers.
  610. * true - automaticaly pad numbers with minimum required number of leading zeroes.
  611. * [int] - length up to which pad line numbers.
  612. */
  613. 'pad-line-numbers' : false,
  614. /** Lines to highlight. */
  615. 'highlight' : false,
  616. /** Title to be displayed above the code block. */
  617. 'title' : null,
  618. /** Enables or disables smart tabs. */
  619. 'smart-tabs' : true,
  620. /** Gets or sets tab size. */
  621. 'tab-size' : 4,
  622. /** Enables or disables gutter. */
  623. 'gutter' : true,
  624. /** Enables or disables toolbar. */
  625. 'toolbar' : true,
  626. /** Enables quick code copy and paste from double click. */
  627. 'quick-code' : true,
  628. /** Forces code view to be collapsed. */
  629. 'collapse' : false,
  630. /** Enables or disables automatic links. */
  631. 'auto-links' : false,
  632. /** Gets or sets light mode. Equavalent to turning off gutter and toolbar. */
  633. 'light' : false,
  634. 'unindent' : true,
  635. 'html-script' : false
  636. },
  637. config : {
  638. space : '&nbsp;',
  639. /** Enables use of <SCRIPT type="syntaxhighlighter" /> tags. */
  640. useScriptTags : true,
  641. /** Blogger mode flag. */
  642. bloggerMode : false,
  643. stripBrs : false,
  644. /** Name of the tag that SyntaxHighlighter will automatically look for. */
  645. tagName : 'pre',
  646. strings : {
  647. expandSource : 'expand source',
  648. help : '?',
  649. alert: 'SyntaxHighlighter\n\n',
  650. noBrush : 'Can\'t find brush for: ',
  651. brushNotHtmlScript : 'Brush wasn\'t configured for html-script option: ',
  652. // this is populated by the build script
  653. aboutDialog : '@ABOUT@'
  654. }
  655. },
  656. /** Internal 'global' variables. */
  657. vars : {
  658. discoveredBrushes : null,
  659. highlighters : {}
  660. },
  661. /** This object is populated by user included external brush files. */
  662. brushes : {},
  663. /** Common regular expressions. */
  664. regexLib : {
  665. multiLineCComments : /\/\*[\s\S]*?\*\//gm,
  666. singleLineCComments : /\/\/.*$/gm,
  667. singleLinePerlComments : /#.*$/gm,
  668. doubleQuotedString : /"([^\\"\n]|\\.)*"/g,
  669. singleQuotedString : /'([^\\'\n]|\\.)*'/g,
  670. multiLineDoubleQuotedString : new XRegExp('"([^\\\\"]|\\\\.)*"', 'gs'),
  671. multiLineSingleQuotedString : new XRegExp("'([^\\\\']|\\\\.)*'", 'gs'),
  672. xmlComments : /(&lt;|<)!--[\s\S]*?--(&gt;|>)/gm,
  673. url : /\w+:\/\/[\w-.\/?%&=:@;#]*/g,
  674. /** <?= ?> tags. */
  675. phpScriptTags : { left: /(&lt;|<)\?(?:=|php)?/g, right: /\?(&gt;|>)/g, 'eof' : true },
  676. /** <%= %> tags. */
  677. aspScriptTags : { left: /(&lt;|<)%=?/g, right: /%(&gt;|>)/g },
  678. /** <script> tags. */
  679. scriptScriptTags : { left: /(&lt;|<)\s*script.*?(&gt;|>)/gi, right: /(&lt;|<)\/\s*script\s*(&gt;|>)/gi }
  680. },
  681. toolbar: {
  682. /**
  683. * Generates HTML markup for the toolbar.
  684. * @param {Highlighter} highlighter Highlighter instance.
  685. * @return {String} Returns HTML markup.
  686. */
  687. getHtml: function(highlighter)
  688. {
  689. var html = '<div class="toolbar">',
  690. items = sh.toolbar.items,
  691. list = items.list
  692. ;
  693. function defaultGetHtml(highlighter, name)
  694. {
  695. return sh.toolbar.getButtonHtml(highlighter, name, sh.config.strings[name]);
  696. };
  697. for (var i = 0; i < list.length; i++)
  698. html += (items[list[i]].getHtml || defaultGetHtml)(highlighter, list[i]);
  699. html += '</div>';
  700. return html;
  701. },
  702. /**
  703. * Generates HTML markup for a regular button in the toolbar.
  704. * @param {Highlighter} highlighter Highlighter instance.
  705. * @param {String} commandName Command name that would be executed.
  706. * @param {String} label Label text to display.
  707. * @return {String} Returns HTML markup.
  708. */
  709. getButtonHtml: function(highlighter, commandName, label)
  710. {
  711. return '<span><a href="#" class="toolbar_item'
  712. + ' command_' + commandName
  713. + ' ' + commandName
  714. + '">' + label + '</a></span>'
  715. ;
  716. },
  717. /**
  718. * Event handler for a toolbar anchor.
  719. */
  720. handler: function(e)
  721. {
  722. var target = e.target,
  723. className = target.className || ''
  724. ;
  725. function getValue(name)
  726. {
  727. var r = new RegExp(name + '_(\\w+)'),
  728. match = r.exec(className)
  729. ;
  730. return match ? match[1] : null;
  731. };
  732. var highlighter = getHighlighterById(findParentElement(target, '.syntaxhighlighter').id),
  733. commandName = getValue('command')
  734. ;
  735. // execute the toolbar command
  736. if (highlighter && commandName)
  737. sh.toolbar.items[commandName].execute(highlighter);
  738. // disable default A click behaviour
  739. e.preventDefault();
  740. },
  741. /** Collection of toolbar items. */
  742. items : {
  743. // Ordered lis of items in the toolbar. Can't expect `for (var n in items)` to be consistent.
  744. list: ['expandSource', 'help'],
  745. expandSource: {
  746. getHtml: function(highlighter)
  747. {
  748. if (highlighter.getParam('collapse') != true)
  749. return '';
  750. var title = highlighter.getParam('title');
  751. return sh.toolbar.getButtonHtml(highlighter, 'expandSource', title ? title : sh.config.strings.expandSource);
  752. },
  753. execute: function(highlighter)
  754. {
  755. var div = getHighlighterDivById(highlighter.id);
  756. removeClass(div, 'collapsed');
  757. }
  758. },
  759. /** Command to display the about dialog window. */
  760. help: {
  761. execute: function(highlighter)
  762. {
  763. var wnd = popup('', '_blank', 500, 250, 'scrollbars=0'),
  764. doc = wnd.document
  765. ;
  766. doc.write(sh.config.strings.aboutDialog);
  767. doc.close();
  768. wnd.focus();
  769. }
  770. }
  771. }
  772. },
  773. /**
  774. * Finds all elements on the page which should be processes by SyntaxHighlighter.
  775. *
  776. * @param {Object} globalParams Optional parameters which override element's
  777. * parameters. Only used if element is specified.
  778. *
  779. * @param {Object} element Optional element to highlight. If none is
  780. * provided, all elements in the current document
  781. * are returned which qualify.
  782. *
  783. * @return {Array} Returns list of <code>{ target: DOMElement, params: Object }</code> objects.
  784. */
  785. findElements: function(globalParams, element)
  786. {
  787. var elements = element ? [element] : toArray(document.getElementsByTagName(sh.config.tagName)),
  788. conf = sh.config,
  789. result = []
  790. ;
  791. // support for <SCRIPT TYPE="syntaxhighlighter" /> feature
  792. if (conf.useScriptTags)
  793. elements = elements.concat(getSyntaxHighlighterScriptTags());
  794. if (elements.length === 0)
  795. return result;
  796. for (var i = 0; i < elements.length; i++)
  797. {
  798. var item = {
  799. target: elements[i],
  800. // local params take precedence over globals
  801. params: merge(globalParams, parseParams(elements[i].className))
  802. };
  803. if (item.params['brush'] == null)
  804. continue;
  805. result.push(item);
  806. }
  807. return result;
  808. },
  809. /**
  810. * Shorthand to highlight all elements on the page that are marked as
  811. * SyntaxHighlighter source code.
  812. *
  813. * @param {Object} globalParams Optional parameters which override element's
  814. * parameters. Only used if element is specified.
  815. *
  816. * @param {Object} element Optional element to highlight. If none is
  817. * provided, all elements in the current document
  818. * are highlighted.
  819. */
  820. highlight: function(globalParams, element)
  821. {
  822. var elements = this.findElements(globalParams, element),
  823. propertyName = 'innerHTML',
  824. highlighter = null,
  825. conf = sh.config
  826. ;
  827. if (elements.length === 0)
  828. return;
  829. for (var i = 0; i < elements.length; i++)
  830. {
  831. var element = elements[i],
  832. target = element.target,
  833. params = element.params,
  834. brushName = params.brush,
  835. code
  836. ;
  837. if (brushName == null)
  838. continue;
  839. // Instantiate a brush
  840. if (params['html-script'] == 'true' || sh.defaults['html-script'] == true)
  841. {
  842. highlighter = new sh.HtmlScript(brushName);
  843. brushName = 'htmlscript';
  844. }
  845. else
  846. {
  847. var brush = findBrush(brushName);
  848. if (brush)
  849. highlighter = new brush();
  850. else
  851. continue;
  852. }
  853. code = target[propertyName];
  854. // remove CDATA from <SCRIPT/> tags if it's present
  855. if (conf.useScriptTags)
  856. code = stripCData(code);
  857. // Inject title if the attribute is present
  858. if ((target.title || '') != '')
  859. params.title = target.title;
  860. params['brush'] = brushName;
  861. highlighter.init(params);
  862. element = highlighter.getDiv(code);
  863. // carry over ID
  864. if ((target.id || '') != '')
  865. element.id = target.id;
  866. //by zhanyi 去掉多余的外围div
  867. var tmp = element.firstChild.firstChild;
  868. tmp.className = element.firstChild.className;
  869. target.parentNode.replaceChild(tmp, target);
  870. }
  871. },
  872. /**
  873. * Main entry point for the SyntaxHighlighter.
  874. * @param {Object} params Optional params to apply to all highlighted elements.
  875. */
  876. all: function(params)
  877. {
  878. attachEvent(
  879. window,
  880. 'load',
  881. function() { sh.highlight(params); }
  882. );
  883. }
  884. }; // end of sh
  885. /**
  886. * Checks if target DOM elements has specified CSS class.
  887. * @param {DOMElement} target Target DOM element to check.
  888. * @param {String} className Name of the CSS class to check for.
  889. * @return {Boolean} Returns true if class name is present, false otherwise.
  890. */
  891. function hasClass(target, className)
  892. {
  893. return target.className.indexOf(className) != -1;
  894. };
  895. /**
  896. * Adds CSS class name to the target DOM element.
  897. * @param {DOMElement} target Target DOM element.
  898. * @param {String} className New CSS class to add.
  899. */
  900. function addClass(target, className)
  901. {
  902. if (!hasClass(target, className))
  903. target.className += ' ' + className;
  904. };
  905. /**
  906. * Removes CSS class name from the target DOM element.
  907. * @param {DOMElement} target Target DOM element.
  908. * @param {String} className CSS class to remove.
  909. */
  910. function removeClass(target, className)
  911. {
  912. target.className = target.className.replace(className, '');
  913. };
  914. /**
  915. * Converts the source to array object. Mostly used for function arguments and
  916. * lists returned by getElementsByTagName() which aren't Array objects.
  917. * @param {List} source Source list.
  918. * @return {Array} Returns array.
  919. */
  920. function toArray(source)
  921. {
  922. var result = [];
  923. for (var i = 0; i < source.length; i++)
  924. result.push(source[i]);
  925. return result;
  926. };
  927. /**
  928. * Splits block of text into lines.
  929. * @param {String} block Block of text.
  930. * @return {Array} Returns array of lines.
  931. */
  932. function splitLines(block)
  933. {
  934. return block.split(/\r?\n/);
  935. }
  936. /**
  937. * Generates HTML ID for the highlighter.
  938. * @param {String} highlighterId Highlighter ID.
  939. * @return {String} Returns HTML ID.
  940. */
  941. function getHighlighterId(id)
  942. {
  943. var prefix = 'highlighter_';
  944. return id.indexOf(prefix) == 0 ? id : prefix + id;
  945. };
  946. /**
  947. * Finds Highlighter instance by ID.
  948. * @param {String} highlighterId Highlighter ID.
  949. * @return {Highlighter} Returns instance of the highlighter.
  950. */
  951. function getHighlighterById(id)
  952. {
  953. return sh.vars.highlighters[getHighlighterId(id)];
  954. };
  955. /**
  956. * Finds highlighter's DIV container.
  957. * @param {String} highlighterId Highlighter ID.
  958. * @return {Element} Returns highlighter's DIV element.
  959. */
  960. function getHighlighterDivById(id)
  961. {
  962. return document.getElementById(getHighlighterId(id));
  963. };
  964. /**
  965. * Stores highlighter so that getHighlighterById() can do its thing. Each
  966. * highlighter must call this method to preserve itself.
  967. * @param {Highilghter} highlighter Highlighter instance.
  968. */
  969. function storeHighlighter(highlighter)
  970. {
  971. sh.vars.highlighters[getHighlighterId(highlighter.id)] = highlighter;
  972. };
  973. /**
  974. * Looks for a child or parent node which has specified classname.
  975. * Equivalent to jQuery's $(container).find(".className")
  976. * @param {Element} target Target element.
  977. * @param {String} search Class name or node name to look for.
  978. * @param {Boolean} reverse If set to true, will go up the node tree instead of down.
  979. * @return {Element} Returns found child or parent element on null.
  980. */
  981. function findElement(target, search, reverse /* optional */)
  982. {
  983. if (target == null)
  984. return null;
  985. var nodes = reverse != true ? target.childNodes : [ target.parentNode ],
  986. propertyToFind = { '#' : 'id', '.' : 'className' }[search.substr(0, 1)] || 'nodeName',
  987. expectedValue,
  988. found
  989. ;
  990. expectedValue = propertyToFind != 'nodeName'
  991. ? search.substr(1)
  992. : search.toUpperCase()
  993. ;
  994. // main return of the found node
  995. if ((target[propertyToFind] || '').indexOf(expectedValue) != -1)
  996. return target;
  997. for (var i = 0; nodes && i < nodes.length && found == null; i++)
  998. found = findElement(nodes[i], search, reverse);
  999. return found;
  1000. };
  1001. /**
  1002. * Looks for a parent node which has specified classname.
  1003. * This is an alias to <code>findElement(container, className, true)</code>.
  1004. * @param {Element} target Target element.
  1005. * @param {String} className Class name to look for.
  1006. * @return {Element} Returns found parent element on null.
  1007. */
  1008. function findParentElement(target, className)
  1009. {
  1010. return findElement(target, className, true);
  1011. };
  1012. /**
  1013. * Finds an index of element in the array.
  1014. * @ignore
  1015. * @param {Object} searchElement
  1016. * @param {Number} fromIndex
  1017. * @return {Number} Returns index of element if found; -1 otherwise.
  1018. */
  1019. function indexOf(array, searchElement, fromIndex)
  1020. {
  1021. fromIndex = Math.max(fromIndex || 0, 0);
  1022. for (var i = fromIndex; i < array.length; i++)
  1023. if(array[i] == searchElement)
  1024. return i;
  1025. return -1;
  1026. };
  1027. /**
  1028. * Generates a unique element ID.
  1029. */
  1030. function guid(prefix)
  1031. {
  1032. return (prefix || '') + Math.round(Math.random() * 1000000).toString();
  1033. };
  1034. /**
  1035. * Merges two objects. Values from obj2 override values in obj1.
  1036. * Function is NOT recursive and works only for one dimensional objects.
  1037. * @param {Object} obj1 First object.
  1038. * @param {Object} obj2 Second object.
  1039. * @return {Object} Returns combination of both objects.
  1040. */
  1041. function merge(obj1, obj2)
  1042. {
  1043. var result = {}, name;
  1044. for (name in obj1)
  1045. result[name] = obj1[name];
  1046. for (name in obj2)
  1047. result[name] = obj2[name];
  1048. return result;
  1049. };
  1050. /**
  1051. * Attempts to convert string to boolean.
  1052. * @param {String} value Input string.
  1053. * @return {Boolean} Returns true if input was "true", false if input was "false" and value otherwise.
  1054. */
  1055. function toBoolean(value)
  1056. {
  1057. var result = { "true" : true, "false" : false }[value];
  1058. return result == null ? value : result;
  1059. };
  1060. /**
  1061. * Opens up a centered popup window.
  1062. * @param {String} url URL to open in the window.
  1063. * @param {String} name Popup name.
  1064. * @param {int} width Popup width.
  1065. * @param {int} height Popup height.
  1066. * @param {String} options window.open() options.
  1067. * @return {Window} Returns window instance.
  1068. */
  1069. function popup(url, name, width, height, options)
  1070. {
  1071. var x = (screen.width - width) / 2,
  1072. y = (screen.height - height) / 2
  1073. ;
  1074. options += ', left=' + x +
  1075. ', top=' + y +
  1076. ', width=' + width +
  1077. ', height=' + height
  1078. ;
  1079. options = options.replace(/^,/, '');
  1080. var win = window.open(url, name, options);
  1081. win.focus();
  1082. return win;
  1083. };
  1084. /**
  1085. * Adds event handler to the target object.
  1086. * @param {Object} obj Target object.
  1087. * @param {String} type Name of the event.
  1088. * @param {Function} func Handling function.
  1089. */
  1090. function attachEvent(obj, type, func, scope)
  1091. {
  1092. function handler(e)
  1093. {
  1094. e = e || window.event;
  1095. if (!e.target)
  1096. {
  1097. e.target = e.srcElement;
  1098. e.preventDefault = function()
  1099. {
  1100. this.returnValue = false;
  1101. };
  1102. }
  1103. func.call(scope || window, e);
  1104. };
  1105. if (obj.attachEvent)
  1106. {
  1107. obj.attachEvent('on' + type, handler);
  1108. }
  1109. else
  1110. {
  1111. obj.addEventListener(type, handler, false);
  1112. }
  1113. };
  1114. /**
  1115. * Displays an alert.
  1116. * @param {String} str String to display.
  1117. */
  1118. function alert(str)
  1119. {
  1120. window.alert(sh.config.strings.alert + str);
  1121. };
  1122. /**
  1123. * Finds a brush by its alias.
  1124. *
  1125. * @param {String} alias Brush alias.
  1126. * @param {Boolean} showAlert Suppresses the alert if false.
  1127. * @return {Brush} Returns bursh constructor if found, null otherwise.
  1128. */
  1129. function findBrush(alias, showAlert)
  1130. {
  1131. var brushes = sh.vars.discoveredBrushes,
  1132. result = null
  1133. ;
  1134. if (brushes == null)
  1135. {
  1136. brushes = {};
  1137. // Find all brushes
  1138. for (var brush in sh.brushes)
  1139. {
  1140. var info = sh.brushes[brush],
  1141. aliases = info.aliases
  1142. ;
  1143. if (aliases == null)
  1144. continue;
  1145. // keep the brush name
  1146. info.brushName = brush.toLowerCase();
  1147. for (var i = 0; i < aliases.length; i++)
  1148. brushes[aliases[i]] = brush;
  1149. }
  1150. sh.vars.discoveredBrushes = brushes;
  1151. }
  1152. result = sh.brushes[brushes[alias]];
  1153. if (result == null && showAlert)
  1154. alert(sh.config.strings.noBrush + alias);
  1155. return result;
  1156. };
  1157. /**
  1158. * Executes a callback on each line and replaces each line with result from the callback.
  1159. * @param {Object} str Input string.
  1160. * @param {Object} callback Callback function taking one string argument and returning a string.
  1161. */
  1162. function eachLine(str, callback)
  1163. {
  1164. var lines = splitLines(str);
  1165. for (var i = 0; i < lines.length; i++)
  1166. lines[i] = callback(lines[i], i);
  1167. // include \r to enable copy-paste on windows (ie8) without getting everything on one line
  1168. return lines.join('\r\n');
  1169. };
  1170. /**
  1171. * This is a special trim which only removes first and last empty lines
  1172. * and doesn't affect valid leading space on the first line.
  1173. *
  1174. * @param {String} str Input string
  1175. * @return {String} Returns string without empty first and last lines.
  1176. */
  1177. function trimFirstAndLastLines(str)
  1178. {
  1179. return str.replace(/^[ ]*[\n]+|[\n]*[ ]*$/g, '');
  1180. };
  1181. /**
  1182. * Parses key/value pairs into hash object.
  1183. *
  1184. * Understands the following formats:
  1185. * - name: word;
  1186. * - name: [word, word];
  1187. * - name: "string";
  1188. * - name: 'string';
  1189. *
  1190. * For example:
  1191. * name1: value; name2: [value, value]; name3: 'value'
  1192. *
  1193. * @param {String} str Input string.
  1194. * @return {Object} Returns deserialized object.
  1195. */
  1196. function parseParams(str)
  1197. {
  1198. var match,
  1199. result = {},
  1200. arrayRegex = new XRegExp("^\\[(?<values>(.*?))\\]$"),
  1201. regex = new XRegExp(
  1202. "(?<name>[\\w-]+)" +
  1203. "\\s*:\\s*" +
  1204. "(?<value>" +
  1205. "[\\w-%#]+|" + // word
  1206. "\\[.*?\\]|" + // [] array
  1207. '".*?"|' + // "" string
  1208. "'.*?'" + // '' string
  1209. ")\\s*;?",
  1210. "g"
  1211. )
  1212. ;
  1213. while ((match = regex.exec(str)) != null)
  1214. {
  1215. var value = match.value
  1216. .replace(/^['"]|['"]$/g, '') // strip quotes from end of strings
  1217. ;
  1218. // try to parse array value
  1219. if (value != null && arrayRegex.test(value))
  1220. {
  1221. var m = arrayRegex.exec(value);
  1222. value = m.values.length > 0 ? m.values.split(/\s*,\s*/) : [];
  1223. }
  1224. result[match.name] = value;
  1225. }
  1226. return result;
  1227. };
  1228. /**
  1229. * Wraps each line of the string into <code/> tag with given style applied to it.
  1230. *
  1231. * @param {String} str Input string.
  1232. * @param {String} css Style name to apply to the string.
  1233. * @return {String} Returns input string with each line surrounded by <span/> tag.
  1234. */
  1235. function wrapLinesWithCode(str, css)
  1236. {
  1237. if (str == null || str.length == 0 || str == '\n')
  1238. return str;
  1239. str = str.replace(/</g, '&lt;');
  1240. // Replace two or more sequential spaces with &nbsp; leaving last space untouched.
  1241. str = str.replace(/ {2,}/g, function(m)
  1242. {
  1243. var spaces = '';
  1244. for (var i = 0; i < m.length - 1; i++)
  1245. spaces += sh.config.space;
  1246. return spaces + ' ';
  1247. });
  1248. // Split each line and apply <span class="...">...</span> to them so that
  1249. // leading spaces aren't included.
  1250. if (css != null)
  1251. str = eachLine(str, function(line)
  1252. {
  1253. if (line.length == 0)
  1254. return '';
  1255. var spaces = '';
  1256. line = line.replace(/^(&nbsp;| )+/, function(s)
  1257. {
  1258. spaces = s;
  1259. return '';
  1260. });
  1261. if (line.length == 0)
  1262. return spaces;
  1263. return spaces + '<code class="' + css + '">' + line + '</code>';
  1264. });
  1265. return str;
  1266. };
  1267. /**
  1268. * Pads number with zeros until it's length is the same as given length.
  1269. *
  1270. * @param {Number} number Number to pad.
  1271. * @param {Number} length Max string length with.
  1272. * @return {String} Returns a string padded with proper amount of '0'.
  1273. */
  1274. function padNumber(number, length)
  1275. {
  1276. var result = number.toString();
  1277. while (result.length < length)
  1278. result = '0' + result;
  1279. return result;
  1280. };
  1281. /**
  1282. * Replaces tabs with spaces.
  1283. *
  1284. * @param {String} code Source code.
  1285. * @param {Number} tabSize Size of the tab.
  1286. * @return {String} Returns code with all tabs replaces by spaces.
  1287. */
  1288. function processTabs(code, tabSize)
  1289. {
  1290. var tab = '';
  1291. for (var i = 0; i < tabSize; i++)
  1292. tab += ' ';
  1293. return code.replace(/\t/g, tab);
  1294. };
  1295. /**
  1296. * Replaces tabs with smart spaces.
  1297. *
  1298. * @param {String} code Code to fix the tabs in.
  1299. * @param {Number} tabSize Number of spaces in a column.
  1300. * @return {String} Returns code with all tabs replaces with roper amount of spaces.
  1301. */
  1302. function processSmartTabs(code, tabSize)
  1303. {
  1304. var lines = splitLines(code),
  1305. tab = '\t',
  1306. spaces = ''
  1307. ;
  1308. // Create a string with 1000 spaces to copy spaces from...
  1309. // It's assumed that there would be no indentation longer than that.
  1310. for (var i = 0; i < 50; i++)
  1311. spaces += ' '; // 20 spaces * 50
  1312. // This function inserts specified amount of spaces in the string
  1313. // where a tab is while removing that given tab.
  1314. function insertSpaces(line, pos, count)
  1315. {
  1316. return line.substr(0, pos)
  1317. + spaces.substr(0, count)
  1318. + line.substr(pos + 1, line.length) // pos + 1 will get rid of the tab
  1319. ;
  1320. };
  1321. // Go through all the lines and do the 'smart tabs' magic.
  1322. code = eachLine(code, function(line)
  1323. {
  1324. if (line.indexOf(tab) == -1)
  1325. return line;
  1326. var pos = 0;
  1327. while ((pos = line.indexOf(tab)) != -1)
  1328. {
  1329. // This is pretty much all there is to the 'smart tabs' logic.
  1330. // Based on the position within the line and size of a tab,
  1331. // calculate the amount of spaces we need to insert.
  1332. var spaces = tabSize - pos % tabSize;
  1333. line = insertSpaces(line, pos, spaces);
  1334. }
  1335. return line;
  1336. });
  1337. return code;
  1338. };
  1339. /**
  1340. * Performs various string fixes based on configuration.
  1341. */
  1342. function fixInputString(str)
  1343. {
  1344. var br = /<br\s*\/?>|&lt;br\s*\/?&gt;/gi;
  1345. if (sh.config.bloggerMode == true)
  1346. str = str.replace(br, '\n');
  1347. if (sh.config.stripBrs == true)
  1348. str = str.replace(br, '');
  1349. return str;
  1350. };
  1351. /**
  1352. * Removes all white space at the begining and end of a string.
  1353. *
  1354. * @param {String} str String to trim.
  1355. * @return {String} Returns string without leading and following white space characters.
  1356. */
  1357. function trim(str)
  1358. {
  1359. return str.replace(/^\s+|\s+$/g, '');
  1360. };
  1361. /**
  1362. * Unindents a block of text by the lowest common indent amount.
  1363. * @param {String} str Text to unindent.
  1364. * @return {String} Returns unindented text block.
  1365. */
  1366. function unindent(str)
  1367. {
  1368. var lines = splitLines(fixInputString(str)),
  1369. indents = new Array(),
  1370. regex = /^\s*/,
  1371. min = 1000
  1372. ;
  1373. // go through every line and check for common number of indents
  1374. for (var i = 0; i < lines.length && min > 0; i++)
  1375. {
  1376. var line = lines[i];
  1377. if (trim(line).length == 0)
  1378. continue;
  1379. var matches = regex.exec(line);
  1380. // In the event that just one line doesn't have leading white space
  1381. // we can't unindent anything, so bail completely.
  1382. if (matches == null)
  1383. return str;
  1384. min = Math.min(matches[0].length, min);
  1385. }
  1386. // trim minimum common number of white space from the begining of every line
  1387. if (min > 0)
  1388. for (var i = 0; i < lines.length; i++)
  1389. lines[i] = lines[i].substr(min);
  1390. return lines.join('\n');
  1391. };
  1392. /**
  1393. * Callback method for Array.sort() which sorts matches by
  1394. * index position and then by length.
  1395. *
  1396. * @param {Match} m1 Left object.
  1397. * @param {Match} m2 Right object.
  1398. * @return {Number} Returns -1, 0 or -1 as a comparison result.
  1399. */
  1400. function matchesSortCallback(m1, m2)
  1401. {
  1402. // sort matches by index first
  1403. if(m1.index < m2.index)
  1404. return -1;
  1405. else if(m1.index > m2.index)
  1406. return 1;
  1407. else
  1408. {
  1409. // if index is the same, sort by length
  1410. if(m1.length < m2.length)
  1411. return -1;
  1412. else if(m1.length > m2.length)
  1413. return 1;
  1414. }
  1415. return 0;
  1416. };
  1417. /**
  1418. * Executes given regular expression on provided code and returns all
  1419. * matches that are found.
  1420. *
  1421. * @param {String} code Code to execute regular expression on.
  1422. * @param {Object} regex Regular expression item info from <code>regexList</code> collection.
  1423. * @return {Array} Returns a list of Match objects.
  1424. */
  1425. function getMatches(code, regexInfo)
  1426. {
  1427. function defaultAdd(match, regexInfo)
  1428. {
  1429. return match[0];
  1430. };
  1431. var index = 0,
  1432. match = null,
  1433. matches = [],
  1434. func = regexInfo.func ? regexInfo.func : defaultAdd
  1435. ;
  1436. while((match = regexInfo.regex.exec(code)) != null)
  1437. {
  1438. var resultMatch = func(match, regexInfo);
  1439. if (typeof(resultMatch) == 'string')
  1440. resultMatch = [new sh.Match(resultMatch, match.index, regexInfo.css)];
  1441. matches = matches.concat(resultMatch);
  1442. }
  1443. return matches;
  1444. };
  1445. /**
  1446. * Turns all URLs in the code into <a/> tags.
  1447. * @param {String} code Input code.
  1448. * @return {String} Returns code with </a> tags.
  1449. */
  1450. function processUrls(code)
  1451. {
  1452. var gt = /(.*)((&gt;|&lt;).*)/;
  1453. return code.replace(sh.regexLib.url, function(m)
  1454. {
  1455. var suffix = '',
  1456. match = null
  1457. ;
  1458. // We include &lt; and &gt; in the URL for the common cases like <http://google.com>
  1459. // The problem is that they get transformed into &lt;http://google.com&gt;
  1460. // Where as &gt; easily looks like part of the URL string.
  1461. if (match = gt.exec(m))
  1462. {
  1463. m = match[1];
  1464. suffix = match[2];
  1465. }
  1466. return '<a href="' + m + '">' + m + '</a>' + suffix;
  1467. });
  1468. };
  1469. /**
  1470. * Finds all <SCRIPT TYPE="syntaxhighlighter" /> elementss.
  1471. * @return {Array} Returns array of all found SyntaxHighlighter tags.
  1472. */
  1473. function getSyntaxHighlighterScriptTags()
  1474. {
  1475. var tags = document.getElementsByTagName('script'),
  1476. result = []
  1477. ;
  1478. for (var i = 0; i < tags.length; i++)
  1479. if (tags[i].type == 'syntaxhighlighter')
  1480. result.push(tags[i]);
  1481. return result;
  1482. };
  1483. /**
  1484. * Strips <![CDATA[]]> from <SCRIPT /> content because it should be used
  1485. * there in most cases for XHTML compliance.
  1486. * @param {String} original Input code.
  1487. * @return {String} Returns code without leading <![CDATA[]]> tags.
  1488. */
  1489. function stripCData(original)
  1490. {
  1491. var left = '<![CDATA[',
  1492. right = ']]>',
  1493. // for some reason IE inserts some leading blanks here
  1494. copy = trim(original),
  1495. changed = false,
  1496. leftLength = left.length,
  1497. rightLength = right.length
  1498. ;
  1499. if (copy.indexOf(left) == 0)
  1500. {
  1501. copy = copy.substring(leftLength);
  1502. changed = true;
  1503. }
  1504. var copyLength = copy.length;
  1505. if (copy.indexOf(right) == copyLength - rightLength)
  1506. {
  1507. copy = copy.substring(0, copyLength - rightLength);
  1508. changed = true;
  1509. }
  1510. return changed ? copy : original;
  1511. };
  1512. /**
  1513. * Quick code mouse double click handler.
  1514. */
  1515. function quickCodeHandler(e)
  1516. {
  1517. var target = e.target,
  1518. highlighterDiv = findParentElement(target, '.syntaxhighlighter'),
  1519. container = findParentElement(target, '.container'),
  1520. textarea = document.createElement('textarea'),
  1521. highlighter
  1522. ;
  1523. if (!container || !highlighterDiv || findElement(container, 'textarea'))
  1524. return;
  1525. highlighter = getHighlighterById(highlighterDiv.id);
  1526. // add source class name
  1527. addClass(highlighterDiv, 'source');
  1528. // Have to go over each line and grab it's text, can't just do it on the
  1529. // container because Firefox loses all \n where as Webkit doesn't.
  1530. var lines = container.childNodes,
  1531. code = []
  1532. ;
  1533. for (var i = 0; i < lines.length; i++)
  1534. code.push(lines[i].innerText || lines[i].textContent);
  1535. // using \r instead of \r or \r\n makes this work equally well on IE, FF and Webkit
  1536. code = code.join('\r');
  1537. // For Webkit browsers, replace nbsp with a breaking space
  1538. code = code.replace(/\u00a0/g, " ");
  1539. // inject <textarea/> tag
  1540. textarea.appendChild(document.createTextNode(code));
  1541. container.appendChild(textarea);
  1542. // preselect all text
  1543. textarea.focus();
  1544. textarea.select();
  1545. // set up handler for lost focus
  1546. attachEvent(textarea, 'blur', function(e)
  1547. {
  1548. textarea.parentNode.removeChild(textarea);
  1549. removeClass(highlighterDiv, 'source');
  1550. });
  1551. };
  1552. /**
  1553. * Match object.
  1554. */
  1555. sh.Match = function(value, index, css)
  1556. {
  1557. this.value = value;
  1558. this.index = index;
  1559. this.length = value.length;
  1560. this.css = css;
  1561. this.brushName = null;
  1562. };
  1563. sh.Match.prototype.toString = function()
  1564. {
  1565. return this.value;
  1566. };
  1567. /**
  1568. * Simulates HTML code with a scripting language embedded.
  1569. *
  1570. * @param {String} scriptBrushName Brush name of the scripting language.
  1571. */
  1572. sh.HtmlScript = function(scriptBrushName)
  1573. {
  1574. var brushClass = findBrush(scriptBrushName),
  1575. scriptBrush,
  1576. xmlBrush = new sh.brushes.Xml(),
  1577. bracketsRegex = null,
  1578. ref = this,
  1579. methodsToExpose = 'getDiv getHtml init'.split(' ')
  1580. ;
  1581. if (brushClass == null)
  1582. return;
  1583. scriptBrush = new brushClass();
  1584. for(var i = 0; i < methodsToExpose.length; i++)
  1585. // make a closure so we don't lose the name after i changes
  1586. (function() {
  1587. var name = methodsToExpose[i];
  1588. ref[name] = function()
  1589. {
  1590. return xmlBrush[name].apply(xmlBrush, arguments);
  1591. };
  1592. })();
  1593. if (scriptBrush.htmlScript == null)
  1594. {
  1595. alert(sh.config.strings.brushNotHtmlScript + scriptBrushName);
  1596. return;
  1597. }
  1598. xmlBrush.regexList.push(
  1599. { regex: scriptBrush.htmlScript.code, func: process }
  1600. );
  1601. function offsetMatches(matches, offset)
  1602. {
  1603. for (var j = 0; j < matches.length; j++)
  1604. matches[j].index += offset;
  1605. }
  1606. function process(match, info)
  1607. {
  1608. var code = match.code,
  1609. matches = [],
  1610. regexList = scriptBrush.regexList,
  1611. offset = match.index + match.left.length,
  1612. htmlScript = scriptBrush.htmlScript,
  1613. result
  1614. ;
  1615. // add all matches from the code
  1616. for (var i = 0; i < regexList.length; i++)
  1617. {
  1618. result = getMatches(code, regexList[i]);
  1619. offsetMatches(result, offset);
  1620. matches = matches.concat(result);
  1621. }
  1622. // add left script bracket
  1623. if (htmlScript.left != null && match.left != null)
  1624. {
  1625. result = getMatches(match.left, htmlScript.left);
  1626. offsetMatches(result, match.index);
  1627. matches = matches.concat(result);
  1628. }
  1629. // add right script bracket
  1630. if (htmlScript.right != null && match.right != null)
  1631. {
  1632. result = getMatches(match.right, htmlScript.right);
  1633. offsetMatches(result, match.index + match[0].lastIndexOf(match.right));
  1634. matches = matches.concat(result);
  1635. }
  1636. for (var j = 0; j < matches.length; j++)
  1637. matches[j].brushName = brushClass.brushName;
  1638. return matches;
  1639. }
  1640. };
  1641. /**
  1642. * Main Highlither class.
  1643. * @constructor
  1644. */
  1645. sh.Highlighter = function()
  1646. {
  1647. // not putting any code in here because of the prototype inheritance
  1648. };
  1649. sh.Highlighter.prototype = {
  1650. /**
  1651. * Returns value of the parameter passed to the highlighter.
  1652. * @param {String} name Name of the parameter.
  1653. * @param {Object} defaultValue Default value.
  1654. * @return {Object} Returns found value or default value otherwise.
  1655. */
  1656. getParam: function(name, defaultValue)
  1657. {
  1658. var result = this.params[name];
  1659. return toBoolean(result == null ? defaultValue : result);
  1660. },
  1661. /**
  1662. * Shortcut to document.createElement().
  1663. * @param {String} name Name of the element to create (DIV, A, etc).
  1664. * @return {HTMLElement} Returns new HTML element.
  1665. */
  1666. create: function(name)
  1667. {
  1668. return document.createElement(name);
  1669. },
  1670. /**
  1671. * Applies all regular expression to the code and stores all found
  1672. * matches in the `this.matches` array.
  1673. * @param {Array} regexList List of regular expressions.
  1674. * @param {String} code Source code.
  1675. * @return {Array} Returns list of matches.
  1676. */
  1677. findMatches: function(regexList, code)
  1678. {
  1679. var result = [];
  1680. if (regexList != null)
  1681. for (var i = 0; i < regexList.length; i++)
  1682. // BUG: length returns len+1 for array if methods added to prototype chain (oising@gmail.com)
  1683. if (typeof (regexList[i]) == "object")
  1684. result = result.concat(getMatches(code, regexList[i]));
  1685. // sort and remove nested the matches
  1686. return this.removeNestedMatches(result.sort(matchesSortCallback));
  1687. },
  1688. /**
  1689. * Checks to see if any of the matches are inside of other matches.
  1690. * This process would get rid of highligted strings inside comments,
  1691. * keywords inside strings and so on.
  1692. */
  1693. removeNestedMatches: function(matches)
  1694. {
  1695. // Optimized by Jose Prado (http://joseprado.com)
  1696. for (var i = 0; i < matches.length; i++)
  1697. {
  1698. if (matches[i] === null)
  1699. continue;
  1700. var itemI = matches[i],
  1701. itemIEndPos = itemI.index + itemI.length
  1702. ;
  1703. for (var j = i + 1; j < matches.length && matches[i] !== null; j++)
  1704. {
  1705. var itemJ = matches[j];
  1706. if (itemJ === null)
  1707. continue;
  1708. else if (itemJ.index > itemIEndPos)
  1709. break;
  1710. else if (itemJ.index == itemI.index && itemJ.length > itemI.length)
  1711. matches[i] = null;
  1712. else if (itemJ.index >= itemI.index && itemJ.index < itemIEndPos)
  1713. matches[j] = null;
  1714. }
  1715. }
  1716. return matches;
  1717. },
  1718. /**
  1719. * Creates an array containing integer line numbers starting from the 'first-line' param.
  1720. * @return {Array} Returns array of integers.
  1721. */
  1722. figureOutLineNumbers: function(code)
  1723. {
  1724. var lines = [],
  1725. firstLine = parseInt(this.getParam('first-line'))
  1726. ;
  1727. eachLine(code, function(line, index)
  1728. {
  1729. lines.push(index + firstLine);
  1730. });
  1731. return lines;
  1732. },
  1733. /**
  1734. * Determines if specified line number is in the highlighted list.
  1735. */
  1736. isLineHighlighted: function(lineNumber)
  1737. {
  1738. var list = this.getParam('highlight', []);
  1739. if (typeof(list) != 'object' && list.push == null)
  1740. list = [ list ];
  1741. return indexOf(list, lineNumber.toString()) != -1;
  1742. },
  1743. /**
  1744. * Generates HTML markup for a single line of code while determining alternating line style.
  1745. * @param {Integer} lineNumber Line number.
  1746. * @param {String} code Line HTML markup.
  1747. * @return {String} Returns HTML markup.
  1748. */
  1749. getLineHtml: function(lineIndex, lineNumber, code)
  1750. {
  1751. var classes = [
  1752. 'line',
  1753. 'number' + lineNumber,
  1754. 'index' + lineIndex,
  1755. 'alt' + (lineNumber % 2 == 0 ? 1 : 2).toString()
  1756. ];
  1757. if (this.isLineHighlighted(lineNumber))
  1758. classes.push('highlighted');
  1759. if (lineNumber == 0)
  1760. classes.push('break');
  1761. return '<div class="' + classes.join(' ') + '">' + code + '</div>';
  1762. },
  1763. /**
  1764. * Generates HTML markup for line number column.
  1765. * @param {String} code Complete code HTML markup.
  1766. * @param {Array} lineNumbers Calculated line numbers.
  1767. * @return {String} Returns HTML markup.
  1768. */
  1769. getLineNumbersHtml: function(code, lineNumbers)
  1770. {
  1771. var html = '',
  1772. count = splitLines(code).length,
  1773. firstLine = parseInt(this.getParam('first-line')),
  1774. pad = this.getParam('pad-line-numbers')
  1775. ;
  1776. if (pad == true)
  1777. pad = (firstLine + count - 1).toString().length;
  1778. else if (isNaN(pad) == true)
  1779. pad = 0;
  1780. for (var i = 0; i < count; i++)
  1781. {
  1782. var lineNumber = lineNumbers ? lineNumbers[i] : firstLine + i,
  1783. code = lineNumber == 0 ? sh.config.space : padNumber(lineNumber, pad)
  1784. ;
  1785. html += this.getLineHtml(i, lineNumber, code);
  1786. }
  1787. return html;
  1788. },
  1789. /**
  1790. * Splits block of text into individual DIV lines.
  1791. * @param {String} code Code to highlight.
  1792. * @param {Array} lineNumbers Calculated line numbers.
  1793. * @return {String} Returns highlighted code in HTML form.
  1794. */
  1795. getCodeLinesHtml: function(html, lineNumbers)
  1796. {
  1797. html = trim(html);
  1798. var lines = splitLines(html),
  1799. padLength = this.getParam('pad-line-numbers'),
  1800. firstLine = parseInt(this.getParam('first-line')),
  1801. html = '',
  1802. brushName = this.getParam('brush')
  1803. ;
  1804. for (var i = 0; i < lines.length; i++)
  1805. {
  1806. var line = lines[i],
  1807. indent = /^(&nbsp;|\s)+/.exec(line),
  1808. spaces = null,
  1809. lineNumber = lineNumbers ? lineNumbers[i] : firstLine + i;
  1810. ;
  1811. if (indent != null)
  1812. {
  1813. spaces = indent[0].toString();
  1814. line = line.substr(spaces.length);
  1815. spaces = spaces.replace(' ', sh.config.space);
  1816. }
  1817. line = trim(line);
  1818. if (line.length == 0)
  1819. line = sh.config.space;
  1820. html += this.getLineHtml(
  1821. i,
  1822. lineNumber,
  1823. (spaces != null ? '<code class="' + brushName + ' spaces">' + spaces + '</code>' : '') + line
  1824. );
  1825. }
  1826. return html;
  1827. },
  1828. /**
  1829. * Returns HTML for the table title or empty string if title is null.
  1830. */
  1831. getTitleHtml: function(title)
  1832. {
  1833. return title ? '<caption>' + title + '</caption>' : '';
  1834. },
  1835. /**
  1836. * Finds all matches in the source code.
  1837. * @param {String} code Source code to process matches in.
  1838. * @param {Array} matches Discovered regex matches.
  1839. * @return {String} Returns formatted HTML with processed mathes.
  1840. */
  1841. getMatchesHtml: function(code, matches)
  1842. {
  1843. var pos = 0,
  1844. result = '',
  1845. brushName = this.getParam('brush', '')
  1846. ;
  1847. function getBrushNameCss(match)
  1848. {
  1849. var result = match ? (match.brushName || brushName) : brushName;
  1850. return result ? result + ' ' : '';
  1851. };
  1852. // Finally, go through the final list of matches and pull the all
  1853. // together adding everything in between that isn't a match.
  1854. for (var i = 0; i < matches.length; i++)
  1855. {
  1856. var match = matches[i],
  1857. matchBrushName
  1858. ;
  1859. if (match === null || match.length === 0)
  1860. continue;
  1861. matchBrushName = getBrushNameCss(match);
  1862. result += wrapLinesWithCode(code.substr(pos, match.index - pos), matchBrushName + 'plain')
  1863. + wrapLinesWithCode(match.value, matchBrushName + match.css)
  1864. ;
  1865. pos = match.index + match.length + (match.offset || 0);
  1866. }
  1867. // don't forget to add whatever's remaining in the string
  1868. result += wrapLinesWithCode(code.substr(pos), getBrushNameCss() + 'plain');
  1869. return result;
  1870. },
  1871. /**
  1872. * Generates HTML markup for the whole syntax highlighter.
  1873. * @param {String} code Source code.
  1874. * @return {String} Returns HTML markup.
  1875. */
  1876. getHtml: function(code)
  1877. {
  1878. var html = '',
  1879. classes = [ 'syntaxhighlighter' ],
  1880. tabSize,
  1881. matches,
  1882. lineNumbers
  1883. ;
  1884. // process light mode
  1885. if (this.getParam('light') == true)
  1886. this.params.toolbar = this.params.gutter = false;
  1887. className = 'syntaxhighlighter';
  1888. if (this.getParam('collapse') == true)
  1889. classes.push('collapsed');
  1890. if ((gutter = this.getParam('gutter')) == false)
  1891. classes.push('nogutter');
  1892. // add custom user style name
  1893. classes.push(this.getParam('class-name'));
  1894. // add brush alias to the class name for custom CSS
  1895. classes.push(this.getParam('brush'));
  1896. code = trimFirstAndLastLines(code)
  1897. .replace(/\r/g, ' ') // IE lets these buggers through
  1898. ;
  1899. tabSize = this.getParam('tab-size');
  1900. // replace tabs with spaces
  1901. code = this.getParam('smart-tabs') == true
  1902. ? processSmartTabs(code, tabSize)
  1903. : processTabs(code, tabSize)
  1904. ;
  1905. // unindent code by the common indentation
  1906. if (this.getParam('unindent'))
  1907. code = unindent(code);
  1908. if (gutter)
  1909. lineNumbers = this.figureOutLineNumbers(code);
  1910. // find matches in the code using brushes regex list
  1911. matches = this.findMatches(this.regexList, code);
  1912. // processes found matches into the html
  1913. html = this.getMatchesHtml(code, matches);
  1914. // finally, split all lines so that they wrap well
  1915. html = this.getCodeLinesHtml(html, lineNumbers);
  1916. // finally, process the links
  1917. if (this.getParam('auto-links'))
  1918. html = processUrls(html);
  1919. if (typeof(navigator) != 'undefined' && navigator.userAgent && navigator.userAgent.match(/MSIE/))
  1920. classes.push('ie');
  1921. html =
  1922. '<div id="' + getHighlighterId(this.id) + '" class="' + classes.join(' ') + '">'
  1923. + (this.getParam('toolbar') ? sh.toolbar.getHtml(this) : '')
  1924. + '<table border="0" cellpadding="0" cellspacing="0">'
  1925. + this.getTitleHtml(this.getParam('title'))
  1926. + '<tbody>'
  1927. + '<tr>'
  1928. + (gutter ? '<td class="gutter">' + this.getLineNumbersHtml(code) + '</td>' : '')
  1929. + '<td class="code">'
  1930. + '<div class="container">'
  1931. + html
  1932. + '</div>'
  1933. + '</td>'
  1934. + '</tr>'
  1935. + '</tbody>'
  1936. + '</table>'
  1937. + '</div>'
  1938. ;
  1939. return html;
  1940. },
  1941. /**
  1942. * Highlights the code and returns complete HTML.
  1943. * @param {String} code Code to highlight.
  1944. * @return {Element} Returns container DIV element with all markup.
  1945. */
  1946. getDiv: function(code)
  1947. {
  1948. if (code === null)
  1949. code = '';
  1950. this.code = code;
  1951. var div = this.create('div');
  1952. // create main HTML
  1953. div.innerHTML = this.getHtml(code);
  1954. // set up click handlers
  1955. if (this.getParam('toolbar'))
  1956. attachEvent(findElement(div, '.toolbar'), 'click', sh.toolbar.handler);
  1957. if (this.getParam('quick-code'))
  1958. attachEvent(findElement(div, '.code'), 'dblclick', quickCodeHandler);
  1959. return div;
  1960. },
  1961. /**
  1962. * Initializes the highlighter/brush.
  1963. *
  1964. * Constructor isn't used for initialization so that nothing executes during necessary
  1965. * `new SyntaxHighlighter.Highlighter()` call when setting up brush inheritence.
  1966. *
  1967. * @param {Hash} params Highlighter parameters.
  1968. */
  1969. init: function(params)
  1970. {
  1971. this.id = guid();
  1972. // register this instance in the highlighters list
  1973. storeHighlighter(this);
  1974. // local params take precedence over defaults
  1975. this.params = merge(sh.defaults, params || {})
  1976. // process light mode
  1977. if (this.getParam('light') == true)
  1978. this.params.toolbar = this.params.gutter = false;
  1979. },
  1980. /**
  1981. * Converts space separated list of keywords into a regular expression string.
  1982. * @param {String} str Space separated keywords.
  1983. * @return {String} Returns regular expression string.
  1984. */
  1985. getKeywords: function(str)
  1986. {
  1987. str = str
  1988. .replace(/^\s+|\s+$/g, '')
  1989. .replace(/\s+/g, '|')
  1990. ;
  1991. return '\\b(?:' + str + ')\\b';
  1992. },
  1993. /**
  1994. * Makes a brush compatible with the `html-script` functionality.
  1995. * @param {Object} regexGroup Object containing `left` and `right` regular expressions.
  1996. */
  1997. forHtmlScript: function(regexGroup)
  1998. {
  1999. var regex = { 'end' : regexGroup.right.source };
  2000. if(regexGroup.eof)
  2001. regex.end = "(?:(?:" + regex.end + ")|$)";
  2002. this.htmlScript = {
  2003. left : { regex: regexGroup.left, css: 'script' },
  2004. right : { regex: regexGroup.right, css: 'script' },
  2005. code : new XRegExp(
  2006. "(?<left>" + regexGroup.left.source + ")" +
  2007. "(?<code>.*?)" +
  2008. "(?<right>" + regex.end + ")",
  2009. "sgi"
  2010. )
  2011. };
  2012. }
  2013. }; // end of Highlighter
  2014. return sh;
  2015. }(); // end of anonymous function
  2016. // CommonJS
  2017. typeof(exports) != 'undefined' ? exports.SyntaxHighlighter = SyntaxHighlighter : null;
  2018. ;(function()
  2019. {
  2020. // CommonJS
  2021. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2022. function Brush()
  2023. {
  2024. // Created by Peter Atoria @ http://iAtoria.com
  2025. var inits = 'class interface function package';
  2026. var keywords = '-Infinity ...rest Array as AS3 Boolean break case catch const continue Date decodeURI ' +
  2027. 'decodeURIComponent default delete do dynamic each else encodeURI encodeURIComponent escape ' +
  2028. 'extends false final finally flash_proxy for get if implements import in include Infinity ' +
  2029. 'instanceof int internal is isFinite isNaN isXMLName label namespace NaN native new null ' +
  2030. 'Null Number Object object_proxy override parseFloat parseInt private protected public ' +
  2031. 'return set static String super switch this throw true try typeof uint undefined unescape ' +
  2032. 'use void while with'
  2033. ;
  2034. this.regexList = [
  2035. { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
  2036. { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
  2037. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
  2038. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
  2039. { regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi, css: 'value' }, // numbers
  2040. { regex: new RegExp(this.getKeywords(inits), 'gm'), css: 'color3' }, // initializations
  2041. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
  2042. { regex: new RegExp('var', 'gm'), css: 'variable' }, // variable
  2043. { regex: new RegExp('trace', 'gm'), css: 'color1' } // trace
  2044. ];
  2045. this.forHtmlScript(SyntaxHighlighter.regexLib.scriptScriptTags);
  2046. };
  2047. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2048. Brush.aliases = ['actionscript3', 'as3'];
  2049. SyntaxHighlighter.brushes.AS3 = Brush;
  2050. // CommonJS
  2051. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2052. })();
  2053. ;(function()
  2054. {
  2055. // CommonJS
  2056. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2057. function Brush()
  2058. {
  2059. // AppleScript brush by David Chambers
  2060. // http://davidchambersdesign.com/
  2061. var keywords = 'after before beginning continue copy each end every from return get global in local named of set some that the then times to where whose with without';
  2062. var ordinals = 'first second third fourth fifth sixth seventh eighth ninth tenth last front back middle';
  2063. var specials = 'activate add alias AppleScript ask attachment boolean class constant delete duplicate empty exists false id integer list make message modal modified new no paragraph pi properties quit real record remove rest result reveal reverse run running save string true word yes';
  2064. this.regexList = [
  2065. { regex: /(--|#).*$/gm,
  2066. css: 'comments' },
  2067. { regex: /\(\*(?:[\s\S]*?\(\*[\s\S]*?\*\))*[\s\S]*?\*\)/gm, // support nested comments
  2068. css: 'comments' },
  2069. { regex: /"[\s\S]*?"/gm,
  2070. css: 'string' },
  2071. { regex: /(?:,|:|¬|'s\b|\(|\)|\{|\}|«|\b\w*»)/g,
  2072. css: 'color1' },
  2073. { regex: /(-)?(\d)+(\.(\d)?)?(E\+(\d)+)?/g, // numbers
  2074. css: 'color1' },
  2075. { regex: /(?:&(amp;|gt;|lt;)?|=|� |>|<|≥|>=|≤|<=|\*|\+|-|\/|÷|\^)/g,
  2076. css: 'color2' },
  2077. { regex: /\b(?:and|as|div|mod|not|or|return(?!\s&)(ing)?|equals|(is(n't| not)? )?equal( to)?|does(n't| not) equal|(is(n't| not)? )?(greater|less) than( or equal( to)?)?|(comes|does(n't| not) come) (after|before)|is(n't| not)?( in)? (back|front) of|is(n't| not)? behind|is(n't| not)?( (in|contained by))?|does(n't| not) contain|contain(s)?|(start|begin|end)(s)? with|((but|end) )?(consider|ignor)ing|prop(erty)?|(a )?ref(erence)?( to)?|repeat (until|while|with)|((end|exit) )?repeat|((else|end) )?if|else|(end )?(script|tell|try)|(on )?error|(put )?into|(of )?(it|me)|its|my|with (timeout( of)?|transaction)|end (timeout|transaction))\b/g,
  2078. css: 'keyword' },
  2079. { regex: /\b\d+(st|nd|rd|th)\b/g, // ordinals
  2080. css: 'keyword' },
  2081. { regex: /\b(?:about|above|against|around|at|below|beneath|beside|between|by|(apart|aside) from|(instead|out) of|into|on(to)?|over|since|thr(ough|u)|under)\b/g,
  2082. css: 'color3' },
  2083. { regex: /\b(?:adding folder items to|after receiving|choose( ((remote )?application|color|folder|from list|URL))?|clipboard info|set the clipboard to|(the )?clipboard|entire contents|display(ing| (alert|dialog|mode))?|document( (edited|file|nib name))?|file( (name|type))?|(info )?for|giving up after|(name )?extension|quoted form|return(ed)?|second(?! item)(s)?|list (disks|folder)|text item(s| delimiters)?|(Unicode )?text|(disk )?item(s)?|((current|list) )?view|((container|key) )?window|with (data|icon( (caution|note|stop))?|parameter(s)?|prompt|properties|seed|title)|case|diacriticals|hyphens|numeric strings|punctuation|white space|folder creation|application(s( folder)?| (processes|scripts position|support))?|((desktop )?(pictures )?|(documents|downloads|favorites|home|keychain|library|movies|music|public|scripts|sites|system|users|utilities|workflows) )folder|desktop|Folder Action scripts|font(s| panel)?|help|internet plugins|modem scripts|(system )?preferences|printer descriptions|scripting (additions|components)|shared (documents|libraries)|startup (disk|items)|temporary items|trash|on server|in AppleTalk zone|((as|long|short) )?user name|user (ID|locale)|(with )?password|in (bundle( with identifier)?|directory)|(close|open for) access|read|write( permission)?|(g|s)et eof|using( delimiters)?|starting at|default (answer|button|color|country code|entr(y|ies)|identifiers|items|name|location|script editor)|hidden( answer)?|open(ed| (location|untitled))?|error (handling|reporting)|(do( shell)?|load|run|store) script|administrator privileges|altering line endings|get volume settings|(alert|boot|input|mount|output|set) volume|output muted|(fax|random )?number|round(ing)?|up|down|toward zero|to nearest|as taught in school|system (attribute|info)|((AppleScript( Studio)?|system) )?version|(home )?directory|(IPv4|primary Ethernet) address|CPU (type|speed)|physical memory|time (stamp|to GMT)|replacing|ASCII (character|number)|localized string|from table|offset|summarize|beep|delay|say|(empty|multiple) selections allowed|(of|preferred) type|invisibles|showing( package contents)?|editable URL|(File|FTP|News|Media|Web) [Ss]ervers|Telnet hosts|Directory services|Remote applications|waiting until completion|saving( (in|to))?|path (for|to( (((current|frontmost) )?application|resource))?)|POSIX (file|path)|(background|RGB) color|(OK|cancel) button name|cancel button|button(s)?|cubic ((centi)?met(re|er)s|yards|feet|inches)|square ((kilo)?met(re|er)s|miles|yards|feet)|(centi|kilo)?met(re|er)s|miles|yards|feet|inches|lit(re|er)s|gallons|quarts|(kilo)?grams|ounces|pounds|degrees (Celsius|Fahrenheit|Kelvin)|print( (dialog|settings))?|clos(e(able)?|ing)|(de)?miniaturized|miniaturizable|zoom(ed|able)|attribute run|action (method|property|title)|phone|email|((start|end)ing|home) page|((birth|creation|current|custom|modification) )?date|((((phonetic )?(first|last|middle))|computer|host|maiden|related) |nick)?name|aim|icq|jabber|msn|yahoo|address(es)?|save addressbook|should enable action|city|country( code)?|formatte(r|d address)|(palette )?label|state|street|zip|AIM [Hh]andle(s)?|my card|select(ion| all)?|unsaved|(alpha )?value|entr(y|ies)|group|(ICQ|Jabber|MSN) handle|person|people|company|department|icon image|job title|note|organization|suffix|vcard|url|copies|collating|pages (across|down)|request print time|target( printer)?|((GUI Scripting|Script menu) )?enabled|show Computer scripts|(de)?activated|awake from nib|became (key|main)|call method|of (class|object)|center|clicked toolbar item|closed|for document|exposed|(can )?hide|idle|keyboard (down|up)|event( (number|type))?|launch(ed)?|load (image|movie|nib|sound)|owner|log|mouse (down|dragged|entered|exited|moved|up)|move|column|localization|resource|script|register|drag (info|types)|resigned (active|key|main)|resiz(e(d)?|able)|right mouse (down|dragged|up)|scroll wheel|(at )?index|should (close|open( untitled)?|quit( after last window closed)?|zoom)|((proposed|screen) )?bounds|show(n)?|behind|in front of|size (mode|to fit)|update(d| toolbar item)?|was (hidden|miniaturized)|will (become active|close|finish launching|hide|miniaturize|move|open|quit|(resign )?active|((maximum|minimum|proposed) )?size|show|zoom)|bundle|data source|movie|pasteboard|sound|tool(bar| tip)|(color|open|save) panel|coordinate system|frontmost|main( (bundle|menu|window))?|((services|(excluded from )?windows) )?menu|((executable|frameworks|resource|scripts|shared (frameworks|support)) )?path|(selected item )?identifier|data|content(s| view)?|character(s)?|click count|(command|control|option|shift) key down|context|delta (x|y|z)|key( code)?|location|pressure|unmodified characters|types|(first )?responder|playing|(allowed|selectable) identifiers|allows customization|(auto saves )?configuration|visible|image( name)?|menu form representation|tag|user(-| )defaults|associated file name|(auto|needs) display|current field editor|floating|has (resize indicator|shadow)|hides when deactivated|level|minimized (image|title)|opaque|position|release when closed|sheet|title(d)?)\b/g,
  2084. css: 'color3' },
  2085. { regex: new RegExp(this.getKeywords(specials), 'gm'), css: 'color3' },
  2086. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' },
  2087. { regex: new RegExp(this.getKeywords(ordinals), 'gm'), css: 'keyword' }
  2088. ];
  2089. };
  2090. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2091. Brush.aliases = ['applescript'];
  2092. SyntaxHighlighter.brushes.AppleScript = Brush;
  2093. // CommonJS
  2094. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2095. })();
  2096. ;(function()
  2097. {
  2098. // CommonJS
  2099. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2100. function Brush()
  2101. {
  2102. var keywords = 'if fi then elif else for do done until while break continue case esac function return in eq ne ge le';
  2103. var commands = 'alias apropos awk basename bash bc bg builtin bzip2 cal cat cd cfdisk chgrp chmod chown chroot' +
  2104. 'cksum clear cmp comm command cp cron crontab csplit cut date dc dd ddrescue declare df ' +
  2105. 'diff diff3 dig dir dircolors dirname dirs du echo egrep eject enable env ethtool eval ' +
  2106. 'exec exit expand export expr false fdformat fdisk fg fgrep file find fmt fold format ' +
  2107. 'free fsck ftp gawk getopts grep groups gzip hash head history hostname id ifconfig ' +
  2108. 'import install join kill less let ln local locate logname logout look lpc lpr lprint ' +
  2109. 'lprintd lprintq lprm ls lsof make man mkdir mkfifo mkisofs mknod more mount mtools ' +
  2110. 'mv netstat nice nl nohup nslookup open op passwd paste pathchk ping popd pr printcap ' +
  2111. 'printenv printf ps pushd pwd quota quotacheck quotactl ram rcp read readonly renice ' +
  2112. 'remsync rm rmdir rsync screen scp sdiff sed select seq set sftp shift shopt shutdown ' +
  2113. 'sleep sort source split ssh strace su sudo sum symlink sync tail tar tee test time ' +
  2114. 'times touch top traceroute trap tr true tsort tty type ulimit umask umount unalias ' +
  2115. 'uname unexpand uniq units unset unshar useradd usermod users uuencode uudecode v vdir ' +
  2116. 'vi watch wc whereis which who whoami Wget xargs yes'
  2117. ;
  2118. this.regexList = [
  2119. { regex: /^#!.*$/gm, css: 'preprocessor bold' },
  2120. { regex: /\/[\w-\/]+/gm, css: 'plain' },
  2121. { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, // one line comments
  2122. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
  2123. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
  2124. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
  2125. { regex: new RegExp(this.getKeywords(commands), 'gm'), css: 'functions' } // commands
  2126. ];
  2127. }
  2128. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2129. Brush.aliases = ['bash', 'shell', 'sh'];
  2130. SyntaxHighlighter.brushes.Bash = Brush;
  2131. // CommonJS
  2132. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2133. })();
  2134. ;(function()
  2135. {
  2136. // CommonJS
  2137. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2138. function Brush()
  2139. {
  2140. // Contributed by Jen
  2141. // http://www.jensbits.com/2009/05/14/coldfusion-brush-for-syntaxhighlighter-plus
  2142. var funcs = 'Abs ACos AddSOAPRequestHeader AddSOAPResponseHeader AjaxLink AjaxOnLoad ArrayAppend ArrayAvg ArrayClear ArrayDeleteAt ' +
  2143. 'ArrayInsertAt ArrayIsDefined ArrayIsEmpty ArrayLen ArrayMax ArrayMin ArraySet ArraySort ArraySum ArraySwap ArrayToList ' +
  2144. 'Asc ASin Atn BinaryDecode BinaryEncode BitAnd BitMaskClear BitMaskRead BitMaskSet BitNot BitOr BitSHLN BitSHRN BitXor ' +
  2145. 'Ceiling CharsetDecode CharsetEncode Chr CJustify Compare CompareNoCase Cos CreateDate CreateDateTime CreateObject ' +
  2146. 'CreateODBCDate CreateODBCDateTime CreateODBCTime CreateTime CreateTimeSpan CreateUUID DateAdd DateCompare DateConvert ' +
  2147. 'DateDiff DateFormat DatePart Day DayOfWeek DayOfWeekAsString DayOfYear DaysInMonth DaysInYear DE DecimalFormat DecrementValue ' +
  2148. 'Decrypt DecryptBinary DeleteClientVariable DeserializeJSON DirectoryExists DollarFormat DotNetToCFType Duplicate Encrypt ' +
  2149. 'EncryptBinary Evaluate Exp ExpandPath FileClose FileCopy FileDelete FileExists FileIsEOF FileMove FileOpen FileRead ' +
  2150. 'FileReadBinary FileReadLine FileSetAccessMode FileSetAttribute FileSetLastModified FileWrite Find FindNoCase FindOneOf ' +
  2151. 'FirstDayOfMonth Fix FormatBaseN GenerateSecretKey GetAuthUser GetBaseTagData GetBaseTagList GetBaseTemplatePath ' +
  2152. 'GetClientVariablesList GetComponentMetaData GetContextRoot GetCurrentTemplatePath GetDirectoryFromPath GetEncoding ' +
  2153. 'GetException GetFileFromPath GetFileInfo GetFunctionList GetGatewayHelper GetHttpRequestData GetHttpTimeString ' +
  2154. 'GetK2ServerDocCount GetK2ServerDocCountLimit GetLocale GetLocaleDisplayName GetLocalHostIP GetMetaData GetMetricData ' +
  2155. 'GetPageContext GetPrinterInfo GetProfileSections GetProfileString GetReadableImageFormats GetSOAPRequest GetSOAPRequestHeader ' +
  2156. 'GetSOAPResponse GetSOAPResponseHeader GetTempDirectory GetTempFile GetTemplatePath GetTickCount GetTimeZoneInfo GetToken ' +
  2157. 'GetUserRoles GetWriteableImageFormats Hash Hour HTMLCodeFormat HTMLEditFormat IIf ImageAddBorder ImageBlur ImageClearRect ' +
  2158. 'ImageCopy ImageCrop ImageDrawArc ImageDrawBeveledRect ImageDrawCubicCurve ImageDrawLine ImageDrawLines ImageDrawOval ' +
  2159. 'ImageDrawPoint ImageDrawQuadraticCurve ImageDrawRect ImageDrawRoundRect ImageDrawText ImageFlip ImageGetBlob ImageGetBufferedImage ' +
  2160. 'ImageGetEXIFTag ImageGetHeight ImageGetIPTCTag ImageGetWidth ImageGrayscale ImageInfo ImageNegative ImageNew ImageOverlay ImagePaste ' +
  2161. 'ImageRead ImageReadBase64 ImageResize ImageRotate ImageRotateDrawingAxis ImageScaleToFit ImageSetAntialiasing ImageSetBackgroundColor ' +
  2162. 'ImageSetDrawingColor ImageSetDrawingStroke ImageSetDrawingTransparency ImageSharpen ImageShear ImageShearDrawingAxis ImageTranslate ' +
  2163. 'ImageTranslateDrawingAxis ImageWrite ImageWriteBase64 ImageXORDrawingMode IncrementValue InputBaseN Insert Int IsArray IsBinary ' +
  2164. 'IsBoolean IsCustomFunction IsDate IsDDX IsDebugMode IsDefined IsImage IsImageFile IsInstanceOf IsJSON IsLeapYear IsLocalHost ' +
  2165. 'IsNumeric IsNumericDate IsObject IsPDFFile IsPDFObject IsQuery IsSimpleValue IsSOAPRequest IsStruct IsUserInAnyRole IsUserInRole ' +
  2166. 'IsUserLoggedIn IsValid IsWDDX IsXML IsXmlAttribute IsXmlDoc IsXmlElem IsXmlNode IsXmlRoot JavaCast JSStringFormat LCase Left Len ' +
  2167. 'ListAppend ListChangeDelims ListContains ListContainsNoCase ListDeleteAt ListFind ListFindNoCase ListFirst ListGetAt ListInsertAt ' +
  2168. 'ListLast ListLen ListPrepend ListQualify ListRest ListSetAt ListSort ListToArray ListValueCount ListValueCountNoCase LJustify Log ' +
  2169. 'Log10 LSCurrencyFormat LSDateFormat LSEuroCurrencyFormat LSIsCurrency LSIsDate LSIsNumeric LSNumberFormat LSParseCurrency LSParseDateTime ' +
  2170. 'LSParseEuroCurrency LSParseNumber LSTimeFormat LTrim Max Mid Min Minute Month MonthAsString Now NumberFormat ParagraphFormat ParseDateTime ' +
  2171. 'Pi PrecisionEvaluate PreserveSingleQuotes Quarter QueryAddColumn QueryAddRow QueryConvertForGrid QueryNew QuerySetCell QuotedValueList Rand ' +
  2172. 'Randomize RandRange REFind REFindNoCase ReleaseComObject REMatch REMatchNoCase RemoveChars RepeatString Replace ReplaceList ReplaceNoCase ' +
  2173. 'REReplace REReplaceNoCase Reverse Right RJustify Round RTrim Second SendGatewayMessage SerializeJSON SetEncoding SetLocale SetProfileString ' +
  2174. 'SetVariable Sgn Sin Sleep SpanExcluding SpanIncluding Sqr StripCR StructAppend StructClear StructCopy StructCount StructDelete StructFind ' +
  2175. 'StructFindKey StructFindValue StructGet StructInsert StructIsEmpty StructKeyArray StructKeyExists StructKeyList StructKeyList StructNew ' +
  2176. 'StructSort StructUpdate Tan TimeFormat ToBase64 ToBinary ToScript ToString Trim UCase URLDecode URLEncodedFormat URLSessionFormat Val ' +
  2177. 'ValueList VerifyClient Week Wrap Wrap WriteOutput XmlChildPos XmlElemNew XmlFormat XmlGetNodeType XmlNew XmlParse XmlSearch XmlTransform ' +
  2178. 'XmlValidate Year YesNoFormat';
  2179. var keywords = 'cfabort cfajaximport cfajaxproxy cfapplet cfapplication cfargument cfassociate cfbreak cfcache cfcalendar ' +
  2180. 'cfcase cfcatch cfchart cfchartdata cfchartseries cfcol cfcollection cfcomponent cfcontent cfcookie cfdbinfo ' +
  2181. 'cfdefaultcase cfdirectory cfdiv cfdocument cfdocumentitem cfdocumentsection cfdump cfelse cfelseif cferror ' +
  2182. 'cfexchangecalendar cfexchangeconnection cfexchangecontact cfexchangefilter cfexchangemail cfexchangetask ' +
  2183. 'cfexecute cfexit cffeed cffile cfflush cfform cfformgroup cfformitem cfftp cffunction cfgrid cfgridcolumn ' +
  2184. 'cfgridrow cfgridupdate cfheader cfhtmlhead cfhttp cfhttpparam cfif cfimage cfimport cfinclude cfindex ' +
  2185. 'cfinput cfinsert cfinterface cfinvoke cfinvokeargument cflayout cflayoutarea cfldap cflocation cflock cflog ' +
  2186. 'cflogin cfloginuser cflogout cfloop cfmail cfmailparam cfmailpart cfmenu cfmenuitem cfmodule cfNTauthenticate ' +
  2187. 'cfobject cfobjectcache cfoutput cfparam cfpdf cfpdfform cfpdfformparam cfpdfparam cfpdfsubform cfpod cfpop ' +
  2188. 'cfpresentation cfpresentationslide cfpresenter cfprint cfprocessingdirective cfprocparam cfprocresult ' +
  2189. 'cfproperty cfquery cfqueryparam cfregistry cfreport cfreportparam cfrethrow cfreturn cfsavecontent cfschedule ' +
  2190. 'cfscript cfsearch cfselect cfset cfsetting cfsilent cfslider cfsprydataset cfstoredproc cfswitch cftable ' +
  2191. 'cftextarea cfthread cfthrow cftimer cftooltip cftrace cftransaction cftree cftreeitem cftry cfupdate cfwddx ' +
  2192. 'cfwindow cfxml cfzip cfzipparam';
  2193. var operators = 'all and any between cross in join like not null or outer some';
  2194. this.regexList = [
  2195. { regex: new RegExp('--(.*)$', 'gm'), css: 'comments' }, // one line and multiline comments
  2196. { regex: SyntaxHighlighter.regexLib.xmlComments, css: 'comments' }, // single quoted strings
  2197. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
  2198. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
  2199. { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' }, // functions
  2200. { regex: new RegExp(this.getKeywords(operators), 'gmi'), css: 'color1' }, // operators and such
  2201. { regex: new RegExp(this.getKeywords(keywords), 'gmi'), css: 'keyword' } // keyword
  2202. ];
  2203. }
  2204. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2205. Brush.aliases = ['coldfusion','cf'];
  2206. SyntaxHighlighter.brushes.ColdFusion = Brush;
  2207. // CommonJS
  2208. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2209. })();
  2210. ;(function()
  2211. {
  2212. // CommonJS
  2213. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2214. function Brush()
  2215. {
  2216. // Copyright 2006 Shin, YoungJin
  2217. var datatypes = 'ATOM BOOL BOOLEAN BYTE CHAR COLORREF DWORD DWORDLONG DWORD_PTR ' +
  2218. 'DWORD32 DWORD64 FLOAT HACCEL HALF_PTR HANDLE HBITMAP HBRUSH ' +
  2219. 'HCOLORSPACE HCONV HCONVLIST HCURSOR HDC HDDEDATA HDESK HDROP HDWP ' +
  2220. 'HENHMETAFILE HFILE HFONT HGDIOBJ HGLOBAL HHOOK HICON HINSTANCE HKEY ' +
  2221. 'HKL HLOCAL HMENU HMETAFILE HMODULE HMONITOR HPALETTE HPEN HRESULT ' +
  2222. 'HRGN HRSRC HSZ HWINSTA HWND INT INT_PTR INT32 INT64 LANGID LCID LCTYPE ' +
  2223. 'LGRPID LONG LONGLONG LONG_PTR LONG32 LONG64 LPARAM LPBOOL LPBYTE LPCOLORREF ' +
  2224. 'LPCSTR LPCTSTR LPCVOID LPCWSTR LPDWORD LPHANDLE LPINT LPLONG LPSTR LPTSTR ' +
  2225. 'LPVOID LPWORD LPWSTR LRESULT PBOOL PBOOLEAN PBYTE PCHAR PCSTR PCTSTR PCWSTR ' +
  2226. 'PDWORDLONG PDWORD_PTR PDWORD32 PDWORD64 PFLOAT PHALF_PTR PHANDLE PHKEY PINT ' +
  2227. 'PINT_PTR PINT32 PINT64 PLCID PLONG PLONGLONG PLONG_PTR PLONG32 PLONG64 POINTER_32 ' +
  2228. 'POINTER_64 PSHORT PSIZE_T PSSIZE_T PSTR PTBYTE PTCHAR PTSTR PUCHAR PUHALF_PTR ' +
  2229. 'PUINT PUINT_PTR PUINT32 PUINT64 PULONG PULONGLONG PULONG_PTR PULONG32 PULONG64 ' +
  2230. 'PUSHORT PVOID PWCHAR PWORD PWSTR SC_HANDLE SC_LOCK SERVICE_STATUS_HANDLE SHORT ' +
  2231. 'SIZE_T SSIZE_T TBYTE TCHAR UCHAR UHALF_PTR UINT UINT_PTR UINT32 UINT64 ULONG ' +
  2232. 'ULONGLONG ULONG_PTR ULONG32 ULONG64 USHORT USN VOID WCHAR WORD WPARAM WPARAM WPARAM ' +
  2233. 'char bool short int __int32 __int64 __int8 __int16 long float double __wchar_t ' +
  2234. 'clock_t _complex _dev_t _diskfree_t div_t ldiv_t _exception _EXCEPTION_POINTERS ' +
  2235. 'FILE _finddata_t _finddatai64_t _wfinddata_t _wfinddatai64_t __finddata64_t ' +
  2236. '__wfinddata64_t _FPIEEE_RECORD fpos_t _HEAPINFO _HFILE lconv intptr_t ' +
  2237. 'jmp_buf mbstate_t _off_t _onexit_t _PNH ptrdiff_t _purecall_handler ' +
  2238. 'sig_atomic_t size_t _stat __stat64 _stati64 terminate_function ' +
  2239. 'time_t __time64_t _timeb __timeb64 tm uintptr_t _utimbuf ' +
  2240. 'va_list wchar_t wctrans_t wctype_t wint_t signed';
  2241. var keywords = 'auto break case catch class const decltype __finally __exception __try ' +
  2242. 'const_cast continue private public protected __declspec ' +
  2243. 'default delete deprecated dllexport dllimport do dynamic_cast ' +
  2244. 'else enum explicit extern if for friend goto inline ' +
  2245. 'mutable naked namespace new noinline noreturn nothrow ' +
  2246. 'register reinterpret_cast return selectany ' +
  2247. 'sizeof static static_cast struct switch template this ' +
  2248. 'thread throw true false try typedef typeid typename union ' +
  2249. 'using uuid virtual void volatile whcar_t while';
  2250. var functions = 'assert isalnum isalpha iscntrl isdigit isgraph islower isprint' +
  2251. 'ispunct isspace isupper isxdigit tolower toupper errno localeconv ' +
  2252. 'setlocale acos asin atan atan2 ceil cos cosh exp fabs floor fmod ' +
  2253. 'frexp ldexp log log10 modf pow sin sinh sqrt tan tanh jmp_buf ' +
  2254. 'longjmp setjmp raise signal sig_atomic_t va_arg va_end va_start ' +
  2255. 'clearerr fclose feof ferror fflush fgetc fgetpos fgets fopen ' +
  2256. 'fprintf fputc fputs fread freopen fscanf fseek fsetpos ftell ' +
  2257. 'fwrite getc getchar gets perror printf putc putchar puts remove ' +
  2258. 'rename rewind scanf setbuf setvbuf sprintf sscanf tmpfile tmpnam ' +
  2259. 'ungetc vfprintf vprintf vsprintf abort abs atexit atof atoi atol ' +
  2260. 'bsearch calloc div exit free getenv labs ldiv malloc mblen mbstowcs ' +
  2261. 'mbtowc qsort rand realloc srand strtod strtol strtoul system ' +
  2262. 'wcstombs wctomb memchr memcmp memcpy memmove memset strcat strchr ' +
  2263. 'strcmp strcoll strcpy strcspn strerror strlen strncat strncmp ' +
  2264. 'strncpy strpbrk strrchr strspn strstr strtok strxfrm asctime ' +
  2265. 'clock ctime difftime gmtime localtime mktime strftime time';
  2266. this.regexList = [
  2267. { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
  2268. { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
  2269. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
  2270. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
  2271. { regex: /^ *#.*/gm, css: 'preprocessor' },
  2272. { regex: new RegExp(this.getKeywords(datatypes), 'gm'), css: 'color1 bold' },
  2273. { regex: new RegExp(this.getKeywords(functions), 'gm'), css: 'functions bold' },
  2274. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword bold' }
  2275. ];
  2276. };
  2277. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2278. Brush.aliases = ['cpp', 'c'];
  2279. SyntaxHighlighter.brushes.Cpp = Brush;
  2280. // CommonJS
  2281. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2282. })();
  2283. ;(function()
  2284. {
  2285. // CommonJS
  2286. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2287. function Brush()
  2288. {
  2289. var keywords = 'abstract as base bool break byte case catch char checked class const ' +
  2290. 'continue decimal default delegate do double else enum event explicit volatile ' +
  2291. 'extern false finally fixed float for foreach get goto if implicit in int ' +
  2292. 'interface internal is lock long namespace new null object operator out ' +
  2293. 'override params private protected public readonly ref return sbyte sealed set ' +
  2294. 'short sizeof stackalloc static string struct switch this throw true try ' +
  2295. 'typeof uint ulong unchecked unsafe ushort using virtual void while var ' +
  2296. 'from group by into select let where orderby join on equals ascending descending';
  2297. function fixComments(match, regexInfo)
  2298. {
  2299. var css = (match[0].indexOf("///") == 0)
  2300. ? 'color1'
  2301. : 'comments'
  2302. ;
  2303. return [new SyntaxHighlighter.Match(match[0], match.index, css)];
  2304. }
  2305. this.regexList = [
  2306. { regex: SyntaxHighlighter.regexLib.singleLineCComments, func : fixComments }, // one line comments
  2307. { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
  2308. { regex: /@"(?:[^"]|"")*"/g, css: 'string' }, // @-quoted strings
  2309. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
  2310. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
  2311. { regex: /^\s*#.*/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion
  2312. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // c# keyword
  2313. { regex: /\bpartial(?=\s+(?:class|interface|struct)\b)/g, css: 'keyword' }, // contextual keyword: 'partial'
  2314. { regex: /\byield(?=\s+(?:return|break)\b)/g, css: 'keyword' } // contextual keyword: 'yield'
  2315. ];
  2316. this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
  2317. };
  2318. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2319. Brush.aliases = ['c#', 'c-sharp', 'csharp'];
  2320. SyntaxHighlighter.brushes.CSharp = Brush;
  2321. // CommonJS
  2322. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2323. })();
  2324. ;(function()
  2325. {
  2326. // CommonJS
  2327. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2328. function Brush()
  2329. {
  2330. function getKeywordsCSS(str)
  2331. {
  2332. return '\\b([a-z_]|)' + str.replace(/ /g, '(?=:)\\b|\\b([a-z_\\*]|\\*|)') + '(?=:)\\b';
  2333. };
  2334. function getValuesCSS(str)
  2335. {
  2336. return '\\b' + str.replace(/ /g, '(?!-)(?!:)\\b|\\b()') + '\:\\b';
  2337. };
  2338. var keywords = 'ascent azimuth background-attachment background-color background-image background-position ' +
  2339. 'background-repeat background baseline bbox border-collapse border-color border-spacing border-style border-top ' +
  2340. 'border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color ' +
  2341. 'border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width ' +
  2342. 'border-bottom-width border-left-width border-width border bottom cap-height caption-side centerline clear clip color ' +
  2343. 'content counter-increment counter-reset cue-after cue-before cue cursor definition-src descent direction display ' +
  2344. 'elevation empty-cells float font-size-adjust font-family font-size font-stretch font-style font-variant font-weight font ' +
  2345. 'height left letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-top ' +
  2346. 'margin-right margin-bottom margin-left margin marker-offset marks mathline max-height max-width min-height min-width orphans ' +
  2347. 'outline-color outline-style outline-width outline overflow padding-top padding-right padding-bottom padding-left padding page ' +
  2348. 'page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position ' +
  2349. 'quotes right richness size slope src speak-header speak-numeral speak-punctuation speak speech-rate stemh stemv stress ' +
  2350. 'table-layout text-align top text-decoration text-indent text-shadow text-transform unicode-bidi unicode-range units-per-em ' +
  2351. 'vertical-align visibility voice-family volume white-space widows width widths word-spacing x-height z-index';
  2352. var values = 'above absolute all always aqua armenian attr aural auto avoid baseline behind below bidi-override black blink block blue bold bolder '+
  2353. 'both bottom braille capitalize caption center center-left center-right circle close-quote code collapse compact condensed '+
  2354. 'continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero default digits disc dotted double '+
  2355. 'embed embossed e-resize expanded extra-condensed extra-expanded fantasy far-left far-right fast faster fixed format fuchsia '+
  2356. 'gray green groove handheld hebrew help hidden hide high higher icon inline-table inline inset inside invert italic '+
  2357. 'justify landscape large larger left-side left leftwards level lighter lime line-through list-item local loud lower-alpha '+
  2358. 'lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower '+
  2359. 'navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once open-quote outset '+
  2360. 'outside overline pointer portrait pre print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side '+
  2361. 'rightwards rtl run-in screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow '+
  2362. 'small small-caps small-caption smaller soft solid speech spell-out square s-resize static status-bar sub super sw-resize '+
  2363. 'table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group teal '+
  2364. 'text-bottom text-top thick thin top transparent tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin '+
  2365. 'upper-roman url visible wait white wider w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow';
  2366. var fonts = '[mM]onospace [tT]ahoma [vV]erdana [aA]rial [hH]elvetica [sS]ans-serif [sS]erif [cC]ourier mono sans serif';
  2367. this.regexList = [
  2368. { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
  2369. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
  2370. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
  2371. { regex: /\#[a-fA-F0-9]{3,6}/g, css: 'value' }, // html colors
  2372. { regex: /(-?\d+)(\.\d+)?(px|em|pt|\:|\%|)/g, css: 'value' }, // sizes
  2373. { regex: /!important/g, css: 'color3' }, // !important
  2374. { regex: new RegExp(getKeywordsCSS(keywords), 'gm'), css: 'keyword' }, // keywords
  2375. { regex: new RegExp(getValuesCSS(values), 'g'), css: 'value' }, // values
  2376. { regex: new RegExp(this.getKeywords(fonts), 'g'), css: 'color1' } // fonts
  2377. ];
  2378. this.forHtmlScript({
  2379. left: /(&lt;|<)\s*style.*?(&gt;|>)/gi,
  2380. right: /(&lt;|<)\/\s*style\s*(&gt;|>)/gi
  2381. });
  2382. };
  2383. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2384. Brush.aliases = ['css'];
  2385. SyntaxHighlighter.brushes.CSS = Brush;
  2386. // CommonJS
  2387. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2388. })();
  2389. ;(function()
  2390. {
  2391. // CommonJS
  2392. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2393. function Brush()
  2394. {
  2395. var keywords = 'abs addr and ansichar ansistring array as asm begin boolean byte cardinal ' +
  2396. 'case char class comp const constructor currency destructor div do double ' +
  2397. 'downto else end except exports extended false file finalization finally ' +
  2398. 'for function goto if implementation in inherited int64 initialization ' +
  2399. 'integer interface is label library longint longword mod nil not object ' +
  2400. 'of on or packed pansichar pansistring pchar pcurrency pdatetime pextended ' +
  2401. 'pint64 pointer private procedure program property pshortstring pstring ' +
  2402. 'pvariant pwidechar pwidestring protected public published raise real real48 ' +
  2403. 'record repeat set shl shortint shortstring shr single smallint string then ' +
  2404. 'threadvar to true try type unit until uses val var varirnt while widechar ' +
  2405. 'widestring with word write writeln xor';
  2406. this.regexList = [
  2407. { regex: /\(\*[\s\S]*?\*\)/gm, css: 'comments' }, // multiline comments (* *)
  2408. { regex: /{(?!\$)[\s\S]*?}/gm, css: 'comments' }, // multiline comments { }
  2409. { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line
  2410. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
  2411. { regex: /\{\$[a-zA-Z]+ .+\}/g, css: 'color1' }, // compiler Directives and Region tags
  2412. { regex: /\b[\d\.]+\b/g, css: 'value' }, // numbers 12345
  2413. { regex: /\$[a-zA-Z0-9]+\b/g, css: 'value' }, // numbers $F5D3
  2414. { regex: new RegExp(this.getKeywords(keywords), 'gmi'), css: 'keyword' } // keyword
  2415. ];
  2416. };
  2417. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2418. Brush.aliases = ['delphi', 'pascal', 'pas'];
  2419. SyntaxHighlighter.brushes.Delphi = Brush;
  2420. // CommonJS
  2421. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2422. })();
  2423. ;(function()
  2424. {
  2425. // CommonJS
  2426. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2427. function Brush()
  2428. {
  2429. this.regexList = [
  2430. { regex: /^\+\+\+ .*$/gm, css: 'color2' }, // new file
  2431. { regex: /^\-\-\- .*$/gm, css: 'color2' }, // old file
  2432. { regex: /^\s.*$/gm, css: 'color1' }, // unchanged
  2433. { regex: /^@@.*@@.*$/gm, css: 'variable' }, // location
  2434. { regex: /^\+.*$/gm, css: 'string' }, // additions
  2435. { regex: /^\-.*$/gm, css: 'color3' } // deletions
  2436. ];
  2437. };
  2438. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2439. Brush.aliases = ['diff', 'patch'];
  2440. SyntaxHighlighter.brushes.Diff = Brush;
  2441. // CommonJS
  2442. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2443. })();
  2444. ;(function()
  2445. {
  2446. // CommonJS
  2447. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2448. function Brush()
  2449. {
  2450. // Contributed by Jean-Lou Dupont
  2451. // http://jldupont.blogspot.com/2009/06/erlang-syntax-highlighter.html
  2452. // According to: http://erlang.org/doc/reference_manual/introduction.html#1.5
  2453. var keywords = 'after and andalso band begin bnot bor bsl bsr bxor '+
  2454. 'case catch cond div end fun if let not of or orelse '+
  2455. 'query receive rem try when xor'+
  2456. // additional
  2457. ' module export import define';
  2458. this.regexList = [
  2459. { regex: new RegExp("[A-Z][A-Za-z0-9_]+", 'g'), css: 'constants' },
  2460. { regex: new RegExp("\\%.+", 'gm'), css: 'comments' },
  2461. { regex: new RegExp("\\?[A-Za-z0-9_]+", 'g'), css: 'preprocessor' },
  2462. { regex: new RegExp("[a-z0-9_]+:[a-z0-9_]+", 'g'), css: 'functions' },
  2463. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' },
  2464. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' },
  2465. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }
  2466. ];
  2467. };
  2468. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2469. Brush.aliases = ['erl', 'erlang'];
  2470. SyntaxHighlighter.brushes.Erland = Brush;
  2471. // CommonJS
  2472. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2473. })();
  2474. ;(function()
  2475. {
  2476. // CommonJS
  2477. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2478. function Brush()
  2479. {
  2480. // Contributed by Andres Almiray
  2481. // http://jroller.com/aalmiray/entry/nice_source_code_syntax_highlighter
  2482. var keywords = 'as assert break case catch class continue def default do else extends finally ' +
  2483. 'if in implements import instanceof interface new package property return switch ' +
  2484. 'throw throws try while public protected private static';
  2485. var types = 'void boolean byte char short int long float double';
  2486. var constants = 'null';
  2487. var methods = 'allProperties count get size '+
  2488. 'collect each eachProperty eachPropertyName eachWithIndex find findAll ' +
  2489. 'findIndexOf grep inject max min reverseEach sort ' +
  2490. 'asImmutable asSynchronized flatten intersect join pop reverse subMap toList ' +
  2491. 'padRight padLeft contains eachMatch toCharacter toLong toUrl tokenize ' +
  2492. 'eachFile eachFileRecurse eachB yte eachLine readBytes readLine getText ' +
  2493. 'splitEachLine withReader append encodeBase64 decodeBase64 filterLine ' +
  2494. 'transformChar transformLine withOutputStream withPrintWriter withStream ' +
  2495. 'withStreams withWriter withWriterAppend write writeLine '+
  2496. 'dump inspect invokeMethod print println step times upto use waitForOrKill '+
  2497. 'getText';
  2498. this.regexList = [
  2499. { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
  2500. { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
  2501. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
  2502. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
  2503. { regex: /""".*"""/g, css: 'string' }, // GStrings
  2504. { regex: new RegExp('\\b([\\d]+(\\.[\\d]+)?|0x[a-f0-9]+)\\b', 'gi'), css: 'value' }, // numbers
  2505. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // goovy keyword
  2506. { regex: new RegExp(this.getKeywords(types), 'gm'), css: 'color1' }, // goovy/java type
  2507. { regex: new RegExp(this.getKeywords(constants), 'gm'), css: 'constants' }, // constants
  2508. { regex: new RegExp(this.getKeywords(methods), 'gm'), css: 'functions' } // methods
  2509. ];
  2510. this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
  2511. }
  2512. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2513. Brush.aliases = ['groovy'];
  2514. SyntaxHighlighter.brushes.Groovy = Brush;
  2515. // CommonJS
  2516. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2517. })();
  2518. ;(function()
  2519. {
  2520. // CommonJS
  2521. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2522. function Brush()
  2523. {
  2524. var keywords = 'abstract assert boolean break byte case catch char class const ' +
  2525. 'continue default do double else enum extends ' +
  2526. 'false final finally float for goto if implements import ' +
  2527. 'instanceof int interface long native new null ' +
  2528. 'package private protected public return ' +
  2529. 'short static strictfp super switch synchronized this throw throws true ' +
  2530. 'transient try void volatile while';
  2531. this.regexList = [
  2532. { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
  2533. { regex: /\/\*([^\*][\s\S]*)?\*\//gm, css: 'comments' }, // multiline comments
  2534. { regex: /\/\*(?!\*\/)\*[\s\S]*?\*\//gm, css: 'preprocessor' }, // documentation comments
  2535. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
  2536. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
  2537. { regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi, css: 'value' }, // numbers
  2538. { regex: /(?!\@interface\b)\@[\$\w]+\b/g, css: 'color1' }, // annotation @anno
  2539. { regex: /\@interface\b/g, css: 'color2' }, // @interface keyword
  2540. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // java keyword
  2541. ];
  2542. this.forHtmlScript({
  2543. left : /(&lt;|<)%[@!=]?/g,
  2544. right : /%(&gt;|>)/g
  2545. });
  2546. };
  2547. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2548. Brush.aliases = ['java'];
  2549. SyntaxHighlighter.brushes.Java = Brush;
  2550. // CommonJS
  2551. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2552. })();
  2553. ;(function()
  2554. {
  2555. // CommonJS
  2556. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2557. function Brush()
  2558. {
  2559. // Contributed by Patrick Webster
  2560. // http://patrickwebster.blogspot.com/2009/04/javafx-brush-for-syntaxhighlighter.html
  2561. var datatypes = 'Boolean Byte Character Double Duration '
  2562. + 'Float Integer Long Number Short String Void'
  2563. ;
  2564. var keywords = 'abstract after and as assert at before bind bound break catch class '
  2565. + 'continue def delete else exclusive extends false finally first for from '
  2566. + 'function if import in indexof init insert instanceof into inverse last '
  2567. + 'lazy mixin mod nativearray new not null on or override package postinit '
  2568. + 'protected public public-init public-read replace return reverse sizeof '
  2569. + 'step super then this throw true try tween typeof var where while with '
  2570. + 'attribute let private readonly static trigger'
  2571. ;
  2572. this.regexList = [
  2573. { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' },
  2574. { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' },
  2575. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' },
  2576. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' },
  2577. { regex: /(-?\.?)(\b(\d*\.?\d+|\d+\.?\d*)(e[+-]?\d+)?|0x[a-f\d]+)\b\.?/gi, css: 'color2' }, // numbers
  2578. { regex: new RegExp(this.getKeywords(datatypes), 'gm'), css: 'variable' }, // datatypes
  2579. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }
  2580. ];
  2581. this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
  2582. };
  2583. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2584. Brush.aliases = ['jfx', 'javafx'];
  2585. SyntaxHighlighter.brushes.JavaFX = Brush;
  2586. // CommonJS
  2587. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2588. })();
  2589. ;(function()
  2590. {
  2591. // CommonJS
  2592. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2593. function Brush()
  2594. {
  2595. var keywords = 'break case catch continue ' +
  2596. 'default delete do else false ' +
  2597. 'for function if in instanceof ' +
  2598. 'new null return super switch ' +
  2599. 'this throw true try typeof var while with'
  2600. ;
  2601. var r = SyntaxHighlighter.regexLib;
  2602. this.regexList = [
  2603. { regex: r.multiLineDoubleQuotedString, css: 'string' }, // double quoted strings
  2604. { regex: r.multiLineSingleQuotedString, css: 'string' }, // single quoted strings
  2605. { regex: r.singleLineCComments, css: 'comments' }, // one line comments
  2606. { regex: r.multiLineCComments, css: 'comments' }, // multiline comments
  2607. { regex: /\s*#.*/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion
  2608. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // keywords
  2609. ];
  2610. this.forHtmlScript(r.scriptScriptTags);
  2611. };
  2612. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2613. Brush.aliases = ['js', 'jscript', 'javascript'];
  2614. SyntaxHighlighter.brushes.JScript = Brush;
  2615. // CommonJS
  2616. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2617. })();
  2618. ;(function()
  2619. {
  2620. // CommonJS
  2621. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2622. function Brush()
  2623. {
  2624. // Contributed by David Simmons-Duffin and Marty Kube
  2625. var funcs =
  2626. 'abs accept alarm atan2 bind binmode chdir chmod chomp chop chown chr ' +
  2627. 'chroot close closedir connect cos crypt defined delete each endgrent ' +
  2628. 'endhostent endnetent endprotoent endpwent endservent eof exec exists ' +
  2629. 'exp fcntl fileno flock fork format formline getc getgrent getgrgid ' +
  2630. 'getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr ' +
  2631. 'getnetbyname getnetent getpeername getpgrp getppid getpriority ' +
  2632. 'getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid ' +
  2633. 'getservbyname getservbyport getservent getsockname getsockopt glob ' +
  2634. 'gmtime grep hex index int ioctl join keys kill lc lcfirst length link ' +
  2635. 'listen localtime lock log lstat map mkdir msgctl msgget msgrcv msgsnd ' +
  2636. 'oct open opendir ord pack pipe pop pos print printf prototype push ' +
  2637. 'quotemeta rand read readdir readline readlink readpipe recv rename ' +
  2638. 'reset reverse rewinddir rindex rmdir scalar seek seekdir select semctl ' +
  2639. 'semget semop send setgrent sethostent setnetent setpgrp setpriority ' +
  2640. 'setprotoent setpwent setservent setsockopt shift shmctl shmget shmread ' +
  2641. 'shmwrite shutdown sin sleep socket socketpair sort splice split sprintf ' +
  2642. 'sqrt srand stat study substr symlink syscall sysopen sysread sysseek ' +
  2643. 'system syswrite tell telldir time times tr truncate uc ucfirst umask ' +
  2644. 'undef unlink unpack unshift utime values vec wait waitpid warn write ' +
  2645. // feature
  2646. 'say';
  2647. var keywords =
  2648. 'bless caller continue dbmclose dbmopen die do dump else elsif eval exit ' +
  2649. 'for foreach goto if import last local my next no our package redo ref ' +
  2650. 'require return sub tie tied unless untie until use wantarray while ' +
  2651. // feature
  2652. 'given when default ' +
  2653. // Try::Tiny
  2654. 'try catch finally ' +
  2655. // Moose
  2656. 'has extends with before after around override augment';
  2657. this.regexList = [
  2658. { regex: /(<<|&lt;&lt;)((\w+)|(['"])(.+?)\4)[\s\S]+?\n\3\5\n/g, css: 'string' }, // here doc (maybe html encoded)
  2659. { regex: /#.*$/gm, css: 'comments' },
  2660. { regex: /^#!.*\n/g, css: 'preprocessor' }, // shebang
  2661. { regex: /-?\w+(?=\s*=(>|&gt;))/g, css: 'string' }, // fat comma
  2662. // is this too much?
  2663. { regex: /\bq[qwxr]?\([\s\S]*?\)/g, css: 'string' }, // quote-like operators ()
  2664. { regex: /\bq[qwxr]?\{[\s\S]*?\}/g, css: 'string' }, // quote-like operators {}
  2665. { regex: /\bq[qwxr]?\[[\s\S]*?\]/g, css: 'string' }, // quote-like operators []
  2666. { regex: /\bq[qwxr]?(<|&lt;)[\s\S]*?(>|&gt;)/g, css: 'string' }, // quote-like operators <>
  2667. { regex: /\bq[qwxr]?([^\w({<[])[\s\S]*?\1/g, css: 'string' }, // quote-like operators non-paired
  2668. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' },
  2669. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' },
  2670. // currently ignoring single quote package separator and utf8 names
  2671. { regex: /(?:&amp;|[$@%*]|\$#)[a-zA-Z_](\w+|::)*/g, css: 'variable' },
  2672. { regex: /\b__(?:END|DATA)__\b[\s\S]*$/g, css: 'comments' },
  2673. { regex: /(^|\n)=\w[\s\S]*?(\n=cut\s*\n|$)/g, css: 'comments' }, // pod
  2674. { regex: new RegExp(this.getKeywords(funcs), 'gm'), css: 'functions' },
  2675. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }
  2676. ];
  2677. this.forHtmlScript(SyntaxHighlighter.regexLib.phpScriptTags);
  2678. }
  2679. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2680. Brush.aliases = ['perl', 'Perl', 'pl'];
  2681. SyntaxHighlighter.brushes.Perl = Brush;
  2682. // CommonJS
  2683. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2684. })();
  2685. ;(function()
  2686. {
  2687. // CommonJS
  2688. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2689. function Brush()
  2690. {
  2691. var funcs = 'abs acos acosh addcslashes addslashes ' +
  2692. 'array_change_key_case array_chunk array_combine array_count_values array_diff '+
  2693. 'array_diff_assoc array_diff_key array_diff_uassoc array_diff_ukey array_fill '+
  2694. 'array_filter array_flip array_intersect array_intersect_assoc array_intersect_key '+
  2695. 'array_intersect_uassoc array_intersect_ukey array_key_exists array_keys array_map '+
  2696. 'array_merge array_merge_recursive array_multisort array_pad array_pop array_product '+
  2697. 'array_push array_rand array_reduce array_reverse array_search array_shift '+
  2698. 'array_slice array_splice array_sum array_udiff array_udiff_assoc '+
  2699. 'array_udiff_uassoc array_uintersect array_uintersect_assoc '+
  2700. 'array_uintersect_uassoc array_unique array_unshift array_values array_walk '+
  2701. 'array_walk_recursive atan atan2 atanh base64_decode base64_encode base_convert '+
  2702. 'basename bcadd bccomp bcdiv bcmod bcmul bindec bindtextdomain bzclose bzcompress '+
  2703. 'bzdecompress bzerrno bzerror bzerrstr bzflush bzopen bzread bzwrite ceil chdir '+
  2704. 'checkdate checkdnsrr chgrp chmod chop chown chr chroot chunk_split class_exists '+
  2705. 'closedir closelog copy cos cosh count count_chars date decbin dechex decoct '+
  2706. 'deg2rad delete ebcdic2ascii echo empty end ereg ereg_replace eregi eregi_replace error_log '+
  2707. 'error_reporting escapeshellarg escapeshellcmd eval exec exit exp explode extension_loaded '+
  2708. 'feof fflush fgetc fgetcsv fgets fgetss file_exists file_get_contents file_put_contents '+
  2709. 'fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype '+
  2710. 'floatval flock floor flush fmod fnmatch fopen fpassthru fprintf fputcsv fputs fread fscanf '+
  2711. 'fseek fsockopen fstat ftell ftok getallheaders getcwd getdate getenv gethostbyaddr gethostbyname '+
  2712. 'gethostbynamel getimagesize getlastmod getmxrr getmygid getmyinode getmypid getmyuid getopt '+
  2713. 'getprotobyname getprotobynumber getrandmax getrusage getservbyname getservbyport gettext '+
  2714. 'gettimeofday gettype glob gmdate gmmktime ini_alter ini_get ini_get_all ini_restore ini_set '+
  2715. 'interface_exists intval ip2long is_a is_array is_bool is_callable is_dir is_double '+
  2716. 'is_executable is_file is_finite is_float is_infinite is_int is_integer is_link is_long '+
  2717. 'is_nan is_null is_numeric is_object is_readable is_real is_resource is_scalar is_soap_fault '+
  2718. 'is_string is_subclass_of is_uploaded_file is_writable is_writeable mkdir mktime nl2br '+
  2719. 'parse_ini_file parse_str parse_url passthru pathinfo print readlink realpath rewind rewinddir rmdir '+
  2720. 'round str_ireplace str_pad str_repeat str_replace str_rot13 str_shuffle str_split '+
  2721. 'str_word_count strcasecmp strchr strcmp strcoll strcspn strftime strip_tags stripcslashes '+
  2722. 'stripos stripslashes stristr strlen strnatcasecmp strnatcmp strncasecmp strncmp strpbrk '+
  2723. 'strpos strptime strrchr strrev strripos strrpos strspn strstr strtok strtolower strtotime '+
  2724. 'strtoupper strtr strval substr substr_compare';
  2725. var keywords = 'abstract and array as break case catch cfunction class clone const continue declare default die do ' +
  2726. 'else elseif enddeclare endfor endforeach endif endswitch endwhile extends final for foreach ' +
  2727. 'function global goto if implements include include_once interface instanceof insteadof namespace new ' +
  2728. 'old_function or private protected public return require require_once static switch ' +
  2729. 'trait throw try use var while xor ';
  2730. var constants = '__FILE__ __LINE__ __METHOD__ __FUNCTION__ __CLASS__';
  2731. this.regexList = [
  2732. { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
  2733. { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
  2734. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
  2735. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
  2736. { regex: /\$\w+/g, css: 'variable' }, // variables
  2737. { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' }, // common functions
  2738. { regex: new RegExp(this.getKeywords(constants), 'gmi'), css: 'constants' }, // constants
  2739. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // keyword
  2740. ];
  2741. this.forHtmlScript(SyntaxHighlighter.regexLib.phpScriptTags);
  2742. };
  2743. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2744. Brush.aliases = ['php'];
  2745. SyntaxHighlighter.brushes.Php = Brush;
  2746. // CommonJS
  2747. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2748. })();
  2749. ;(function()
  2750. {
  2751. // CommonJS
  2752. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2753. function Brush()
  2754. {
  2755. };
  2756. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2757. Brush.aliases = ['text', 'plain'];
  2758. SyntaxHighlighter.brushes.Plain = Brush;
  2759. // CommonJS
  2760. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2761. })();
  2762. ;(function()
  2763. {
  2764. // CommonJS
  2765. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2766. function Brush()
  2767. {
  2768. // Contributed by Joel 'Jaykul' Bennett, http://PoshCode.org | http://HuddledMasses.org
  2769. var keywords = 'while validateset validaterange validatepattern validatelength validatecount ' +
  2770. 'until trap switch return ref process param parameter in if global: '+
  2771. 'function foreach for finally filter end elseif else dynamicparam do default ' +
  2772. 'continue cmdletbinding break begin alias \\? % #script #private #local #global '+
  2773. 'mandatory parametersetname position valuefrompipeline ' +
  2774. 'valuefrompipelinebypropertyname valuefromremainingarguments helpmessage ';
  2775. var operators = ' and as band bnot bor bxor casesensitive ccontains ceq cge cgt cle ' +
  2776. 'clike clt cmatch cne cnotcontains cnotlike cnotmatch contains ' +
  2777. 'creplace eq exact f file ge gt icontains ieq ige igt ile ilike ilt ' +
  2778. 'imatch ine inotcontains inotlike inotmatch ireplace is isnot le like ' +
  2779. 'lt match ne not notcontains notlike notmatch or regex replace wildcard';
  2780. var verbs = 'write where wait use update unregister undo trace test tee take suspend ' +
  2781. 'stop start split sort skip show set send select scroll resume restore ' +
  2782. 'restart resolve resize reset rename remove register receive read push ' +
  2783. 'pop ping out new move measure limit join invoke import group get format ' +
  2784. 'foreach export expand exit enter enable disconnect disable debug cxnew ' +
  2785. 'copy convertto convertfrom convert connect complete compare clear ' +
  2786. 'checkpoint aggregate add';
  2787. // I can't find a way to match the comment based help in multi-line comments, because SH won't highlight in highlights, and javascript doesn't support lookbehind
  2788. var commenthelp = ' component description example externalhelp forwardhelpcategory forwardhelptargetname forwardhelptargetname functionality inputs link notes outputs parameter remotehelprunspace role synopsis';
  2789. this.regexList = [
  2790. { regex: new RegExp('^\\s*#[#\\s]*\\.('+this.getKeywords(commenthelp)+').*$', 'gim'), css: 'preprocessor help bold' }, // comment-based help
  2791. { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, // one line comments
  2792. { regex: /(&lt;|<)#[\s\S]*?#(&gt;|>)/gm, css: 'comments here' }, // multi-line comments
  2793. { regex: new RegExp('@"\\n[\\s\\S]*?\\n"@', 'gm'), css: 'script string here' }, // double quoted here-strings
  2794. { regex: new RegExp("@'\\n[\\s\\S]*?\\n'@", 'gm'), css: 'script string single here' }, // single quoted here-strings
  2795. { regex: new RegExp('"(?:\\$\\([^\\)]*\\)|[^"]|`"|"")*[^`]"','g'), css: 'string' }, // double quoted strings
  2796. { regex: new RegExp("'(?:[^']|'')*'", 'g'), css: 'string single' }, // single quoted strings
  2797. { regex: new RegExp('[\\$|@|@@](?:(?:global|script|private|env):)?[A-Z0-9_]+', 'gi'), css: 'variable' }, // $variables
  2798. { regex: new RegExp('(?:\\b'+verbs.replace(/ /g, '\\b|\\b')+')-[a-zA-Z_][a-zA-Z0-9_]*', 'gmi'), css: 'functions' }, // functions and cmdlets
  2799. { regex: new RegExp(this.getKeywords(keywords), 'gmi'), css: 'keyword' }, // keywords
  2800. { regex: new RegExp('-'+this.getKeywords(operators), 'gmi'), css: 'operator value' }, // operators
  2801. { regex: new RegExp('\\[[A-Z_\\[][A-Z0-9_. `,\\[\\]]*\\]', 'gi'), css: 'constants' }, // .Net [Type]s
  2802. { regex: new RegExp('\\s+-(?!'+this.getKeywords(operators)+')[a-zA-Z_][a-zA-Z0-9_]*', 'gmi'), css: 'color1' }, // parameters
  2803. ];
  2804. };
  2805. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2806. Brush.aliases = ['powershell', 'ps', 'posh'];
  2807. SyntaxHighlighter.brushes.PowerShell = Brush;
  2808. // CommonJS
  2809. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2810. })();
  2811. ;(function()
  2812. {
  2813. // CommonJS
  2814. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2815. function Brush()
  2816. {
  2817. // Contributed by Gheorghe Milas and Ahmad Sherif
  2818. var keywords = 'and assert break class continue def del elif else ' +
  2819. 'except exec finally for from global if import in is ' +
  2820. 'lambda not or pass print raise return try yield while';
  2821. var funcs = '__import__ abs all any apply basestring bin bool buffer callable ' +
  2822. 'chr classmethod cmp coerce compile complex delattr dict dir ' +
  2823. 'divmod enumerate eval execfile file filter float format frozenset ' +
  2824. 'getattr globals hasattr hash help hex id input int intern ' +
  2825. 'isinstance issubclass iter len list locals long map max min next ' +
  2826. 'object oct open ord pow print property range raw_input reduce ' +
  2827. 'reload repr reversed round set setattr slice sorted staticmethod ' +
  2828. 'str sum super tuple type type unichr unicode vars xrange zip';
  2829. var special = 'None True False self cls class_';
  2830. this.regexList = [
  2831. { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' },
  2832. { regex: /^\s*@\w+/gm, css: 'decorator' },
  2833. { regex: /(['\"]{3})([^\1])*?\1/gm, css: 'comments' },
  2834. { regex: /"(?!")(?:\.|\\\"|[^\""\n])*"/gm, css: 'string' },
  2835. { regex: /'(?!')(?:\.|(\\\')|[^\''\n])*'/gm, css: 'string' },
  2836. { regex: /\+|\-|\*|\/|\%|=|==/gm, css: 'keyword' },
  2837. { regex: /\b\d+\.?\w*/g, css: 'value' },
  2838. { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' },
  2839. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' },
  2840. { regex: new RegExp(this.getKeywords(special), 'gm'), css: 'color1' }
  2841. ];
  2842. this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
  2843. };
  2844. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2845. Brush.aliases = ['py', 'python'];
  2846. SyntaxHighlighter.brushes.Python = Brush;
  2847. // CommonJS
  2848. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2849. })();
  2850. ;(function()
  2851. {
  2852. // CommonJS
  2853. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2854. function Brush()
  2855. {
  2856. // Contributed by Erik Peterson.
  2857. var keywords = 'alias and BEGIN begin break case class def define_method defined do each else elsif ' +
  2858. 'END end ensure false for if in module new next nil not or raise redo rescue retry return ' +
  2859. 'self super then throw true undef unless until when while yield';
  2860. var builtins = 'Array Bignum Binding Class Continuation Dir Exception FalseClass File::Stat File Fixnum Fload ' +
  2861. 'Hash Integer IO MatchData Method Module NilClass Numeric Object Proc Range Regexp String Struct::TMS Symbol ' +
  2862. 'ThreadGroup Thread Time TrueClass';
  2863. this.regexList = [
  2864. { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, // one line comments
  2865. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
  2866. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
  2867. { regex: /\b[A-Z0-9_]+\b/g, css: 'constants' }, // constants
  2868. { regex: /:[a-z][A-Za-z0-9_]*/g, css: 'color2' }, // symbols
  2869. { regex: /(\$|@@|@)\w+/g, css: 'variable bold' }, // $global, @instance, and @@class variables
  2870. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
  2871. { regex: new RegExp(this.getKeywords(builtins), 'gm'), css: 'color1' } // builtins
  2872. ];
  2873. this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
  2874. };
  2875. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2876. Brush.aliases = ['ruby', 'rails', 'ror', 'rb'];
  2877. SyntaxHighlighter.brushes.Ruby = Brush;
  2878. // CommonJS
  2879. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2880. })();
  2881. ;(function()
  2882. {
  2883. // CommonJS
  2884. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2885. function Brush()
  2886. {
  2887. function getKeywordsCSS(str)
  2888. {
  2889. return '\\b([a-z_]|)' + str.replace(/ /g, '(?=:)\\b|\\b([a-z_\\*]|\\*|)') + '(?=:)\\b';
  2890. };
  2891. function getValuesCSS(str)
  2892. {
  2893. return '\\b' + str.replace(/ /g, '(?!-)(?!:)\\b|\\b()') + '\:\\b';
  2894. };
  2895. var keywords = 'ascent azimuth background-attachment background-color background-image background-position ' +
  2896. 'background-repeat background baseline bbox border-collapse border-color border-spacing border-style border-top ' +
  2897. 'border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color ' +
  2898. 'border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width ' +
  2899. 'border-bottom-width border-left-width border-width border bottom cap-height caption-side centerline clear clip color ' +
  2900. 'content counter-increment counter-reset cue-after cue-before cue cursor definition-src descent direction display ' +
  2901. 'elevation empty-cells float font-size-adjust font-family font-size font-stretch font-style font-variant font-weight font ' +
  2902. 'height left letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-top ' +
  2903. 'margin-right margin-bottom margin-left margin marker-offset marks mathline max-height max-width min-height min-width orphans ' +
  2904. 'outline-color outline-style outline-width outline overflow padding-top padding-right padding-bottom padding-left padding page ' +
  2905. 'page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position ' +
  2906. 'quotes right richness size slope src speak-header speak-numeral speak-punctuation speak speech-rate stemh stemv stress ' +
  2907. 'table-layout text-align top text-decoration text-indent text-shadow text-transform unicode-bidi unicode-range units-per-em ' +
  2908. 'vertical-align visibility voice-family volume white-space widows width widths word-spacing x-height z-index';
  2909. var values = 'above absolute all always aqua armenian attr aural auto avoid baseline behind below bidi-override black blink block blue bold bolder '+
  2910. 'both bottom braille capitalize caption center center-left center-right circle close-quote code collapse compact condensed '+
  2911. 'continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero digits disc dotted double '+
  2912. 'embed embossed e-resize expanded extra-condensed extra-expanded fantasy far-left far-right fast faster fixed format fuchsia '+
  2913. 'gray green groove handheld hebrew help hidden hide high higher icon inline-table inline inset inside invert italic '+
  2914. 'justify landscape large larger left-side left leftwards level lighter lime line-through list-item local loud lower-alpha '+
  2915. 'lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower '+
  2916. 'navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once open-quote outset '+
  2917. 'outside overline pointer portrait pre print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side '+
  2918. 'rightwards rtl run-in screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow '+
  2919. 'small small-caps small-caption smaller soft solid speech spell-out square s-resize static status-bar sub super sw-resize '+
  2920. 'table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group teal '+
  2921. 'text-bottom text-top thick thin top transparent tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin '+
  2922. 'upper-roman url visible wait white wider w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow';
  2923. var fonts = '[mM]onospace [tT]ahoma [vV]erdana [aA]rial [hH]elvetica [sS]ans-serif [sS]erif [cC]ourier mono sans serif';
  2924. var statements = '!important !default';
  2925. var preprocessor = '@import @extend @debug @warn @if @for @while @mixin @include';
  2926. var r = SyntaxHighlighter.regexLib;
  2927. this.regexList = [
  2928. { regex: r.multiLineCComments, css: 'comments' }, // multiline comments
  2929. { regex: r.singleLineCComments, css: 'comments' }, // singleline comments
  2930. { regex: r.doubleQuotedString, css: 'string' }, // double quoted strings
  2931. { regex: r.singleQuotedString, css: 'string' }, // single quoted strings
  2932. { regex: /\#[a-fA-F0-9]{3,6}/g, css: 'value' }, // html colors
  2933. { regex: /\b(-?\d+)(\.\d+)?(px|em|pt|\:|\%|)\b/g, css: 'value' }, // sizes
  2934. { regex: /\$\w+/g, css: 'variable' }, // variables
  2935. { regex: new RegExp(this.getKeywords(statements), 'g'), css: 'color3' }, // statements
  2936. { regex: new RegExp(this.getKeywords(preprocessor), 'g'), css: 'preprocessor' }, // preprocessor
  2937. { regex: new RegExp(getKeywordsCSS(keywords), 'gm'), css: 'keyword' }, // keywords
  2938. { regex: new RegExp(getValuesCSS(values), 'g'), css: 'value' }, // values
  2939. { regex: new RegExp(this.getKeywords(fonts), 'g'), css: 'color1' } // fonts
  2940. ];
  2941. };
  2942. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2943. Brush.aliases = ['sass', 'scss'];
  2944. SyntaxHighlighter.brushes.Sass = Brush;
  2945. // CommonJS
  2946. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2947. })();
  2948. ;(function()
  2949. {
  2950. // CommonJS
  2951. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2952. function Brush()
  2953. {
  2954. // Contributed by Yegor Jbanov and David Bernard.
  2955. var keywords = 'val sealed case def true trait implicit forSome import match object null finally super ' +
  2956. 'override try lazy for var catch throw type extends class while with new final yield abstract ' +
  2957. 'else do if return protected private this package false';
  2958. var keyops = '[_:=><%#@]+';
  2959. this.regexList = [
  2960. { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
  2961. { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
  2962. { regex: SyntaxHighlighter.regexLib.multiLineSingleQuotedString, css: 'string' }, // multi-line strings
  2963. { regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString, css: 'string' }, // double-quoted string
  2964. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
  2965. { regex: /0x[a-f0-9]+|\d+(\.\d+)?/gi, css: 'value' }, // numbers
  2966. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
  2967. { regex: new RegExp(keyops, 'gm'), css: 'keyword' } // scala keyword
  2968. ];
  2969. }
  2970. Brush.prototype = new SyntaxHighlighter.Highlighter();
  2971. Brush.aliases = ['scala'];
  2972. SyntaxHighlighter.brushes.Scala = Brush;
  2973. // CommonJS
  2974. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  2975. })();
  2976. ;(function()
  2977. {
  2978. // CommonJS
  2979. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  2980. function Brush()
  2981. {
  2982. var funcs = 'abs avg case cast coalesce convert count current_timestamp ' +
  2983. 'current_user day isnull left lower month nullif replace right ' +
  2984. 'session_user space substring sum system_user upper user year';
  2985. var keywords = 'absolute action add after alter as asc at authorization begin bigint ' +
  2986. 'binary bit by cascade char character check checkpoint close collate ' +
  2987. 'column commit committed connect connection constraint contains continue ' +
  2988. 'create cube current current_date current_time cursor database date ' +
  2989. 'deallocate dec decimal declare default delete desc distinct double drop ' +
  2990. 'dynamic else end end-exec escape except exec execute false fetch first ' +
  2991. 'float for force foreign forward free from full function global goto grant ' +
  2992. 'group grouping having hour ignore index inner insensitive insert instead ' +
  2993. 'int integer intersect into is isolation key last level load local max min ' +
  2994. 'minute modify move name national nchar next no numeric of off on only ' +
  2995. 'open option order out output partial password precision prepare primary ' +
  2996. 'prior privileges procedure public read real references relative repeatable ' +
  2997. 'restrict return returns revoke rollback rollup rows rule schema scroll ' +
  2998. 'second section select sequence serializable set size smallint static ' +
  2999. 'statistics table temp temporary then time timestamp to top transaction ' +
  3000. 'translation trigger true truncate uncommitted union unique update values ' +
  3001. 'varchar varying view when where with work';
  3002. var operators = 'all and any between cross in join like not null or outer some';
  3003. this.regexList = [
  3004. { regex: /--(.*)$/gm, css: 'comments' }, // one line and multiline comments
  3005. { regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString, css: 'string' }, // double quoted strings
  3006. { regex: SyntaxHighlighter.regexLib.multiLineSingleQuotedString, css: 'string' }, // single quoted strings
  3007. { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'color2' }, // functions
  3008. { regex: new RegExp(this.getKeywords(operators), 'gmi'), css: 'color1' }, // operators and such
  3009. { regex: new RegExp(this.getKeywords(keywords), 'gmi'), css: 'keyword' } // keyword
  3010. ];
  3011. };
  3012. Brush.prototype = new SyntaxHighlighter.Highlighter();
  3013. Brush.aliases = ['sql'];
  3014. SyntaxHighlighter.brushes.Sql = Brush;
  3015. // CommonJS
  3016. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  3017. })();
  3018. ;(function()
  3019. {
  3020. // CommonJS
  3021. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  3022. function Brush()
  3023. {
  3024. var keywords = 'AddHandler AddressOf AndAlso Alias And Ansi As Assembly Auto ' +
  3025. 'Boolean ByRef Byte ByVal Call Case Catch CBool CByte CChar CDate ' +
  3026. 'CDec CDbl Char CInt Class CLng CObj Const CShort CSng CStr CType ' +
  3027. 'Date Decimal Declare Default Delegate Dim DirectCast Do Double Each ' +
  3028. 'Else ElseIf End Enum Erase Error Event Exit False Finally For Friend ' +
  3029. 'Function Get GetType GoSub GoTo Handles If Implements Imports In ' +
  3030. 'Inherits Integer Interface Is Let Lib Like Long Loop Me Mod Module ' +
  3031. 'MustInherit MustOverride MyBase MyClass Namespace New Next Not Nothing ' +
  3032. 'NotInheritable NotOverridable Object On Option Optional Or OrElse ' +
  3033. 'Overloads Overridable Overrides ParamArray Preserve Private Property ' +
  3034. 'Protected Public RaiseEvent ReadOnly ReDim REM RemoveHandler Resume ' +
  3035. 'Return Select Set Shadows Shared Short Single Static Step Stop String ' +
  3036. 'Structure Sub SyncLock Then Throw To True Try TypeOf Unicode Until ' +
  3037. 'Variant When While With WithEvents WriteOnly Xor';
  3038. this.regexList = [
  3039. { regex: /'.*$/gm, css: 'comments' }, // one line comments
  3040. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
  3041. { regex: /^\s*#.*$/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion
  3042. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // vb keyword
  3043. ];
  3044. this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
  3045. };
  3046. Brush.prototype = new SyntaxHighlighter.Highlighter();
  3047. Brush.aliases = ['vb', 'vbnet'];
  3048. SyntaxHighlighter.brushes.Vb = Brush;
  3049. // CommonJS
  3050. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  3051. })();
  3052. ;(function()
  3053. {
  3054. // CommonJS
  3055. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  3056. function Brush()
  3057. {
  3058. function process(match, regexInfo)
  3059. {
  3060. var constructor = SyntaxHighlighter.Match,
  3061. code = match[0],
  3062. tag = new XRegExp('(&lt;|<)[\\s\\/\\?]*(?<name>[:\\w-\\.]+)', 'xg').exec(code),
  3063. result = []
  3064. ;
  3065. if (match.attributes != null)
  3066. {
  3067. var attributes,
  3068. regex = new XRegExp('(?<name> [\\w:\\-\\.]+)' +
  3069. '\\s*=\\s*' +
  3070. '(?<value> ".*?"|\'.*?\'|\\w+)',
  3071. 'xg');
  3072. while ((attributes = regex.exec(code)) != null)
  3073. {
  3074. result.push(new constructor(attributes.name, match.index + attributes.index, 'color1'));
  3075. result.push(new constructor(attributes.value, match.index + attributes.index + attributes[0].indexOf(attributes.value), 'string'));
  3076. }
  3077. }
  3078. if (tag != null)
  3079. result.push(
  3080. new constructor(tag.name, match.index + tag[0].indexOf(tag.name), 'keyword')
  3081. );
  3082. return result;
  3083. }
  3084. this.regexList = [
  3085. { regex: new XRegExp('(\\&lt;|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\\&gt;|>)', 'gm'), css: 'color2' }, // <![ ... [ ... ]]>
  3086. { regex: SyntaxHighlighter.regexLib.xmlComments, css: 'comments' }, // <!-- ... -->
  3087. { regex: new XRegExp('(&lt;|<)[\\s\\/\\?]*(\\w+)(?<attributes>.*?)[\\s\\/\\?]*(&gt;|>)', 'sg'), func: process }
  3088. ];
  3089. };
  3090. Brush.prototype = new SyntaxHighlighter.Highlighter();
  3091. Brush.aliases = ['xml', 'xhtml', 'xslt', 'html'];
  3092. SyntaxHighlighter.brushes.Xml = Brush;
  3093. // CommonJS
  3094. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  3095. })();