shCore.js 160 KB

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