syntax-highlighter.js 134 KB

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