shCore.js 134 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604
  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. // Run within an anonymous function to protect variables and avoid new globals
  29. (function () {
  30. //---------------------------------
  31. // Constructor
  32. //---------------------------------
  33. // Accepts a pattern and flags; returns a new, extended `RegExp` object. Differs from a native
  34. // regular expression in that additional syntax and flags are supported and cross-browser
  35. // syntax inconsistencies are ameliorated
  36. XRegExp = function (pattern, flags) {
  37. var output = [],
  38. currScope = XRegExp.OUTSIDE_CLASS,
  39. pos = 0,
  40. context, tokenResult, match, chr, regex;
  41. if (XRegExp.isRegExp(pattern)) {
  42. if (flags !== undefined)
  43. throw TypeError("can't supply flags when constructing one RegExp from another");
  44. return clone(pattern);
  45. }
  46. // Tokens become part of the regex construction process, so protect against infinite
  47. // recursion when an XRegExp is constructed within a token handler or trigger
  48. if (isInsideConstructor)
  49. throw Error("can't call the XRegExp constructor within token definition functions");
  50. flags = flags || "";
  51. context = { // `this` object for custom tokens
  52. hasNamedCapture: false,
  53. captureNames: [],
  54. hasFlag: function (flag) {return flags.indexOf(flag) > -1;},
  55. setFlag: function (flag) {flags += flag;}
  56. };
  57. while (pos < pattern.length) {
  58. // Check for custom tokens at the current position
  59. tokenResult = runTokens(pattern, pos, currScope, context);
  60. if (tokenResult) {
  61. output.push(tokenResult.output);
  62. pos += (tokenResult.match[0].length || 1);
  63. } else {
  64. // Check for native multicharacter metasequences (excluding character classes) at
  65. // the current position
  66. if (match = real.exec.call(nativeTokens[currScope], pattern.slice(pos))) {
  67. output.push(match[0]);
  68. pos += match[0].length;
  69. } else {
  70. chr = pattern.charAt(pos);
  71. if (chr === "[")
  72. currScope = XRegExp.INSIDE_CLASS;
  73. else if (chr === "]")
  74. currScope = XRegExp.OUTSIDE_CLASS;
  75. // Advance position one character
  76. output.push(chr);
  77. pos++;
  78. }
  79. }
  80. }
  81. regex = RegExp(output.join(""), real.replace.call(flags, flagClip, ""));
  82. regex._xregexp = {
  83. source: pattern,
  84. captureNames: context.hasNamedCapture ? context.captureNames : null
  85. };
  86. return regex;
  87. };
  88. //---------------------------------
  89. // Public properties
  90. //---------------------------------
  91. XRegExp.version = "1.5.0";
  92. // Token scope bitflags
  93. XRegExp.INSIDE_CLASS = 1;
  94. XRegExp.OUTSIDE_CLASS = 2;
  95. //---------------------------------
  96. // Private variables
  97. //---------------------------------
  98. var replacementToken = /\$(?:(\d\d?|[$&`'])|{([$\w]+)})/g,
  99. flagClip = /[^gimy]+|([\s\S])(?=[\s\S]*\1)/g, // Nonnative and duplicate flags
  100. quantifier = /^(?:[?*+]|{\d+(?:,\d*)?})\??/,
  101. isInsideConstructor = false,
  102. tokens = [],
  103. // Copy native globals for reference ("native" is an ES3 reserved keyword)
  104. real = {
  105. exec: RegExp.prototype.exec,
  106. test: RegExp.prototype.test,
  107. match: String.prototype.match,
  108. replace: String.prototype.replace,
  109. split: String.prototype.split
  110. },
  111. compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
  112. compliantLastIndexIncrement = function () {
  113. var x = /^/g;
  114. real.test.call(x, "");
  115. return !x.lastIndex;
  116. }(),
  117. compliantLastIndexReset = function () {
  118. var x = /x/g;
  119. real.replace.call("x", x, "");
  120. return !x.lastIndex;
  121. }(),
  122. hasNativeY = RegExp.prototype.sticky !== undefined,
  123. nativeTokens = {};
  124. // `nativeTokens` match native multicharacter metasequences only (including deprecated octals,
  125. // excluding character classes)
  126. 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]))/;
  127. 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*)?}\??)/;
  128. //---------------------------------
  129. // Public methods
  130. //---------------------------------
  131. // Lets you extend or change XRegExp syntax and create custom flags. This is used internally by
  132. // the XRegExp library and can be used to create XRegExp plugins. This function is intended for
  133. // users with advanced knowledge of JavaScript's regular expression syntax and behavior. It can
  134. // be disabled by `XRegExp.freezeTokens`
  135. XRegExp.addToken = function (regex, handler, scope, trigger) {
  136. tokens.push({
  137. pattern: clone(regex, "g" + (hasNativeY ? "y" : "")),
  138. handler: handler,
  139. scope: scope || XRegExp.OUTSIDE_CLASS,
  140. trigger: trigger || null
  141. });
  142. };
  143. // Accepts a pattern and flags; returns an extended `RegExp` object. If the pattern and flag
  144. // combination has previously been cached, the cached copy is returned; otherwise the newly
  145. // created regex is cached
  146. XRegExp.cache = function (pattern, flags) {
  147. var key = pattern + "/" + (flags || "");
  148. return XRegExp.cache[key] || (XRegExp.cache[key] = XRegExp(pattern, flags));
  149. };
  150. // Accepts a `RegExp` instance; returns a copy with the `/g` flag set. The copy has a fresh
  151. // `lastIndex` (set to zero). If you want to copy a regex without forcing the `global`
  152. // property, use `XRegExp(regex)`. Do not use `RegExp(regex)` because it will not preserve
  153. // special properties required for named capture
  154. XRegExp.copyAsGlobal = function (regex) {
  155. return clone(regex, "g");
  156. };
  157. // Accepts a string; returns the string with regex metacharacters escaped. The returned string
  158. // can safely be used at any point within a regex to match the provided literal string. Escaped
  159. // characters are [ ] { } ( ) * + ? - . , \ ^ $ | # and whitespace
  160. XRegExp.escape = function (str) {
  161. return str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  162. };
  163. // Accepts a string to search, regex to search with, position to start the search within the
  164. // string (default: 0), and an optional Boolean indicating whether matches must start at-or-
  165. // after the position or at the specified position only. This function ignores the `lastIndex`
  166. // property of the provided regex
  167. XRegExp.execAt = function (str, regex, pos, anchored) {
  168. regex = clone(regex, "g" + ((anchored && hasNativeY) ? "y" : ""));
  169. regex.lastIndex = pos = pos || 0;
  170. var match = regex.exec(str);
  171. if (anchored)
  172. return (match && match.index === pos) ? match : null;
  173. else
  174. return match;
  175. };
  176. // Breaks the unrestorable link to XRegExp's private list of tokens, thereby preventing
  177. // syntax and flag changes. Should be run after XRegExp and any plugins are loaded
  178. XRegExp.freezeTokens = function () {
  179. XRegExp.addToken = function () {
  180. throw Error("can't run addToken after freezeTokens");
  181. };
  182. };
  183. // Accepts any value; returns a Boolean indicating whether the argument is a `RegExp` object.
  184. // Note that this is also `true` for regex literals and regexes created by the `XRegExp`
  185. // constructor. This works correctly for variables created in another frame, when `instanceof`
  186. // and `constructor` checks would fail to work as intended
  187. XRegExp.isRegExp = function (o) {
  188. return Object.prototype.toString.call(o) === "[object RegExp]";
  189. };
  190. // Executes `callback` once per match within `str`. Provides a simpler and cleaner way to
  191. // iterate over regex matches compared to the traditional approaches of subverting
  192. // `String.prototype.replace` or repeatedly calling `exec` within a `while` loop
  193. XRegExp.iterate = function (str, origRegex, callback, context) {
  194. var regex = clone(origRegex, "g"),
  195. i = -1, match;
  196. while (match = regex.exec(str)) {
  197. callback.call(context, match, ++i, str, regex);
  198. if (regex.lastIndex === match.index)
  199. regex.lastIndex++;
  200. }
  201. if (origRegex.global)
  202. origRegex.lastIndex = 0;
  203. };
  204. // Accepts a string and an array of regexes; returns the result of using each successive regex
  205. // to search within the matches of the previous regex. The array of regexes can also contain
  206. // objects with `regex` and `backref` properties, in which case the named or numbered back-
  207. // references specified are passed forward to the next regex or returned. E.g.:
  208. // var xregexpImgFileNames = XRegExp.matchChain(html, [
  209. // {regex: /<img\b([^>]+)>/i, backref: 1}, // <img> tag attributes
  210. // {regex: XRegExp('(?ix) \\s src=" (?<src> [^"]+ )'), backref: "src"}, // src attribute values
  211. // {regex: XRegExp("^http://xregexp\\.com(/[^#?]+)", "i"), backref: 1}, // xregexp.com paths
  212. // /[^\/]+$/ // filenames (strip directory paths)
  213. // ]);
  214. XRegExp.matchChain = function (str, chain) {
  215. return function recurseChain (values, level) {
  216. var item = chain[level].regex ? chain[level] : {regex: chain[level]},
  217. regex = clone(item.regex, "g"),
  218. matches = [], i;
  219. for (i = 0; i < values.length; i++) {
  220. XRegExp.iterate(values[i], regex, function (match) {
  221. matches.push(item.backref ? (match[item.backref] || "") : match[0]);
  222. });
  223. }
  224. return ((level === chain.length - 1) || !matches.length) ?
  225. matches : recurseChain(matches, level + 1);
  226. }([str], 0);
  227. };
  228. //---------------------------------
  229. // New RegExp prototype methods
  230. //---------------------------------
  231. // Accepts a context object and arguments array; returns the result of calling `exec` with the
  232. // first value in the arguments array. the context is ignored but is accepted for congruity
  233. // with `Function.prototype.apply`
  234. RegExp.prototype.apply = function (context, args) {
  235. return this.exec(args[0]);
  236. };
  237. // Accepts a context object and string; returns the result of calling `exec` with the provided
  238. // string. the context is ignored but is accepted for congruity with `Function.prototype.call`
  239. RegExp.prototype.call = function (context, str) {
  240. return this.exec(str);
  241. };
  242. //---------------------------------
  243. // Overriden native methods
  244. //---------------------------------
  245. // Adds named capture support (with backreferences returned as `result.name`), and fixes two
  246. // cross-browser issues per ES3:
  247. // - Captured values for nonparticipating capturing groups should be returned as `undefined`,
  248. // rather than the empty string.
  249. // - `lastIndex` should not be incremented after zero-length matches.
  250. RegExp.prototype.exec = function (str) {
  251. var match = real.exec.apply(this, arguments),
  252. name, r2;
  253. if (match) {
  254. // Fix browsers whose `exec` methods don't consistently return `undefined` for
  255. // nonparticipating capturing groups
  256. if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
  257. r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
  258. // Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed
  259. // matching due to characters outside the match
  260. //修复跟jquery冲突的问题
  261. if (str) str += '';
  262. real.replace.call(str.toString().slice(match.index), r2, function () {
  263. for (var i = 1; i < arguments.length - 2; i++) {
  264. if (arguments[i] === undefined)
  265. match[i] = undefined;
  266. }
  267. });
  268. }
  269. // Attach named capture properties
  270. if (this._xregexp && this._xregexp.captureNames) {
  271. for (var i = 1; i < match.length; i++) {
  272. name = this._xregexp.captureNames[i - 1];
  273. if (name)
  274. match[name] = match[i];
  275. }
  276. }
  277. // Fix browsers that increment `lastIndex` after zero-length matches
  278. if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
  279. this.lastIndex--;
  280. }
  281. return match;
  282. };
  283. // Don't override `test` if it won't change anything
  284. if (!compliantLastIndexIncrement) {
  285. // Fix browser bug in native method
  286. RegExp.prototype.test = function (str) {
  287. // Use the native `exec` to skip some processing overhead, even though the overriden
  288. // `exec` would take care of the `lastIndex` fix
  289. var match = real.exec.call(this, str);
  290. // Fix browsers that increment `lastIndex` after zero-length matches
  291. if (match && this.global && !match[0].length && (this.lastIndex > match.index))
  292. this.lastIndex--;
  293. return !!match;
  294. };
  295. }
  296. // Adds named capture support and fixes browser bugs in native method
  297. String.prototype.match = function (regex) {
  298. if (!XRegExp.isRegExp(regex))
  299. regex = RegExp(regex); // Native `RegExp`
  300. if (regex.global) {
  301. var result = real.match.apply(this, arguments);
  302. regex.lastIndex = 0; // Fix IE bug
  303. return result;
  304. }
  305. return regex.exec(this); // Run the altered `exec`
  306. };
  307. // Adds support for `${n}` tokens for named and numbered backreferences in replacement text,
  308. // and provides named backreferences to replacement functions as `arguments[0].name`. Also
  309. // fixes cross-browser differences in replacement text syntax when performing a replacement
  310. // using a nonregex search value, and the value of replacement regexes' `lastIndex` property
  311. // during replacement iterations. Note that this doesn't support SpiderMonkey's proprietary
  312. // third (`flags`) parameter
  313. String.prototype.replace = function (search, replacement) {
  314. var isRegex = XRegExp.isRegExp(search),
  315. captureNames, result, str;
  316. // There are many combinations of search/replacement types/values and browser bugs that
  317. // preclude passing to native `replace`, so just keep this check relatively simple
  318. if (isRegex && typeof replacement.valueOf() === "string" && replacement.indexOf("${") === -1 && compliantLastIndexReset)
  319. return real.replace.apply(this, arguments);
  320. if (!isRegex)
  321. search = search + ""; // Type conversion
  322. else if (search._xregexp)
  323. captureNames = search._xregexp.captureNames; // Array or `null`
  324. if (typeof replacement === "function") {
  325. result = real.replace.call(this, search, function () {
  326. if (captureNames) {
  327. // Change the `arguments[0]` string primitive to a String object which can store properties
  328. arguments[0] = new String(arguments[0]);
  329. // Store named backreferences on `arguments[0]`
  330. for (var i = 0; i < captureNames.length; i++) {
  331. if (captureNames[i])
  332. arguments[0][captureNames[i]] = arguments[i + 1];
  333. }
  334. }
  335. // Update `lastIndex` before calling `replacement`
  336. if (isRegex && search.global)
  337. search.lastIndex = arguments[arguments.length - 2] + arguments[0].length;
  338. return replacement.apply(null, arguments);
  339. });
  340. } else {
  341. str = this + ""; // Type conversion, so `args[args.length - 1]` will be a string (given nonstring `this`)
  342. result = real.replace.call(str, search, function () {
  343. var args = arguments; // Keep this function's `arguments` available through closure
  344. return real.replace.call(replacement, replacementToken, function ($0, $1, $2) {
  345. // Numbered backreference (without delimiters) or special variable
  346. if ($1) {
  347. switch ($1) {
  348. case "$": return "$";
  349. case "&": return args[0];
  350. case "`": return args[args.length - 1].slice(0, args[args.length - 2]);
  351. case "'": return args[args.length - 1].slice(args[args.length - 2] + args[0].length);
  352. // Numbered backreference
  353. default:
  354. // What does "$10" mean?
  355. // - Backreference 10, if 10 or more capturing groups exist
  356. // - Backreference 1 followed by "0", if 1-9 capturing groups exist
  357. // - Otherwise, it's the string "$10"
  358. // Also note:
  359. // - Backreferences cannot be more than two digits (enforced by `replacementToken`)
  360. // - "$01" is equivalent to "$1" if a capturing group exists, otherwise it's the string "$01"
  361. // - There is no "$0" token ("$&" is the entire match)
  362. var literalNumbers = "";
  363. $1 = +$1; // Type conversion; drop leading zero
  364. if (!$1) // `$1` was "0" or "00"
  365. return $0;
  366. while ($1 > args.length - 3) {
  367. literalNumbers = String.prototype.slice.call($1, -1) + literalNumbers;
  368. $1 = Math.floor($1 / 10); // Drop the last digit
  369. }
  370. return ($1 ? args[$1] || "" : "$") + literalNumbers;
  371. }
  372. // Named backreference or delimited numbered backreference
  373. } else {
  374. // What does "${n}" mean?
  375. // - Backreference to numbered capture n. Two differences from "$n":
  376. // - n can be more than two digits
  377. // - Backreference 0 is allowed, and is the entire match
  378. // - Backreference to named capture n, if it exists and is not a number overridden by numbered capture
  379. // - Otherwise, it's the string "${n}"
  380. var n = +$2; // Type conversion; drop leading zeros
  381. if (n <= args.length - 3)
  382. return args[n];
  383. n = captureNames ? indexOf(captureNames, $2) : -1;
  384. return n > -1 ? args[n + 1] : $0;
  385. }
  386. });
  387. });
  388. }
  389. if (isRegex && search.global)
  390. search.lastIndex = 0; // Fix IE bug
  391. return result;
  392. };
  393. // A consistent cross-browser, ES3 compliant `split`
  394. String.prototype.split = function (s /* separator */, limit) {
  395. // If separator `s` is not a regex, use the native `split`
  396. if (!XRegExp.isRegExp(s))
  397. return real.split.apply(this, arguments);
  398. var str = this + "", // Type conversion
  399. output = [],
  400. lastLastIndex = 0,
  401. match, lastLength;
  402. // Behavior for `limit`: if it's...
  403. // - `undefined`: No limit
  404. // - `NaN` or zero: Return an empty array
  405. // - A positive number: Use `Math.floor(limit)`
  406. // - A negative number: No limit
  407. // - Other: Type-convert, then use the above rules
  408. if (limit === undefined || +limit < 0) {
  409. limit = Infinity;
  410. } else {
  411. limit = Math.floor(+limit);
  412. if (!limit)
  413. return [];
  414. }
  415. // This is required if not `s.global`, and it avoids needing to set `s.lastIndex` to zero
  416. // and restore it to its original value when we're done using the regex
  417. s = XRegExp.copyAsGlobal(s);
  418. while (match = s.exec(str)) { // Run the altered `exec` (required for `lastIndex` fix, etc.)
  419. if (s.lastIndex > lastLastIndex) {
  420. output.push(str.slice(lastLastIndex, match.index));
  421. if (match.length > 1 && match.index < str.length)
  422. Array.prototype.push.apply(output, match.slice(1));
  423. lastLength = match[0].length;
  424. lastLastIndex = s.lastIndex;
  425. if (output.length >= limit)
  426. break;
  427. }
  428. if (s.lastIndex === match.index)
  429. s.lastIndex++;
  430. }
  431. if (lastLastIndex === str.length) {
  432. if (!real.test.call(s, "") || lastLength)
  433. output.push("");
  434. } else {
  435. output.push(str.slice(lastLastIndex));
  436. }
  437. return output.length > limit ? output.slice(0, limit) : output;
  438. };
  439. //---------------------------------
  440. // Private helper functions
  441. //---------------------------------
  442. // Supporting function for `XRegExp`, `XRegExp.copyAsGlobal`, etc. Returns a copy of a `RegExp`
  443. // instance with a fresh `lastIndex` (set to zero), preserving properties required for named
  444. // capture. Also allows adding new flags in the process of copying the regex
  445. function clone (regex, additionalFlags) {
  446. if (!XRegExp.isRegExp(regex))
  447. throw TypeError("type RegExp expected");
  448. var x = regex._xregexp;
  449. regex = XRegExp(regex.source, getNativeFlags(regex) + (additionalFlags || ""));
  450. if (x) {
  451. regex._xregexp = {
  452. source: x.source,
  453. captureNames: x.captureNames ? x.captureNames.slice(0) : null
  454. };
  455. }
  456. return regex;
  457. };
  458. function getNativeFlags (regex) {
  459. return (regex.global ? "g" : "") +
  460. (regex.ignoreCase ? "i" : "") +
  461. (regex.multiline ? "m" : "") +
  462. (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
  463. (regex.sticky ? "y" : "");
  464. };
  465. function runTokens (pattern, index, scope, context) {
  466. var i = tokens.length,
  467. result, match, t;
  468. // Protect against constructing XRegExps within token handler and trigger functions
  469. isInsideConstructor = true;
  470. // Must reset `isInsideConstructor`, even if a `trigger` or `handler` throws
  471. try {
  472. while (i--) { // Run in reverse order
  473. t = tokens[i];
  474. if ((scope & t.scope) && (!t.trigger || t.trigger.call(context))) {
  475. t.pattern.lastIndex = index;
  476. match = t.pattern.exec(pattern); // Running the altered `exec` here allows use of named backreferences, etc.
  477. if (match && match.index === index) {
  478. result = {
  479. output: t.handler.call(context, match, scope),
  480. match: match
  481. };
  482. break;
  483. }
  484. }
  485. }
  486. } catch (err) {
  487. throw err;
  488. } finally {
  489. isInsideConstructor = false;
  490. }
  491. return result;
  492. };
  493. function indexOf (array, item, from) {
  494. if (Array.prototype.indexOf) // Use the native array method if available
  495. return array.indexOf(item, from);
  496. for (var i = from || 0; i < array.length; i++) {
  497. if (array[i] === item)
  498. return i;
  499. }
  500. return -1;
  501. };
  502. //---------------------------------
  503. // Built-in tokens
  504. //---------------------------------
  505. // Augment XRegExp's regular expression syntax and flags. Note that when adding tokens, the
  506. // third (`scope`) argument defaults to `XRegExp.OUTSIDE_CLASS`
  507. // Comment pattern: (?# )
  508. XRegExp.addToken(
  509. /\(\?#[^)]*\)/,
  510. function (match) {
  511. // Keep tokens separated unless the following token is a quantifier
  512. return real.test.call(quantifier, match.input.slice(match.index + match[0].length)) ? "" : "(?:)";
  513. }
  514. );
  515. // Capturing group (match the opening parenthesis only).
  516. // Required for support of named capturing groups
  517. XRegExp.addToken(
  518. /\((?!\?)/,
  519. function () {
  520. this.captureNames.push(null);
  521. return "(";
  522. }
  523. );
  524. // Named capturing group (match the opening delimiter only): (?<name>
  525. XRegExp.addToken(
  526. /\(\?<([$\w]+)>/,
  527. function (match) {
  528. this.captureNames.push(match[1]);
  529. this.hasNamedCapture = true;
  530. return "(";
  531. }
  532. );
  533. // Named backreference: \k<name>
  534. XRegExp.addToken(
  535. /\\k<([\w$]+)>/,
  536. function (match) {
  537. var index = indexOf(this.captureNames, match[1]);
  538. // Keep backreferences separate from subsequent literal numbers. Preserve back-
  539. // references to named groups that are undefined at this point as literal strings
  540. return index > -1 ?
  541. "\\" + (index + 1) + (isNaN(match.input.charAt(match.index + match[0].length)) ? "" : "(?:)") :
  542. match[0];
  543. }
  544. );
  545. // Empty character class: [] or [^]
  546. XRegExp.addToken(
  547. /\[\^?]/,
  548. function (match) {
  549. // For cross-browser compatibility with ES3, convert [] to \b\B and [^] to [\s\S].
  550. // (?!) should work like \b\B, but is unreliable in Firefox
  551. return match[0] === "[]" ? "\\b\\B" : "[\\s\\S]";
  552. }
  553. );
  554. // Mode modifier at the start of the pattern only, with any combination of flags imsx: (?imsx)
  555. // Does not support x(?i), (?-i), (?i-m), (?i: ), (?i)(?m), etc.
  556. XRegExp.addToken(
  557. /^\(\?([imsx]+)\)/,
  558. function (match) {
  559. this.setFlag(match[1]);
  560. return "";
  561. }
  562. );
  563. // Whitespace and comments, in free-spacing (aka extended) mode only
  564. XRegExp.addToken(
  565. /(?:\s+|#.*)+/,
  566. function (match) {
  567. // Keep tokens separated unless the following token is a quantifier
  568. return real.test.call(quantifier, match.input.slice(match.index + match[0].length)) ? "" : "(?:)";
  569. },
  570. XRegExp.OUTSIDE_CLASS,
  571. function () {return this.hasFlag("x");}
  572. );
  573. // Dot, in dotall (aka singleline) mode only
  574. XRegExp.addToken(
  575. /\./,
  576. function () {return "[\\s\\S]";},
  577. XRegExp.OUTSIDE_CLASS,
  578. function () {return this.hasFlag("s");}
  579. );
  580. //---------------------------------
  581. // Backward compatibility
  582. //---------------------------------
  583. // Uncomment the following block for compatibility with XRegExp 1.0-1.2:
  584. /*
  585. XRegExp.matchWithinChain = XRegExp.matchChain;
  586. RegExp.prototype.addFlags = function (s) {return clone(this, s);};
  587. RegExp.prototype.execAll = function (s) {var r = []; XRegExp.iterate(s, this, function (m) {r.push(m);}); return r;};
  588. RegExp.prototype.forEachExec = function (s, f, c) {return XRegExp.iterate(s, this, f, c);};
  589. RegExp.prototype.validate = function (s) {var r = RegExp("^(?:" + this.source + ")$(?!\\s)", getNativeFlags(this)); if (this.global) this.lastIndex = 0; return s.search(r) === 0;};
  590. */
  591. })();
  592. // CommonJS
  593. typeof(exports) != 'undefined' ? exports.XRegExp = XRegExp : null;
  594. var SyntaxHighlighter = function() {
  595. // CommonJS
  596. if (typeof(require) != 'undefined' && typeof(XRegExp) == 'undefined')
  597. {
  598. XRegExp = require('XRegExp').XRegExp;
  599. }
  600. // Shortcut object which will be assigned to the SyntaxHighlighter variable.
  601. // This is a shorthand for local reference in order to avoid long namespace
  602. // references to SyntaxHighlighter.whatever...
  603. var sh = {
  604. defaults : {
  605. /** Additional CSS class names to be added to highlighter elements. */
  606. 'class-name' : '',
  607. /** First line number. */
  608. 'first-line' : 1,
  609. /**
  610. * Pads line numbers. Possible values are:
  611. *
  612. * false - don't pad line numbers.
  613. * true - automaticaly pad numbers with minimum required number of leading zeroes.
  614. * [int] - length up to which pad line numbers.
  615. */
  616. 'pad-line-numbers' : false,
  617. /** Lines to highlight. */
  618. 'highlight' : null,
  619. /** Title to be displayed above the code block. */
  620. 'title' : null,
  621. /** Enables or disables smart tabs. */
  622. 'smart-tabs' : true,
  623. /** Gets or sets tab size. */
  624. 'tab-size' : 4,
  625. /** Enables or disables gutter. */
  626. 'gutter' : true,
  627. /** Enables or disables toolbar. */
  628. 'toolbar' : true,
  629. /** Enables quick code copy and paste from double click. */
  630. 'quick-code' : true,
  631. /** Forces code view to be collapsed. */
  632. 'collapse' : false,
  633. /** Enables or disables automatic links. */
  634. 'auto-links' : true,
  635. /** Gets or sets light mode. Equavalent to turning off gutter and toolbar. */
  636. 'light' : false,
  637. 'html-script' : false
  638. },
  639. config : {
  640. space : '&nbsp;',
  641. /** Enables use of <SCRIPT type="syntaxhighlighter" /> tags. */
  642. useScriptTags : true,
  643. /** Blogger mode flag. */
  644. bloggerMode : false,
  645. stripBrs : false,
  646. /** Name of the tag that SyntaxHighlighter will automatically look for. */
  647. tagName : 'pre',
  648. strings : {
  649. expandSource : 'expand source',
  650. help : '?',
  651. alert: 'SyntaxHighlighter\n\n',
  652. noBrush : 'Can\'t find brush for: ',
  653. brushNotHtmlScript : 'Brush wasn\'t configured for html-script option: ',
  654. // this is populated by the build script
  655. 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>'
  656. }
  657. },
  658. /** Internal 'global' variables. */
  659. vars : {
  660. discoveredBrushes : null,
  661. highlighters : {}
  662. },
  663. /** This object is populated by user included external brush files. */
  664. brushes : {},
  665. /** Common regular expressions. */
  666. regexLib : {
  667. multiLineCComments : /\/\*[\s\S]*?\*\//gm,
  668. singleLineCComments : /\/\/.*$/gm,
  669. singleLinePerlComments : /#.*$/gm,
  670. doubleQuotedString : /"([^\\"\n]|\\.)*"/g,
  671. singleQuotedString : /'([^\\'\n]|\\.)*'/g,
  672. multiLineDoubleQuotedString : new XRegExp('"([^\\\\"]|\\\\.)*"', 'gs'),
  673. multiLineSingleQuotedString : new XRegExp("'([^\\\\']|\\\\.)*'", 'gs'),
  674. xmlComments : /(&lt;|<)!--[\s\S]*?--(&gt;|>)/gm,
  675. url : /\w+:\/\/[\w-.\/?%&=:@;]*/g,
  676. /** <?= ?> tags. */
  677. phpScriptTags : { left: /(&lt;|<)\?=?/g, right: /\?(&gt;|>)/g },
  678. /** <%= %> tags. */
  679. aspScriptTags : { left: /(&lt;|<)%=?/g, right: /%(&gt;|>)/g },
  680. /** <script></script> tags. */
  681. scriptScriptTags : { left: /(&lt;|<)\s*script.*?(&gt;|>)/gi, right: /(&lt;|<)\/\s*script\s*(&gt;|>)/gi }
  682. },
  683. toolbar: {
  684. /**
  685. * Generates HTML markup for the toolbar.
  686. * @param {Highlighter} highlighter Highlighter instance.
  687. * @return {String} Returns HTML markup.
  688. */
  689. getHtml: function(highlighter)
  690. {
  691. var html = '<div class="toolbar">',
  692. items = sh.toolbar.items,
  693. list = items.list
  694. ;
  695. function defaultGetHtml(highlighter, name)
  696. {
  697. return sh.toolbar.getButtonHtml(highlighter, name, sh.config.strings[name]);
  698. };
  699. for (var i = 0; i < list.length; i++)
  700. html += (items[list[i]].getHtml || defaultGetHtml)(highlighter, list[i]);
  701. html += '</div>';
  702. return html;
  703. },
  704. /**
  705. * Generates HTML markup for a regular button in the toolbar.
  706. * @param {Highlighter} highlighter Highlighter instance.
  707. * @param {String} commandName Command name that would be executed.
  708. * @param {String} label Label text to display.
  709. * @return {String} Returns HTML markup.
  710. */
  711. getButtonHtml: function(highlighter, commandName, label)
  712. {
  713. return '<span><a href="#" class="toolbar_item'
  714. + ' command_' + commandName
  715. + ' ' + commandName
  716. + '">' + label + '</a></span>'
  717. ;
  718. },
  719. /**
  720. * Event handler for a toolbar anchor.
  721. */
  722. handler: function(e)
  723. {
  724. var target = e.target,
  725. className = target.className || ''
  726. ;
  727. function getValue(name)
  728. {
  729. var r = new RegExp(name + '_(\\w+)'),
  730. match = r.exec(className)
  731. ;
  732. return match ? match[1] : null;
  733. };
  734. var highlighter = getHighlighterById(findParentElement(target, '.syntaxhighlighter').id),
  735. commandName = getValue('command')
  736. ;
  737. // execute the toolbar command
  738. if (highlighter && commandName)
  739. sh.toolbar.items[commandName].execute(highlighter);
  740. // disable default A click behaviour
  741. e.preventDefault();
  742. },
  743. /** Collection of toolbar items. */
  744. items : {
  745. // Ordered lis of items in the toolbar. Can't expect `for (var n in items)` to be consistent.
  746. list: ['expandSource', 'help'],
  747. expandSource: {
  748. getHtml: function(highlighter)
  749. {
  750. if (highlighter.getParam('collapse') != true)
  751. return '';
  752. var title = highlighter.getParam('title');
  753. return sh.toolbar.getButtonHtml(highlighter, 'expandSource', title ? title : sh.config.strings.expandSource);
  754. },
  755. execute: function(highlighter)
  756. {
  757. var div = getHighlighterDivById(highlighter.id);
  758. removeClass(div, 'collapsed');
  759. }
  760. },
  761. /** Command to display the about dialog window. */
  762. help: {
  763. execute: function(highlighter)
  764. {
  765. var wnd = popup('', '_blank', 500, 250, 'scrollbars=0'),
  766. doc = wnd.document
  767. ;
  768. doc.write(sh.config.strings.aboutDialog);
  769. doc.close();
  770. wnd.focus();
  771. }
  772. }
  773. }
  774. },
  775. getHighlighterDivId : function(){
  776. return highlighterDivId;
  777. },
  778. /**
  779. * Finds all elements on the page which should be processes by SyntaxHighlighter.
  780. *
  781. * @param {Object} globalParams Optional parameters which override element's
  782. * parameters. Only used if element is specified.
  783. *
  784. * @param {Object} element Optional element to highlight. If none is
  785. * provided, all elements in the current document
  786. * are returned which qualify.
  787. *
  788. * @return {Array} Returns list of <code>{ target: DOMElement, params: Object }</code> objects.
  789. */
  790. findElements: function(globalParams, element)
  791. {
  792. var elements = element ? [element] : toArray(document.getElementsByTagName(sh.config.tagName)),
  793. conf = sh.config,
  794. result = []
  795. ;
  796. // support for <SCRIPT TYPE="syntaxhighlighter" /> feature
  797. if (conf.useScriptTags)
  798. elements = elements.concat(getSyntaxHighlighterScriptTags());
  799. if (elements.length === 0)
  800. return result;
  801. for (var i = 0; i < elements.length; i++)
  802. {
  803. var item = {
  804. target: elements[i],
  805. // local params take precedence over globals
  806. params: merge(globalParams, parseParams(elements[i].className))
  807. };
  808. if (item.params['brush'] == null)
  809. continue;
  810. result.push(item);
  811. }
  812. return result;
  813. },
  814. /**
  815. * Shorthand to highlight all elements on the page that are marked as
  816. * SyntaxHighlighter source code.
  817. *
  818. * @param {Object} globalParams Optional parameters which override element's
  819. * parameters. Only used if element is specified.
  820. *
  821. * @param {Object} element Optional element to highlight. If none is
  822. * provided, all elements in the current document
  823. * are highlighted.
  824. */
  825. highlight: function(globalParams, element,print)
  826. {
  827. var elements = this.findElements(globalParams, element),
  828. propertyName = 'innerHTML',
  829. highlighter = null,
  830. conf = sh.config
  831. ;
  832. if (elements.length === 0)
  833. return;
  834. for (var i = 0; i < elements.length; i++)
  835. {
  836. var element = elements[i],
  837. target = element.target,
  838. params = element.params,
  839. brushName = params.brush,
  840. code
  841. ;
  842. if (brushName == null)
  843. continue;
  844. // Instantiate a brush
  845. if (params['html-script'] == 'true' || sh.defaults['html-script'] == true)
  846. {
  847. highlighter = new sh.HtmlScript(brushName);
  848. brushName = 'htmlscript';
  849. }
  850. else
  851. {
  852. var brush = findBrush(brushName);
  853. if (brush)
  854. highlighter = new brush();
  855. else
  856. continue;
  857. }
  858. code = target[propertyName];
  859. // remove CDATA from <SCRIPT/> tags if it's present
  860. if (conf.useScriptTags)
  861. code = stripCData(code);
  862. // Inject title if the attribute is present
  863. if ((target.title || '') != '')
  864. params.title = target.title;
  865. params['brush'] = brushName;
  866. highlighter.init(params);
  867. element = highlighter.getDiv(code);
  868. // carry over ID
  869. if ((target.id || '') != '')
  870. element.id = target.id;
  871. if(print)
  872. return element.innerHTML;
  873. target.parentNode.replaceChild(element, target);
  874. this.highlightContainers.push(element);
  875. }
  876. },
  877. highlightContainers : [],
  878. /**
  879. * Main entry point for the SyntaxHighlighter.
  880. * @param {Object} params Optional params to apply to all highlighted elements.
  881. */
  882. all: function(params)
  883. {
  884. attachEvent(
  885. window,
  886. 'load',
  887. function() { sh.highlight(params); }
  888. );
  889. }
  890. }; // end of sh
  891. sh['all'] = sh.all;
  892. sh['highlight'] = sh.highlight;
  893. /**
  894. * Checks if target DOM elements has specified CSS class.
  895. * @param {DOMElement} target Target DOM element to check.
  896. * @param {String} className Name of the CSS class to check for.
  897. * @return {Boolean} Returns true if class name is present, false otherwise.
  898. */
  899. function hasClass(target, className)
  900. {
  901. return target.className.indexOf(className) != -1;
  902. };
  903. /**
  904. * Adds CSS class name to the target DOM element.
  905. * @param {DOMElement} target Target DOM element.
  906. * @param {String} className New CSS class to add.
  907. */
  908. function addClass(target, className)
  909. {
  910. if (!hasClass(target, className))
  911. target.className += ' ' + className;
  912. };
  913. /**
  914. * Removes CSS class name from the target DOM element.
  915. * @param {DOMElement} target Target DOM element.
  916. * @param {String} className CSS class to remove.
  917. */
  918. function removeClass(target, className)
  919. {
  920. target.className = target.className.replace(className, '');
  921. };
  922. /**
  923. * Converts the source to array object. Mostly used for function arguments and
  924. * lists returned by getElementsByTagName() which aren't Array objects.
  925. * @param {List} source Source list.
  926. * @return {Array} Returns array.
  927. */
  928. function toArray(source)
  929. {
  930. var result = [];
  931. for (var i = 0; i < source.length; i++)
  932. result.push(source[i]);
  933. return result;
  934. };
  935. /**
  936. * Splits block of text into lines.
  937. * @param {String} block Block of text.
  938. * @return {Array} Returns array of lines.
  939. */
  940. function splitLines(block)
  941. {
  942. return block.split('\n');
  943. }
  944. /**
  945. * Generates HTML ID for the highlighter.
  946. * @param {String} highlighterId Highlighter ID.
  947. * @return {String} Returns HTML ID.
  948. */
  949. var highlighterDivId;
  950. function getHighlighterId(id)
  951. {
  952. var prefix = 'highlighter_';
  953. highlighterDivId = id.indexOf(prefix) == 0 ? id : prefix + id;
  954. return highlighterDivId
  955. };
  956. /**
  957. * Finds Highlighter instance by ID.
  958. * @param {String} highlighterId Highlighter ID.
  959. * @return {Highlighter} Returns instance of the highlighter.
  960. */
  961. function getHighlighterById(id)
  962. {
  963. return sh.vars.highlighters[getHighlighterId(id)];
  964. };
  965. /**
  966. * Finds highlighter's DIV container.
  967. * @param {String} highlighterId Highlighter ID.
  968. * @return {Element} Returns highlighter's DIV element.
  969. */
  970. function getHighlighterDivById(id)
  971. {
  972. return document.getElementById(getHighlighterId(id))
  973. };
  974. /**
  975. * Stores highlighter so that getHighlighterById() can do its thing. Each
  976. * highlighter must call this method to preserve itself.
  977. * @param {Highilghter} highlighter Highlighter instance.
  978. */
  979. function storeHighlighter(highlighter)
  980. {
  981. sh.vars.highlighters[getHighlighterId(highlighter.id)] = highlighter;
  982. };
  983. /**
  984. * Looks for a child or parent node which has specified classname.
  985. * Equivalent to jQuery's $(container).find(".className")
  986. * @param {Element} target Target element.
  987. * @param {String} search Class name or node name to look for.
  988. * @param {Boolean} reverse If set to true, will go up the node tree instead of down.
  989. * @return {Element} Returns found child or parent element on null.
  990. */
  991. function findElement(target, search, reverse /* optional */)
  992. {
  993. if (target == null)
  994. return null;
  995. var nodes = reverse != true ? target.childNodes : [ target.parentNode ],
  996. propertyToFind = { '#' : 'id', '.' : 'className' }[search.substr(0, 1)] || 'nodeName',
  997. expectedValue,
  998. found
  999. ;
  1000. expectedValue = propertyToFind != 'nodeName'
  1001. ? search.substr(1)
  1002. : search.toUpperCase()
  1003. ;
  1004. // main return of the found node
  1005. if ((target[propertyToFind] || '').indexOf(expectedValue) != -1)
  1006. return target;
  1007. for (var i = 0; nodes && i < nodes.length && found == null; i++)
  1008. found = findElement(nodes[i], search, reverse);
  1009. return found;
  1010. };
  1011. /**
  1012. * Looks for a parent node which has specified classname.
  1013. * This is an alias to <code>findElement(container, className, true)</code>.
  1014. * @param {Element} target Target element.
  1015. * @param {String} className Class name to look for.
  1016. * @return {Element} Returns found parent element on null.
  1017. */
  1018. function findParentElement(target, className)
  1019. {
  1020. return findElement(target, className, true);
  1021. };
  1022. /**
  1023. * Finds an index of element in the array.
  1024. * @ignore
  1025. * @param {Object} searchElement
  1026. * @param {Number} fromIndex
  1027. * @return {Number} Returns index of element if found; -1 otherwise.
  1028. */
  1029. function indexOf(array, searchElement, fromIndex)
  1030. {
  1031. fromIndex = Math.max(fromIndex || 0, 0);
  1032. for (var i = fromIndex; i < array.length; i++)
  1033. if(array[i] == searchElement)
  1034. return i;
  1035. return -1;
  1036. };
  1037. /**
  1038. * Generates a unique element ID.
  1039. */
  1040. function guid(prefix)
  1041. {
  1042. return (prefix || '') + Math.round(Math.random() * 1000000).toString();
  1043. };
  1044. /**
  1045. * Merges two objects. Values from obj2 override values in obj1.
  1046. * Function is NOT recursive and works only for one dimensional objects.
  1047. * @param {Object} obj1 First object.
  1048. * @param {Object} obj2 Second object.
  1049. * @return {Object} Returns combination of both objects.
  1050. */
  1051. function merge(obj1, obj2)
  1052. {
  1053. var result = {}, name;
  1054. for (name in obj1)
  1055. result[name] = obj1[name];
  1056. for (name in obj2)
  1057. result[name] = obj2[name];
  1058. return result;
  1059. };
  1060. /**
  1061. * Attempts to convert string to boolean.
  1062. * @param {String} value Input string.
  1063. * @return {Boolean} Returns true if input was "true", false if input was "false" and value otherwise.
  1064. */
  1065. function toBoolean(value)
  1066. {
  1067. var result = { "true" : true, "false" : false }[value];
  1068. return result == null ? value : result;
  1069. };
  1070. /**
  1071. * Opens up a centered popup window.
  1072. * @param {String} url URL to open in the window.
  1073. * @param {String} name Popup name.
  1074. * @param {int} width Popup width.
  1075. * @param {int} height Popup height.
  1076. * @param {String} options window.open() options.
  1077. * @return {Window} Returns window instance.
  1078. */
  1079. function popup(url, name, width, height, options)
  1080. {
  1081. var x = (screen.width - width) / 2,
  1082. y = (screen.height - height) / 2
  1083. ;
  1084. options += ', left=' + x +
  1085. ', top=' + y +
  1086. ', width=' + width +
  1087. ', height=' + height
  1088. ;
  1089. options = options.replace(/^,/, '');
  1090. var win = window.open(url, name, options);
  1091. win.focus();
  1092. return win;
  1093. };
  1094. /**
  1095. * Adds event handler to the target object.
  1096. * @param {Object} obj Target object.
  1097. * @param {String} type Name of the event.
  1098. * @param {Function} func Handling function.
  1099. */
  1100. function attachEvent(obj, type, func, scope)
  1101. {
  1102. function handler(e)
  1103. {
  1104. e = e || window.event;
  1105. if (!e.target)
  1106. {
  1107. e.target = e.srcElement;
  1108. e.preventDefault = function()
  1109. {
  1110. this.returnValue = false;
  1111. };
  1112. }
  1113. func.call(scope || window, e);
  1114. };
  1115. if (obj.attachEvent)
  1116. {
  1117. obj.attachEvent('on' + type, handler);
  1118. }
  1119. else
  1120. {
  1121. obj.addEventListener(type, handler, false);
  1122. }
  1123. };
  1124. /**
  1125. * Displays an alert.
  1126. * @param {String} str String to display.
  1127. */
  1128. function alert(str)
  1129. {
  1130. window.alert(sh.config.strings.alert + str);
  1131. };
  1132. /**
  1133. * Finds a brush by its alias.
  1134. *
  1135. * @param {String} alias Brush alias.
  1136. * @param {Boolean} showAlert Suppresses the alert if false.
  1137. * @return {Brush} Returns bursh constructor if found, null otherwise.
  1138. */
  1139. function findBrush(alias, showAlert)
  1140. {
  1141. var brushes = sh.vars.discoveredBrushes,
  1142. result = null
  1143. ;
  1144. if (brushes == null)
  1145. {
  1146. brushes = {};
  1147. // Find all brushes
  1148. for (var brush in sh.brushes)
  1149. {
  1150. var info = sh.brushes[brush],
  1151. aliases = info.aliases
  1152. ;
  1153. if (aliases == null)
  1154. continue;
  1155. // keep the brush name
  1156. info.brushName = brush.toLowerCase();
  1157. for (var i = 0; i < aliases.length; i++)
  1158. brushes[aliases[i]] = brush;
  1159. }
  1160. sh.vars.discoveredBrushes = brushes;
  1161. }
  1162. result = sh.brushes[brushes[alias]];
  1163. if (result == null && showAlert != false)
  1164. alert(sh.config.strings.noBrush + alias);
  1165. return result;
  1166. };
  1167. /**
  1168. * Executes a callback on each line and replaces each line with result from the callback.
  1169. * @param {Object} str Input string.
  1170. * @param {Object} callback Callback function taking one string argument and returning a string.
  1171. */
  1172. function eachLine(str, callback)
  1173. {
  1174. var lines = splitLines(str);
  1175. for (var i = 0; i < lines.length; i++)
  1176. lines[i] = callback(lines[i], i);
  1177. return lines.join('\n');
  1178. };
  1179. /**
  1180. * This is a special trim which only removes first and last empty lines
  1181. * and doesn't affect valid leading space on the first line.
  1182. *
  1183. * @param {String} str Input string
  1184. * @return {String} Returns string without empty first and last lines.
  1185. */
  1186. function trimFirstAndLastLines(str)
  1187. {
  1188. return str.replace(/^[ ]*[\n]+|[\n]*[ ]*$/g, '');
  1189. };
  1190. /**
  1191. * Parses key/value pairs into hash object.
  1192. *
  1193. * Understands the following formats:
  1194. * - name: word;
  1195. * - name: [word, word];
  1196. * - name: "string";
  1197. * - name: 'string';
  1198. *
  1199. * For example:
  1200. * name1: value; name2: [value, value]; name3: 'value'
  1201. *
  1202. * @param {String} str Input string.
  1203. * @return {Object} Returns deserialized object.
  1204. */
  1205. function parseParams(str)
  1206. {
  1207. var match,
  1208. result = {},
  1209. arrayRegex = new XRegExp("^\\[(?<values>(.*?))\\]$"),
  1210. regex = new XRegExp(
  1211. "(?<name>[\\w-]+)" +
  1212. "\\s*:\\s*" +
  1213. "(?<value>" +
  1214. "[\\w-%#]+|" + // word
  1215. "\\[.*?\\]|" + // [] array
  1216. '".*?"|' + // "" string
  1217. "'.*?'" + // '' string
  1218. ")\\s*;?",
  1219. "g"
  1220. )
  1221. ;
  1222. while ((match = regex.exec(str)) != null)
  1223. {
  1224. var value = match.value
  1225. .replace(/^['"]|['"]$/g, '') // strip quotes from end of strings
  1226. ;
  1227. // try to parse array value
  1228. if (value != null && arrayRegex.test(value))
  1229. {
  1230. var m = arrayRegex.exec(value);
  1231. value = m.values.length > 0 ? m.values.split(/\s*,\s*/) : [];
  1232. }
  1233. result[match.name] = value;
  1234. }
  1235. return result;
  1236. };
  1237. /**
  1238. * Wraps each line of the string into <code/> tag with given style applied to it.
  1239. *
  1240. * @param {String} str Input string.
  1241. * @param {String} css Style name to apply to the string.
  1242. * @return {String} Returns input string with each line surrounded by <span/> tag.
  1243. */
  1244. function wrapLinesWithCode(str, css)
  1245. {
  1246. if (str == null || str.length == 0 || str == '\n')
  1247. return str;
  1248. str = str.replace(/</g, '&lt;');
  1249. // Replace two or more sequential spaces with &nbsp; leaving last space untouched.
  1250. str = str.replace(/ {2,}/g, function(m)
  1251. {
  1252. var spaces = '';
  1253. for (var i = 0; i < m.length - 1; i++)
  1254. spaces += sh.config.space;
  1255. return spaces + ' ';
  1256. });
  1257. // Split each line and apply <span class="...">...</span> to them so that
  1258. // leading spaces aren't included.
  1259. if (css != null)
  1260. str = eachLine(str, function(line)
  1261. {
  1262. if (line.length == 0)
  1263. return '';
  1264. var spaces = '';
  1265. line = line.replace(/^(&nbsp;| )+/, function(s)
  1266. {
  1267. spaces = s;
  1268. return '';
  1269. });
  1270. if (line.length == 0)
  1271. return spaces;
  1272. return spaces + '<code class="' + css + '">' + line + '</code>';
  1273. });
  1274. return str;
  1275. };
  1276. /**
  1277. * Pads number with zeros until it's length is the same as given length.
  1278. *
  1279. * @param {Number} number Number to pad.
  1280. * @param {Number} length Max string length with.
  1281. * @return {String} Returns a string padded with proper amount of '0'.
  1282. */
  1283. function padNumber(number, length)
  1284. {
  1285. var result = number.toString();
  1286. while (result.length < length)
  1287. result = '0' + result;
  1288. return result;
  1289. };
  1290. /**
  1291. * Replaces tabs with spaces.
  1292. *
  1293. * @param {String} code Source code.
  1294. * @param {Number} tabSize Size of the tab.
  1295. * @return {String} Returns code with all tabs replaces by spaces.
  1296. */
  1297. function processTabs(code, tabSize)
  1298. {
  1299. var tab = '';
  1300. for (var i = 0; i < tabSize; i++)
  1301. tab += ' ';
  1302. return code.replace(/\t/g, tab);
  1303. };
  1304. /**
  1305. * Replaces tabs with smart spaces.
  1306. *
  1307. * @param {String} code Code to fix the tabs in.
  1308. * @param {Number} tabSize Number of spaces in a column.
  1309. * @return {String} Returns code with all tabs replaces with roper amount of spaces.
  1310. */
  1311. function processSmartTabs(code, tabSize)
  1312. {
  1313. var lines = splitLines(code),
  1314. tab = '\t',
  1315. spaces = ''
  1316. ;
  1317. // Create a string with 1000 spaces to copy spaces from...
  1318. // It's assumed that there would be no indentation longer than that.
  1319. for (var i = 0; i < 50; i++)
  1320. spaces += ' '; // 20 spaces * 50
  1321. // This function inserts specified amount of spaces in the string
  1322. // where a tab is while removing that given tab.
  1323. function insertSpaces(line, pos, count)
  1324. {
  1325. return line.substr(0, pos)
  1326. + spaces.substr(0, count)
  1327. + line.substr(pos + 1, line.length) // pos + 1 will get rid of the tab
  1328. ;
  1329. };
  1330. // Go through all the lines and do the 'smart tabs' magic.
  1331. code = eachLine(code, function(line)
  1332. {
  1333. if (line.indexOf(tab) == -1)
  1334. return line;
  1335. var pos = 0;
  1336. while ((pos = line.indexOf(tab)) != -1)
  1337. {
  1338. // This is pretty much all there is to the 'smart tabs' logic.
  1339. // Based on the position within the line and size of a tab,
  1340. // calculate the amount of spaces we need to insert.
  1341. var spaces = tabSize - pos % tabSize;
  1342. line = insertSpaces(line, pos, spaces);
  1343. }
  1344. return line;
  1345. });
  1346. return code;
  1347. };
  1348. /**
  1349. * Performs various string fixes based on configuration.
  1350. */
  1351. function fixInputString(str)
  1352. {
  1353. var br = /<br\s*\/?>|&lt;br\s*\/?&gt;/gi;
  1354. if (sh.config.bloggerMode == true)
  1355. str = str.replace(br, '\n');
  1356. if (sh.config.stripBrs == true)
  1357. str = str.replace(br, '');
  1358. return str;
  1359. };
  1360. /**
  1361. * Removes all white space at the begining and end of a string.
  1362. *
  1363. * @param {String} str String to trim.
  1364. * @return {String} Returns string without leading and following white space characters.
  1365. */
  1366. function trim(str)
  1367. {
  1368. return str.replace(/^\s+|\s+$/g, '');
  1369. };
  1370. /**
  1371. * Unindents a block of text by the lowest common indent amount.
  1372. * @param {String} str Text to unindent.
  1373. * @return {String} Returns unindented text block.
  1374. */
  1375. function unindent(str)
  1376. {
  1377. var lines = splitLines(fixInputString(str)),
  1378. indents = new Array(),
  1379. regex = /^\s*/,
  1380. min = 1000
  1381. ;
  1382. // go through every line and check for common number of indents
  1383. for (var i = 0; i < lines.length && min > 0; i++)
  1384. {
  1385. var line = lines[i];
  1386. if (trim(line).length == 0)
  1387. continue;
  1388. var matches = regex.exec(line);
  1389. // In the event that just one line doesn't have leading white space
  1390. // we can't unindent anything, so bail completely.
  1391. if (matches == null)
  1392. return str;
  1393. min = Math.min(matches[0].length, min);
  1394. }
  1395. // trim minimum common number of white space from the begining of every line
  1396. if (min > 0)
  1397. for (var i = 0; i < lines.length; i++)
  1398. lines[i] = lines[i].substr(min);
  1399. return lines.join('\n');
  1400. };
  1401. /**
  1402. * Callback method for Array.sort() which sorts matches by
  1403. * index position and then by length.
  1404. *
  1405. * @param {Match} m1 Left object.
  1406. * @param {Match} m2 Right object.
  1407. * @return {Number} Returns -1, 0 or -1 as a comparison result.
  1408. */
  1409. function matchesSortCallback(m1, m2)
  1410. {
  1411. // sort matches by index first
  1412. if(m1.index < m2.index)
  1413. return -1;
  1414. else if(m1.index > m2.index)
  1415. return 1;
  1416. else
  1417. {
  1418. // if index is the same, sort by length
  1419. if(m1.length < m2.length)
  1420. return -1;
  1421. else if(m1.length > m2.length)
  1422. return 1;
  1423. }
  1424. return 0;
  1425. };
  1426. /**
  1427. * Executes given regular expression on provided code and returns all
  1428. * matches that are found.
  1429. *
  1430. * @param {String} code Code to execute regular expression on.
  1431. * @param {Object} regex Regular expression item info from <code>regexList</code> collection.
  1432. * @return {Array} Returns a list of Match objects.
  1433. */
  1434. function getMatches(code, regexInfo)
  1435. {
  1436. function defaultAdd(match, regexInfo)
  1437. {
  1438. return match[0];
  1439. };
  1440. var index = 0,
  1441. match = null,
  1442. matches = [],
  1443. func = regexInfo.func ? regexInfo.func : defaultAdd
  1444. ;
  1445. while((match = regexInfo.regex.exec(code)) != null)
  1446. {
  1447. var resultMatch = func(match, regexInfo);
  1448. if (typeof(resultMatch) == 'string')
  1449. resultMatch = [new sh.Match(resultMatch, match.index, regexInfo.css)];
  1450. matches = matches.concat(resultMatch);
  1451. }
  1452. return matches;
  1453. };
  1454. /**
  1455. * Turns all URLs in the code into <a/> tags.
  1456. * @param {String} code Input code.
  1457. * @return {String} Returns code with </a> tags.
  1458. */
  1459. function processUrls(code)
  1460. {
  1461. var gt = /(.*)((&gt;|&lt;).*)/;
  1462. return code.replace(sh.regexLib.url, function(m)
  1463. {
  1464. var suffix = '',
  1465. match = null
  1466. ;
  1467. // We include &lt; and &gt; in the URL for the common cases like <http://google.com>
  1468. // The problem is that they get transformed into &lt;http://google.com&gt;
  1469. // Where as &gt; easily looks like part of the URL string.
  1470. if (match = gt.exec(m))
  1471. {
  1472. m = match[1];
  1473. suffix = match[2];
  1474. }
  1475. return '<a href="' + m + '">' + m + '</a>' + suffix;
  1476. });
  1477. };
  1478. /**
  1479. * Finds all <SCRIPT TYPE="syntaxhighlighter" /> elementss.
  1480. * @return {Array} Returns array of all found SyntaxHighlighter tags.
  1481. */
  1482. function getSyntaxHighlighterScriptTags()
  1483. {
  1484. var tags = document.getElementsByTagName('script'),
  1485. result = []
  1486. ;
  1487. for (var i = 0; i < tags.length; i++)
  1488. if (tags[i].type == 'syntaxhighlighter')
  1489. result.push(tags[i]);
  1490. return result;
  1491. };
  1492. /**
  1493. * Strips <![CDATA[]]> from <SCRIPT /> content because it should be used
  1494. * there in most cases for XHTML compliance.
  1495. * @param {String} original Input code.
  1496. * @return {String} Returns code without leading <![CDATA[]]> tags.
  1497. */
  1498. function stripCData(original)
  1499. {
  1500. var left = '<![CDATA[',
  1501. right = ']]>',
  1502. // for some reason IE inserts some leading blanks here
  1503. copy = trim(original),
  1504. changed = false,
  1505. leftLength = left.length,
  1506. rightLength = right.length
  1507. ;
  1508. if (copy.indexOf(left) == 0)
  1509. {
  1510. copy = copy.substring(leftLength);
  1511. changed = true;
  1512. }
  1513. var copyLength = copy.length;
  1514. //trace:2472
  1515. //当输入的内容是2个字符时,悲剧了copy.indexOf(right) == copyLength - rightLength 为真
  1516. //前边加个copy.indexOf(right)!= -1先判断一下
  1517. if (copy.indexOf(right)!= -1 && 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 (oising@gmail.com)
  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. })();
  3042. }