You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.html 226KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115
  1. <!DOCTYPE html>
  2. <html><head><meta charset="utf-8" content="text/html" http-equiv="Content-Type" /><meta content="lightweight literate programming for clojure -- inspired by [docco](http://jashkenas.github.com/docco/)" name="description" /><style type="text/css">/**
  3. * SyntaxHighlighter
  4. * http://alexgorbatchev.com/SyntaxHighlighter
  5. *
  6. * SyntaxHighlighter is donationware. If you are using it, please donate.
  7. * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
  8. *
  9. * @version
  10. * 3.0.83 (July 02 2010)
  11. *
  12. * @copyright
  13. * Copyright (C) 2004-2010 Alex Gorbatchev.
  14. *
  15. * @license
  16. * Dual licensed under the MIT and GPL licenses.
  17. */
  18. .syntaxhighlighter a,
  19. .syntaxhighlighter div,
  20. .syntaxhighlighter code,
  21. .syntaxhighlighter table,
  22. .syntaxhighlighter table td,
  23. .syntaxhighlighter table tr,
  24. .syntaxhighlighter table tbody,
  25. .syntaxhighlighter table thead,
  26. .syntaxhighlighter table caption,
  27. .syntaxhighlighter textarea {
  28. -moz-border-radius: 0 0 0 0 !important;
  29. -webkit-border-radius: 0 0 0 0 !important;
  30. background: none !important;
  31. border: 0 !important;
  32. bottom: auto !important;
  33. float: none !important;
  34. height: auto !important;
  35. left: auto !important;
  36. line-height: 1.1em !important;
  37. /* margin: 0 !important; */
  38. outline: 0 !important;
  39. overflow: visible !important;
  40. padding: 0 !important;
  41. position: static !important;
  42. right: auto !important;
  43. text-align: left !important;
  44. top: auto !important;
  45. vertical-align: baseline !important;
  46. width: auto !important;
  47. box-sizing: content-box !important;
  48. font-family: "Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important;
  49. font-weight: normal !important;
  50. font-style: normal !important;
  51. min-height: inherit !important;
  52. min-height: auto !important;
  53. }
  54. .syntaxhighlighter {
  55. /* width: 100% !important; */
  56. margin: 1em 0 1em 0 !important;
  57. position: relative !important;
  58. overflow: auto !important;
  59. }
  60. .syntaxhighlighter.source {
  61. overflow: hidden !important;
  62. }
  63. .syntaxhighlighter .bold {
  64. font-weight: bold !important;
  65. }
  66. .syntaxhighlighter .italic {
  67. font-style: italic !important;
  68. }
  69. .syntaxhighlighter .line {
  70. white-space: pre !important;
  71. }
  72. .syntaxhighlighter table {
  73. /* width: 100% !important;*/
  74. }
  75. .syntaxhighlighter table caption {
  76. text-align: left !important;
  77. padding: .5em 0 0.5em 1em !important;
  78. }
  79. .syntaxhighlighter table td.code {
  80. width: 100% !important;
  81. }
  82. .syntaxhighlighter table td.code .container {
  83. position: relative !important;
  84. }
  85. .syntaxhighlighter table td.code .container textarea {
  86. box-sizing: border-box !important;
  87. position: absolute !important;
  88. left: 0 !important;
  89. top: 0 !important;
  90. width: 100% !important;
  91. height: 100% !important;
  92. border: none !important;
  93. background: white !important;
  94. padding-left: 1em !important;
  95. overflow: hidden !important;
  96. white-space: pre !important;
  97. }
  98. .syntaxhighlighter table td.gutter .line {
  99. text-align: right !important;
  100. padding: 0 0.5em 0 1em !important;
  101. }
  102. .syntaxhighlighter table td.code .line {
  103. padding: 0 1em !important;
  104. }
  105. .syntaxhighlighter.nogutter td.code .container textarea, .syntaxhighlighter.nogutter td.code .line {
  106. padding-left: 0em !important;
  107. }
  108. .syntaxhighlighter.show {
  109. display: block !important;
  110. }
  111. .syntaxhighlighter.collapsed table {
  112. display: none !important;
  113. }
  114. .syntaxhighlighter.collapsed .toolbar {
  115. display: none;
  116. /* padding: 0.1em 0.8em 0em 0.8em !important;
  117. font-size: 1em !important;
  118. position: static !important;
  119. width: auto !important;
  120. height: auto !important;*/
  121. }
  122. .syntaxhighlighter.collapsed .toolbar span {
  123. display: inline !important;
  124. margin-right: 1em !important;
  125. }
  126. .syntaxhighlighter.collapsed .toolbar span a {
  127. padding: 0 !important;
  128. display: none !important;
  129. }
  130. .syntaxhighlighter.collapsed .toolbar span a.expandSource {
  131. display: inline !important;
  132. }
  133. .syntaxhighlighter .toolbar {
  134. display: none;
  135. /* position: absolute !important;
  136. right: 1px !important;
  137. top: 1px !important;
  138. width: 11px !important;
  139. height: 11px !important;
  140. font-size: 10px !important;
  141. z-index: 10 !important;*/
  142. }
  143. .syntaxhighlighter .toolbar span.title {
  144. display: inline !important;
  145. }
  146. .syntaxhighlighter .toolbar a {
  147. display: block !important;
  148. text-align: center !important;
  149. text-decoration: none !important;
  150. padding-top: 1px !important;
  151. }
  152. .syntaxhighlighter .toolbar a.expandSource {
  153. display: none !important;
  154. }
  155. .syntaxhighlighter.ie {
  156. font-size: .9em !important;
  157. padding: 1px 0 1px 0 !important;
  158. }
  159. .syntaxhighlighter.ie .toolbar {
  160. line-height: 8px !important;
  161. }
  162. .syntaxhighlighter.ie .toolbar a {
  163. padding-top: 0px !important;
  164. }
  165. .syntaxhighlighter.printing .line.alt1 .content,
  166. .syntaxhighlighter.printing .line.alt2 .content,
  167. .syntaxhighlighter.printing .line.highlighted .number,
  168. .syntaxhighlighter.printing .line.highlighted.alt1 .content,
  169. .syntaxhighlighter.printing .line.highlighted.alt2 .content {
  170. background: none !important;
  171. }
  172. .syntaxhighlighter.printing .line .number {
  173. color: #bbbbbb !important;
  174. }
  175. .syntaxhighlighter.printing .line .content {
  176. color: black !important;
  177. }
  178. .syntaxhighlighter.printing .toolbar {
  179. display: none !important;
  180. }
  181. .syntaxhighlighter.printing a {
  182. text-decoration: none !important;
  183. }
  184. .syntaxhighlighter.printing .plain, .syntaxhighlighter.printing .plain a {
  185. color: black !important;
  186. }
  187. .syntaxhighlighter.printing .comments, .syntaxhighlighter.printing .comments a {
  188. color: #008200 !important;
  189. }
  190. .syntaxhighlighter.printing .string, .syntaxhighlighter.printing .string a {
  191. color: blue !important;
  192. }
  193. .syntaxhighlighter.printing .keyword {
  194. color: #006699 !important;
  195. font-weight: bold !important;
  196. }
  197. .syntaxhighlighter.printing .preprocessor {
  198. color: gray !important;
  199. }
  200. .syntaxhighlighter.printing .variable {
  201. color: #aa7700 !important;
  202. }
  203. .syntaxhighlighter.printing .value {
  204. color: #009900 !important;
  205. }
  206. .syntaxhighlighter.printing .functions {
  207. color: #ff1493 !important;
  208. }
  209. .syntaxhighlighter.printing .constants {
  210. color: #0066cc !important;
  211. }
  212. .syntaxhighlighter.printing .script {
  213. font-weight: bold !important;
  214. }
  215. .syntaxhighlighter.printing .color1, .syntaxhighlighter.printing .color1 a {
  216. color: gray !important;
  217. }
  218. .syntaxhighlighter.printing .color2, .syntaxhighlighter.printing .color2 a {
  219. color: #ff1493 !important;
  220. }
  221. .syntaxhighlighter.printing .color3, .syntaxhighlighter.printing .color3 a {
  222. color: red !important;
  223. }
  224. .syntaxhighlighter.printing .break, .syntaxhighlighter.printing .break a {
  225. color: black !important;
  226. }
  227. </style><style type="text/css">.syntaxhighlighter{overflow:hidden !important;}</style><style type="text/css">/**
  228. * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
  229. *
  230. * @version
  231. * 3.0.83 (July 02 2010)
  232. *
  233. * @copyright
  234. * Copyright (C) 2004-2010 Alex Gorbatchev.
  235. *
  236. * @license
  237. * Dual licensed under the MIT and GPL licenses.
  238. */
  239. .syntaxhighlighter {
  240. background-color: transparent !important;
  241. }
  242. .syntaxhighlighter .line.alt1 {
  243. background-color: transparent !important;
  244. }
  245. .syntaxhighlighter .line.alt2 {
  246. background-color: transparent !important;
  247. }
  248. .syntaxhighlighter .line.highlighted.alt1, .syntaxhighlighter .line.highlighted.alt2 {
  249. background-color: #c3defe !important;
  250. }
  251. .syntaxhighlighter .line.highlighted.number {
  252. color: white !important;
  253. }
  254. .syntaxhighlighter table caption {
  255. color: black !important;
  256. }
  257. .syntaxhighlighter .gutter {
  258. color: #787878 !important;
  259. }
  260. .syntaxhighlighter .gutter .line {
  261. border-right: 3px solid #d4d0c8 !important;
  262. }
  263. .syntaxhighlighter .gutter .line.highlighted {
  264. background-color: #d4d0c8 !important;
  265. color: white !important;
  266. }
  267. .syntaxhighlighter.printing .line .content {
  268. border: none !important;
  269. }
  270. .syntaxhighlighter.collapsed {
  271. overflow: visible !important;
  272. }
  273. .syntaxhighlighter.collapsed .toolbar {
  274. color: #3f5fbf !important;
  275. background: white !important;
  276. border: 1px solid #d4d0c8 !important;
  277. }
  278. .syntaxhighlighter.collapsed .toolbar a {
  279. color: #3f5fbf !important;
  280. }
  281. .syntaxhighlighter.collapsed .toolbar a:hover {
  282. color: #aa7700 !important;
  283. }
  284. .syntaxhighlighter .toolbar {
  285. color: #a0a0a0 !important;
  286. background: #d4d0c8 !important;
  287. border: none !important;
  288. }
  289. .syntaxhighlighter .toolbar a {
  290. color: #a0a0a0 !important;
  291. }
  292. .syntaxhighlighter .toolbar a:hover {
  293. color: red !important;
  294. }
  295. .syntaxhighlighter .plain, .syntaxhighlighter .plain a {
  296. color: black !important;
  297. }
  298. .syntaxhighlighter .comments, .syntaxhighlighter .comments a {
  299. color: #3f5fbf !important;
  300. }
  301. .syntaxhighlighter .string, .syntaxhighlighter .string a {
  302. color: #2a00ff !important;
  303. }
  304. .syntaxhighlighter .keyword {
  305. color: #7f0055 !important;
  306. }
  307. .syntaxhighlighter .preprocessor {
  308. color: #646464 !important;
  309. }
  310. .syntaxhighlighter .variable {
  311. color: #aa7700 !important;
  312. }
  313. .syntaxhighlighter .value {
  314. color: #009900 !important;
  315. }
  316. .syntaxhighlighter .functions {
  317. color: #ff1493 !important;
  318. }
  319. .syntaxhighlighter .constants {
  320. color: #0066cc !important;
  321. }
  322. .syntaxhighlighter .script {
  323. font-weight: bold !important;
  324. color: #7f0055 !important;
  325. background-color: none !important;
  326. }
  327. .syntaxhighlighter .color1, .syntaxhighlighter .color1 a {
  328. color: gray !important;
  329. }
  330. .syntaxhighlighter .color2, .syntaxhighlighter .color2 a {
  331. color: #ff1493 !important;
  332. }
  333. .syntaxhighlighter .color3, .syntaxhighlighter .color3 a {
  334. color: red !important;
  335. }
  336. .syntaxhighlighter .xml .keyword {
  337. color: #3f7f7f !important;
  338. font-weight: normal !important;
  339. }
  340. .syntaxhighlighter .xml .color1, .syntaxhighlighter .xml .color1 a {
  341. color: #7f007f !important;
  342. }
  343. .syntaxhighlighter .xml .string {
  344. font-style: italic !important;
  345. color: #2a00ff !important;
  346. }
  347. .clojure.syntaxhighlighter .invalid {
  348. background-color: #FAA !important;
  349. }
  350. .clojure.syntaxhighlighter .quoted {
  351. font-style: italic !important;
  352. }
  353. .syntaxhighlighter .clojure.variable,
  354. .syntaxhighlighter .clojure.symbol,
  355. .syntaxhighlighter .clojure.value
  356. {
  357. color: #006060 !important;
  358. }
  359. .syntaxhighlighter .clojure.string {
  360. color: #55B !important;
  361. }
  362. .syntaxhighlighter .clojure.functions {
  363. color: black !important;
  364. }
  365. .syntaxhighlighter .clojure.color1 {
  366. color: #666 !important;
  367. }
  368. .syntaxhighlighter .clojure.color3 {
  369. color: #900 !important;
  370. }
  371. .syntaxhighlighter .clojure.constants {
  372. color: #1A734D !important;
  373. }
  374. </style><style type="text/css">html{margin:0;padding:0;}h1{margin:0;padding:0;}h2{margin:0;padding:0;}h3{margin:0;padding:0;}h4{margin:0;padding:0;}a{color:#261A3B;}a:visited{color:#261A3B;}</style><style type="text/css">.header{margin-top:30px;}h1.project-name{display:inline;font-size:34px;}h2.project-version{display:inline;margin-left:10px;margin-top:0;font-size:18px;}.toc-link{margin-left:10px;color:#252519;font-size:12px;text-decoration:none;}.toc-link:hover{color:#5050A6;}.toc h1{margin:0;font-size:34px;}.docs-header{margin-bottom:25px;padding-bottom:10px;border-bottom:dotted #aaa 1px;}.toc h1{font-size:24px;}.toc{margin-bottom:40px;border-bottom:solid #bbb 1px;}.toc ul{padding-left:0px;margin-left:20px;margin-top:0;padding-top:0;}.toc li{padding-left:0;list-style-type:none;}.dependencies{}.dependencies table{border:none;width:99.99%;margin-left:20px;font-size:16px;}.dependencies td{padding-right:20px;;white-space:nowrap;}.dependencies .dotted{width:99%;}.dependencies .dotted hr{margin-bottom:-6px;noshade:noshade;border-top:none;color:transparent;border-left:none;border-bottom:dotted #bbb 1px;border-right:none;background-color:transparent;height:0;}.dependencies .dep-version{text-align:right;}.plugins ul{padding-left:0px;margin-left:20px;margin-top:0;padding-top:0;}.plugins li{padding-left:0;list-style-type:none;}.header p{margin-left:20px;}</style><style type="text/css">#floating-toc{position:fixed;text-align:right;overflow:hidden;top:10px;right:20px;height:20px;}#floating-toc li{margin:0;padding:0;list-style-type:none;}</style><style type="text/css">body{margin:0;padding:0;color:#252519;font-size:16px;background-color:#F5F5FF;font-family:'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;;}h1{margin-top:0;font-size:20px;}a.anchor{color:#252519;text-decoration:none;}a.anchor:hover{color:#5050A6;}table{margin-bottom:10px;border-bottom:solid #ddd 1px;;border-spacing:0;}code{display:inline;}p{margin-top:8px;}tr{margin:0px;padding:0px;}td.docs{border:none;margin:0px;padding-left:55px;width:410px;padding-right:20px;vertical-align:top;max-width:410px;background-color:#FFF;}td.docs pre{font-size:12px;overflow:hidden;}td.codes{border:none;margin:0px;padding-left:20px;width:55%;border-left:solid #E5E5EE 1px;font-size:10pt;vertical-align:top;overflow:hidden;background-color:#F5F5FF;}td.spacer{padding-bottom:40px;}pre code{display:block;padding:4px;}code{border:solid #DEDEDE 1px;padding-left:3px;padding-right:3px;font-size:14px;background-color:ghostWhite;}.syntaxhighlighter code{font-size:13px;}.footer{text-align:center;}</style><script type="text/javascript">/*!
  375. * jQuery JavaScript Library v1.4.4
  376. * http://jquery.com/
  377. *
  378. * Copyright 2010, John Resig
  379. * Dual licensed under the MIT or GPL Version 2 licenses.
  380. * http://jquery.org/license
  381. *
  382. * Includes Sizzle.js
  383. * http://sizzlejs.com/
  384. * Copyright 2010, The Dojo Foundation
  385. * Released under the MIT, BSD, and GPL Licenses.
  386. *
  387. * Date: Thu Nov 11 19:04:53 2010 -0500
  388. */
  389. (function(E,B){function ka(a,b,d){if(d===B&&a.nodeType===1){d=a.getAttribute("data-"+b);if(typeof d==="string"){try{d=d==="true"?true:d==="false"?false:d==="null"?null:!c.isNaN(d)?parseFloat(d):Ja.test(d)?c.parseJSON(d):d}catch(e){}c.data(a,b,d)}else d=B}return d}function U(){return false}function ca(){return true}function la(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function Ka(a){var b,d,e,f,h,l,k,o,x,r,A,C=[];f=[];h=c.data(this,this.nodeType?"events":"__events__");if(typeof h==="function")h=
  390. h.events;if(!(a.liveFired===this||!h||!h.live||a.button&&a.type==="click")){if(a.namespace)A=RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)");a.liveFired=this;var J=h.live.slice(0);for(k=0;k<J.length;k++){h=J[k];h.origType.replace(X,"")===a.type?f.push(h.selector):J.splice(k--,1)}f=c(a.target).closest(f,a.currentTarget);o=0;for(x=f.length;o<x;o++){r=f[o];for(k=0;k<J.length;k++){h=J[k];if(r.selector===h.selector&&(!A||A.test(h.namespace))){l=r.elem;e=null;if(h.preType==="mouseenter"||
  391. h.preType==="mouseleave"){a.type=h.preType;e=c(a.relatedTarget).closest(h.selector)[0]}if(!e||e!==l)C.push({elem:l,handleObj:h,level:r.level})}}}o=0;for(x=C.length;o<x;o++){f=C[o];if(d&&f.level>d)break;a.currentTarget=f.elem;a.data=f.handleObj.data;a.handleObj=f.handleObj;A=f.handleObj.origHandler.apply(f.elem,arguments);if(A===false||a.isPropagationStopped()){d=f.level;if(A===false)b=false;if(a.isImmediatePropagationStopped())break}}return b}}function Y(a,b){return(a&&a!=="*"?a+".":"")+b.replace(La,
  392. "`").replace(Ma,"&")}function ma(a,b,d){if(c.isFunction(b))return c.grep(a,function(f,h){return!!b.call(f,h,f)===d});else if(b.nodeType)return c.grep(a,function(f){return f===b===d});else if(typeof b==="string"){var e=c.grep(a,function(f){return f.nodeType===1});if(Na.test(b))return c.filter(b,e,!d);else b=c.filter(b,e)}return c.grep(a,function(f){return c.inArray(f,b)>=0===d})}function na(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var e=c.data(a[d++]),f=c.data(this,
  393. e);if(e=e&&e.events){delete f.handle;f.events={};for(var h in e)for(var l in e[h])c.event.add(this,h,e[h][l],e[h][l].data)}}})}function Oa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function oa(a,b,d){var e=b==="width"?a.offsetWidth:a.offsetHeight;if(d==="border")return e;c.each(b==="width"?Pa:Qa,function(){d||(e-=parseFloat(c.css(a,"padding"+this))||0);if(d==="margin")e+=parseFloat(c.css(a,
  394. "margin"+this))||0;else e-=parseFloat(c.css(a,"border"+this+"Width"))||0});return e}function da(a,b,d,e){if(c.isArray(b)&&b.length)c.each(b,function(f,h){d||Ra.test(a)?e(a,h):da(a+"["+(typeof h==="object"||c.isArray(h)?f:"")+"]",h,d,e)});else if(!d&&b!=null&&typeof b==="object")c.isEmptyObject(b)?e(a,""):c.each(b,function(f,h){da(a+"["+f+"]",h,d,e)});else e(a,b)}function S(a,b){var d={};c.each(pa.concat.apply([],pa.slice(0,b)),function(){d[this]=a});return d}function qa(a){if(!ea[a]){var b=c("<"+
  395. a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d==="")d="block";ea[a]=d}return ea[a]}function fa(a){return c.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var t=E.document,c=function(){function a(){if(!b.isReady){try{t.documentElement.doScroll("left")}catch(j){setTimeout(a,1);return}b.ready()}}var b=function(j,s){return new b.fn.init(j,s)},d=E.jQuery,e=E.$,f,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,l=/\S/,k=/^\s+/,o=/\s+$/,x=/\W/,r=/\d/,A=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,
  396. C=/^[\],:{}\s]*$/,J=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,w=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,I=/(?:^|:|,)(?:\s*\[)+/g,L=/(webkit)[ \/]([\w.]+)/,g=/(opera)(?:.*version)?[ \/]([\w.]+)/,i=/(msie) ([\w.]+)/,n=/(mozilla)(?:.*? rv:([\w.]+))?/,m=navigator.userAgent,p=false,q=[],u,y=Object.prototype.toString,F=Object.prototype.hasOwnProperty,M=Array.prototype.push,N=Array.prototype.slice,O=String.prototype.trim,D=Array.prototype.indexOf,R={};b.fn=b.prototype={init:function(j,
  397. s){var v,z,H;if(!j)return this;if(j.nodeType){this.context=this[0]=j;this.length=1;return this}if(j==="body"&&!s&&t.body){this.context=t;this[0]=t.body;this.selector="body";this.length=1;return this}if(typeof j==="string")if((v=h.exec(j))&&(v[1]||!s))if(v[1]){H=s?s.ownerDocument||s:t;if(z=A.exec(j))if(b.isPlainObject(s)){j=[t.createElement(z[1])];b.fn.attr.call(j,s,true)}else j=[H.createElement(z[1])];else{z=b.buildFragment([v[1]],[H]);j=(z.cacheable?z.fragment.cloneNode(true):z.fragment).childNodes}return b.merge(this,
  398. j)}else{if((z=t.getElementById(v[2]))&&z.parentNode){if(z.id!==v[2])return f.find(j);this.length=1;this[0]=z}this.context=t;this.selector=j;return this}else if(!s&&!x.test(j)){this.selector=j;this.context=t;j=t.getElementsByTagName(j);return b.merge(this,j)}else return!s||s.jquery?(s||f).find(j):b(s).find(j);else if(b.isFunction(j))return f.ready(j);if(j.selector!==B){this.selector=j.selector;this.context=j.context}return b.makeArray(j,this)},selector:"",jquery:"1.4.4",length:0,size:function(){return this.length},
  399. toArray:function(){return N.call(this,0)},get:function(j){return j==null?this.toArray():j<0?this.slice(j)[0]:this[j]},pushStack:function(j,s,v){var z=b();b.isArray(j)?M.apply(z,j):b.merge(z,j);z.prevObject=this;z.context=this.context;if(s==="find")z.selector=this.selector+(this.selector?" ":"")+v;else if(s)z.selector=this.selector+"."+s+"("+v+")";return z},each:function(j,s){return b.each(this,j,s)},ready:function(j){b.bindReady();if(b.isReady)j.call(t,b);else q&&q.push(j);return this},eq:function(j){return j===
  400. -1?this.slice(j):this.slice(j,+j+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(N.apply(this,arguments),"slice",N.call(arguments).join(","))},map:function(j){return this.pushStack(b.map(this,function(s,v){return j.call(s,v,s)}))},end:function(){return this.prevObject||b(null)},push:M,sort:[].sort,splice:[].splice};b.fn.init.prototype=b.fn;b.extend=b.fn.extend=function(){var j,s,v,z,H,G=arguments[0]||{},K=1,Q=arguments.length,ga=false;
  401. if(typeof G==="boolean"){ga=G;G=arguments[1]||{};K=2}if(typeof G!=="object"&&!b.isFunction(G))G={};if(Q===K){G=this;--K}for(;K<Q;K++)if((j=arguments[K])!=null)for(s in j){v=G[s];z=j[s];if(G!==z)if(ga&&z&&(b.isPlainObject(z)||(H=b.isArray(z)))){if(H){H=false;v=v&&b.isArray(v)?v:[]}else v=v&&b.isPlainObject(v)?v:{};G[s]=b.extend(ga,v,z)}else if(z!==B)G[s]=z}return G};b.extend({noConflict:function(j){E.$=e;if(j)E.jQuery=d;return b},isReady:false,readyWait:1,ready:function(j){j===true&&b.readyWait--;
  402. if(!b.readyWait||j!==true&&!b.isReady){if(!t.body)return setTimeout(b.ready,1);b.isReady=true;if(!(j!==true&&--b.readyWait>0))if(q){var s=0,v=q;for(q=null;j=v[s++];)j.call(t,b);b.fn.trigger&&b(t).trigger("ready").unbind("ready")}}},bindReady:function(){if(!p){p=true;if(t.readyState==="complete")return setTimeout(b.ready,1);if(t.addEventListener){t.addEventListener("DOMContentLoaded",u,false);E.addEventListener("load",b.ready,false)}else if(t.attachEvent){t.attachEvent("onreadystatechange",u);E.attachEvent("onload",
  403. b.ready);var j=false;try{j=E.frameElement==null}catch(s){}t.documentElement.doScroll&&j&&a()}}},isFunction:function(j){return b.type(j)==="function"},isArray:Array.isArray||function(j){return b.type(j)==="array"},isWindow:function(j){return j&&typeof j==="object"&&"setInterval"in j},isNaN:function(j){return j==null||!r.test(j)||isNaN(j)},type:function(j){return j==null?String(j):R[y.call(j)]||"object"},isPlainObject:function(j){if(!j||b.type(j)!=="object"||j.nodeType||b.isWindow(j))return false;if(j.constructor&&
  404. !F.call(j,"constructor")&&!F.call(j.constructor.prototype,"isPrototypeOf"))return false;for(var s in j);return s===B||F.call(j,s)},isEmptyObject:function(j){for(var s in j)return false;return true},error:function(j){throw j;},parseJSON:function(j){if(typeof j!=="string"||!j)return null;j=b.trim(j);if(C.test(j.replace(J,"@").replace(w,"]").replace(I,"")))return E.JSON&&E.JSON.parse?E.JSON.parse(j):(new Function("return "+j))();else b.error("Invalid JSON: "+j)},noop:function(){},globalEval:function(j){if(j&&
  405. l.test(j)){var s=t.getElementsByTagName("head")[0]||t.documentElement,v=t.createElement("script");v.type="text/javascript";if(b.support.scriptEval)v.appendChild(t.createTextNode(j));else v.text=j;s.insertBefore(v,s.firstChild);s.removeChild(v)}},nodeName:function(j,s){return j.nodeName&&j.nodeName.toUpperCase()===s.toUpperCase()},each:function(j,s,v){var z,H=0,G=j.length,K=G===B||b.isFunction(j);if(v)if(K)for(z in j){if(s.apply(j[z],v)===false)break}else for(;H<G;){if(s.apply(j[H++],v)===false)break}else if(K)for(z in j){if(s.call(j[z],
  406. z,j[z])===false)break}else for(v=j[0];H<G&&s.call(v,H,v)!==false;v=j[++H]);return j},trim:O?function(j){return j==null?"":O.call(j)}:function(j){return j==null?"":j.toString().replace(k,"").replace(o,"")},makeArray:function(j,s){var v=s||[];if(j!=null){var z=b.type(j);j.length==null||z==="string"||z==="function"||z==="regexp"||b.isWindow(j)?M.call(v,j):b.merge(v,j)}return v},inArray:function(j,s){if(s.indexOf)return s.indexOf(j);for(var v=0,z=s.length;v<z;v++)if(s[v]===j)return v;return-1},merge:function(j,
  407. s){var v=j.length,z=0;if(typeof s.length==="number")for(var H=s.length;z<H;z++)j[v++]=s[z];else for(;s[z]!==B;)j[v++]=s[z++];j.length=v;return j},grep:function(j,s,v){var z=[],H;v=!!v;for(var G=0,K=j.length;G<K;G++){H=!!s(j[G],G);v!==H&&z.push(j[G])}return z},map:function(j,s,v){for(var z=[],H,G=0,K=j.length;G<K;G++){H=s(j[G],G,v);if(H!=null)z[z.length]=H}return z.concat.apply([],z)},guid:1,proxy:function(j,s,v){if(arguments.length===2)if(typeof s==="string"){v=j;j=v[s];s=B}else if(s&&!b.isFunction(s)){v=
  408. s;s=B}if(!s&&j)s=function(){return j.apply(v||this,arguments)};if(j)s.guid=j.guid=j.guid||s.guid||b.guid++;return s},access:function(j,s,v,z,H,G){var K=j.length;if(typeof s==="object"){for(var Q in s)b.access(j,Q,s[Q],z,H,v);return j}if(v!==B){z=!G&&z&&b.isFunction(v);for(Q=0;Q<K;Q++)H(j[Q],s,z?v.call(j[Q],Q,H(j[Q],s)):v,G);return j}return K?H(j[0],s):B},now:function(){return(new Date).getTime()},uaMatch:function(j){j=j.toLowerCase();j=L.exec(j)||g.exec(j)||i.exec(j)||j.indexOf("compatible")<0&&n.exec(j)||
  409. [];return{browser:j[1]||"",version:j[2]||"0"}},browser:{}});b.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(j,s){R["[object "+s+"]"]=s.toLowerCase()});m=b.uaMatch(m);if(m.browser){b.browser[m.browser]=true;b.browser.version=m.version}if(b.browser.webkit)b.browser.safari=true;if(D)b.inArray=function(j,s){return D.call(s,j)};if(!/\s/.test("\u00a0")){k=/^[\s\xA0]+/;o=/[\s\xA0]+$/}f=b(t);if(t.addEventListener)u=function(){t.removeEventListener("DOMContentLoaded",u,
  410. false);b.ready()};else if(t.attachEvent)u=function(){if(t.readyState==="complete"){t.detachEvent("onreadystatechange",u);b.ready()}};return E.jQuery=E.$=b}();(function(){c.support={};var a=t.documentElement,b=t.createElement("script"),d=t.createElement("div"),e="script"+c.now();d.style.display="none";d.innerHTML=" <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";var f=d.getElementsByTagName("*"),h=d.getElementsByTagName("a")[0],l=t.createElement("select"),
  411. k=l.appendChild(t.createElement("option"));if(!(!f||!f.length||!h)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(h.getAttribute("style")),hrefNormalized:h.getAttribute("href")==="/a",opacity:/^0.55$/.test(h.style.opacity),cssFloat:!!h.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:k.selected,deleteExpando:true,optDisabled:false,checkClone:false,
  412. scriptEval:false,noCloneEvent:true,boxModel:null,inlineBlockNeedsLayout:false,shrinkWrapBlocks:false,reliableHiddenOffsets:true};l.disabled=true;c.support.optDisabled=!k.disabled;b.type="text/javascript";try{b.appendChild(t.createTextNode("window."+e+"=1;"))}catch(o){}a.insertBefore(b,a.firstChild);if(E[e]){c.support.scriptEval=true;delete E[e]}try{delete b.test}catch(x){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function r(){c.support.noCloneEvent=
  413. false;d.detachEvent("onclick",r)});d.cloneNode(true).fireEvent("onclick")}d=t.createElement("div");d.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=t.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var r=t.createElement("div");r.style.width=r.style.paddingLeft="1px";t.body.appendChild(r);c.boxModel=c.support.boxModel=r.offsetWidth===2;if("zoom"in r.style){r.style.display="inline";r.style.zoom=
  414. 1;c.support.inlineBlockNeedsLayout=r.offsetWidth===2;r.style.display="";r.innerHTML="<div style='width:4px;'></div>";c.support.shrinkWrapBlocks=r.offsetWidth!==2}r.innerHTML="<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>";var A=r.getElementsByTagName("td");c.support.reliableHiddenOffsets=A[0].offsetHeight===0;A[0].style.display="";A[1].style.display="none";c.support.reliableHiddenOffsets=c.support.reliableHiddenOffsets&&A[0].offsetHeight===0;r.innerHTML="";t.body.removeChild(r).style.display=
  415. "none"});a=function(r){var A=t.createElement("div");r="on"+r;var C=r in A;if(!C){A.setAttribute(r,"return;");C=typeof A[r]==="function"}return C};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=f=h=null}})();var ra={},Ja=/^(?:\{.*\}|\[.*\])$/;c.extend({cache:{},uuid:0,expando:"jQuery"+c.now(),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},data:function(a,b,d){if(c.acceptData(a)){a=a==E?ra:a;var e=a.nodeType,f=e?a[c.expando]:null,h=
  416. c.cache;if(!(e&&!f&&typeof b==="string"&&d===B)){if(e)f||(a[c.expando]=f=++c.uuid);else h=a;if(typeof b==="object")if(e)h[f]=c.extend(h[f],b);else c.extend(h,b);else if(e&&!h[f])h[f]={};a=e?h[f]:h;if(d!==B)a[b]=d;return typeof b==="string"?a[b]:a}}},removeData:function(a,b){if(c.acceptData(a)){a=a==E?ra:a;var d=a.nodeType,e=d?a[c.expando]:a,f=c.cache,h=d?f[e]:e;if(b){if(h){delete h[b];d&&c.isEmptyObject(h)&&c.removeData(a)}}else if(d&&c.support.deleteExpando)delete a[c.expando];else if(a.removeAttribute)a.removeAttribute(c.expando);
  417. else if(d)delete f[e];else for(var l in a)delete a[l]}},acceptData:function(a){if(a.nodeName){var b=c.noData[a.nodeName.toLowerCase()];if(b)return!(b===true||a.getAttribute("classid")!==b)}return true}});c.fn.extend({data:function(a,b){var d=null;if(typeof a==="undefined"){if(this.length){var e=this[0].attributes,f;d=c.data(this[0]);for(var h=0,l=e.length;h<l;h++){f=e[h].name;if(f.indexOf("data-")===0){f=f.substr(5);ka(this[0],f,d[f])}}}return d}else if(typeof a==="object")return this.each(function(){c.data(this,
  418. a)});var k=a.split(".");k[1]=k[1]?"."+k[1]:"";if(b===B){d=this.triggerHandler("getData"+k[1]+"!",[k[0]]);if(d===B&&this.length){d=c.data(this[0],a);d=ka(this[0],a,d)}return d===B&&k[1]?this.data(k[0]):d}else return this.each(function(){var o=c(this),x=[k[0],b];o.triggerHandler("setData"+k[1]+"!",x);c.data(this,a,b);o.triggerHandler("changeData"+k[1]+"!",x)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var e=
  419. c.data(a,b);if(!d)return e||[];if(!e||c.isArray(d))e=c.data(a,b,c.makeArray(d));else e.push(d);return e}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),e=d.shift();if(e==="inprogress")e=d.shift();if(e){b==="fx"&&d.unshift("inprogress");e.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===B)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,
  420. a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var sa=/[\n\t]/g,ha=/\s+/,Sa=/\r/g,Ta=/^(?:href|src|style)$/,Ua=/^(?:button|input)$/i,Va=/^(?:button|input|object|select|textarea)$/i,Wa=/^a(?:rea)?$/i,ta=/^(?:radio|checkbox)$/i;c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",
  421. colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};c.fn.extend({attr:function(a,b){return c.access(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(x){var r=c(this);r.addClass(a.call(this,x,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ha),d=0,e=this.length;d<e;d++){var f=this[d];if(f.nodeType===
  422. 1)if(f.className){for(var h=" "+f.className+" ",l=f.className,k=0,o=b.length;k<o;k++)if(h.indexOf(" "+b[k]+" ")<0)l+=" "+b[k];f.className=c.trim(l)}else f.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(o){var x=c(this);x.removeClass(a.call(this,o,x.attr("class")))});if(a&&typeof a==="string"||a===B)for(var b=(a||"").split(ha),d=0,e=this.length;d<e;d++){var f=this[d];if(f.nodeType===1&&f.className)if(a){for(var h=(" "+f.className+" ").replace(sa," "),
  423. l=0,k=b.length;l<k;l++)h=h.replace(" "+b[l]+" "," ");f.className=c.trim(h)}else f.className=""}return this},toggleClass:function(a,b){var d=typeof a,e=typeof b==="boolean";if(c.isFunction(a))return this.each(function(f){var h=c(this);h.toggleClass(a.call(this,f,h.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var f,h=0,l=c(this),k=b,o=a.split(ha);f=o[h++];){k=e?k:!l.hasClass(f);l[k?"addClass":"removeClass"](f)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,
  424. "__className__",this.className);this.className=this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(sa," ").indexOf(a)>-1)return true;return false},val:function(a){if(!arguments.length){var b=this[0];if(b){if(c.nodeName(b,"option")){var d=b.attributes.value;return!d||d.specified?b.value:b.text}if(c.nodeName(b,"select")){var e=b.selectedIndex;d=[];var f=b.options;b=b.type==="select-one";
  425. if(e<0)return null;var h=b?e:0;for(e=b?e+1:f.length;h<e;h++){var l=f[h];if(l.selected&&(c.support.optDisabled?!l.disabled:l.getAttribute("disabled")===null)&&(!l.parentNode.disabled||!c.nodeName(l.parentNode,"optgroup"))){a=c(l).val();if(b)return a;d.push(a)}}return d}if(ta.test(b.type)&&!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Sa,"")}return B}var k=c.isFunction(a);return this.each(function(o){var x=c(this),r=a;if(this.nodeType===1){if(k)r=
  426. a.call(this,o,x.val());if(r==null)r="";else if(typeof r==="number")r+="";else if(c.isArray(r))r=c.map(r,function(C){return C==null?"":C+""});if(c.isArray(r)&&ta.test(this.type))this.checked=c.inArray(x.val(),r)>=0;else if(c.nodeName(this,"select")){var A=c.makeArray(r);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),A)>=0});if(!A.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},
  427. attr:function(a,b,d,e){if(!a||a.nodeType===3||a.nodeType===8)return B;if(e&&b in c.attrFn)return c(a)[b](d);e=a.nodeType!==1||!c.isXMLDoc(a);var f=d!==B;b=e&&c.props[b]||b;var h=Ta.test(b);if((b in a||a[b]!==B)&&e&&!h){if(f){b==="type"&&Ua.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");if(d===null)a.nodeType===1&&a.removeAttribute(b);else a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&
  428. b.specified?b.value:Va.test(a.nodeName)||Wa.test(a.nodeName)&&a.href?0:B;return a[b]}if(!c.support.style&&e&&b==="style"){if(f)a.style.cssText=""+d;return a.style.cssText}f&&a.setAttribute(b,""+d);if(!a.attributes[b]&&a.hasAttribute&&!a.hasAttribute(b))return B;a=!c.support.hrefNormalized&&e&&h?a.getAttribute(b,2):a.getAttribute(b);return a===null?B:a}});var X=/\.(.*)$/,ia=/^(?:textarea|input|select)$/i,La=/\./g,Ma=/ /g,Xa=/[^\w\s.|`]/g,Ya=function(a){return a.replace(Xa,"\\$&")},ua={focusin:0,focusout:0};
  429. c.event={add:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(c.isWindow(a)&&a!==E&&!a.frameElement)a=E;if(d===false)d=U;else if(!d)return;var f,h;if(d.handler){f=d;d=f.handler}if(!d.guid)d.guid=c.guid++;if(h=c.data(a)){var l=a.nodeType?"events":"__events__",k=h[l],o=h.handle;if(typeof k==="function"){o=k.handle;k=k.events}else if(!k){a.nodeType||(h[l]=h=function(){});h.events=k={}}if(!o)h.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,
  430. arguments):B};o.elem=a;b=b.split(" ");for(var x=0,r;l=b[x++];){h=f?c.extend({},f):{handler:d,data:e};if(l.indexOf(".")>-1){r=l.split(".");l=r.shift();h.namespace=r.slice(0).sort().join(".")}else{r=[];h.namespace=""}h.type=l;if(!h.guid)h.guid=d.guid;var A=k[l],C=c.event.special[l]||{};if(!A){A=k[l]=[];if(!C.setup||C.setup.call(a,e,r,o)===false)if(a.addEventListener)a.addEventListener(l,o,false);else a.attachEvent&&a.attachEvent("on"+l,o)}if(C.add){C.add.call(a,h);if(!h.handler.guid)h.handler.guid=
  431. d.guid}A.push(h);c.event.global[l]=true}a=null}}},global:{},remove:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(d===false)d=U;var f,h,l=0,k,o,x,r,A,C,J=a.nodeType?"events":"__events__",w=c.data(a),I=w&&w[J];if(w&&I){if(typeof I==="function"){w=I;I=I.events}if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(f in I)c.event.remove(a,f+b)}else{for(b=b.split(" ");f=b[l++];){r=f;k=f.indexOf(".")<0;o=[];if(!k){o=f.split(".");f=o.shift();x=RegExp("(^|\\.)"+
  432. c.map(o.slice(0).sort(),Ya).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(A=I[f])if(d){r=c.event.special[f]||{};for(h=e||0;h<A.length;h++){C=A[h];if(d.guid===C.guid){if(k||x.test(C.namespace)){e==null&&A.splice(h--,1);r.remove&&r.remove.call(a,C)}if(e!=null)break}}if(A.length===0||e!=null&&A.length===1){if(!r.teardown||r.teardown.call(a,o)===false)c.removeEvent(a,f,w.handle);delete I[f]}}else for(h=0;h<A.length;h++){C=A[h];if(k||x.test(C.namespace)){c.event.remove(a,r,C.handler,h);A.splice(h--,1)}}}if(c.isEmptyObject(I)){if(b=
  433. w.handle)b.elem=null;delete w.events;delete w.handle;if(typeof w==="function")c.removeData(a,J);else c.isEmptyObject(w)&&c.removeData(a)}}}}},trigger:function(a,b,d,e){var f=a.type||a;if(!e){a=typeof a==="object"?a[c.expando]?a:c.extend(c.Event(f),a):c.Event(f);if(f.indexOf("!")>=0){a.type=f=f.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[f]&&c.each(c.cache,function(){this.events&&this.events[f]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===
  434. 8)return B;a.result=B;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(e=d.nodeType?c.data(d,"handle"):(c.data(d,"__events__")||{}).handle)&&e.apply(d,b);e=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+f]&&d["on"+f].apply(d,b)===false){a.result=false;a.preventDefault()}}catch(h){}if(!a.isPropagationStopped()&&e)c.event.trigger(a,b,e,true);else if(!a.isDefaultPrevented()){var l;e=a.target;var k=f.replace(X,""),o=c.nodeName(e,"a")&&k===
  435. "click",x=c.event.special[k]||{};if((!x._default||x._default.call(d,a)===false)&&!o&&!(e&&e.nodeName&&c.noData[e.nodeName.toLowerCase()])){try{if(e[k]){if(l=e["on"+k])e["on"+k]=null;c.event.triggered=true;e[k]()}}catch(r){}if(l)e["on"+k]=l;c.event.triggered=false}}},handle:function(a){var b,d,e,f;d=[];var h=c.makeArray(arguments);a=h[0]=c.event.fix(a||E.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;if(!b){e=a.type.split(".");a.type=e.shift();d=e.slice(0).sort();e=RegExp("(^|\\.)"+
  436. d.join("\\.(?:.*\\.)?")+"(\\.|$)")}a.namespace=a.namespace||d.join(".");f=c.data(this,this.nodeType?"events":"__events__");if(typeof f==="function")f=f.events;d=(f||{})[a.type];if(f&&d){d=d.slice(0);f=0;for(var l=d.length;f<l;f++){var k=d[f];if(b||e.test(k.namespace)){a.handler=k.handler;a.data=k.data;a.handleObj=k;k=k.handler.apply(this,h);if(k!==B){a.result=k;if(k===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
  437. fix:function(a){if(a[c.expando])return a;var b=a;a=c.Event(b);for(var d=this.props.length,e;d;){e=this.props[--d];a[e]=b[e]}if(!a.target)a.target=a.srcElement||t;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=t.documentElement;d=t.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||
  438. d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(a.which==null&&(a.charCode!=null||a.keyCode!=null))a.which=a.charCode!=null?a.charCode:a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==B)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a){c.event.add(this,Y(a.origType,a.selector),c.extend({},a,{handler:Ka,guid:a.handler.guid}))},remove:function(a){c.event.remove(this,
  439. Y(a.origType,a.selector),a)}},beforeunload:{setup:function(a,b,d){if(c.isWindow(this))this.onbeforeunload=d},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};c.removeEvent=t.removeEventListener?function(a,b,d){a.removeEventListener&&a.removeEventListener(b,d,false)}:function(a,b,d){a.detachEvent&&a.detachEvent("on"+b,d)};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=a;this.type=a.type}else this.type=a;this.timeStamp=
  440. c.now();this[c.expando]=true};c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=ca;var a=this.originalEvent;if(a)if(a.preventDefault)a.preventDefault();else a.returnValue=false},stopPropagation:function(){this.isPropagationStopped=ca;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=ca;this.stopPropagation()},isDefaultPrevented:U,isPropagationStopped:U,isImmediatePropagationStopped:U};
  441. var va=function(a){var b=a.relatedTarget;try{for(;b&&b!==this;)b=b.parentNode;if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}}catch(d){}},wa=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?wa:va,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?wa:va)}}});if(!c.support.submitBubbles)c.event.special.submit={setup:function(){if(this.nodeName.toLowerCase()!==
  442. "form"){c.event.add(this,"click.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="submit"||d==="image")&&c(b).closest("form").length){a.liveFired=B;return la("submit",this,arguments)}});c.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="text"||d==="password")&&c(b).closest("form").length&&a.keyCode===13){a.liveFired=B;return la("submit",this,arguments)}})}else return false},teardown:function(){c.event.remove(this,".specialSubmit")}};if(!c.support.changeBubbles){var V,
  443. xa=function(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(e){return e.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},Z=function(a,b){var d=a.target,e,f;if(!(!ia.test(d.nodeName)||d.readOnly)){e=c.data(d,"_change_data");f=xa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",f);if(!(e===B||f===e))if(e!=null||f){a.type="change";a.liveFired=
  444. B;return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:Z,beforedeactivate:Z,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return Z.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return Z.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,"_change_data",xa(a))}},setup:function(){if(this.type===
  445. "file")return false;for(var a in V)c.event.add(this,a+".specialChange",V[a]);return ia.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return ia.test(this.nodeName)}};V=c.event.special.change.filters;V.focus=V.beforeactivate}t.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.trigger(e,null,e.target)}c.event.special[b]={setup:function(){ua[b]++===0&&t.addEventListener(a,d,true)},teardown:function(){--ua[b]===
  446. 0&&t.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,e,f){if(typeof d==="object"){for(var h in d)this[b](h,e,d[h],f);return this}if(c.isFunction(e)||e===false){f=e;e=B}var l=b==="one"?c.proxy(f,function(o){c(this).unbind(o,l);return f.apply(this,arguments)}):f;if(d==="unload"&&b!=="one")this.one(d,e,f);else{h=0;for(var k=this.length;h<k;h++)c.event.add(this[h],d,l,e)}return this}});c.fn.extend({unbind:function(a,b){if(typeof a==="object"&&!a.preventDefault)for(var d in a)this.unbind(d,
  447. a[d]);else{d=0;for(var e=this.length;d<e;d++)c.event.remove(this[d],a,b)}return this},delegate:function(a,b,d,e){return this.live(b,d,e,a)},undelegate:function(a,b,d){return arguments.length===0?this.unbind("live"):this.die(b,null,d,a)},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){var d=c.Event(a);d.preventDefault();d.stopPropagation();c.event.trigger(d,b,this[0]);return d.result}},toggle:function(a){for(var b=arguments,d=
  448. 1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(e){var f=(c.data(this,"lastToggle"+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,f+1);e.preventDefault();return b[f].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var ya={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};c.each(["live","die"],function(a,b){c.fn[b]=function(d,e,f,h){var l,k=0,o,x,r=h||this.selector;h=h?this:c(this.context);if(typeof d===
  449. "object"&&!d.preventDefault){for(l in d)h[b](l,e,d[l],r);return this}if(c.isFunction(e)){f=e;e=B}for(d=(d||"").split(" ");(l=d[k++])!=null;){o=X.exec(l);x="";if(o){x=o[0];l=l.replace(X,"")}if(l==="hover")d.push("mouseenter"+x,"mouseleave"+x);else{o=l;if(l==="focus"||l==="blur"){d.push(ya[l]+x);l+=x}else l=(ya[l]||l)+x;if(b==="live"){x=0;for(var A=h.length;x<A;x++)c.event.add(h[x],"live."+Y(l,r),{data:e,selector:r,handler:f,origType:l,origHandler:f,preType:o})}else h.unbind("live."+Y(l,r),f)}}return this}});
  450. c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){c.fn[b]=function(d,e){if(e==null){e=d;d=null}return arguments.length>0?this.bind(b,d,e):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});E.attachEvent&&!E.addEventListener&&c(E).bind("unload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});
  451. (function(){function a(g,i,n,m,p,q){p=0;for(var u=m.length;p<u;p++){var y=m[p];if(y){var F=false;for(y=y[g];y;){if(y.sizcache===n){F=m[y.sizset];break}if(y.nodeType===1&&!q){y.sizcache=n;y.sizset=p}if(y.nodeName.toLowerCase()===i){F=y;break}y=y[g]}m[p]=F}}}function b(g,i,n,m,p,q){p=0;for(var u=m.length;p<u;p++){var y=m[p];if(y){var F=false;for(y=y[g];y;){if(y.sizcache===n){F=m[y.sizset];break}if(y.nodeType===1){if(!q){y.sizcache=n;y.sizset=p}if(typeof i!=="string"){if(y===i){F=true;break}}else if(k.filter(i,
  452. [y]).length>0){F=y;break}}y=y[g]}m[p]=F}}}var d=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,h=false,l=true;[0,0].sort(function(){l=false;return 0});var k=function(g,i,n,m){n=n||[];var p=i=i||t;if(i.nodeType!==1&&i.nodeType!==9)return[];if(!g||typeof g!=="string")return n;var q,u,y,F,M,N=true,O=k.isXML(i),D=[],R=g;do{d.exec("");if(q=d.exec(R)){R=q[3];D.push(q[1]);if(q[2]){F=q[3];
  453. break}}}while(q);if(D.length>1&&x.exec(g))if(D.length===2&&o.relative[D[0]])u=L(D[0]+D[1],i);else for(u=o.relative[D[0]]?[i]:k(D.shift(),i);D.length;){g=D.shift();if(o.relative[g])g+=D.shift();u=L(g,u)}else{if(!m&&D.length>1&&i.nodeType===9&&!O&&o.match.ID.test(D[0])&&!o.match.ID.test(D[D.length-1])){q=k.find(D.shift(),i,O);i=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]}if(i){q=m?{expr:D.pop(),set:C(m)}:k.find(D.pop(),D.length===1&&(D[0]==="~"||D[0]==="+")&&i.parentNode?i.parentNode:i,O);u=q.expr?k.filter(q.expr,
  454. q.set):q.set;if(D.length>0)y=C(u);else N=false;for(;D.length;){q=M=D.pop();if(o.relative[M])q=D.pop();else M="";if(q==null)q=i;o.relative[M](y,q,O)}}else y=[]}y||(y=u);y||k.error(M||g);if(f.call(y)==="[object Array]")if(N)if(i&&i.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&k.contains(i,y[g])))n.push(u[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&n.push(u[g]);else n.push.apply(n,y);else C(y,n);if(F){k(F,p,n,m);k.uniqueSort(n)}return n};k.uniqueSort=function(g){if(w){h=
  455. l;g.sort(w);if(h)for(var i=1;i<g.length;i++)g[i]===g[i-1]&&g.splice(i--,1)}return g};k.matches=function(g,i){return k(g,null,null,i)};k.matchesSelector=function(g,i){return k(i,null,null,[g]).length>0};k.find=function(g,i,n){var m;if(!g)return[];for(var p=0,q=o.order.length;p<q;p++){var u,y=o.order[p];if(u=o.leftMatch[y].exec(g)){var F=u[1];u.splice(1,1);if(F.substr(F.length-1)!=="\\"){u[1]=(u[1]||"").replace(/\\/g,"");m=o.find[y](u,i,n);if(m!=null){g=g.replace(o.match[y],"");break}}}}m||(m=i.getElementsByTagName("*"));
  456. return{set:m,expr:g}};k.filter=function(g,i,n,m){for(var p,q,u=g,y=[],F=i,M=i&&i[0]&&k.isXML(i[0]);g&&i.length;){for(var N in o.filter)if((p=o.leftMatch[N].exec(g))!=null&&p[2]){var O,D,R=o.filter[N];D=p[1];q=false;p.splice(1,1);if(D.substr(D.length-1)!=="\\"){if(F===y)y=[];if(o.preFilter[N])if(p=o.preFilter[N](p,F,n,y,m,M)){if(p===true)continue}else q=O=true;if(p)for(var j=0;(D=F[j])!=null;j++)if(D){O=R(D,p,j,F);var s=m^!!O;if(n&&O!=null)if(s)q=true;else F[j]=false;else if(s){y.push(D);q=true}}if(O!==
  457. B){n||(F=y);g=g.replace(o.match[N],"");if(!q)return[];break}}}if(g===u)if(q==null)k.error(g);else break;u=g}return F};k.error=function(g){throw"Syntax error, unrecognized expression: "+g;};var o=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/,
  458. POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},relative:{"+":function(g,i){var n=typeof i==="string",m=n&&!/\W/.test(i);n=n&&!m;if(m)i=i.toLowerCase();m=0;for(var p=g.length,q;m<p;m++)if(q=g[m]){for(;(q=q.previousSibling)&&q.nodeType!==1;);g[m]=n||q&&q.nodeName.toLowerCase()===
  459. i?q||false:q===i}n&&k.filter(i,g,true)},">":function(g,i){var n,m=typeof i==="string",p=0,q=g.length;if(m&&!/\W/.test(i))for(i=i.toLowerCase();p<q;p++){if(n=g[p]){n=n.parentNode;g[p]=n.nodeName.toLowerCase()===i?n:false}}else{for(;p<q;p++)if(n=g[p])g[p]=m?n.parentNode:n.parentNode===i;m&&k.filter(i,g,true)}},"":function(g,i,n){var m,p=e++,q=b;if(typeof i==="string"&&!/\W/.test(i)){m=i=i.toLowerCase();q=a}q("parentNode",i,p,g,m,n)},"~":function(g,i,n){var m,p=e++,q=b;if(typeof i==="string"&&!/\W/.test(i)){m=
  460. i=i.toLowerCase();q=a}q("previousSibling",i,p,g,m,n)}},find:{ID:function(g,i,n){if(typeof i.getElementById!=="undefined"&&!n)return(g=i.getElementById(g[1]))&&g.parentNode?[g]:[]},NAME:function(g,i){if(typeof i.getElementsByName!=="undefined"){for(var n=[],m=i.getElementsByName(g[1]),p=0,q=m.length;p<q;p++)m[p].getAttribute("name")===g[1]&&n.push(m[p]);return n.length===0?null:n}},TAG:function(g,i){return i.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,i,n,m,p,q){g=" "+g[1].replace(/\\/g,
  461. "")+" ";if(q)return g;q=0;for(var u;(u=i[q])!=null;q++)if(u)if(p^(u.className&&(" "+u.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))n||m.push(u);else if(n)i[q]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var i=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=i[1]+(i[2]||1)-0;g[3]=i[3]-0}g[0]=e++;return g},ATTR:function(g,i,n,
  462. m,p,q){i=g[1].replace(/\\/g,"");if(!q&&o.attrMap[i])g[1]=o.attrMap[i];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,i,n,m,p){if(g[1]==="not")if((d.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,i);else{g=k.filter(g[3],i,n,true^p);n||m.push.apply(m,g);return false}else if(o.match.POS.test(g[0])||o.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===
  463. true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,i,n){return!!k(n[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===
  464. g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,i){return i===0},last:function(g,i,n,m){return i===m.length-1},even:function(g,i){return i%2===0},odd:function(g,i){return i%2===1},lt:function(g,i,n){return i<n[3]-0},gt:function(g,i,n){return i>n[3]-0},nth:function(g,i,n){return n[3]-
  465. 0===i},eq:function(g,i,n){return n[3]-0===i}},filter:{PSEUDO:function(g,i,n,m){var p=i[1],q=o.filters[p];if(q)return q(g,n,i,m);else if(p==="contains")return(g.textContent||g.innerText||k.getText([g])||"").indexOf(i[3])>=0;else if(p==="not"){i=i[3];n=0;for(m=i.length;n<m;n++)if(i[n]===g)return false;return true}else k.error("Syntax error, unrecognized expression: "+p)},CHILD:function(g,i){var n=i[1],m=g;switch(n){case "only":case "first":for(;m=m.previousSibling;)if(m.nodeType===1)return false;if(n===
  466. "first")return true;m=g;case "last":for(;m=m.nextSibling;)if(m.nodeType===1)return false;return true;case "nth":n=i[2];var p=i[3];if(n===1&&p===0)return true;var q=i[0],u=g.parentNode;if(u&&(u.sizcache!==q||!g.nodeIndex)){var y=0;for(m=u.firstChild;m;m=m.nextSibling)if(m.nodeType===1)m.nodeIndex=++y;u.sizcache=q}m=g.nodeIndex-p;return n===0?m===0:m%n===0&&m/n>=0}},ID:function(g,i){return g.nodeType===1&&g.getAttribute("id")===i},TAG:function(g,i){return i==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===
  467. i},CLASS:function(g,i){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(i)>-1},ATTR:function(g,i){var n=i[1];n=o.attrHandle[n]?o.attrHandle[n](g):g[n]!=null?g[n]:g.getAttribute(n);var m=n+"",p=i[2],q=i[4];return n==null?p==="!=":p==="="?m===q:p==="*="?m.indexOf(q)>=0:p==="~="?(" "+m+" ").indexOf(q)>=0:!q?m&&n!==false:p==="!="?m!==q:p==="^="?m.indexOf(q)===0:p==="$="?m.substr(m.length-q.length)===q:p==="|="?m===q||m.substr(0,q.length+1)===q+"-":false},POS:function(g,i,n,m){var p=o.setFilters[i[2]];
  468. if(p)return p(g,n,i,m)}}},x=o.match.POS,r=function(g,i){return"\\"+(i-0+1)},A;for(A in o.match){o.match[A]=RegExp(o.match[A].source+/(?![^\[]*\])(?![^\(]*\))/.source);o.leftMatch[A]=RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[A].source.replace(/\\(\d+)/g,r))}var C=function(g,i){g=Array.prototype.slice.call(g,0);if(i){i.push.apply(i,g);return i}return g};try{Array.prototype.slice.call(t.documentElement.childNodes,0)}catch(J){C=function(g,i){var n=0,m=i||[];if(f.call(g)==="[object Array]")Array.prototype.push.apply(m,
  469. g);else if(typeof g.length==="number")for(var p=g.length;n<p;n++)m.push(g[n]);else for(;g[n];n++)m.push(g[n]);return m}}var w,I;if(t.documentElement.compareDocumentPosition)w=function(g,i){if(g===i){h=true;return 0}if(!g.compareDocumentPosition||!i.compareDocumentPosition)return g.compareDocumentPosition?-1:1;return g.compareDocumentPosition(i)&4?-1:1};else{w=function(g,i){var n,m,p=[],q=[];n=g.parentNode;m=i.parentNode;var u=n;if(g===i){h=true;return 0}else if(n===m)return I(g,i);else if(n){if(!m)return 1}else return-1;
  470. for(;u;){p.unshift(u);u=u.parentNode}for(u=m;u;){q.unshift(u);u=u.parentNode}n=p.length;m=q.length;for(u=0;u<n&&u<m;u++)if(p[u]!==q[u])return I(p[u],q[u]);return u===n?I(g,q[u],-1):I(p[u],i,1)};I=function(g,i,n){if(g===i)return n;for(g=g.nextSibling;g;){if(g===i)return-1;g=g.nextSibling}return 1}}k.getText=function(g){for(var i="",n,m=0;g[m];m++){n=g[m];if(n.nodeType===3||n.nodeType===4)i+=n.nodeValue;else if(n.nodeType!==8)i+=k.getText(n.childNodes)}return i};(function(){var g=t.createElement("div"),
  471. i="script"+(new Date).getTime(),n=t.documentElement;g.innerHTML="<a name='"+i+"'/>";n.insertBefore(g,n.firstChild);if(t.getElementById(i)){o.find.ID=function(m,p,q){if(typeof p.getElementById!=="undefined"&&!q)return(p=p.getElementById(m[1]))?p.id===m[1]||typeof p.getAttributeNode!=="undefined"&&p.getAttributeNode("id").nodeValue===m[1]?[p]:B:[]};o.filter.ID=function(m,p){var q=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&q&&q.nodeValue===p}}n.removeChild(g);
  472. n=g=null})();(function(){var g=t.createElement("div");g.appendChild(t.createComment(""));if(g.getElementsByTagName("*").length>0)o.find.TAG=function(i,n){var m=n.getElementsByTagName(i[1]);if(i[1]==="*"){for(var p=[],q=0;m[q];q++)m[q].nodeType===1&&p.push(m[q]);m=p}return m};g.innerHTML="<a href='#'></a>";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")o.attrHandle.href=function(i){return i.getAttribute("href",2)};g=null})();t.querySelectorAll&&
  473. function(){var g=k,i=t.createElement("div");i.innerHTML="<p class='TEST'></p>";if(!(i.querySelectorAll&&i.querySelectorAll(".TEST").length===0)){k=function(m,p,q,u){p=p||t;m=m.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!u&&!k.isXML(p))if(p.nodeType===9)try{return C(p.querySelectorAll(m),q)}catch(y){}else if(p.nodeType===1&&p.nodeName.toLowerCase()!=="object"){var F=p.getAttribute("id"),M=F||"__sizzle__";F||p.setAttribute("id",M);try{return C(p.querySelectorAll("#"+M+" "+m),q)}catch(N){}finally{F||
  474. p.removeAttribute("id")}}return g(m,p,q,u)};for(var n in g)k[n]=g[n];i=null}}();(function(){var g=t.documentElement,i=g.matchesSelector||g.mozMatchesSelector||g.webkitMatchesSelector||g.msMatchesSelector,n=false;try{i.call(t.documentElement,"[test!='']:sizzle")}catch(m){n=true}if(i)k.matchesSelector=function(p,q){q=q.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(p))try{if(n||!o.match.PSEUDO.test(q)&&!/!=/.test(q))return i.call(p,q)}catch(u){}return k(q,null,null,[p]).length>0}})();(function(){var g=
  475. t.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){o.order.splice(1,0,"CLASS");o.find.CLASS=function(i,n,m){if(typeof n.getElementsByClassName!=="undefined"&&!m)return n.getElementsByClassName(i[1])};g=null}}})();k.contains=t.documentElement.contains?function(g,i){return g!==i&&(g.contains?g.contains(i):true)}:t.documentElement.compareDocumentPosition?
  476. function(g,i){return!!(g.compareDocumentPosition(i)&16)}:function(){return false};k.isXML=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false};var L=function(g,i){for(var n,m=[],p="",q=i.nodeType?[i]:i;n=o.match.PSEUDO.exec(g);){p+=n[0];g=g.replace(o.match.PSEUDO,"")}g=o.relative[g]?g+"*":g;n=0;for(var u=q.length;n<u;n++)k(g,q[n],m);return k.filter(p,m)};c.find=k;c.expr=k.selectors;c.expr[":"]=c.expr.filters;c.unique=k.uniqueSort;c.text=k.getText;c.isXMLDoc=k.isXML;
  477. c.contains=k.contains})();var Za=/Until$/,$a=/^(?:parents|prevUntil|prevAll)/,ab=/,/,Na=/^.[^:#\[\.,]*$/,bb=Array.prototype.slice,cb=c.expr.match.POS;c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,e=0,f=this.length;e<f;e++){d=b.length;c.find(a,this[e],b);if(e>0)for(var h=d;h<b.length;h++)for(var l=0;l<d;l++)if(b[l]===b[h]){b.splice(h--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=0,e=b.length;d<e;d++)if(c.contains(this,b[d]))return true})},
  478. not:function(a){return this.pushStack(ma(this,a,false),"not",a)},filter:function(a){return this.pushStack(ma(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){var d=[],e,f,h=this[0];if(c.isArray(a)){var l,k={},o=1;if(h&&a.length){e=0;for(f=a.length;e<f;e++){l=a[e];k[l]||(k[l]=c.expr.match.POS.test(l)?c(l,b||this.context):l)}for(;h&&h.ownerDocument&&h!==b;){for(l in k){e=k[l];if(e.jquery?e.index(h)>-1:c(h).is(e))d.push({selector:l,elem:h,level:o})}h=
  479. h.parentNode;o++}}return d}l=cb.test(a)?c(a,b||this.context):null;e=0;for(f=this.length;e<f;e++)for(h=this[e];h;)if(l?l.index(h)>-1:c.find.matchesSelector(h,a)){d.push(h);break}else{h=h.parentNode;if(!h||!h.ownerDocument||h===b)break}d=d.length>1?c.unique(d):d;return this.pushStack(d,"closest",a)},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var d=typeof a==="string"?c(a,b||this.context):
  480. c.makeArray(a),e=c.merge(this.get(),d);return this.pushStack(!d[0]||!d[0].parentNode||d[0].parentNode.nodeType===11||!e[0]||!e[0].parentNode||e[0].parentNode.nodeType===11?e:c.unique(e))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,
  481. 2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,
  482. b){c.fn[a]=function(d,e){var f=c.map(this,b,d);Za.test(a)||(e=d);if(e&&typeof e==="string")f=c.filter(e,f);f=this.length>1?c.unique(f):f;if((this.length>1||ab.test(e))&&$a.test(a))f=f.reverse();return this.pushStack(f,a,bb.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return b.length===1?c.find.matchesSelector(b[0],a)?[b[0]]:[]:c.find.matches(a,b)},dir:function(a,b,d){var e=[];for(a=a[b];a&&a.nodeType!==9&&(d===B||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&&
  483. e.push(a);a=a[b]}return e},nth:function(a,b,d){b=b||1;for(var e=0;a;a=a[d])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var za=/ jQuery\d+="(?:\d+|null)"/g,$=/^\s+/,Aa=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Ba=/<([\w:]+)/,db=/<tbody/i,eb=/<|&#?\w+;/,Ca=/<(?:script|object|embed|option|style)/i,Da=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/\=([^="'>\s]+\/)>/g,P={option:[1,
  484. "<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};P.optgroup=P.option;P.tbody=P.tfoot=P.colgroup=P.caption=P.thead;P.th=P.td;if(!c.support.htmlSerialize)P._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=
  485. c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==B)return this.empty().append((this[0]&&this[0].ownerDocument||t).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},
  486. wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},
  487. prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,
  488. this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,e;(e=this[d])!=null;d++)if(!a||c.filter(a,[e]).length){if(!b&&e.nodeType===1){c.cleanData(e.getElementsByTagName("*"));c.cleanData([e])}e.parentNode&&e.parentNode.removeChild(e)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);
  489. return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,e=this.ownerDocument;if(!d){d=e.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(za,"").replace(fb,'="$1">').replace($,"")],e)[0]}else return this.cloneNode(true)});if(a===true){na(this,b);na(this.find("*"),b.find("*"))}return b},html:function(a){if(a===B)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(za,""):null;
  490. else if(typeof a==="string"&&!Ca.test(a)&&(c.support.leadingWhitespace||!$.test(a))&&!P[(Ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Aa,"<$1></$2>");try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){c.cleanData(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(e){this.empty().append(a)}}else c.isFunction(a)?this.each(function(f){var h=c(this);h.html(a.call(this,f,h.html()))}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(c.isFunction(a))return this.each(function(b){var d=
  491. c(this),e=d.html();d.replaceWith(a.call(this,b,e))});if(typeof a!=="string")a=c(a).detach();return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){var e,f,h,l=a[0],k=[];if(!c.support.checkClone&&arguments.length===3&&typeof l==="string"&&Da.test(l))return this.each(function(){c(this).domManip(a,
  492. b,d,true)});if(c.isFunction(l))return this.each(function(x){var r=c(this);a[0]=l.call(this,x,b?r.html():B);r.domManip(a,b,d)});if(this[0]){e=l&&l.parentNode;e=c.support.parentNode&&e&&e.nodeType===11&&e.childNodes.length===this.length?{fragment:e}:c.buildFragment(a,this,k);h=e.fragment;if(f=h.childNodes.length===1?h=h.firstChild:h.firstChild){b=b&&c.nodeName(f,"tr");f=0;for(var o=this.length;f<o;f++)d.call(b?c.nodeName(this[f],"table")?this[f].getElementsByTagName("tbody")[0]||this[f].appendChild(this[f].ownerDocument.createElement("tbody")):
  493. this[f]:this[f],f>0||e.cacheable||this.length>1?h.cloneNode(true):h)}k.length&&c.each(k,Oa)}return this}});c.buildFragment=function(a,b,d){var e,f,h;b=b&&b[0]?b[0].ownerDocument||b[0]:t;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===t&&!Ca.test(a[0])&&(c.support.checkClone||!Da.test(a[0]))){f=true;if(h=c.fragments[a[0]])if(h!==1)e=h}if(!e){e=b.createDocumentFragment();c.clean(a,b,e,d)}if(f)c.fragments[a[0]]=h?e:1;return{fragment:e,cacheable:f}};c.fragments={};c.each({appendTo:"append",
  494. prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var e=[];d=c(d);var f=this.length===1&&this[0].parentNode;if(f&&f.nodeType===11&&f.childNodes.length===1&&d.length===1){d[b](this[0]);return this}else{f=0;for(var h=d.length;f<h;f++){var l=(f>0?this.clone(true):this).get();c(d[f])[b](l);e=e.concat(l)}return this.pushStack(e,a,d.selector)}}});c.extend({clean:function(a,b,d,e){b=b||t;if(typeof b.createElement==="undefined")b=b.ownerDocument||
  495. b[0]&&b[0].ownerDocument||t;for(var f=[],h=0,l;(l=a[h])!=null;h++){if(typeof l==="number")l+="";if(l){if(typeof l==="string"&&!eb.test(l))l=b.createTextNode(l);else if(typeof l==="string"){l=l.replace(Aa,"<$1></$2>");var k=(Ba.exec(l)||["",""])[1].toLowerCase(),o=P[k]||P._default,x=o[0],r=b.createElement("div");for(r.innerHTML=o[1]+l+o[2];x--;)r=r.lastChild;if(!c.support.tbody){x=db.test(l);k=k==="table"&&!x?r.firstChild&&r.firstChild.childNodes:o[1]==="<table>"&&!x?r.childNodes:[];for(o=k.length-
  496. 1;o>=0;--o)c.nodeName(k[o],"tbody")&&!k[o].childNodes.length&&k[o].parentNode.removeChild(k[o])}!c.support.leadingWhitespace&&$.test(l)&&r.insertBefore(b.createTextNode($.exec(l)[0]),r.firstChild);l=r.childNodes}if(l.nodeType)f.push(l);else f=c.merge(f,l)}}if(d)for(h=0;f[h];h++)if(e&&c.nodeName(f[h],"script")&&(!f[h].type||f[h].type.toLowerCase()==="text/javascript"))e.push(f[h].parentNode?f[h].parentNode.removeChild(f[h]):f[h]);else{f[h].nodeType===1&&f.splice.apply(f,[h+1,0].concat(c.makeArray(f[h].getElementsByTagName("script"))));
  497. d.appendChild(f[h])}return f},cleanData:function(a){for(var b,d,e=c.cache,f=c.event.special,h=c.support.deleteExpando,l=0,k;(k=a[l])!=null;l++)if(!(k.nodeName&&c.noData[k.nodeName.toLowerCase()]))if(d=k[c.expando]){if((b=e[d])&&b.events)for(var o in b.events)f[o]?c.event.remove(k,o):c.removeEvent(k,o,b.handle);if(h)delete k[c.expando];else k.removeAttribute&&k.removeAttribute(c.expando);delete e[d]}}});var Ea=/alpha\([^)]*\)/i,gb=/opacity=([^)]*)/,hb=/-([a-z])/ig,ib=/([A-Z])/g,Fa=/^-?\d+(?:px)?$/i,
  498. jb=/^-?\d/,kb={position:"absolute",visibility:"hidden",display:"block"},Pa=["Left","Right"],Qa=["Top","Bottom"],W,Ga,aa,lb=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){if(arguments.length===2&&b===B)return this;return c.access(this,a,b,true,function(d,e,f){return f!==B?c.style(d,e,f):c.css(d,e)})};c.extend({cssHooks:{opacity:{get:function(a,b){if(b){var d=W(a,"opacity","opacity");return d===""?"1":d}else return a.style.opacity}}},cssNumber:{zIndex:true,fontWeight:true,opacity:true,
  499. zoom:true,lineHeight:true},cssProps:{"float":c.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,d,e){if(!(!a||a.nodeType===3||a.nodeType===8||!a.style)){var f,h=c.camelCase(b),l=a.style,k=c.cssHooks[h];b=c.cssProps[h]||h;if(d!==B){if(!(typeof d==="number"&&isNaN(d)||d==null)){if(typeof d==="number"&&!c.cssNumber[h])d+="px";if(!k||!("set"in k)||(d=k.set(a,d))!==B)try{l[b]=d}catch(o){}}}else{if(k&&"get"in k&&(f=k.get(a,false,e))!==B)return f;return l[b]}}},css:function(a,b,d){var e,f=c.camelCase(b),
  500. h=c.cssHooks[f];b=c.cssProps[f]||f;if(h&&"get"in h&&(e=h.get(a,true,d))!==B)return e;else if(W)return W(a,b,f)},swap:function(a,b,d){var e={},f;for(f in b){e[f]=a.style[f];a.style[f]=b[f]}d.call(a);for(f in b)a.style[f]=e[f]},camelCase:function(a){return a.replace(hb,lb)}});c.curCSS=c.css;c.each(["height","width"],function(a,b){c.cssHooks[b]={get:function(d,e,f){var h;if(e){if(d.offsetWidth!==0)h=oa(d,b,f);else c.swap(d,kb,function(){h=oa(d,b,f)});if(h<=0){h=W(d,b,b);if(h==="0px"&&aa)h=aa(d,b,b);
  501. if(h!=null)return h===""||h==="auto"?"0px":h}if(h<0||h==null){h=d.style[b];return h===""||h==="auto"?"0px":h}return typeof h==="string"?h:h+"px"}},set:function(d,e){if(Fa.test(e)){e=parseFloat(e);if(e>=0)return e+"px"}else return e}}});if(!c.support.opacity)c.cssHooks.opacity={get:function(a,b){return gb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var d=a.style;d.zoom=1;var e=c.isNaN(b)?"":"alpha(opacity="+b*100+")",f=
  502. d.filter||"";d.filter=Ea.test(f)?f.replace(Ea,e):d.filter+" "+e}};if(t.defaultView&&t.defaultView.getComputedStyle)Ga=function(a,b,d){var e;d=d.replace(ib,"-$1").toLowerCase();if(!(b=a.ownerDocument.defaultView))return B;if(b=b.getComputedStyle(a,null)){e=b.getPropertyValue(d);if(e===""&&!c.contains(a.ownerDocument.documentElement,a))e=c.style(a,d)}return e};if(t.documentElement.currentStyle)aa=function(a,b){var d,e,f=a.currentStyle&&a.currentStyle[b],h=a.style;if(!Fa.test(f)&&jb.test(f)){d=h.left;
  503. e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=b==="fontSize"?"1em":f||0;f=h.pixelLeft+"px";h.left=d;a.runtimeStyle.left=e}return f===""?"auto":f};W=Ga||aa;if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetHeight;return a.offsetWidth===0&&b===0||!c.support.reliableHiddenOffsets&&(a.style.display||c.css(a,"display"))==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var mb=c.now(),nb=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
  504. ob=/^(?:select|textarea)/i,pb=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,qb=/^(?:GET|HEAD)$/,Ra=/\[\]$/,T=/\=\?(&|$)/,ja=/\?/,rb=/([?&])_=[^&]*/,sb=/^(\w+:)?\/\/([^\/?#]+)/,tb=/%20/g,ub=/#.*$/,Ha=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!=="string"&&Ha)return Ha.apply(this,arguments);else if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var f=a.slice(e,a.length);a=a.slice(0,e)}e="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b===
  505. "object"){b=c.param(b,c.ajaxSettings.traditional);e="POST"}var h=this;c.ajax({url:a,type:e,dataType:"html",data:b,complete:function(l,k){if(k==="success"||k==="notmodified")h.html(f?c("<div>").append(l.responseText.replace(nb,"")).find(f):l.responseText);d&&h.each(d,[l.responseText,k,l])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&
  506. !this.disabled&&(this.checked||ob.test(this.nodeName)||pb.test(this.type))}).map(function(a,b){var d=c(this).val();return d==null?null:c.isArray(d)?c.map(d,function(e){return{name:b.name,value:e}}):{name:b.name,value:d}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:e})},
  507. getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:e})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return new E.XMLHttpRequest},accepts:{xml:"application/xml, text/xml",html:"text/html",
  508. script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},ajax:function(a){var b=c.extend(true,{},c.ajaxSettings,a),d,e,f,h=b.type.toUpperCase(),l=qb.test(h);b.url=b.url.replace(ub,"");b.context=a&&a.context!=null?a.context:b;if(b.data&&b.processData&&typeof b.data!=="string")b.data=c.param(b.data,b.traditional);if(b.dataType==="jsonp"){if(h==="GET")T.test(b.url)||(b.url+=(ja.test(b.url)?"&":"?")+(b.jsonp||"callback")+"=?");else if(!b.data||
  509. !T.test(b.data))b.data=(b.data?b.data+"&":"")+(b.jsonp||"callback")+"=?";b.dataType="json"}if(b.dataType==="json"&&(b.data&&T.test(b.data)||T.test(b.url))){d=b.jsonpCallback||"jsonp"+mb++;if(b.data)b.data=(b.data+"").replace(T,"="+d+"$1");b.url=b.url.replace(T,"="+d+"$1");b.dataType="script";var k=E[d];E[d]=function(m){if(c.isFunction(k))k(m);else{E[d]=B;try{delete E[d]}catch(p){}}f=m;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);r&&r.removeChild(A)}}if(b.dataType==="script"&&b.cache===null)b.cache=
  510. false;if(b.cache===false&&l){var o=c.now(),x=b.url.replace(rb,"$1_="+o);b.url=x+(x===b.url?(ja.test(b.url)?"&":"?")+"_="+o:"")}if(b.data&&l)b.url+=(ja.test(b.url)?"&":"?")+b.data;b.global&&c.active++===0&&c.event.trigger("ajaxStart");o=(o=sb.exec(b.url))&&(o[1]&&o[1].toLowerCase()!==location.protocol||o[2].toLowerCase()!==location.host);if(b.dataType==="script"&&h==="GET"&&o){var r=t.getElementsByTagName("head")[0]||t.documentElement,A=t.createElement("script");if(b.scriptCharset)A.charset=b.scriptCharset;
  511. A.src=b.url;if(!d){var C=false;A.onload=A.onreadystatechange=function(){if(!C&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){C=true;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);A.onload=A.onreadystatechange=null;r&&A.parentNode&&r.removeChild(A)}}}r.insertBefore(A,r.firstChild);return B}var J=false,w=b.xhr();if(w){b.username?w.open(h,b.url,b.async,b.username,b.password):w.open(h,b.url,b.async);try{if(b.data!=null&&!l||a&&a.contentType)w.setRequestHeader("Content-Type",
  512. b.contentType);if(b.ifModified){c.lastModified[b.url]&&w.setRequestHeader("If-Modified-Since",c.lastModified[b.url]);c.etag[b.url]&&w.setRequestHeader("If-None-Match",c.etag[b.url])}o||w.setRequestHeader("X-Requested-With","XMLHttpRequest");w.setRequestHeader("Accept",b.dataType&&b.accepts[b.dataType]?b.accepts[b.dataType]+", */*; q=0.01":b.accepts._default)}catch(I){}if(b.beforeSend&&b.beforeSend.call(b.context,w,b)===false){b.global&&c.active--===1&&c.event.trigger("ajaxStop");w.abort();return false}b.global&&
  513. c.triggerGlobal(b,"ajaxSend",[w,b]);var L=w.onreadystatechange=function(m){if(!w||w.readyState===0||m==="abort"){J||c.handleComplete(b,w,e,f);J=true;if(w)w.onreadystatechange=c.noop}else if(!J&&w&&(w.readyState===4||m==="timeout")){J=true;w.onreadystatechange=c.noop;e=m==="timeout"?"timeout":!c.httpSuccess(w)?"error":b.ifModified&&c.httpNotModified(w,b.url)?"notmodified":"success";var p;if(e==="success")try{f=c.httpData(w,b.dataType,b)}catch(q){e="parsererror";p=q}if(e==="success"||e==="notmodified")d||
  514. c.handleSuccess(b,w,e,f);else c.handleError(b,w,e,p);d||c.handleComplete(b,w,e,f);m==="timeout"&&w.abort();if(b.async)w=null}};try{var g=w.abort;w.abort=function(){w&&Function.prototype.call.call(g,w);L("abort")}}catch(i){}b.async&&b.timeout>0&&setTimeout(function(){w&&!J&&L("timeout")},b.timeout);try{w.send(l||b.data==null?null:b.data)}catch(n){c.handleError(b,w,null,n);c.handleComplete(b,w,e,f)}b.async||L();return w}},param:function(a,b){var d=[],e=function(h,l){l=c.isFunction(l)?l():l;d[d.length]=
  515. encodeURIComponent(h)+"="+encodeURIComponent(l)};if(b===B)b=c.ajaxSettings.traditional;if(c.isArray(a)||a.jquery)c.each(a,function(){e(this.name,this.value)});else for(var f in a)da(f,a[f],b,e);return d.join("&").replace(tb,"+")}});c.extend({active:0,lastModified:{},etag:{},handleError:function(a,b,d,e){a.error&&a.error.call(a.context,b,d,e);a.global&&c.triggerGlobal(a,"ajaxError",[b,a,e])},handleSuccess:function(a,b,d,e){a.success&&a.success.call(a.context,e,d,b);a.global&&c.triggerGlobal(a,"ajaxSuccess",
  516. [b,a])},handleComplete:function(a,b,d){a.complete&&a.complete.call(a.context,b,d);a.global&&c.triggerGlobal(a,"ajaxComplete",[b,a]);a.global&&c.active--===1&&c.event.trigger("ajaxStop")},triggerGlobal:function(a,b,d){(a.context&&a.context.url==null?c(a.context):c.event).trigger(b,d)},httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),
  517. e=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(e)c.etag[b]=e;return a.status===304},httpData:function(a,b,d){var e=a.getResponseHeader("content-type")||"",f=b==="xml"||!b&&e.indexOf("xml")>=0;a=f?a.responseXML:a.responseText;f&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&e.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&e.indexOf("javascript")>=0)c.globalEval(a);return a}});
  518. if(E.ActiveXObject)c.ajaxSettings.xhr=function(){if(E.location.protocol!=="file:")try{return new E.XMLHttpRequest}catch(a){}try{return new E.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}};c.support.ajax=!!c.ajaxSettings.xhr();var ea={},vb=/^(?:toggle|show|hide)$/,wb=/^([+\-]=)?([\d+.\-]+)(.*)$/,ba,pa=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b,d){if(a||a===0)return this.animate(S("show",
  519. 3),a,b,d);else{d=0;for(var e=this.length;d<e;d++){a=this[d];b=a.style.display;if(!c.data(a,"olddisplay")&&b==="none")b=a.style.display="";b===""&&c.css(a,"display")==="none"&&c.data(a,"olddisplay",qa(a.nodeName))}for(d=0;d<e;d++){a=this[d];b=a.style.display;if(b===""||b==="none")a.style.display=c.data(a,"olddisplay")||""}return this}},hide:function(a,b,d){if(a||a===0)return this.animate(S("hide",3),a,b,d);else{a=0;for(b=this.length;a<b;a++){d=c.css(this[a],"display");d!=="none"&&c.data(this[a],"olddisplay",
  520. d)}for(a=0;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b,d){var e=typeof a==="boolean";if(c.isFunction(a)&&c.isFunction(b))this._toggle.apply(this,arguments);else a==null||e?this.each(function(){var f=e?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(S("toggle",3),a,b,d);return this},fadeTo:function(a,b,d,e){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d,e)},animate:function(a,b,d,e){var f=c.speed(b,
  521. d,e);if(c.isEmptyObject(a))return this.each(f.complete);return this[f.queue===false?"each":"queue"](function(){var h=c.extend({},f),l,k=this.nodeType===1,o=k&&c(this).is(":hidden"),x=this;for(l in a){var r=c.camelCase(l);if(l!==r){a[r]=a[l];delete a[l];l=r}if(a[l]==="hide"&&o||a[l]==="show"&&!o)return h.complete.call(this);if(k&&(l==="height"||l==="width")){h.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY];if(c.css(this,"display")==="inline"&&c.css(this,"float")==="none")if(c.support.inlineBlockNeedsLayout)if(qa(this.nodeName)===
  522. "inline")this.style.display="inline-block";else{this.style.display="inline";this.style.zoom=1}else this.style.display="inline-block"}if(c.isArray(a[l])){(h.specialEasing=h.specialEasing||{})[l]=a[l][1];a[l]=a[l][0]}}if(h.overflow!=null)this.style.overflow="hidden";h.curAnim=c.extend({},a);c.each(a,function(A,C){var J=new c.fx(x,h,A);if(vb.test(C))J[C==="toggle"?o?"show":"hide":C](a);else{var w=wb.exec(C),I=J.cur()||0;if(w){var L=parseFloat(w[2]),g=w[3]||"px";if(g!=="px"){c.style(x,A,(L||1)+g);I=(L||
  523. 1)/J.cur()*I;c.style(x,A,I+g)}if(w[1])L=(w[1]==="-="?-1:1)*L+I;J.custom(I,L,g)}else J.custom(I,C,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);this.each(function(){for(var e=d.length-1;e>=0;e--)if(d[e].elem===this){b&&d[e](true);d.splice(e,1)}});b||this.dequeue();return this}});c.each({slideDown:S("show",1),slideUp:S("hide",1),slideToggle:S("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){c.fn[a]=function(d,e,f){return this.animate(b,
  524. d,e,f)}});c.extend({speed:function(a,b,d){var e=a&&typeof a==="object"?c.extend({},a):{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};e.duration=c.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in c.fx.speeds?c.fx.speeds[e.duration]:c.fx.speeds._default;e.old=e.complete;e.complete=function(){e.queue!==false&&c(this).dequeue();c.isFunction(e.old)&&e.old.call(this)};return e},easing:{linear:function(a,b,d,e){return d+e*a},swing:function(a,b,d,e){return(-Math.cos(a*
  525. Math.PI)/2+0.5)*e+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a=parseFloat(c.css(this.elem,this.prop));return a&&a>-1E4?a:0},custom:function(a,b,d){function e(l){return f.step(l)}
  526. var f=this,h=c.fx;this.startTime=c.now();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;e.elem=this.elem;if(e()&&c.timers.push(e)&&!ba)ba=setInterval(h.tick,h.interval)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;
  527. this.custom(this.cur(),0)},step:function(a){var b=c.now(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var e in this.options.curAnim)if(this.options.curAnim[e]!==true)d=false;if(d){if(this.options.overflow!=null&&!c.support.shrinkWrapBlocks){var f=this.elem,h=this.options;c.each(["","X","Y"],function(k,o){f.style["overflow"+o]=h.overflow[k]})}this.options.hide&&c(this.elem).hide();if(this.options.hide||
  528. this.options.show)for(var l in this.options.curAnim)c.style(this.elem,l,this.options.orig[l]);this.options.complete.call(this.elem)}return false}else{a=b-this.startTime;this.state=a/this.options.duration;b=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||b](this.state,a,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=
  529. c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||c.fx.stop()},interval:13,stop:function(){clearInterval(ba);ba=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===
  530. b.elem}).length};var xb=/^t(?:able|d|h)$/i,Ia=/^(?:body|html)$/i;c.fn.offset="getBoundingClientRect"in t.documentElement?function(a){var b=this[0],d;if(a)return this.each(function(l){c.offset.setOffset(this,a,l)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);try{d=b.getBoundingClientRect()}catch(e){}var f=b.ownerDocument,h=f.documentElement;if(!d||!c.contains(h,b))return d||{top:0,left:0};b=f.body;f=fa(f);return{top:d.top+(f.pageYOffset||c.support.boxModel&&
  531. h.scrollTop||b.scrollTop)-(h.clientTop||b.clientTop||0),left:d.left+(f.pageXOffset||c.support.boxModel&&h.scrollLeft||b.scrollLeft)-(h.clientLeft||b.clientLeft||0)}}:function(a){var b=this[0];if(a)return this.each(function(x){c.offset.setOffset(this,a,x)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d,e=b.offsetParent,f=b.ownerDocument,h=f.documentElement,l=f.body;d=(f=f.defaultView)?f.getComputedStyle(b,null):b.currentStyle;
  532. for(var k=b.offsetTop,o=b.offsetLeft;(b=b.parentNode)&&b!==l&&b!==h;){if(c.offset.supportsFixedPosition&&d.position==="fixed")break;d=f?f.getComputedStyle(b,null):b.currentStyle;k-=b.scrollTop;o-=b.scrollLeft;if(b===e){k+=b.offsetTop;o+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&xb.test(b.nodeName))){k+=parseFloat(d.borderTopWidth)||0;o+=parseFloat(d.borderLeftWidth)||0}e=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&d.overflow!=="visible"){k+=
  533. parseFloat(d.borderTopWidth)||0;o+=parseFloat(d.borderLeftWidth)||0}d=d}if(d.position==="relative"||d.position==="static"){k+=l.offsetTop;o+=l.offsetLeft}if(c.offset.supportsFixedPosition&&d.position==="fixed"){k+=Math.max(h.scrollTop,l.scrollTop);o+=Math.max(h.scrollLeft,l.scrollLeft)}return{top:k,left:o}};c.offset={initialize:function(){var a=t.body,b=t.createElement("div"),d,e,f,h=parseFloat(c.css(a,"marginTop"))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",
  534. height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";a.insertBefore(b,a.firstChild);d=b.firstChild;e=d.firstChild;f=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=e.offsetTop!==5;this.doesAddBorderForTableAndCells=
  535. f.offsetTop===5;e.style.position="fixed";e.style.top="20px";this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15;e.style.position=e.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==h;a.removeChild(b);c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.css(a,
  536. "marginTop"))||0;d+=parseFloat(c.css(a,"marginLeft"))||0}return{top:b,left:d}},setOffset:function(a,b,d){var e=c.css(a,"position");if(e==="static")a.style.position="relative";var f=c(a),h=f.offset(),l=c.css(a,"top"),k=c.css(a,"left"),o=e==="absolute"&&c.inArray("auto",[l,k])>-1;e={};var x={};if(o)x=f.position();l=o?x.top:parseInt(l,10)||0;k=o?x.left:parseInt(k,10)||0;if(c.isFunction(b))b=b.call(a,d,h);if(b.top!=null)e.top=b.top-h.top+l;if(b.left!=null)e.left=b.left-h.left+k;"using"in b?b.using.call(a,
  537. e):f.css(e)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),e=Ia.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.css(a,"marginTop"))||0;d.left-=parseFloat(c.css(a,"marginLeft"))||0;e.top+=parseFloat(c.css(b[0],"borderTopWidth"))||0;e.left+=parseFloat(c.css(b[0],"borderLeftWidth"))||0;return{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||t.body;a&&!Ia.test(a.nodeName)&&
  538. c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(e){var f=this[0],h;if(!f)return null;if(e!==B)return this.each(function(){if(h=fa(this))h.scrollTo(!a?e:c(h).scrollLeft(),a?e:c(h).scrollTop());else this[d]=e});else return(h=fa(f))?"pageXOffset"in h?h[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&h.document.documentElement[d]||h.document.body[d]:f[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();
  539. c.fn["inner"+b]=function(){return this[0]?parseFloat(c.css(this[0],d,"padding")):null};c.fn["outer"+b]=function(e){return this[0]?parseFloat(c.css(this[0],d,e?"margin":"border")):null};c.fn[d]=function(e){var f=this[0];if(!f)return e==null?null:this;if(c.isFunction(e))return this.each(function(l){var k=c(this);k[d](e.call(this,l,k[d]()))});if(c.isWindow(f))return f.document.compatMode==="CSS1Compat"&&f.document.documentElement["client"+b]||f.document.body["client"+b];else if(f.nodeType===9)return Math.max(f.documentElement["client"+
  540. b],f.body["scroll"+b],f.documentElement["scroll"+b],f.body["offset"+b],f.documentElement["offset"+b]);else if(e===B){f=c.css(f,d);var h=parseFloat(f);return c.isNaN(h)?f:h}else return this.css(d,typeof e==="string"?e:e+"px")}})})(window);
  541. </script><script type="text/javascript">//XRegExp 1.5.0 <xregexp.com> MIT License
  542. var XRegExp;if(XRegExp){throw Error("can't load XRegExp twice in the same frame")}(function(){XRegExp=function(w,r){var q=[],u=XRegExp.OUTSIDE_CLASS,x=0,p,s,v,t,y;if(XRegExp.isRegExp(w)){if(r!==undefined){throw TypeError("can't supply flags when constructing one RegExp from another")}return j(w)}if(g){throw Error("can't call the XRegExp constructor within token definition functions")}r=r||"";p={hasNamedCapture:false,captureNames:[],hasFlag:function(z){return r.indexOf(z)>-1},setFlag:function(z){r+=z}};while(x<w.length){s=o(w,x,u,p);if(s){q.push(s.output);x+=(s.match[0].length||1)}else{if(v=m.exec.call(i[u],w.slice(x))){q.push(v[0]);x+=v[0].length}else{t=w.charAt(x);if(t==="["){u=XRegExp.INSIDE_CLASS}else{if(t==="]"){u=XRegExp.OUTSIDE_CLASS}}q.push(t);x++}}}y=RegExp(q.join(""),m.replace.call(r,h,""));y._xregexp={source:w,captureNames:p.hasNamedCapture?p.captureNames:null};return y};XRegExp.version="1.5.0";XRegExp.INSIDE_CLASS=1;XRegExp.OUTSIDE_CLASS=2;var c=/\$(?:(\d\d?|[$&`'])|{([$\w]+)})/g,h=/[^gimy]+|([\s\S])(?=[\s\S]*\1)/g,n=/^(?:[?*+]|{\d+(?:,\d*)?})\??/,g=false,k=[],m={exec:RegExp.prototype.exec,test:RegExp.prototype.test,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split},a=m.exec.call(/()??/,"")[1]===undefined,e=function(){var p=/^/g;m.test.call(p,"");return !p.lastIndex}(),f=function(){var p=/x/g;m.replace.call("x",p,"");return !p.lastIndex}(),b=RegExp.prototype.sticky!==undefined,i={};i[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]))/;i[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*)?}\??)/;XRegExp.addToken=function(s,r,q,p){k.push({pattern:j(s,"g"+(b?"y":"")),handler:r,scope:q||XRegExp.OUTSIDE_CLASS,trigger:p||null})};XRegExp.cache=function(r,p){var q=r+"/"+(p||"");return XRegExp.cache[q]||(XRegExp.cache[q]=XRegExp(r,p))};XRegExp.copyAsGlobal=function(p){return j(p,"g")};XRegExp.escape=function(p){return p.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")};XRegExp.execAt=function(s,r,t,q){r=j(r,"g"+((q&&b)?"y":""));r.lastIndex=t=t||0;var p=r.exec(s);if(q){return(p&&p.index===t)?p:null}else{return p}};XRegExp.freezeTokens=function(){XRegExp.addToken=function(){throw Error("can't run addToken after freezeTokens")}};XRegExp.isRegExp=function(p){return Object.prototype.toString.call(p)==="[object RegExp]"};XRegExp.iterate=function(u,p,v,s){var t=j(p,"g"),r=-1,q;while(q=t.exec(u)){v.call(s,q,++r,u,t);if(t.lastIndex===q.index){t.lastIndex++}}if(p.global){p.lastIndex=0}};XRegExp.matchChain=function(q,p){return function r(s,x){var v=p[x].regex?p[x]:{regex:p[x]},u=j(v.regex,"g"),w=[],t;for(t=0;t<s.length;t++){XRegExp.iterate(s[t],u,function(y){w.push(v.backref?(y[v.backref]||""):y[0])})}return((x===p.length-1)||!w.length)?w:r(w,x+1)}([q],0)};RegExp.prototype.apply=function(q,p){return this.exec(p[0])};RegExp.prototype.call=function(p,q){return this.exec(q)};RegExp.prototype.exec=function(t){var r=m.exec.apply(this,arguments),q,p;if(r){if(!a&&r.length>1&&l(r,"")>-1){p=RegExp(this.source,m.replace.call(d(this),"g",""));m.replace.call(t.slice(r.index),p,function(){for(var u=1;u<arguments.length-2;u++){if(arguments[u]===undefined){r[u]=undefined}}})}if(this._xregexp&&this._xregexp.captureNames){for(var s=1;s<r.length;s++){q=this._xregexp.captureNames[s-1];if(q){r[q]=r[s]}}}if(!e&&this.global&&!r[0].length&&(this.lastIndex>r.index)){this.lastIndex--}}return r};if(!e){RegExp.prototype.test=function(q){var p=m.exec.call(this,q);if(p&&this.global&&!p[0].length&&(this.lastIndex>p.index)){this.lastIndex--}return !!p}}String.prototype.match=function(q){if(!XRegExp.isRegExp(q)){q=RegExp(q)}if(q.global){var p=m.match.apply(this,arguments);q.lastIndex=0;return p}return q.exec(this)};String.prototype.replace=function(r,s){var t=XRegExp.isRegExp(r),q,p,u;if(t&&typeof s.valueOf()==="string"&&s.indexOf("${")===-1&&f){return m.replace.apply(this,arguments)}if(!t){r=r+""}else{if(r._xregexp){q=r._xregexp.captureNames}}if(typeof s==="function"){p=m.replace.call(this,r,function(){if(q){arguments[0]=new String(arguments[0]);for(var v=0;v<q.length;v++){if(q[v]){arguments[0][q[v]]=arguments[v+1]}}}if(t&&r.global){r.lastIndex=arguments[arguments.length-2]+arguments[0].length}return s.apply(null,arguments)})}else{u=this+"";p=m.replace.call(u,r,function(){var v=arguments;return m.replace.call(s,c,function(x,w,A){if(w){switch(w){case"$":return"$";case"&":return v[0];case"`":return v[v.length-1].slice(0,v[v.length-2]);case"'":return v[v.length-1].slice(v[v.length-2]+v[0].length);default:var y="";w=+w;if(!w){return x}while(w>v.length-3){y=String.prototype.slice.call(w,-1)+y;w=Math.floor(w/10)}return(w?v[w]||"":"$")+y}}else{var z=+A;if(z<=v.length-3){return v[z]}z=q?l(q,A):-1;return z>-1?v[z+1]:x}})})}if(t&&r.global){r.lastIndex=0}return p};String.prototype.split=function(u,p){if(!XRegExp.isRegExp(u)){return m.split.apply(this,arguments)}var w=this+"",r=[],v=0,t,q;if(p===undefined||+p<0){p=Infinity}else{p=Math.floor(+p);if(!p){return[]}}u=XRegExp.copyAsGlobal(u);while(t=u.exec(w)){if(u.lastIndex>v){r.push(w.slice(v,t.index));if(t.length>1&&t.index<w.length){Array.prototype.push.apply(r,t.slice(1))}q=t[0].length;v=u.lastIndex;if(r.length>=p){break}}if(u.lastIndex===t.index){u.lastIndex++}}if(v===w.length){if(!m.test.call(u,"")||q){r.push("")}}else{r.push(w.slice(v))}return r.length>p?r.slice(0,p):r};function j(r,q){if(!XRegExp.isRegExp(r)){throw TypeError("type RegExp expected")}var p=r._xregexp;r=XRegExp(r.source,d(r)+(q||""));if(p){r._xregexp={source:p.source,captureNames:p.captureNames?p.captureNames.slice(0):null}}return r}function d(p){return(p.global?"g":"")+(p.ignoreCase?"i":"")+(p.multiline?"m":"")+(p.extended?"x":"")+(p.sticky?"y":"")}function o(v,u,w,p){var r=k.length,y,s,x;g=true;try{while(r--){x=k[r];if((w&x.scope)&&(!x.trigger||x.trigger.call(p))){x.pattern.lastIndex=u;s=x.pattern.exec(v);if(s&&s.index===u){y={output:x.handler.call(p,s,w),match:s};break}}}}catch(q){throw q}finally{g=false}return y}function l(s,q,r){if(Array.prototype.indexOf){return s.indexOf(q,r)}for(var p=r||0;p<s.length;p++){if(s[p]===q){return p}}return -1}XRegExp.addToken(/\(\?#[^)]*\)/,function(p){return m.test.call(n,p.input.slice(p.index+p[0].length))?"":"(?:)"});XRegExp.addToken(/\((?!\?)/,function(){this.captureNames.push(null);return"("});XRegExp.addToken(/\(\?<([$\w]+)>/,function(p){this.captureNames.push(p[1]);this.hasNamedCapture=true;return"("});XRegExp.addToken(/\\k<([\w$]+)>/,function(q){var p=l(this.captureNames,q[1]);return p>-1?"\\"+(p+1)+(isNaN(q.input.charAt(q.index+q[0].length))?"":"(?:)"):q[0]});XRegExp.addToken(/\[\^?]/,function(p){return p[0]==="[]"?"\\b\\B":"[\\s\\S]"});XRegExp.addToken(/^\(\?([imsx]+)\)/,function(p){this.setFlag(p[1]);return""});XRegExp.addToken(/(?:\s+|#.*)+/,function(p){return m.test.call(n,p.input.slice(p.index+p[0].length))?"":"(?:)"},XRegExp.OUTSIDE_CLASS,function(){return this.hasFlag("x")});XRegExp.addToken(/\./,function(){return"[\\s\\S]"},XRegExp.OUTSIDE_CLASS,function(){return this.hasFlag("s")})})();
  543. </script><script type="text/javascript">/**
  544. * SyntaxHighlighter
  545. * http://alexgorbatchev.com/SyntaxHighlighter
  546. *
  547. * SyntaxHighlighter is donationware. If you are using it, please donate.
  548. * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
  549. *
  550. * @version
  551. * 3.0.83 (July 02 2010)
  552. *
  553. * @copyright
  554. * Copyright (C) 2004-2010 Alex Gorbatchev.
  555. *
  556. * @license
  557. * Dual licensed under the MIT and GPL licenses.
  558. */
  559. //
  560. // Begin anonymous function. This is used to contain local scope variables without polutting global scope.
  561. //
  562. var SyntaxHighlighter = function() {
  563. // CommonJS
  564. if (typeof(require) != 'undefined' && typeof(XRegExp) == 'undefined')
  565. {
  566. XRegExp = require('XRegExp').XRegExp;
  567. }
  568. // Shortcut object which will be assigned to the SyntaxHighlighter variable.
  569. // This is a shorthand for local reference in order to avoid long namespace
  570. // references to SyntaxHighlighter.whatever...
  571. var sh = {
  572. defaults : {
  573. /** Additional CSS class names to be added to highlighter elements. */
  574. 'class-name' : '',
  575. /** First line number. */
  576. 'first-line' : 1,
  577. /**
  578. * Pads line numbers. Possible values are:
  579. *
  580. * false - don't pad line numbers.
  581. * true - automaticaly pad numbers with minimum required number of leading zeroes.
  582. * [int] - length up to which pad line numbers.
  583. */
  584. 'pad-line-numbers' : false,
  585. /** Lines to highlight. */
  586. 'highlight' : null,
  587. /** Title to be displayed above the code block. */
  588. 'title' : null,
  589. /** Enables or disables smart tabs. */
  590. 'smart-tabs' : true,
  591. /** Gets or sets tab size. */
  592. 'tab-size' : 4,
  593. /** Enables or disables gutter. */
  594. 'gutter' : true,
  595. /** Enables or disables toolbar. */
  596. 'toolbar' : true,
  597. /** Enables quick code copy and paste from double click. */
  598. 'quick-code' : true,
  599. /** Forces code view to be collapsed. */
  600. 'collapse' : false,
  601. /** Enables or disables automatic links. */
  602. 'auto-links' : true,
  603. /** Gets or sets light mode. Equavalent to turning off gutter and toolbar. */
  604. 'light' : false,
  605. 'html-script' : false
  606. },
  607. config : {
  608. space : '&nbsp;',
  609. /** Enables use of <SCRIPT type="syntaxhighlighter" /> tags. */
  610. useScriptTags : true,
  611. /** Blogger mode flag. */
  612. bloggerMode : false,
  613. stripBrs : false,
  614. /** Name of the tag that SyntaxHighlighter will automatically look for. */
  615. tagName : 'pre',
  616. strings : {
  617. expandSource : 'expand source',
  618. help : '?',
  619. alert: 'SyntaxHighlighter\n\n',
  620. noBrush : 'Can\'t find brush for: ',
  621. brushNotHtmlScript : 'Brush wasn\'t configured for html-script option: ',
  622. // this is populated by the build script
  623. 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>'
  624. }
  625. },
  626. /** Internal 'global' variables. */
  627. vars : {
  628. discoveredBrushes : null,
  629. highlighters : {}
  630. },
  631. /** This object is populated by user included external brush files. */
  632. brushes : {},
  633. /** Common regular expressions. */
  634. regexLib : {
  635. multiLineCComments : /\/\*[\s\S]*?\*\//gm,
  636. singleLineCComments : /\/\/.*$/gm,
  637. singleLinePerlComments : /#.*$/gm,
  638. doubleQuotedString : /"([^\\"\n]|\\.)*"/g,
  639. singleQuotedString : /'([^\\'\n]|\\.)*'/g,
  640. multiLineDoubleQuotedString : new XRegExp('"([^\\\\"]|\\\\.)*"', 'gs'),
  641. multiLineSingleQuotedString : new XRegExp("'([^\\\\']|\\\\.)*'", 'gs'),
  642. xmlComments : /(&lt;|<)!--[\s\S]*?--(&gt;|>)/gm,
  643. url : /\w+:\/\/[\w-.\/?%&=:@;]*/g,
  644. /** <?= ?> tags. */
  645. phpScriptTags : { left: /(&lt;|<)\?=?/g, right: /\?(&gt;|>)/g },
  646. /** <%= %> tags. */
  647. aspScriptTags : { left: /(&lt;|<)%=?/g, right: /%(&gt;|>)/g },
  648. scriptScriptTags : { left: /(&lt;|<)\s*script.*?(&gt;|>)/gi, right: /(&lt;|<)\/\s*script\s*(&gt;|>)/gi }
  649. },
  650. toolbar: {
  651. /**
  652. * Generates HTML markup for the toolbar.
  653. * @param {Highlighter} highlighter Highlighter instance.
  654. * @return {String} Returns HTML markup.
  655. */
  656. getHtml: function(highlighter)
  657. {
  658. var html = '<div class="toolbar">',
  659. items = sh.toolbar.items,
  660. list = items.list
  661. ;
  662. function defaultGetHtml(highlighter, name)
  663. {
  664. return sh.toolbar.getButtonHtml(highlighter, name, sh.config.strings[name]);
  665. };
  666. for (var i = 0; i < list.length; i++)
  667. html += (items[list[i]].getHtml || defaultGetHtml)(highlighter, list[i]);
  668. html += '</div>';
  669. return html;
  670. },
  671. /**
  672. * Generates HTML markup for a regular button in the toolbar.
  673. * @param {Highlighter} highlighter Highlighter instance.
  674. * @param {String} commandName Command name that would be executed.
  675. * @param {String} label Label text to display.
  676. * @return {String} Returns HTML markup.
  677. */
  678. getButtonHtml: function(highlighter, commandName, label)
  679. {
  680. return '<span><a href="#" class="toolbar_item'
  681. + ' command_' + commandName
  682. + ' ' + commandName
  683. + '">' + label + '</a></span>'
  684. ;
  685. },
  686. /**
  687. * Event handler for a toolbar anchor.
  688. */
  689. handler: function(e)
  690. {
  691. var target = e.target,
  692. className = target.className || ''
  693. ;
  694. function getValue(name)
  695. {
  696. var r = new RegExp(name + '_(\\w+)'),
  697. match = r.exec(className)
  698. ;
  699. return match ? match[1] : null;
  700. };
  701. var highlighter = getHighlighterById(findParentElement(target, '.syntaxhighlighter').id),
  702. commandName = getValue('command')
  703. ;
  704. // execute the toolbar command
  705. if (highlighter && commandName)
  706. sh.toolbar.items[commandName].execute(highlighter);
  707. // disable default A click behaviour
  708. e.preventDefault();
  709. },
  710. /** Collection of toolbar items. */
  711. items : {
  712. // Ordered lis of items in the toolbar. Can't expect `for (var n in items)` to be consistent.
  713. list: ['expandSource', 'help'],
  714. expandSource: {
  715. getHtml: function(highlighter)
  716. {
  717. if (highlighter.getParam('collapse') != true)
  718. return '';
  719. var title = highlighter.getParam('title');
  720. return sh.toolbar.getButtonHtml(highlighter, 'expandSource', title ? title : sh.config.strings.expandSource);
  721. },
  722. execute: function(highlighter)
  723. {
  724. var div = getHighlighterDivById(highlighter.id);
  725. removeClass(div, 'collapsed');
  726. }
  727. },
  728. /** Command to display the about dialog window. */
  729. help: {
  730. execute: function(highlighter)
  731. {
  732. var wnd = popup('', '_blank', 500, 250, 'scrollbars=0'),
  733. doc = wnd.document
  734. ;
  735. doc.write(sh.config.strings.aboutDialog);
  736. doc.close();
  737. wnd.focus();
  738. }
  739. }
  740. }
  741. },
  742. /**
  743. * Finds all elements on the page which should be processes by SyntaxHighlighter.
  744. *
  745. * @param {Object} globalParams Optional parameters which override element's
  746. * parameters. Only used if element is specified.
  747. *
  748. * @param {Object} element Optional element to highlight. If none is
  749. * provided, all elements in the current document
  750. * are returned which qualify.
  751. *
  752. * @return {Array} Returns list of <code>{ target: DOMElement, params: Object }</code> objects.
  753. */
  754. findElements: function(globalParams, element)
  755. {
  756. var elements = element ? [element] : toArray(document.getElementsByTagName(sh.config.tagName)),
  757. conf = sh.config,
  758. result = []
  759. ;
  760. // support for <SCRIPT TYPE="syntaxhighlighter" /> feature
  761. if (conf.useScriptTags)
  762. elements = elements.concat(getSyntaxHighlighterScriptTags());
  763. if (elements.length === 0)
  764. return result;
  765. for (var i = 0; i < elements.length; i++)
  766. {
  767. var item = {
  768. target: elements[i],
  769. // local params take precedence over globals
  770. params: merge(globalParams, parseParams(elements[i].className))
  771. };
  772. if (item.params['brush'] == null)
  773. continue;
  774. result.push(item);
  775. }
  776. return result;
  777. },
  778. /**
  779. * Shorthand to highlight all elements on the page that are marked as
  780. * SyntaxHighlighter source code.
  781. *
  782. * @param {Object} globalParams Optional parameters which override element's
  783. * parameters. Only used if element is specified.
  784. *
  785. * @param {Object} element Optional element to highlight. If none is
  786. * provided, all elements in the current document
  787. * are highlighted.
  788. */
  789. highlight: function(globalParams, element)
  790. {
  791. var elements = this.findElements(globalParams, element),
  792. propertyName = 'innerHTML',
  793. highlighter = null,
  794. conf = sh.config
  795. ;
  796. if (elements.length === 0)
  797. return;
  798. for (var i = 0; i < elements.length; i++)
  799. {
  800. var element = elements[i],
  801. target = element.target,
  802. params = element.params,
  803. brushName = params.brush,
  804. code
  805. ;
  806. if (brushName == null)
  807. continue;
  808. // Instantiate a brush
  809. if (params['html-script'] == 'true' || sh.defaults['html-script'] == true)
  810. {
  811. highlighter = new sh.HtmlScript(brushName);
  812. brushName = 'htmlscript';
  813. }
  814. else
  815. {
  816. var brush = findBrush(brushName);
  817. if (brush)
  818. highlighter = new brush();
  819. else
  820. continue;
  821. }
  822. code = target[propertyName];
  823. // remove CDATA from <SCRIPT/> tags if it's present
  824. if (conf.useScriptTags)
  825. code = stripCData(code);
  826. // Inject title if the attribute is present
  827. if ((target.title || '') != '')
  828. params.title = target.title;
  829. params['brush'] = brushName;
  830. highlighter.init(params);
  831. element = highlighter.getDiv(code);
  832. // carry over ID
  833. if ((target.id || '') != '')
  834. element.id = target.id;
  835. target.parentNode.replaceChild(element, target);
  836. }
  837. },
  838. /**
  839. * Main entry point for the SyntaxHighlighter.
  840. * @param {Object} params Optional params to apply to all highlighted elements.
  841. */
  842. all: function(params)
  843. {
  844. attachEvent(
  845. window,
  846. 'load',
  847. function() { sh.highlight(params); }
  848. );
  849. }
  850. }; // end of sh
  851. sh['all'] = sh.all;
  852. sh['highlight'] = sh.highlight;
  853. /**
  854. * Checks if target DOM elements has specified CSS class.
  855. * @param {DOMElement} target Target DOM element to check.
  856. * @param {String} className Name of the CSS class to check for.
  857. * @return {Boolean} Returns true if class name is present, false otherwise.
  858. */
  859. function hasClass(target, className)
  860. {
  861. return target.className.indexOf(className) != -1;
  862. };
  863. /**
  864. * Adds CSS class name to the target DOM element.
  865. * @param {DOMElement} target Target DOM element.
  866. * @param {String} className New CSS class to add.
  867. */
  868. function addClass(target, className)
  869. {
  870. if (!hasClass(target, className))
  871. target.className += ' ' + className;
  872. };
  873. /**
  874. * Removes CSS class name from the target DOM element.
  875. * @param {DOMElement} target Target DOM element.
  876. * @param {String} className CSS class to remove.
  877. */
  878. function removeClass(target, className)
  879. {
  880. target.className = target.className.replace(className, '');
  881. };
  882. /**
  883. * Converts the source to array object. Mostly used for function arguments and
  884. * lists returned by getElementsByTagName() which aren't Array objects.
  885. * @param {List} source Source list.
  886. * @return {Array} Returns array.
  887. */
  888. function toArray(source)
  889. {
  890. var result = [];
  891. for (var i = 0; i < source.length; i++)
  892. result.push(source[i]);
  893. return result;
  894. };
  895. /**
  896. * Splits block of text into lines.
  897. * @param {String} block Block of text.
  898. * @return {Array} Returns array of lines.
  899. */
  900. function splitLines(block)
  901. {
  902. return block.split('\n');
  903. }
  904. /**
  905. * Generates HTML ID for the highlighter.
  906. * @param {String} highlighterId Highlighter ID.
  907. * @return {String} Returns HTML ID.
  908. */
  909. function getHighlighterId(id)
  910. {
  911. var prefix = 'highlighter_';
  912. return id.indexOf(prefix) == 0 ? id : prefix + id;
  913. };
  914. /**
  915. * Finds Highlighter instance by ID.
  916. * @param {String} highlighterId Highlighter ID.
  917. * @return {Highlighter} Returns instance of the highlighter.
  918. */
  919. function getHighlighterById(id)
  920. {
  921. return sh.vars.highlighters[getHighlighterId(id)];
  922. };
  923. /**
  924. * Finds highlighter's DIV container.
  925. * @param {String} highlighterId Highlighter ID.
  926. * @return {Element} Returns highlighter's DIV element.
  927. */
  928. function getHighlighterDivById(id)
  929. {
  930. return document.getElementById(getHighlighterId(id));
  931. };
  932. /**
  933. * Stores highlighter so that getHighlighterById() can do its thing. Each
  934. * highlighter must call this method to preserve itself.
  935. * @param {Highilghter} highlighter Highlighter instance.
  936. */
  937. function storeHighlighter(highlighter)
  938. {
  939. sh.vars.highlighters[getHighlighterId(highlighter.id)] = highlighter;
  940. };
  941. /**
  942. * Looks for a child or parent node which has specified classname.
  943. * Equivalent to jQuery's $(container).find(".className")
  944. * @param {Element} target Target element.
  945. * @param {String} search Class name or node name to look for.
  946. * @param {Boolean} reverse If set to true, will go up the node tree instead of down.
  947. * @return {Element} Returns found child or parent element on null.
  948. */
  949. function findElement(target, search, reverse /* optional */)
  950. {
  951. if (target == null)
  952. return null;
  953. var nodes = reverse != true ? target.childNodes : [ target.parentNode ],
  954. propertyToFind = { '#' : 'id', '.' : 'className' }[search.substr(0, 1)] || 'nodeName',
  955. expectedValue,
  956. found
  957. ;
  958. expectedValue = propertyToFind != 'nodeName'
  959. ? search.substr(1)
  960. : search.toUpperCase()
  961. ;
  962. // main return of the found node
  963. if ((target[propertyToFind] || '').indexOf(expectedValue) != -1)
  964. return target;
  965. for (var i = 0; nodes && i < nodes.length && found == null; i++)
  966. found = findElement(nodes[i], search, reverse);
  967. return found;
  968. };
  969. /**
  970. * Looks for a parent node which has specified classname.
  971. * This is an alias to <code>findElement(container, className, true)</code>.
  972. * @param {Element} target Target element.
  973. * @param {String} className Class name to look for.
  974. * @return {Element} Returns found parent element on null.
  975. */
  976. function findParentElement(target, className)
  977. {
  978. return findElement(target, className, true);
  979. };
  980. /**
  981. * Finds an index of element in the array.
  982. * @ignore
  983. * @param {Object} searchElement
  984. * @param {Number} fromIndex
  985. * @return {Number} Returns index of element if found; -1 otherwise.
  986. */
  987. function indexOf(array, searchElement, fromIndex)
  988. {
  989. fromIndex = Math.max(fromIndex || 0, 0);
  990. for (var i = fromIndex; i < array.length; i++)
  991. if(array[i] == searchElement)
  992. return i;
  993. return -1;
  994. };
  995. /**
  996. * Generates a unique element ID.
  997. */
  998. function guid(prefix)
  999. {
  1000. return (prefix || '') + Math.round(Math.random() * 1000000).toString();
  1001. };
  1002. /**
  1003. * Merges two objects. Values from obj2 override values in obj1.
  1004. * Function is NOT recursive and works only for one dimensional objects.
  1005. * @param {Object} obj1 First object.
  1006. * @param {Object} obj2 Second object.
  1007. * @return {Object} Returns combination of both objects.
  1008. */
  1009. function merge(obj1, obj2)
  1010. {
  1011. var result = {}, name;
  1012. for (name in obj1)
  1013. result[name] = obj1[name];
  1014. for (name in obj2)
  1015. result[name] = obj2[name];
  1016. return result;
  1017. };
  1018. /**
  1019. * Attempts to convert string to boolean.
  1020. * @param {String} value Input string.
  1021. * @return {Boolean} Returns true if input was "true", false if input was "false" and value otherwise.
  1022. */
  1023. function toBoolean(value)
  1024. {
  1025. var result = { "true" : true, "false" : false }[value];
  1026. return result == null ? value : result;
  1027. };
  1028. /**
  1029. * Opens up a centered popup window.
  1030. * @param {String} url URL to open in the window.
  1031. * @param {String} name Popup name.
  1032. * @param {int} width Popup width.
  1033. * @param {int} height Popup height.
  1034. * @param {String} options window.open() options.
  1035. * @return {Window} Returns window instance.
  1036. */
  1037. function popup(url, name, width, height, options)
  1038. {
  1039. var x = (screen.width - width) / 2,
  1040. y = (screen.height - height) / 2
  1041. ;
  1042. options += ', left=' + x +
  1043. ', top=' + y +
  1044. ', width=' + width +
  1045. ', height=' + height
  1046. ;
  1047. options = options.replace(/^,/, '');
  1048. var win = window.open(url, name, options);
  1049. win.focus();
  1050. return win;
  1051. };
  1052. /**
  1053. * Adds event handler to the target object.
  1054. * @param {Object} obj Target object.
  1055. * @param {String} type Name of the event.
  1056. * @param {Function} func Handling function.
  1057. */
  1058. function attachEvent(obj, type, func, scope)
  1059. {
  1060. function handler(e)
  1061. {
  1062. e = e || window.event;
  1063. if (!e.target)
  1064. {
  1065. e.target = e.srcElement;
  1066. e.preventDefault = function()
  1067. {
  1068. this.returnValue = false;
  1069. };
  1070. }
  1071. func.call(scope || window, e);
  1072. };
  1073. if (obj.attachEvent)
  1074. {
  1075. obj.attachEvent('on' + type, handler);
  1076. }
  1077. else
  1078. {
  1079. obj.addEventListener(type, handler, false);
  1080. }
  1081. };
  1082. /**
  1083. * Displays an alert.
  1084. * @param {String} str String to display.
  1085. */
  1086. function alert(str)
  1087. {
  1088. window.alert(sh.config.strings.alert + str);
  1089. };
  1090. /**
  1091. * Finds a brush by its alias.
  1092. *
  1093. * @param {String} alias Brush alias.
  1094. * @param {Boolean} showAlert Suppresses the alert if false.
  1095. * @return {Brush} Returns bursh constructor if found, null otherwise.
  1096. */
  1097. function findBrush(alias, showAlert)
  1098. {
  1099. var brushes = sh.vars.discoveredBrushes,
  1100. result = null
  1101. ;
  1102. if (brushes == null)
  1103. {
  1104. brushes = {};
  1105. // Find all brushes
  1106. for (var brush in sh.brushes)
  1107. {
  1108. var info = sh.brushes[brush],
  1109. aliases = info.aliases
  1110. ;
  1111. if (aliases == null)
  1112. continue;
  1113. // keep the brush name
  1114. info.brushName = brush.toLowerCase();
  1115. for (var i = 0; i < aliases.length; i++)
  1116. brushes[aliases[i]] = brush;
  1117. }
  1118. sh.vars.discoveredBrushes = brushes;
  1119. }
  1120. result = sh.brushes[brushes[alias]];
  1121. if (result == null && showAlert != false)
  1122. alert(sh.config.strings.noBrush + alias);
  1123. return result;
  1124. };
  1125. /**
  1126. * Executes a callback on each line and replaces each line with result from the callback.
  1127. * @param {Object} str Input string.
  1128. * @param {Object} callback Callback function taking one string argument and returning a string.
  1129. */
  1130. function eachLine(str, callback)
  1131. {
  1132. var lines = splitLines(str);
  1133. for (var i = 0; i < lines.length; i++)
  1134. lines[i] = callback(lines[i], i);
  1135. return lines.join('\n');
  1136. };
  1137. /**
  1138. * This is a special trim which only removes first and last empty lines
  1139. * and doesn't affect valid leading space on the first line.
  1140. *
  1141. * @param {String} str Input string
  1142. * @return {String} Returns string without empty first and last lines.
  1143. */
  1144. function trimFirstAndLastLines(str)
  1145. {
  1146. return str.replace(/^[ ]*[\n]+|[\n]*[ ]*$/g, '');
  1147. };
  1148. /**
  1149. * Parses key/value pairs into hash object.
  1150. *
  1151. * Understands the following formats:
  1152. * - name: word;
  1153. * - name: [word, word];
  1154. * - name: "string";
  1155. * - name: 'string';
  1156. *
  1157. * For example:
  1158. * name1: value; name2: [value, value]; name3: 'value'
  1159. *
  1160. * @param {String} str Input string.
  1161. * @return {Object} Returns deserialized object.
  1162. */
  1163. function parseParams(str)
  1164. {
  1165. var match,
  1166. result = {},
  1167. arrayRegex = new XRegExp("^\\[(?<values>(.*?))\\]$"),
  1168. regex = new XRegExp(
  1169. "(?<name>[\\w-]+)" +
  1170. "\\s*:\\s*" +
  1171. "(?<value>" +
  1172. "[\\w-%#]+|" + // word
  1173. "\\[.*?\\]|" + // [] array
  1174. '".*?"|' + // "" string
  1175. "'.*?'" + // '' string
  1176. ")\\s*;?",
  1177. "g"
  1178. )
  1179. ;
  1180. while ((match = regex.exec(str)) != null)
  1181. {
  1182. var value = match.value
  1183. .replace(/^['"]|['"]$/g, '') // strip quotes from end of strings
  1184. ;
  1185. // try to parse array value
  1186. if (value != null && arrayRegex.test(value))
  1187. {
  1188. var m = arrayRegex.exec(value);
  1189. value = m.values.length > 0 ? m.values.split(/\s*,\s*/) : [];
  1190. }
  1191. result[match.name] = value;
  1192. }
  1193. return result;
  1194. };
  1195. /**
  1196. * Wraps each line of the string into <code/> tag with given style applied to it.
  1197. *
  1198. * @param {String} str Input string.
  1199. * @param {String} css Style name to apply to the string.
  1200. * @return {String} Returns input string with each line surrounded by <span/> tag.
  1201. */
  1202. function wrapLinesWithCode(str, css)
  1203. {
  1204. if (str == null || str.length == 0 || str == '\n')
  1205. return str;
  1206. str = str.replace(/</g, '&lt;');
  1207. // Replace two or more sequential spaces with &nbsp; leaving last space untouched.
  1208. str = str.replace(/ {2,}/g, function(m)
  1209. {
  1210. var spaces = '';
  1211. for (var i = 0; i < m.length - 1; i++)
  1212. spaces += sh.config.space;
  1213. return spaces + ' ';
  1214. });
  1215. // Split each line and apply <span class="...">...</span> to them so that
  1216. // leading spaces aren't included.
  1217. if (css != null)
  1218. str = eachLine(str, function(line)
  1219. {
  1220. if (line.length == 0)
  1221. return '';
  1222. var spaces = '';
  1223. line = line.replace(/^(&nbsp;| )+/, function(s)
  1224. {
  1225. spaces = s;
  1226. return '';
  1227. });
  1228. if (line.length == 0)
  1229. return spaces;
  1230. return spaces + '<code class="' + css + '">' + line + '</code>';
  1231. });
  1232. return str;
  1233. };
  1234. /**
  1235. * Pads number with zeros until it's length is the same as given length.
  1236. *
  1237. * @param {Number} number Number to pad.
  1238. * @param {Number} length Max string length with.
  1239. * @return {String} Returns a string padded with proper amount of '0'.
  1240. */
  1241. function padNumber(number, length)
  1242. {
  1243. var result = number.toString();
  1244. while (result.length < length)
  1245. result = '0' + result;
  1246. return result;
  1247. };
  1248. /**
  1249. * Replaces tabs with spaces.
  1250. *
  1251. * @param {String} code Source code.
  1252. * @param {Number} tabSize Size of the tab.
  1253. * @return {String} Returns code with all tabs replaces by spaces.
  1254. */
  1255. function processTabs(code, tabSize)
  1256. {
  1257. var tab = '';
  1258. for (var i = 0; i < tabSize; i++)
  1259. tab += ' ';
  1260. return code.replace(/\t/g, tab);
  1261. };
  1262. /**
  1263. * Replaces tabs with smart spaces.
  1264. *
  1265. * @param {String} code Code to fix the tabs in.
  1266. * @param {Number} tabSize Number of spaces in a column.
  1267. * @return {String} Returns code with all tabs replaces with roper amount of spaces.
  1268. */
  1269. function processSmartTabs(code, tabSize)
  1270. {
  1271. var lines = splitLines(code),
  1272. tab = '\t',
  1273. spaces = ''
  1274. ;
  1275. // Create a string with 1000 spaces to copy spaces from...
  1276. // It's assumed that there would be no indentation longer than that.
  1277. for (var i = 0; i < 50; i++)
  1278. spaces += ' '; // 20 spaces * 50
  1279. // This function inserts specified amount of spaces in the string
  1280. // where a tab is while removing that given tab.
  1281. function insertSpaces(line, pos, count)
  1282. {
  1283. return line.substr(0, pos)
  1284. + spaces.substr(0, count)
  1285. + line.substr(pos + 1, line.length) // pos + 1 will get rid of the tab
  1286. ;
  1287. };
  1288. // Go through all the lines and do the 'smart tabs' magic.
  1289. code = eachLine(code, function(line)
  1290. {
  1291. if (line.indexOf(tab) == -1)
  1292. return line;
  1293. var pos = 0;
  1294. while ((pos = line.indexOf(tab)) != -1)
  1295. {
  1296. // This is pretty much all there is to the 'smart tabs' logic.
  1297. // Based on the position within the line and size of a tab,
  1298. // calculate the amount of spaces we need to insert.
  1299. var spaces = tabSize - pos % tabSize;
  1300. line = insertSpaces(line, pos, spaces);
  1301. }
  1302. return line;
  1303. });
  1304. return code;
  1305. };
  1306. /**
  1307. * Performs various string fixes based on configuration.
  1308. */
  1309. function fixInputString(str)
  1310. {
  1311. var br = /<br\s*\/?>|&lt;br\s*\/?&gt;/gi;
  1312. if (sh.config.bloggerMode == true)
  1313. str = str.replace(br, '\n');
  1314. if (sh.config.stripBrs == true)
  1315. str = str.replace(br, '');
  1316. return str;
  1317. };
  1318. /**
  1319. * Removes all white space at the begining and end of a string.
  1320. *
  1321. * @param {String} str String to trim.
  1322. * @return {String} Returns string without leading and following white space characters.
  1323. */
  1324. function trim(str)
  1325. {
  1326. return str.replace(/^\s+|\s+$/g, '');
  1327. };
  1328. /**
  1329. * Unindents a block of text by the lowest common indent amount.
  1330. * @param {String} str Text to unindent.
  1331. * @return {String} Returns unindented text block.
  1332. */
  1333. function unindent(str)
  1334. {
  1335. var lines = splitLines(fixInputString(str)),
  1336. indents = new Array(),
  1337. regex = /^\s*/,
  1338. min = 1000
  1339. ;
  1340. // go through every line and check for common number of indents
  1341. for (var i = 0; i < lines.length && min > 0; i++)
  1342. {
  1343. var line = lines[i];
  1344. if (trim(line).length == 0)
  1345. continue;
  1346. var matches = regex.exec(line);
  1347. // In the event that just one line doesn't have leading white space
  1348. // we can't unindent anything, so bail completely.
  1349. if (matches == null)
  1350. return str;
  1351. min = Math.min(matches[0].length, min);
  1352. }
  1353. // trim minimum common number of white space from the begining of every line
  1354. if (min > 0)
  1355. for (var i = 0; i < lines.length; i++)
  1356. lines[i] = lines[i].substr(min);
  1357. return lines.join('\n');
  1358. };
  1359. /**
  1360. * Callback method for Array.sort() which sorts matches by
  1361. * index position and then by length.
  1362. *
  1363. * @param {Match} m1 Left object.
  1364. * @param {Match} m2 Right object.
  1365. * @return {Number} Returns -1, 0 or -1 as a comparison result.
  1366. */
  1367. function matchesSortCallback(m1, m2)
  1368. {
  1369. // sort matches by index first
  1370. if(m1.index < m2.index)
  1371. return -1;
  1372. else if(m1.index > m2.index)
  1373. return 1;
  1374. else
  1375. {
  1376. // if index is the same, sort by length
  1377. if(m1.length < m2.length)
  1378. return -1;
  1379. else if(m1.length > m2.length)
  1380. return 1;
  1381. }
  1382. return 0;
  1383. };
  1384. /**
  1385. * Executes given regular expression on provided code and returns all
  1386. * matches that are found.
  1387. *
  1388. * @param {String} code Code to execute regular expression on.
  1389. * @param {Object} regex Regular expression item info from <code>regexList</code> collection.
  1390. * @return {Array} Returns a list of Match objects.
  1391. */
  1392. function getMatches(code, regexInfo)
  1393. {
  1394. function defaultAdd(match, regexInfo)
  1395. {
  1396. return match[0];
  1397. };
  1398. var index = 0,
  1399. match = null,
  1400. matches = [],
  1401. func = regexInfo.func ? regexInfo.func : defaultAdd
  1402. ;
  1403. while((match = regexInfo.regex.exec(code)) != null)
  1404. {
  1405. var resultMatch = func(match, regexInfo);
  1406. if (typeof(resultMatch) == 'string')
  1407. resultMatch = [new sh.Match(resultMatch, match.index, regexInfo.css)];
  1408. matches = matches.concat(resultMatch);
  1409. }
  1410. return matches;
  1411. };
  1412. /**
  1413. * Turns all URLs in the code into <a/> tags.
  1414. * @param {String} code Input code.
  1415. * @return {String} Returns code with </a> tags.
  1416. */
  1417. function processUrls(code)
  1418. {
  1419. var gt = /(.*)((&gt;|&lt;).*)/;
  1420. return code.replace(sh.regexLib.url, function(m)
  1421. {
  1422. var suffix = '',
  1423. match = null
  1424. ;
  1425. // We include &lt; and &gt; in the URL for the common cases like <http://google.com>
  1426. // The problem is that they get transformed into &lt;http://google.com&gt;
  1427. // Where as &gt; easily looks like part of the URL string.
  1428. if (match = gt.exec(m))
  1429. {
  1430. m = match[1];
  1431. suffix = match[2];
  1432. }
  1433. return '<a href="' + m + '">' + m + '</a>' + suffix;
  1434. });
  1435. };
  1436. /**
  1437. * Finds all <SCRIPT TYPE="syntaxhighlighter" /> elementss.
  1438. * @return {Array} Returns array of all found SyntaxHighlighter tags.
  1439. */
  1440. function getSyntaxHighlighterScriptTags()
  1441. {
  1442. var tags = document.getElementsByTagName('script'),
  1443. result = []
  1444. ;
  1445. for (var i = 0; i < tags.length; i++)
  1446. if (tags[i].type == 'syntaxhighlighter')
  1447. result.push(tags[i]);
  1448. return result;
  1449. };
  1450. /**
  1451. * Strips <![CDATA[]]> from <SCRIPT /> content because it should be used
  1452. * there in most cases for XHTML compliance.
  1453. * @param {String} original Input code.
  1454. * @return {String} Returns code without leading <![CDATA[]]> tags.
  1455. */
  1456. function stripCData(original)
  1457. {
  1458. var left = '<![CDATA[',
  1459. right = ']]>',
  1460. // for some reason IE inserts some leading blanks here
  1461. copy = trim(original),
  1462. changed = false,
  1463. leftLength = left.length,
  1464. rightLength = right.length
  1465. ;
  1466. if (copy.indexOf(left) == 0)
  1467. {
  1468. copy = copy.substring(leftLength);
  1469. changed = true;
  1470. }
  1471. var copyLength = copy.length;
  1472. if (copy.indexOf(right) == copyLength - rightLength)
  1473. {
  1474. copy = copy.substring(0, copyLength - rightLength);
  1475. changed = true;
  1476. }
  1477. return changed ? copy : original;
  1478. };
  1479. /**
  1480. * Quick code mouse double click handler.
  1481. */
  1482. function quickCodeHandler(e)
  1483. {
  1484. var target = e.target,
  1485. highlighterDiv = findParentElement(target, '.syntaxhighlighter'),
  1486. container = findParentElement(target, '.container'),
  1487. textarea = document.createElement('textarea'),
  1488. highlighter
  1489. ;
  1490. if (!container || !highlighterDiv || findElement(container, 'textarea'))
  1491. return;
  1492. highlighter = getHighlighterById(highlighterDiv.id);
  1493. // add source class name
  1494. addClass(highlighterDiv, 'source');
  1495. // Have to go over each line and grab it's text, can't just do it on the
  1496. // container because Firefox loses all \n where as Webkit doesn't.
  1497. var lines = container.childNodes,
  1498. code = []
  1499. ;
  1500. for (var i = 0; i < lines.length; i++)
  1501. code.push(lines[i].innerText || lines[i].textContent);
  1502. // using \r instead of \r or \r\n makes this work equally well on IE, FF and Webkit
  1503. code = code.join('\r');
  1504. // inject <textarea/> tag
  1505. textarea.appendChild(document.createTextNode(code));
  1506. container.appendChild(textarea);
  1507. // preselect all text
  1508. textarea.focus();
  1509. textarea.select();
  1510. // set up handler for lost focus
  1511. attachEvent(textarea, 'blur', function(e)
  1512. {
  1513. textarea.parentNode.removeChild(textarea);
  1514. removeClass(highlighterDiv, 'source');
  1515. });
  1516. };
  1517. /**
  1518. * Match object.
  1519. */
  1520. sh.Match = function(value, index, css)
  1521. {
  1522. this.value = value;
  1523. this.index = index;
  1524. this.length = value.length;
  1525. this.css = css;
  1526. this.brushName = null;
  1527. };
  1528. sh.Match.prototype.toString = function()
  1529. {
  1530. return this.value;
  1531. };
  1532. /**
  1533. * Simulates HTML code with a scripting language embedded.
  1534. *
  1535. * @param {String} scriptBrushName Brush name of the scripting language.
  1536. */
  1537. sh.HtmlScript = function(scriptBrushName)
  1538. {
  1539. var brushClass = findBrush(scriptBrushName),
  1540. scriptBrush,
  1541. xmlBrush = new sh.brushes.Xml(),
  1542. bracketsRegex = null,
  1543. ref = this,
  1544. methodsToExpose = 'getDiv getHtml init'.split(' ')
  1545. ;
  1546. if (brushClass == null)
  1547. return;
  1548. scriptBrush = new brushClass();
  1549. for(var i = 0; i < methodsToExpose.length; i++)
  1550. // make a closure so we don't lose the name after i changes
  1551. (function() {
  1552. var name = methodsToExpose[i];
  1553. ref[name] = function()
  1554. {
  1555. return xmlBrush[name].apply(xmlBrush, arguments);
  1556. };
  1557. })();
  1558. if (scriptBrush.htmlScript == null)
  1559. {
  1560. alert(sh.config.strings.brushNotHtmlScript + scriptBrushName);
  1561. return;
  1562. }
  1563. xmlBrush.regexList.push(
  1564. { regex: scriptBrush.htmlScript.code, func: process }
  1565. );
  1566. function offsetMatches(matches, offset)
  1567. {
  1568. for (var j = 0; j < matches.length; j++)
  1569. matches[j].index += offset;
  1570. }
  1571. function process(match, info)
  1572. {
  1573. var code = match.code,
  1574. matches = [],
  1575. regexList = scriptBrush.regexList,
  1576. offset = match.index + match.left.length,
  1577. htmlScript = scriptBrush.htmlScript,
  1578. result
  1579. ;
  1580. // add all matches from the code
  1581. for (var i = 0; i < regexList.length; i++)
  1582. {
  1583. result = getMatches(code, regexList[i]);
  1584. offsetMatches(result, offset);
  1585. matches = matches.concat(result);
  1586. }
  1587. // add left script bracket
  1588. if (htmlScript.left != null && match.left != null)
  1589. {
  1590. result = getMatches(match.left, htmlScript.left);
  1591. offsetMatches(result, match.index);
  1592. matches = matches.concat(result);
  1593. }
  1594. // add right script bracket
  1595. if (htmlScript.right != null && match.right != null)
  1596. {
  1597. result = getMatches(match.right, htmlScript.right);
  1598. offsetMatches(result, match.index + match[0].lastIndexOf(match.right));
  1599. matches = matches.concat(result);
  1600. }
  1601. for (var j = 0; j < matches.length; j++)
  1602. matches[j].brushName = brushClass.brushName;
  1603. return matches;
  1604. }
  1605. };
  1606. /**
  1607. * Main Highlither class.
  1608. * @constructor
  1609. */
  1610. sh.Highlighter = function()
  1611. {
  1612. // not putting any code in here because of the prototype inheritance
  1613. };
  1614. sh.Highlighter.prototype = {
  1615. /**
  1616. * Returns value of the parameter passed to the highlighter.
  1617. * @param {String} name Name of the parameter.
  1618. * @param {Object} defaultValue Default value.
  1619. * @return {Object} Returns found value or default value otherwise.
  1620. */
  1621. getParam: function(name, defaultValue)
  1622. {
  1623. var result = this.params[name];
  1624. return toBoolean(result == null ? defaultValue : result);
  1625. },
  1626. /**
  1627. * Shortcut to document.createElement().
  1628. * @param {String} name Name of the element to create (DIV, A, etc).
  1629. * @return {HTMLElement} Returns new HTML element.
  1630. */
  1631. create: function(name)
  1632. {
  1633. return document.createElement(name);
  1634. },
  1635. /**
  1636. * Applies all regular expression to the code and stores all found
  1637. * matches in the `this.matches` array.
  1638. * @param {Array} regexList List of regular expressions.
  1639. * @param {String} code Source code.
  1640. * @return {Array} Returns list of matches.
  1641. */
  1642. findMatches: function(regexList, code)
  1643. {
  1644. var result = [];
  1645. if (regexList != null)
  1646. for (var i = 0; i < regexList.length; i++)
  1647. // BUG: length returns len+1 for array if methods added to prototype chain (oising@gmail.com)
  1648. if (typeof (regexList[i]) == "object")
  1649. result = result.concat(getMatches(code, regexList[i]));
  1650. // sort and remove nested the matches
  1651. return this.removeNestedMatches(result.sort(matchesSortCallback));
  1652. },
  1653. /**
  1654. * Checks to see if any of the matches are inside of other matches.
  1655. * This process would get rid of highligted strings inside comments,
  1656. * keywords inside strings and so on.
  1657. */
  1658. removeNestedMatches: function(matches)
  1659. {
  1660. // Optimized by Jose Prado (http://joseprado.com)
  1661. for (var i = 0; i < matches.length; i++)
  1662. {
  1663. if (matches[i] === null)
  1664. continue;
  1665. var itemI = matches[i],
  1666. itemIEndPos = itemI.index + itemI.length
  1667. ;
  1668. for (var j = i + 1; j < matches.length && matches[i] !== null; j++)
  1669. {
  1670. var itemJ = matches[j];
  1671. if (itemJ === null)
  1672. continue;
  1673. else if (itemJ.index > itemIEndPos)
  1674. break;
  1675. else if (itemJ.index == itemI.index && itemJ.length > itemI.length)
  1676. matches[i] = null;
  1677. else if (itemJ.index >= itemI.index && itemJ.index < itemIEndPos)
  1678. matches[j] = null;
  1679. }
  1680. }
  1681. return matches;
  1682. },
  1683. /**
  1684. * Creates an array containing integer line numbers starting from the 'first-line' param.
  1685. * @return {Array} Returns array of integers.
  1686. */
  1687. figureOutLineNumbers: function(code)
  1688. {
  1689. var lines = [],
  1690. firstLine = parseInt(this.getParam('first-line'))
  1691. ;
  1692. eachLine(code, function(line, index)
  1693. {
  1694. lines.push(index + firstLine);
  1695. });
  1696. return lines;
  1697. },
  1698. /**
  1699. * Determines if specified line number is in the highlighted list.
  1700. */
  1701. isLineHighlighted: function(lineNumber)
  1702. {
  1703. var list = this.getParam('highlight', []);
  1704. if (typeof(list) != 'object' && list.push == null)
  1705. list = [ list ];
  1706. return indexOf(list, lineNumber.toString()) != -1;
  1707. },
  1708. /**
  1709. * Generates HTML markup for a single line of code while determining alternating line style.
  1710. * @param {Integer} lineNumber Line number.
  1711. * @param {String} code Line HTML markup.
  1712. * @return {String} Returns HTML markup.
  1713. */
  1714. getLineHtml: function(lineIndex, lineNumber, code)
  1715. {
  1716. var classes = [
  1717. 'line',
  1718. 'number' + lineNumber,
  1719. 'index' + lineIndex,
  1720. 'alt' + (lineNumber % 2 == 0 ? 1 : 2).toString()
  1721. ];
  1722. if (this.isLineHighlighted(lineNumber))
  1723. classes.push('highlighted');
  1724. if (lineNumber == 0)
  1725. classes.push('break');
  1726. return '<div class="' + classes.join(' ') + '">' + code + '</div>';
  1727. },
  1728. /**
  1729. * Generates HTML markup for line number column.
  1730. * @param {String} code Complete code HTML markup.
  1731. * @param {Array} lineNumbers Calculated line numbers.
  1732. * @return {String} Returns HTML markup.
  1733. */
  1734. getLineNumbersHtml: function(code, lineNumbers)
  1735. {
  1736. var html = '',
  1737. count = splitLines(code).length,
  1738. firstLine = parseInt(this.getParam('first-line')),
  1739. pad = this.getParam('pad-line-numbers')
  1740. ;
  1741. if (pad == true)
  1742. pad = (firstLine + count - 1).toString().length;
  1743. else if (isNaN(pad) == true)
  1744. pad = 0;
  1745. for (var i = 0; i < count; i++)
  1746. {
  1747. var lineNumber = lineNumbers ? lineNumbers[i] : firstLine + i,
  1748. code = lineNumber == 0 ? sh.config.space : padNumber(lineNumber, pad)
  1749. ;
  1750. html += this.getLineHtml(i, lineNumber, code);
  1751. }
  1752. return html;
  1753. },
  1754. /**
  1755. * Splits block of text into individual DIV lines.
  1756. * @param {String} code Code to highlight.
  1757. * @param {Array} lineNumbers Calculated line numbers.
  1758. * @return {String} Returns highlighted code in HTML form.
  1759. */
  1760. getCodeLinesHtml: function(html, lineNumbers)
  1761. {
  1762. html = trim(html);
  1763. var lines = splitLines(html),
  1764. padLength = this.getParam('pad-line-numbers'),
  1765. firstLine = parseInt(this.getParam('first-line')),
  1766. html = '',
  1767. brushName = this.getParam('brush')
  1768. ;
  1769. for (var i = 0; i < lines.length; i++)
  1770. {
  1771. var line = lines[i],
  1772. indent = /^(&nbsp;|\s)+/.exec(line),
  1773. spaces = null,
  1774. lineNumber = lineNumbers ? lineNumbers[i] : firstLine + i;
  1775. ;
  1776. if (indent != null)
  1777. {
  1778. spaces = indent[0].toString();
  1779. line = line.substr(spaces.length);
  1780. spaces = spaces.replace(' ', sh.config.space);
  1781. }
  1782. line = trim(line);
  1783. if (line.length == 0)
  1784. line = sh.config.space;
  1785. html += this.getLineHtml(
  1786. i,
  1787. lineNumber,
  1788. (spaces != null ? '<code class="' + brushName + ' spaces">' + spaces + '</code>' : '') + line
  1789. );
  1790. }
  1791. return html;
  1792. },
  1793. /**
  1794. * Returns HTML for the table title or empty string if title is null.
  1795. */
  1796. getTitleHtml: function(title)
  1797. {
  1798. return title ? '<caption>' + title + '</caption>' : '';
  1799. },
  1800. /**
  1801. * Finds all matches in the source code.
  1802. * @param {String} code Source code to process matches in.
  1803. * @param {Array} matches Discovered regex matches.
  1804. * @return {String} Returns formatted HTML with processed mathes.
  1805. */
  1806. getMatchesHtml: function(code, matches)
  1807. {
  1808. var pos = 0,
  1809. result = '',
  1810. brushName = this.getParam('brush', '')
  1811. ;
  1812. function getBrushNameCss(match)
  1813. {
  1814. var result = match ? (match.brushName || brushName) : brushName;
  1815. return result ? result + ' ' : '';
  1816. };
  1817. // Finally, go through the final list of matches and pull the all
  1818. // together adding everything in between that isn't a match.
  1819. for (var i = 0; i < matches.length; i++)
  1820. {
  1821. var match = matches[i],
  1822. matchBrushName
  1823. ;
  1824. if (match === null || match.length === 0)
  1825. continue;
  1826. matchBrushName = getBrushNameCss(match);
  1827. result += wrapLinesWithCode(code.substr(pos, match.index - pos), matchBrushName + 'plain')
  1828. + wrapLinesWithCode(match.value, matchBrushName + match.css)
  1829. ;
  1830. pos = match.index + match.length + (match.offset || 0);
  1831. }
  1832. // don't forget to add whatever's remaining in the string
  1833. result += wrapLinesWithCode(code.substr(pos), getBrushNameCss() + 'plain');
  1834. return result;
  1835. },
  1836. /**
  1837. * Generates HTML markup for the whole syntax highlighter.
  1838. * @param {String} code Source code.
  1839. * @return {String} Returns HTML markup.
  1840. */
  1841. getHtml: function(code)
  1842. {
  1843. var html = '',
  1844. classes = [ 'syntaxhighlighter' ],
  1845. tabSize,
  1846. matches,
  1847. lineNumbers
  1848. ;
  1849. // process light mode
  1850. if (this.getParam('light') == true)
  1851. this.params.toolbar = this.params.gutter = false;
  1852. className = 'syntaxhighlighter';
  1853. if (this.getParam('collapse') == true)
  1854. classes.push('collapsed');
  1855. if ((gutter = this.getParam('gutter')) == false)
  1856. classes.push('nogutter');
  1857. // add custom user style name
  1858. classes.push(this.getParam('class-name'));
  1859. // add brush alias to the class name for custom CSS
  1860. classes.push(this.getParam('brush'));
  1861. code = trimFirstAndLastLines(code)
  1862. .replace(/\r/g, ' ') // IE lets these buggers through
  1863. ;
  1864. tabSize = this.getParam('tab-size');
  1865. // replace tabs with spaces
  1866. code = this.getParam('smart-tabs') == true
  1867. ? processSmartTabs(code, tabSize)
  1868. : processTabs(code, tabSize)
  1869. ;
  1870. // unindent code by the common indentation
  1871. code = unindent(code);
  1872. if (gutter)
  1873. lineNumbers = this.figureOutLineNumbers(code);
  1874. // find matches in the code using brushes regex list
  1875. matches = this.findMatches(this.regexList, code);
  1876. // processes found matches into the html
  1877. html = this.getMatchesHtml(code, matches);
  1878. // finally, split all lines so that they wrap well
  1879. html = this.getCodeLinesHtml(html, lineNumbers);
  1880. // finally, process the links
  1881. if (this.getParam('auto-links'))
  1882. html = processUrls(html);
  1883. if (typeof(navigator) != 'undefined' && navigator.userAgent && navigator.userAgent.match(/MSIE/))
  1884. classes.push('ie');
  1885. html =
  1886. '<div id="' + getHighlighterId(this.id) + '" class="' + classes.join(' ') + '">'
  1887. + (this.getParam('toolbar') ? sh.toolbar.getHtml(this) : '')
  1888. + '<table border="0" cellpadding="0" cellspacing="0">'
  1889. + this.getTitleHtml(this.getParam('title'))
  1890. + '<tbody>'
  1891. + '<tr>'
  1892. + (gutter ? '<td class="gutter">' + this.getLineNumbersHtml(code) + '</td>' : '')
  1893. + '<td class="code">'
  1894. + '<div class="container">'
  1895. + html
  1896. + '</div>'
  1897. + '</td>'
  1898. + '</tr>'
  1899. + '</tbody>'
  1900. + '</table>'
  1901. + '</div>'
  1902. ;
  1903. return html;
  1904. },
  1905. /**
  1906. * Highlights the code and returns complete HTML.
  1907. * @param {String} code Code to highlight.
  1908. * @return {Element} Returns container DIV element with all markup.
  1909. */
  1910. getDiv: function(code)
  1911. {
  1912. if (code === null)
  1913. code = '';
  1914. this.code = code;
  1915. var div = this.create('div');
  1916. // create main HTML
  1917. div.innerHTML = this.getHtml(code);
  1918. // set up click handlers
  1919. if (this.getParam('toolbar'))
  1920. attachEvent(findElement(div, '.toolbar'), 'click', sh.toolbar.handler);
  1921. if (this.getParam('quick-code'))
  1922. attachEvent(findElement(div, '.code'), 'dblclick', quickCodeHandler);
  1923. return div;
  1924. },
  1925. /**
  1926. * Initializes the highlighter/brush.
  1927. *
  1928. * Constructor isn't used for initialization so that nothing executes during necessary
  1929. * `new SyntaxHighlighter.Highlighter()` call when setting up brush inheritence.
  1930. *
  1931. * @param {Hash} params Highlighter parameters.
  1932. */
  1933. init: function(params)
  1934. {
  1935. this.id = guid();
  1936. // register this instance in the highlighters list
  1937. storeHighlighter(this);
  1938. // local params take precedence over defaults
  1939. this.params = merge(sh.defaults, params || {})
  1940. // process light mode
  1941. if (this.getParam('light') == true)
  1942. this.params.toolbar = this.params.gutter = false;
  1943. },
  1944. /**
  1945. * Converts space separated list of keywords into a regular expression string.
  1946. * @param {String} str Space separated keywords.
  1947. * @return {String} Returns regular expression string.
  1948. */
  1949. getKeywords: function(str)
  1950. {
  1951. str = str
  1952. .replace(/^\s+|\s+$/g, '')
  1953. .replace(/\s+/g, '|')
  1954. ;
  1955. return '\\b(?:' + str + ')\\b';
  1956. },
  1957. /**
  1958. * Makes a brush compatible with the `html-script` functionality.
  1959. * @param {Object} regexGroup Object containing `left` and `right` regular expressions.
  1960. */
  1961. forHtmlScript: function(regexGroup)
  1962. {
  1963. this.htmlScript = {
  1964. left : { regex: regexGroup.left, css: 'script' },
  1965. right : { regex: regexGroup.right, css: 'script' },
  1966. code : new XRegExp(
  1967. "(?<left>" + regexGroup.left.source + ")" +
  1968. "(?<code>.*?)" +
  1969. "(?<right>" + regexGroup.right.source + ")",
  1970. "sgi"
  1971. )
  1972. };
  1973. }
  1974. }; // end of Highlighter
  1975. return sh;
  1976. }(); // end of anonymous function
  1977. // CommonJS
  1978. typeof(exports) != 'undefined' ? exports['SyntaxHighlighter'] = SyntaxHighlighter : null;
  1979. </script><script type="text/javascript">// (inc clojure-brush) ;; an improved SyntaxHighlighter brush for clojure
  1980. //
  1981. // Copyright (C) 2011 Andrew Brehaut
  1982. //
  1983. // Distributed under the Eclipse Public License, the same as Clojure.
  1984. //
  1985. // https://github.com/brehaut/inc-clojure-brush
  1986. //
  1987. // Written by Andrew Brehaut
  1988. // V0.9.1, November 2011
  1989. if (typeof net == "undefined") net = {};
  1990. if (!(net.brehaut)) net.brehaut = {};
  1991. net.brehaut.ClojureTools = (function (SH) {
  1992. "use strict";
  1993. // utiliies
  1994. if (!Object.create) Object.create = function object(o) {
  1995. function F() {};
  1996. F.prototype = o;
  1997. return new F();
  1998. };
  1999. // data
  2000. function Token(value, index, tag, length) {
  2001. this.value = value;
  2002. this.index = index;
  2003. this.length = length || value.length;
  2004. this.tag = tag;
  2005. this.secondary_tags = {};
  2006. }
  2007. // null_token exists so that LispNodes that have not had a closing tag attached
  2008. // can have a dummy token to simplify annotation
  2009. var null_token = new Token("", -1, "null", -1);
  2010. /* LispNodes are aggregate nodes for sexpressions.
  2011. *
  2012. */
  2013. function LispNode(tag, children, opening) {
  2014. this.tag = tag; // current metadata for syntax inference
  2015. this.parent = null; // the parent expression
  2016. this.list = children; // all the child forms in order
  2017. this.opening = opening; // the token that opens this form.
  2018. this.closing = null_token; // the token that closes this form.
  2019. this.meta = null; // metadata nodes will be attached here if they are found
  2020. }
  2021. var null_lispnode = new LispNode("null", [], null_token);
  2022. function PrefixNode(tag, token, attached_node) {
  2023. this.tag = tag;
  2024. this.token = token;
  2025. this.attached_node = attached_node;
  2026. this.parent = null;
  2027. }
  2028. // tokenize
  2029. function tokenize(code) {
  2030. var tokens = [];
  2031. var tn = 0;
  2032. var zero = "0".charCodeAt(0);
  2033. var nine = "9".charCodeAt(0);
  2034. var lower_a = "a".charCodeAt(0);
  2035. var lower_f = "f".charCodeAt(0);
  2036. var upper_a = "A".charCodeAt(0);
  2037. var upper_f = "F".charCodeAt(0);
  2038. var dispatch = false; // have we just seen a # character?
  2039. // i tracks the start of the current window
  2040. // extent is the window for slicing
  2041. for (var i = 0,
  2042. extent = i,
  2043. j = code.length;
  2044. i < j && extent <= j;) {
  2045. var c = code[i];
  2046. // we care about capturing the whole token when dispatch is used, so back up the
  2047. // starting index by 1
  2048. if (dispatch) i--;
  2049. switch (c) {
  2050. // dispatch alters the value of the next thing read
  2051. case "#":
  2052. dispatch = true;
  2053. i++;
  2054. extent++;
  2055. continue;
  2056. case " ": // ignore whitespace
  2057. case "\t":
  2058. case "\n":
  2059. case "\r":
  2060. case ",":
  2061. extent++
  2062. break;
  2063. // simple terms
  2064. case "^":
  2065. case "`":
  2066. case ")":
  2067. case "[":
  2068. case "]":
  2069. case "}":
  2070. case "@":
  2071. tokens[tn++] = new Token(c, i, c, ++extent - i);
  2072. break;
  2073. case "'":
  2074. tokens[tn++] = new Token(code.slice(i, ++extent), i, dispatch ? "#'" : "'", extent - i);
  2075. break
  2076. case "(":
  2077. tokens[tn++] = new Token(code.slice(i, ++extent), i, "(", extent - i);
  2078. break;
  2079. case "{":
  2080. tokens[tn++] = new Token(code.slice(i, ++extent), i, dispatch ? "#{" : "{", extent - i);
  2081. break;
  2082. case "\\":
  2083. if (code.slice(i + 1, i + 8) === "newline") {
  2084. tokens[tn++] = new Token("\\newline", i, "value", 8);
  2085. extent = i + 9;
  2086. }
  2087. else if (code.slice(i + 1, i + 6) === "space") {
  2088. tokens[tn++] = new Token("\\space", i, "value", 6);
  2089. extent = i + 6;
  2090. }
  2091. else if (code.slice(i + 1, i + 4) === "tab") {
  2092. tokens[tn++] = new Token("\\tab", i, "value", 4);
  2093. extent = i + 5;
  2094. } // work around fun bug with &,>,< in character literals
  2095. else if (code.slice(i + 1, i + 6) === "&amp;") {
  2096. tokens[tn++] = new Token("\\&amp;", i, "value", 6);
  2097. extent = i + 6;
  2098. }
  2099. else if (code.slice(i + 1, i + 5) === "&lt;") {
  2100. tokens[tn++] = new Token("\\&lt;", i, "value", 5);
  2101. extent = i + 5;
  2102. }
  2103. else if (code.slice(i + 1, i + 5) === "&gt;") {
  2104. tokens[tn++] = new Token("\\&gt;", i, "value", 5);
  2105. extent = i + 5;
  2106. }
  2107. else {
  2108. extent += 2;
  2109. tokens[tn++] = new Token(code.slice(i, extent), i, "value", 2);
  2110. }
  2111. break;
  2112. case "~": // slice
  2113. if (code[i + 1] === "@") {
  2114. extent += 2;
  2115. tokens[tn++] = new Token(code.slice(i, extent), i, "splice", 2);
  2116. }
  2117. else {
  2118. tokens[tn++] = new Token(code.slice(i, ++extent), i, "unquote", 2);
  2119. }
  2120. break;
  2121. // complicated terms
  2122. case "\"": // strings and regexps
  2123. for (extent++; extent <= j; extent++) {
  2124. if (code[extent] === "\\") extent++;
  2125. else if (code[extent] === "\"") break;
  2126. }
  2127. tokens[tn++] = new Token(code.slice(i, ++extent), i, dispatch ? "regexp" : "string", extent - i);
  2128. break;
  2129. case ";":
  2130. for (; extent <= j && code[extent] !== "\n" && code[extent] !== "\r"; extent++);
  2131. tokens[tn++] = new Token(code.slice(i, ++extent), i, "comments", extent - i);
  2132. break;
  2133. case "+": // numbers; fall through to symbol for + and - not prefixing a number
  2134. case "-":
  2135. case "0":
  2136. case "1":
  2137. case "2":
  2138. case "3":
  2139. case "4":
  2140. case "5":
  2141. case "6":
  2142. case "7":
  2143. case "8":
  2144. case "9":
  2145. // todo: exponents, hex
  2146. // http://my.safaribooksonline.com/9781449310387/14?reader=pf&readerfullscreen=&readerleftmenu=1
  2147. var c2 = code.charCodeAt(i + 1);
  2148. if (((c === "+" || c === "-") && (c2 >= zero && c2 <= nine)) // prefixes
  2149. || (c !== "+" && c !== "-")) {
  2150. if (c === "+" || c === "-") extent++;
  2151. for (; extent <= j; extent++) {
  2152. var charCode = code.charCodeAt(extent);
  2153. if (charCode < zero || charCode > nine) break;
  2154. }
  2155. c = code[extent];
  2156. c2 = code.charCodeAt(extent + 1);
  2157. if ((c === "r" || c === "R" || c === "/" || c === ".") // interstitial characters
  2158. && (c2 >= zero && c2 <= nine)) {
  2159. for (extent++; extent <= j; extent++) {
  2160. var charCode = code.charCodeAt(extent);
  2161. if (charCode < zero || charCode > nine) break;
  2162. }
  2163. }
  2164. c = code[extent];
  2165. c2 = code.charCodeAt(extent + 1);
  2166. if ((c === "x" || c === "X") &&
  2167. ((c2 >= zero && c2 <= nine)
  2168. || (c2 >= lower_a && c2 <= lower_f)
  2169. || (c2 >= upper_a && c2 <= upper_f))) {
  2170. for (extent++; extent <= j; extent++) {
  2171. var charCode = code.charCodeAt(extent);
  2172. if (((charCode >= zero && charCode <= nine)
  2173. || (charCode >= lower_a && charCode <= lower_f)
  2174. || (charCode >= upper_a && charCode <= upper_f))) continue;
  2175. break;
  2176. }
  2177. }
  2178. c = code[extent];
  2179. c2 = code.charCodeAt(extent + 1);
  2180. if ((c === "e" || c === "E")
  2181. && (c2 >= zero && c2 <= nine)) {
  2182. for (extent++; extent <= j; extent++) {
  2183. var charCode = code.charCodeAt(extent);
  2184. if (charCode < zero || charCode > nine) break;
  2185. }
  2186. }
  2187. c = code[extent];
  2188. if (c === "N" || c === "M") extent++;
  2189. tokens[tn++] = new Token(code.slice(i, extent), i, "value", extent - i);
  2190. break;
  2191. }
  2192. case "_":
  2193. if (dispatch && c === "_") {
  2194. tokens[tn++] = new Token(code.slice(i, ++extent), i, "skip", extent - i);
  2195. break;
  2196. } // if not a skip, fall through to symbols
  2197. // Allow just about any other symbol as a symbol. This is far more permissive than
  2198. // clojure actually allows, but should catch any weirdo crap that accidentally gets
  2199. // into the code.
  2200. default:
  2201. for (extent++; extent <= j; extent++) {
  2202. switch (code[extent]) {
  2203. case " ":
  2204. case "\t":
  2205. case "\n":
  2206. case "\r":
  2207. case "\\":
  2208. case ",":
  2209. case "{":
  2210. case "}":
  2211. case "(":
  2212. case ")":
  2213. case "[":
  2214. case "]":
  2215. case "^":
  2216. case "`":
  2217. case "@":
  2218. break;
  2219. case ";":
  2220. // theres a weird bug via syntax highligher that gives us escaped entities.
  2221. // need to watch out for these
  2222. if (code.slice(extent-3, extent+1) === "&lt;"
  2223. ||code.slice(extent-3, extent+1) === "&gt;"
  2224. ||code.slice(extent-4, extent+1) === "&amp;") {
  2225. continue;
  2226. }
  2227. break;
  2228. default:
  2229. continue;
  2230. }
  2231. break;
  2232. }
  2233. var value = code.slice(i, extent);
  2234. var tag = "symbol";
  2235. if (value[0] == ":") {
  2236. tag = "keyword";
  2237. }
  2238. else if (value === "true" || value === "false" || value === "nil") {
  2239. tag = "value";
  2240. }
  2241. tokens[tn++] = new Token(value, i, tag, extent - i);
  2242. }
  2243. dispatch = false;
  2244. i = extent;
  2245. }
  2246. return tokens;
  2247. }
  2248. function build_tree(tokens) {
  2249. var toplevel = {
  2250. list: [],
  2251. tag: "toplevel",
  2252. parent: null,
  2253. opening: null,
  2254. closing: null,
  2255. depth: -1
  2256. };
  2257. // loop variables hoisted out as semi globals to track position in token stream
  2258. var i = -1;
  2259. var j = tokens.length;
  2260. function parse_one(t) {
  2261. // ignore special tokens and forms that dont belong in the tree
  2262. for (; t && (t.tag === "comments" || t.tag === "invalid" || t.tag == "skip") && i < j; ) {
  2263. if (t.tag === "skip") {
  2264. t.tag = "preprocessor";
  2265. annotate_comment(parse_one(tokens[++i]));
  2266. }
  2267. t = tokens[++i];
  2268. }
  2269. if (!t) return {}; // hackity hack
  2270. switch (t.tag) {
  2271. case "{":
  2272. return build_aggregate(new LispNode("map", [], t), "}");
  2273. case "(":
  2274. return build_aggregate(new LispNode("list", [], t), ")");
  2275. case "#{":
  2276. return build_aggregate(new LispNode("set", [], t), "}");
  2277. case "[":
  2278. return build_aggregate(new LispNode("vector", [], t), "]");
  2279. case "'":
  2280. return new PrefixNode("quote", t, parse_one(tokens[++i]));
  2281. case "#'":
  2282. return new PrefixNode("varquote", t, parse_one(tokens[++i]));
  2283. case "@":
  2284. return new PrefixNode("deref", t, parse_one(tokens[++i]));
  2285. case "`":
  2286. return new PrefixNode("quasiquote", t, parse_one(tokens[++i]));
  2287. case "unquote":
  2288. return new PrefixNode("unquote", t, parse_one(tokens[++i]));
  2289. case "splice":
  2290. return new PrefixNode("splice", t, parse_one(tokens[++i]));
  2291. case "^":
  2292. t.tag = "meta";
  2293. var meta = parse_one(tokens[++i]);
  2294. var next = parse_one(tokens[++i]);
  2295. next.meta = meta;
  2296. return next;
  2297. }
  2298. return t;
  2299. }
  2300. // build_aggregate collects to ether sub forms for one aggregate for.
  2301. function build_aggregate(current, expected_closing) {
  2302. for (i++; i < j; i++) {
  2303. var t = tokens[i];
  2304. if (t.tag === "}" || t.tag === ")" || t.tag === "]") {
  2305. if (t.tag !== expected_closing) t.tag = "invalid";
  2306. current.closing = t;
  2307. if (expected_closing) return current;
  2308. }
  2309. var node = parse_one(t);
  2310. node.parent = current;
  2311. current.list[current.list.length] = node;
  2312. }
  2313. return current;
  2314. }
  2315. build_aggregate(toplevel, null);
  2316. return toplevel;
  2317. }
  2318. // annotation rules to apply to a form based on its head
  2319. var show_locals = true; // HACK. would rather not use a (semi)-global.
  2320. /* annotate_comment is a special case annotation.
  2321. * in addition to its role in styling specific forms, it is called by parse_one to
  2322. * ignore any forms skipped with #_
  2323. */
  2324. function annotate_comment(exp) {
  2325. exp.tag = "comments";
  2326. if (exp.list) {
  2327. exp.opening.tag = "comments";
  2328. exp.closing.tag = "comments";
  2329. for (var i = 0; i < exp.list.length; i++) {
  2330. var child = exp.list[i];
  2331. if (child.list) {
  2332. annotate_comment(child);
  2333. }
  2334. if (child.attached_node) {
  2335. annotate_comment(child.attached_node);
  2336. }
  2337. else {
  2338. child.tag = "comments";
  2339. }
  2340. }
  2341. }
  2342. }
  2343. /* custom annotation rules are stored here */
  2344. var annotation_rules = {};
  2345. // this function is exposed to allow ad hoc extension of the customisation rules
  2346. function register_annotation_rule(names, rule) {
  2347. for (var i = 0; i < names.length; i++) {
  2348. annotation_rules[names[i]] = rule;
  2349. }
  2350. }
  2351. function annotate_destructuring (exp, scope) {
  2352. if (exp.list) {
  2353. if (exp.tag === "vector") {
  2354. for (var i = 0; i < exp.list.length; i++) {
  2355. annotate_destructuring(exp.list[i], scope);
  2356. }
  2357. }
  2358. else if (exp.tag === "map") {
  2359. for (var i = 0; i < exp.list.length; i += 2) {
  2360. var key = exp.list[i];
  2361. var val = exp.list[i + 1];
  2362. if (key.tag === "keyword" && val.tag === "vector") {
  2363. for (var ii = 0, jj = val.list.length; ii < jj; ii++) {
  2364. if (val.list[ii].tag !== "symbol") continue;
  2365. val.list[ii].tag = "variable";
  2366. scope[val.list[ii].value] = true;
  2367. }
  2368. }
  2369. else {
  2370. annotate_destructuring(key, scope);
  2371. annotate_expressions(val, scope);
  2372. }
  2373. }
  2374. }
  2375. }
  2376. else if (exp.tag === "symbol" && (exp.value !== "&" && exp.value !== "&amp;")){
  2377. exp.tag = "variable";
  2378. scope[exp.value] = true;
  2379. }
  2380. }
  2381. function _annotate_binding_vector (exp, scope) {
  2382. if (exp.tag !== "vector") return;
  2383. var bindings = exp.list;
  2384. if (bindings.length % 2 === 1) return;
  2385. for (var i = 0; i < bindings.length; i += 2) {
  2386. annotate_destructuring(bindings[i], scope);
  2387. annotate_expressions(bindings[i + 1], scope);
  2388. }
  2389. }
  2390. function annotate_binding (exp, scope) {
  2391. var bindings = exp.list[1];
  2392. if (!show_locals) return; // HACK
  2393. if (bindings) {
  2394. scope = Object.create(scope);
  2395. _annotate_binding_vector(bindings, scope);
  2396. }
  2397. for (var i = 2; i < exp.list.length; i++) {
  2398. annotate_expressions(exp.list[i], scope);
  2399. }
  2400. }
  2401. function _annotate_function_body (exp, scope, start_idx) {
  2402. var argvec = exp.list[start_idx];
  2403. if (argvec.tag !== "vector") return;
  2404. scope = Object.create(scope);
  2405. for (var i = 0, j = argvec.list.length; i < j; i++) {
  2406. annotate_destructuring(argvec.list[i], scope);
  2407. }
  2408. for (var i = start_idx, j = exp.list.length; i < j; i++) {
  2409. annotate_expressions(exp.list[i], scope);
  2410. }
  2411. }
  2412. function annotate_function (exp, scope) {
  2413. for (var i = 1, j = exp.list.length; i < j; i++) {
  2414. var child = exp.list[i];
  2415. if (child.tag === "vector") {
  2416. _annotate_function_body (exp, scope, i);
  2417. return;
  2418. }
  2419. else if (child.tag === "list") {
  2420. _annotate_function_body(child, scope, 0)
  2421. }
  2422. }
  2423. }
  2424. function annotate_letfn (exp, scope) {
  2425. scope = Object.create(scope);
  2426. var bindings = exp.list[1];
  2427. var fn;
  2428. for (var i = 0, j = bindings.list.length; i < j; i++) {
  2429. fn = bindings.list[i];
  2430. if (!fn.list[0]) continue;
  2431. fn.list[0].tag = "variable";
  2432. scope[fn.list[0].value] = true;
  2433. }
  2434. for (i = 0, j = bindings.list.length; i < j; i++) {
  2435. var fn = bindings.list[i];
  2436. annotate_function(fn, scope);
  2437. }
  2438. for (i = 2, j = exp.list.length; i < j; i++) {
  2439. annotate_expressions(exp.list[i], scope);
  2440. }
  2441. }
  2442. register_annotation_rule(
  2443. ["comment"],
  2444. annotate_comment
  2445. );
  2446. register_annotation_rule(
  2447. ["let", "when-let", "if-let", "binding", "doseq", "for", "dotimes", "let*"],
  2448. annotate_binding
  2449. );
  2450. register_annotation_rule(
  2451. ["defn", "defn-", "fn", "bound-fn", "defmacro", "fn*", "defmethod"],
  2452. annotate_function
  2453. );
  2454. register_annotation_rule(
  2455. ["letfn"],
  2456. annotate_letfn
  2457. );
  2458. // standard annotations
  2459. function _annotate_metadata_recursive(meta, scope) {
  2460. if (!meta) return;
  2461. if (meta.list !== undefined && meta.list !== null) {
  2462. for (var i = 0, j = meta.list.length; i < j; i++) {
  2463. meta.opening.secondary_tags.meta = true
  2464. meta.closing.secondary_tags.meta = true
  2465. _annotate_metadata_recursive(meta.list[i], scope);
  2466. }
  2467. }
  2468. else if (meta.attached_node) {
  2469. meta.token.secondary_tags.meta = true;
  2470. _annotate_metadata_recursive(meta.attached_node, scope);
  2471. }
  2472. else {
  2473. meta.secondary_tags.meta = true;
  2474. }
  2475. }
  2476. function annotate_metadata(exp) {
  2477. if (!(exp && exp.meta)) return;
  2478. var meta = exp.meta;
  2479. annotate_expressions(meta, {});
  2480. _annotate_metadata_recursive(meta, {});
  2481. }
  2482. function annotate_quoted(exp, scope) {
  2483. if (!exp) return;
  2484. if (exp.list !== undefined && exp.list !== null) {
  2485. for (var i = 0, j = exp.list.length; i < j; i++) {
  2486. exp.opening.secondary_tags.quoted = true
  2487. exp.closing.secondary_tags.quoted = true
  2488. annotate_quoted(exp.list[i], scope);
  2489. }
  2490. }
  2491. else if (exp.attached_node) {
  2492. if (exp.tag === "unquote" || exp.tag === "splice") return;
  2493. exp.token.secondary_tags.quoted = true;
  2494. annotate_quoted(exp.attached_node, scope);
  2495. }
  2496. else {
  2497. exp.secondary_tags.quoted = true;
  2498. }
  2499. }
  2500. function annotate_expressions(exp, scope) {
  2501. annotate_metadata(exp);
  2502. switch (exp.tag) {
  2503. case "toplevel":
  2504. for (var i = 0; i < exp.list.length; i++) {
  2505. annotate_expressions(exp.list[i], scope);
  2506. }
  2507. break;
  2508. case "list": // functions, macros, special forms, comments
  2509. var head = exp.list[0];
  2510. if (head) {
  2511. if (head.tag === "list" || head.tag === "vector"
  2512. || head.tag === "map" || head.tag === "set") {
  2513. annotate_expressions(head, scope);
  2514. }
  2515. else if (head.attached_node) {
  2516. annotate_expressions(head.attached_node, scope);
  2517. }
  2518. else {
  2519. head.tag = (head.value.match(/(^\.)|(\.$)|[A-Z].*\//)
  2520. ? "method"
  2521. : "function");
  2522. }
  2523. // apply specific rules
  2524. if (annotation_rules.hasOwnProperty(head.value)) {
  2525. annotation_rules[head.value](exp, scope);
  2526. }
  2527. else {
  2528. for (var i = 1; i < exp.list.length; i++) {
  2529. annotate_expressions(exp.list[i], scope);
  2530. }
  2531. }
  2532. }
  2533. else { // empty list
  2534. exp.opening.tag = "value";
  2535. exp.closing.tag = "value";
  2536. }
  2537. break;
  2538. case "vector": // data
  2539. case "map":
  2540. case "set":
  2541. for (var i = 0; i < exp.list.length; i++) {
  2542. annotate_expressions(exp.list[i], scope);
  2543. }
  2544. break;
  2545. case "symbol":
  2546. if (exp.value.match(/[A-Z].*\/[A-Z_]+/)) {
  2547. exp.tag = "constant";
  2548. }
  2549. else if (show_locals && scope[exp.value]) {
  2550. exp.tag = "variable";
  2551. }
  2552. else if (exp.tag === "symbol" && exp.value.match(/([A-Z].*\/)?[A-Z_]+/)) {
  2553. exp.tag = "type";
  2554. }
  2555. break;
  2556. case "quote":
  2557. case "quasiquote":
  2558. annotate_quoted(exp.attached_node, scope);
  2559. default:
  2560. if (exp.attached_node) annotate_expressions(exp.attached_node, scope);
  2561. }
  2562. }
  2563. // translation of tag to css:
  2564. var css_translation = {
  2565. "constant": "constants",
  2566. "keyword": "constants",
  2567. "method": "color1",
  2568. "type": "color3",
  2569. "function": "functions",
  2570. "string": "string",
  2571. "regexp": "string",
  2572. "value": "value",
  2573. "comments": "comments",
  2574. "symbol": "symbol",
  2575. "variable": "variable",
  2576. "splice": "preprocessor",
  2577. "unquote": "preprocessor",
  2578. "preprocessor": "preprocessor",
  2579. "meta": "preprocessor",
  2580. "'": "preprocessor",
  2581. "#'": "preprocessor",
  2582. "(": "plain",
  2583. ")": "plain",
  2584. "{": "keyword",
  2585. "}": "keyword",
  2586. "#{": "keyword",
  2587. "[": "keyword",
  2588. "]": "keyword",
  2589. "invalid": "invalid",
  2590. "@": "plain"
  2591. };
  2592. function translate_tags_to_css(tokens) {
  2593. for (var i = 0, j = tokens.length; i < j; i++) {
  2594. var token = tokens[i];
  2595. token.css = css_translation[token.tag];
  2596. for (var k in token.secondary_tags) if (token.secondary_tags.hasOwnProperty(k))
  2597. token.css += " " + k ;
  2598. };
  2599. }
  2600. // create the new brush
  2601. SH.brushes.Clojure = function () {};
  2602. SH.brushes.Clojure.prototype = new SyntaxHighlighter.Highlighter();
  2603. SH.brushes.Clojure.prototype.findMatches = function find_matches (regexpList, code) {
  2604. // this is a nasty global hack. need to resolve this
  2605. if (this.params && this.params.locals) {
  2606. show_locals = this.params.locals === true || this.params.locals === "true";
  2607. }
  2608. else {
  2609. show_locals = true;
  2610. }
  2611. var tokens = tokenize(code);
  2612. annotate_expressions(build_tree(tokens), {});
  2613. translate_tags_to_css(tokens);
  2614. return tokens;
  2615. };
  2616. SH.brushes.Clojure.aliases = ['clojure', 'Clojure', 'clj'];
  2617. SH.brushes.Clojure.register_annotation_rule = register_annotation_rule;
  2618. return {
  2619. tokenize: tokenize,
  2620. build_tree: build_tree
  2621. };
  2622. })(SyntaxHighlighter);
  2623. </script>
  2624. <script type="text/javascript" src="mathjax/MathJax.js?config=default"></script>
  2625. </script><title>marginalia -- Marginalia</title></head><body><table><tr><td class="docs"><div class="header"><h1 class="project-name">marginalia</h1><h2 class="project-version">0.7.1</h2><br /><p>lightweight literate programming for clojure -- inspired by <a href="http://jashkenas.github.com/docco/">docco</a></p>
  2626. </div><div class="dependencies"><h3>dependencies</h3><table><tr><td class="dep-name">org.clojure/clojure</td><td class="dotted"><hr /></td><td class="dep-version">1.3.0</td></tr><tr><td class="dep-name">org.clojure/tools.namespace</td><td class="dotted"><hr /></td><td class="dep-version">0.1.1</td></tr><tr><td class="dep-name">org.clojure/tools.cli</td><td class="dotted"><hr /></td><td class="dep-version">0.2.1</td></tr><tr><td class="dep-name">hiccup</td><td class="dotted"><hr /></td><td class="dep-version">0.3.7</td></tr><tr><td class="dep-name">org.markdownj/markdownj</td><td class="dotted"><hr /></td><td class="dep-version">0.3.0-1.0.2b4</td></tr></table></div><div class="dependencies"><h3>dev dependencies</h3><table><tr><td class="dep-name">lein-clojars</td><td class="dotted"><hr /></td><td class="dep-version">0.6.0</td></tr><tr><td class="dep-name">jline</td><td class="dotted"><hr /></td><td class="dep-version">0.9.94</td></tr><tr><td class="dep-name">org.clojars.autre/lein-vimclojure</td><td class="dotted"><hr /></td><td class="dep-version">1.0.0</td></tr><tr><td class="dep-name">lein-marginalia</td><td class="dotted"><hr /></td><td class="dep-version">0.7.1</td></tr></table></div></td><td class="codes" style="text-align: center; vertical-align: middle;color: #666;padding-right:20px"><br /><br /><br />(this space intentionally left almost blank)</td></tr><tr><td class="docs"><div class="toc"><a name="toc"><h3>namespaces</h3></a><ul><li><a href="#marginalia.core">marginalia.core</a></li><li><a href="#marginalia.html">marginalia.html</a></li><li><a href="#marginalia.main">marginalia.main</a></li><li><a href="#marginalia.parser">marginalia.parser</a></li><li><a href="#problem-cases.general">problem-cases.general</a></li></ul></div></td><td class="codes">&nbsp;</td></tr><tr><td class="docs"><div class="docs-header"><a class="anchor" href="#marginalia.core" name="marginalia.core"><h1 class="project-name">marginalia.core</h1><a class="toc-link" href="#toc">toc</a></a></div></td><td class="codes" /></tr><tr><td class="docs"><h2>A new way to think about programs</h2>
  2627. <p>What if your code and its documentation were one and the same?</p>
  2628. <p>Much of the philosophy guiding literate programming is the realization of the answer to this question.
  2629. However, if literate programming stands as a comprehensive programming methodology at one of end of the
  2630. spectrum and no documentation stands as its antithesis, then Marginalia falls somewhere between. That is,
  2631. you should always aim for comprehensive documentation, but the shortest path to a useful subset is the
  2632. commented source code itself.</p>
  2633. <h2>The art of Marginalia</h2>
  2634. <p>If you're fervently writing code that is heavily documented, then using Marginalia for your Clojure projects
  2635. is as simple as running it on your codebase. However, if you're unaccustomed to documenting your source, then
  2636. the guidelines herein will help you make the most out of Marginalia for true-power documentation.</p>
  2637. <p>Following the guidelines will work to make your code not only easier to follow -- it will make it better.
  2638. The very process of using Marginalia will help to crystalize your understanding of problem and its solution(s).</p>
  2639. <p>The quality of the prose in your documentation will often reflect the quality of the code itself thus highlighting
  2640. problem areas. The elimination of problem areas will solidify your code and its accompanying prose. Marginalia
  2641. provides a virtuous circle spiraling inward toward maximal code quality.</p>
  2642. <h2>The one true way</h2>
  2643. <ol>
  2644. <li>Start by running Marginalia against your code</li>
  2645. <li>Cringe at the sad state of your code commentary</li>
  2646. <li>Add docstrings and code comments as appropriate</li>
  2647. <li>Generate the documentation again</li>
  2648. <li>Read the resulting documentation</li>
  2649. <li>Make changes to code and documentation so that the "dialog" flows sensibly</li>
  2650. <li>Repeat from step #4 until complete</li>
  2651. </ol>
  2652. </td><td class="codes"><pre class="brush: clojure">(ns marginalia.core
  2653. (:require [clojure.java.io :as io]
  2654. [clojure.string :as str])
  2655. (:use [marginalia
  2656. [html :only (uberdoc-html index-html single-page-html)]
  2657. [parser :only (parse-file)]]
  2658. [clojure.tools
  2659. [namespace :only (read-file-ns-decl)]
  2660. [cli :only (cli)]]))</pre></td></tr><tr><td class="docs">
  2661. </td><td class="codes"><pre class="brush: clojure">(def ^{:dynamic true} *test* &quot;src/marginalia/core.clj&quot;)
  2662. (def ^{:dynamic true} *docs* &quot;./docs&quot;)
  2663. (def ^{:dynamic true} *comment* #&quot;^\s*;;\s?&quot;)</pre></td></tr><tr><td class="docs"><h2>File System Utilities</h2>
  2664. </td><td class="codes"></td></tr><tr><td class="docs"><p>Performs roughly the same task as the UNIX <code>ls</code>. That is, returns a seq of the filenames
  2665. at a given directory. If a path to a file is supplied, then the seq contains only the
  2666. original path given.</p>
  2667. </td><td class="codes"><pre class="brush: clojure">(defn ls
  2668. [path]
  2669. (let [file (java.io.File. path)]
  2670. (if (.isDirectory file)
  2671. (seq (.list file))
  2672. (when (.exists file)
  2673. [path]))))</pre></td></tr><tr><td class="docs">
  2674. </td><td class="codes"><pre class="brush: clojure">(defn mkdir [path]
  2675. (.mkdirs (io/file path)))</pre></td></tr><tr><td class="docs"><p>Ensure that the directory specified by <code>path</code> exists. If not then make it so.
  2676. Here is a snowman ☃</p>
  2677. </td><td class="codes"><pre class="brush: clojure">(defn ensure-directory!
  2678. [path]
  2679. (when-not (ls path)
  2680. (mkdir path)))</pre></td></tr><tr><td class="docs"><p>Many Marginalia fns use dir? to recursively search a filepath.</p>
  2681. </td><td class="codes"><pre class="brush: clojure">(defn dir?
  2682. [path]
  2683. (.isDirectory (java.io.File. path)))</pre></td></tr><tr><td class="docs"><p>Returns a seq of clojure file paths (strings) in alphabetical order.</p>
  2684. </td><td class="codes"><pre class="brush: clojure">(defn find-processable-file-paths
  2685. [dir matching-re]
  2686. (-&gt;&gt; (io/file dir)
  2687. (file-seq)
  2688. (filter #(re-find matching-re (.getCanonicalPath %)))
  2689. (map #(.getCanonicalPath %))
  2690. (sort)))</pre></td></tr><tr><td class="docs"><h2>Project Info Parsing</h2>
  2691. <p>Marginalia will parse info out of your project.clj to display in
  2692. the generated html file's header.</p>
  2693. </td><td class="codes"></td></tr><tr><td class="docs"><p>Parses a project.clj file and returns a map in the following form</p>
  2694. <pre><code> {:name
  2695. :version
  2696. :dependencies
  2697. :dev-dependencies
  2698. etc...}
  2699. </code></pre>
  2700. <p> by merging into the name and version information the rest of the defproject
  2701. forms (<code>:dependencies</code>, etc)</p>
  2702. </td><td class="codes"><pre class="brush: clojure">(defn parse-project-form
  2703. [[_ project-name version-number &amp; attributes]]
  2704. (merge {:name (str project-name)
  2705. :version version-number}
  2706. (apply hash-map attributes)))</pre></td></tr><tr><td class="docs"><p>Parses a project file -- './project.clj' by default -- and returns a map
  2707. assembled according to the logic in parse-project-form.</p>
  2708. </td><td class="codes"><pre class="brush: clojure">(defn parse-project-file
  2709. ([] (parse-project-file &quot;./project.clj&quot;))
  2710. ([path]
  2711. (try
  2712. (let [rdr (clojure.lang.LineNumberingPushbackReader.
  2713. (java.io.FileReader.
  2714. (java.io.File. path)))]
  2715. (parse-project-form (read rdr)))
  2716. (catch Exception e
  2717. (throw (Exception.
  2718. (str
  2719. &quot;There was a problem reading the project definition from &quot;
  2720. path)))))))</pre></td></tr><tr><td class="docs"><h2>Source File Analysis</h2>
  2721. </td><td class="codes"></td></tr><tr><td class="docs">
  2722. </td><td class="codes"><pre class="brush: clojure">(defn end-of-block? [cur-group groups lines]
  2723. (let [line (first lines)
  2724. next-line (second lines)
  2725. next-line-code (get next-line :code-text )]
  2726. (when (or (and (:code-text line)
  2727. (:docs-text next-line))
  2728. (re-find #&quot;^\(def&quot; (str/trim next-line-code)))
  2729. true)))</pre></td></tr><tr><td class="docs">
  2730. </td><td class="codes"><pre class="brush: clojure">(defn merge-line [line m]
  2731. (cond
  2732. (:docstring-text line) (assoc m
  2733. :docs
  2734. (conj (get m :docs []) line))
  2735. (:code-text line) (assoc m
  2736. :codes
  2737. (conj (get m :codes []) line))
  2738. (:docs-text line) (assoc m
  2739. :docs
  2740. (conj (get m :docs []) line))))</pre></td></tr><tr><td class="docs">
  2741. </td><td class="codes"><pre class="brush: clojure">(defn group-lines [doc-lines]
  2742. (loop [cur-group {}
  2743. groups []
  2744. lines doc-lines]
  2745. (cond
  2746. (empty? lines) (conj groups cur-group)
  2747. (end-of-block? cur-group groups lines)
  2748. (recur (merge-line (first lines) {}) (conj groups cur-group) (rest lines))
  2749. :else (recur (merge-line (first lines) cur-group) groups (rest lines)))))</pre></td></tr><tr><td class="docs">
  2750. </td><td class="codes"><pre class="brush: clojure">(defn path-to-doc [fn]
  2751. (let [ns (-&gt; (java.io.File. fn)
  2752. (read-file-ns-decl)
  2753. (second)
  2754. (str))
  2755. groups (parse-file fn)]
  2756. {:ns ns
  2757. :groups groups}))</pre></td></tr><tr><td class="docs"><h2>Ouput Generation</h2>
  2758. </td><td class="codes"></td></tr><tr><td class="docs">
  2759. </td><td class="codes"><pre class="brush: clojure">(defn filename-contents
  2760. [props output-dir all-files parsed-file]
  2761. {:name (io/file output-dir (str (:ns parsed-file) &quot;.html&quot;))
  2762. :contents (single-page-html props parsed-file all-files)})</pre></td></tr><tr><td class="docs">
  2763. </td><td class="codes"><pre class="brush: clojure">(defn multidoc!
  2764. [output-dir files-to-analyze props]
  2765. (let [parsed-files (map path-to-doc files-to-analyze)
  2766. index (index-html props parsed-files)
  2767. pages (map #(filename-contents props output-dir parsed-files %) parsed-files)]
  2768. (doseq [f (conj pages {:name (io/file output-dir &quot;toc.html&quot;)
  2769. :contents index})]
  2770. (spit (:name f) (:contents f)))))</pre></td></tr><tr><td class="docs"><p>Generates an uberdoc html file from 3 pieces of information:</p>
  2771. <ol>
  2772. <li>The path to spit the result (<code>output-file-name</code>)</li>
  2773. <li>Results from processing source files (<code>path-to-doc</code>)</li>
  2774. <li>Project metadata as a map, containing at a minimum the following:
  2775. <ul><li>:name</li>
  2776. <li>:version</li></ul></li>
  2777. </ol>
  2778. </td><td class="codes"><pre class="brush: clojure">(defn uberdoc!
  2779. [output-file-name files-to-analyze props]
  2780. (let [source (uberdoc-html
  2781. props
  2782. (map path-to-doc files-to-analyze))]
  2783. (spit output-file-name source)))</pre></td></tr><tr><td class="docs"><h2>External Interface (command-line, lein, cake, etc)</h2>
  2784. </td><td class="codes"></td></tr><tr><td class="docs"><p>These functions support Marginalia's use by client software or command-line
  2785. users.</p>
  2786. </td><td class="codes"></td></tr><tr><td class="docs"><p>Given a collection of filepaths, returns a lazy sequence of filepaths to
  2787. all .clj files on those paths: directory paths will be searched recursively
  2788. for .clj files.</p>
  2789. </td><td class="codes"><pre class="brush: clojure">(defn format-sources
  2790. [sources]
  2791. (if (nil? sources)
  2792. (concat
  2793. (find-processable-file-paths &quot;./src&quot; #&quot;\.clj$&quot;)
  2794. (find-processable-file-paths &quot;./src&quot; #&quot;\.cljs$&quot;))
  2795. (-&gt;&gt; sources
  2796. (mapcat #(if (dir? %)
  2797. (concat
  2798. (find-processable-file-paths % #&quot;\.clj$&quot;)
  2799. (find-processable-file-paths % #&quot;\.cljs$&quot;))
  2800. [(.getCanonicalPath (io/file %))])))))</pre></td></tr><tr><td class="docs">
  2801. </td><td class="codes"><pre class="brush: clojure">(defn split-deps [deps]
  2802. (when deps
  2803. (for [d (.split deps &quot;;&quot;)
  2804. :let [[group artifact version] (.split d &quot;:&quot;)]]
  2805. [(if (= group artifact) artifact (str group &quot;/&quot; artifact))
  2806. version])))</pre></td></tr><tr><td class="docs"><p>Default generation: given a collection of filepaths in a project, find the .clj
  2807. files at these paths and, if Clojure source files are found:</p>
  2808. <ol>
  2809. <li>Print out a message to std out letting a user know which files are to be processed;</li>
  2810. <li>Create the docs directory inside the project folder if it doesn't already exist;</li>
  2811. <li><p>Call the uberdoc! function to generate the output file at its default location,
  2812. using the found source files and a project file expected to be in its default location.</p>
  2813. <p>If no source files are found, complain with a usage message.</p></li>
  2814. </ol>
  2815. </td><td class="codes"><pre class="brush: clojure">(defn run-marginalia
  2816. [args &amp; [project]]
  2817. (let [[{:keys [dir file name version desc deps css js multi]} files help]
  2818. (cli args
  2819. [&quot;-d&quot; &quot;--dir&quot; &quot;Directory into which the documentation will be written&quot; :default &quot;./docs&quot;]
  2820. [&quot;-f&quot; &quot;--file&quot; &quot;File into which the documentation will be written&quot; :default &quot;uberdoc.html&quot;]
  2821. [&quot;-n&quot; &quot;--name&quot; &quot;Project name - if not given will be taken from project.clj&quot;]
  2822. [&quot;-v&quot; &quot;--version&quot; &quot;Project version - if not given will be taken from project.clj&quot;]
  2823. [&quot;-D&quot; &quot;--desc&quot; &quot;Project description - if not given will be taken from project.clj&quot;]
  2824. [&quot;-a&quot; &quot;--deps&quot; &quot;Project dependencies in the form &lt;group1&gt;:&lt;artifact1&gt;:&lt;version1&gt;;&lt;group2&gt;...
  2825. If not given will be taken from project.clj&quot;]
  2826. [&quot;-c&quot; &quot;--css&quot; &quot;Additional css resources &lt;resource1&gt;;&lt;resource2&gt;;...
  2827. If not given will be taken from project.clj.&quot;]
  2828. [&quot;-j&quot; &quot;--js&quot; &quot;Additional javascript resources &lt;resource1&gt;;&lt;resource2&gt;;...
  2829. If not given will be taken from project.clj&quot;]
  2830. [&quot;-m&quot; &quot;--multi&quot; &quot;Generate each namespace documentation as a separate file&quot; :flag true])
  2831. sources (distinct (format-sources (seq files)))]
  2832. (if-not sources
  2833. (do
  2834. (println &quot;Wrong number of arguments passed to marginalia.&quot;)
  2835. (println help))
  2836. (binding [*docs* dir]
  2837. (let [project-clj (or project
  2838. (when (.exists (io/file &quot;project.clj&quot;))
  2839. (parse-project-file)))
  2840. choose #(or %1 %2)
  2841. marg-opts (merge-with choose
  2842. {:css (when css (.split css &quot;;&quot;))
  2843. :javascript (when js (.split js &quot;;&quot;))}
  2844. (:marginalia project-clj))
  2845. opts (merge-with choose
  2846. {:name name
  2847. :version version
  2848. :description desc
  2849. :dependencies (split-deps deps)
  2850. :multi multi
  2851. :marginalia marg-opts}
  2852. project-clj)]
  2853. (println &quot;Generating Marginalia documentation for the following source files:&quot;)
  2854. (doseq [s sources]
  2855. (println &quot; &quot; s))
  2856. (println)
  2857. (ensure-directory! *docs*)
  2858. (if multi
  2859. (multidoc! *docs* sources opts)
  2860. (uberdoc! (str *docs* &quot;/&quot; file) sources opts))
  2861. (println &quot;Done generating your documentation in&quot; *docs*)
  2862. (println &quot;&quot;))))))</pre></td></tr><tr><td class="spacer docs">&nbsp;</td><td class="codes" /></tr><tr><td class="docs"><div class="docs-header"><a class="anchor" href="#marginalia.html" name="marginalia.html"><h1 class="project-name">marginalia.html</h1><a class="toc-link" href="#toc">toc</a></a></div></td><td class="codes" /></tr><tr><td class="docs"><p>Utilities for converting parse results into html.</p>
  2863. </td><td class="codes"><pre class="brush: clojure">(ns marginalia.html
  2864. (:use [hiccup.core :only (html escape-html)]
  2865. [hiccup.page-helpers :only (doctype)])
  2866. (:require [clojure.string :as str])
  2867. (:import [com.petebevin.markdown MarkdownProcessor]))</pre></td></tr><tr><td class="docs">
  2868. </td><td class="codes"><pre class="brush: clojure">(def ^{:dynamic true} *resources* &quot;./vendor/&quot;)</pre></td></tr><tr><td class="docs">
  2869. </td><td class="codes"><pre class="brush: clojure">(defn css-rule [rule]
  2870. (let [sels (reverse (rest (reverse rule)))
  2871. props (last rule)]
  2872. (str (apply str (interpose &quot; &quot; (map name sels)))
  2873. &quot;{&quot; (apply str (map #(str (name (key %)) &quot;:&quot; (val %) &quot;;&quot;) props)) &quot;}&quot;)))</pre></td></tr><tr><td class="docs"><p>Quick and dirty dsl for inline css rules, similar to hiccup.</p>
  2874. <p> ex. <code>(css [:h1 {:color "blue"}] [:div.content p {:text-indent "1em"}])</code></p>
  2875. <p> -> <code>h1 {color: blue;} div.content p {text-indent: 1em;}</code></p>
  2876. </td><td class="codes"><pre class="brush: clojure">(defn css
  2877. [&amp; rules]
  2878. (html [:style {:type &quot;text/css&quot;}
  2879. (apply str (map css-rule rules))]))</pre></td></tr><tr><td class="docs"><p>Stolen from leiningen</p>
  2880. </td><td class="codes"><pre class="brush: clojure">(defn slurp-resource
  2881. [resource-name]
  2882. (try
  2883. (-&gt; (.getContextClassLoader (Thread/currentThread))
  2884. (.getResourceAsStream resource-name)
  2885. (java.io.InputStreamReader.)
  2886. (slurp))
  2887. (catch java.lang.NullPointerException npe
  2888. (println (str &quot;Could not locate resources at &quot; resource-name))
  2889. (println &quot; ... attempting to fix.&quot;)
  2890. (let [resource-name (str &quot;./resources/&quot; resource-name)]
  2891. (try
  2892. (-&gt; (.getContextClassLoader (Thread/currentThread))
  2893. (.getResourceAsStream resource-name)
  2894. (java.io.InputStreamReader.)
  2895. (slurp))
  2896. (catch java.lang.NullPointerException npe
  2897. (println (str &quot; STILL could not locate resources at &quot; resource-name &quot;. Giving up!&quot;))))))))</pre></td></tr><tr><td class="docs">
  2898. </td><td class="codes"><pre class="brush: clojure">(defn inline-js [resource]
  2899. (let [src (slurp-resource resource)]
  2900. (html [:script {:type &quot;text/javascript&quot;}
  2901. src])))</pre></td></tr><tr><td class="docs">
  2902. </td><td class="codes"><pre class="brush: clojure">(defn inline-css [resource]
  2903. (let [src (slurp-resource resource)]
  2904. (html [:style {:type &quot;text/css&quot;}
  2905. (slurp-resource resource)])))</pre></td></tr><tr><td class="docs"><p>The following functions handle preparation of doc text (both comment and docstring
  2906. based) for display through html &amp; css.</p>
  2907. </td><td class="codes"></td></tr><tr><td class="docs"><p>Markdown processor.</p>
  2908. </td><td class="codes"><pre class="brush: clojure">(def mdp (com.petebevin.markdown.MarkdownProcessor.))</pre></td></tr><tr><td class="docs"><p>Markdown string to html converter. Translates strings like:</p>
  2909. <p> "# header!" -> <code>"&lt;h1&gt;header!&lt;/h1&gt;"</code></p>
  2910. <p> "## header!" -> <code>"&lt;h2&gt;header!&lt;/h2&gt;"</code></p>
  2911. <p> ...</p>
  2912. </td><td class="codes"><pre class="brush: clojure">(defn md
  2913. [s]
  2914. (.markdown mdp s))</pre></td></tr><tr><td class="docs"><p>As a result of docifying then grouping, you'll end up with a seq like this one:</p>
  2915. <pre><code>[...
  2916. {:docs [{:docs-text "Some doc text"}]
  2917. :codes [{:code-text "(def something \"hi\")"}]}
  2918. ...]</code></pre>
  2919. <p><code>docs-to-html</code> and <code>codes-to-html</code> convert their respective entries into html,
  2920. and <code>group-to-html</code> calls them on each seq item to do so.</p>
  2921. </td><td class="codes"></td></tr><tr><td class="docs"><p>Converts a docs section to html by threading each doc line through the forms
  2922. outlined above.</p>
  2923. <p> ex. (docs-to-html [{:doc-text "# hello world!"} {:docstring-text "I'm a docstring!}])</p>
  2924. <p> -> <code>"&lt;h1&gt;hello world!&lt;/h1&gt;&lt;br /&gt;"</code></p>
  2925. </td><td class="codes"><pre class="brush: clojure">(defn docs-to-html
  2926. [docs]
  2927. (-&gt; docs
  2928. str
  2929. (md)))</pre></td></tr><tr><td class="docs">
  2930. </td><td class="codes"><pre class="brush: clojure">(defn codes-to-html [code-block]
  2931. (html [:pre {:class &quot;brush: clojure&quot;}
  2932. (escape-html code-block)]))</pre></td></tr><tr><td class="docs">
  2933. </td><td class="codes"><pre class="brush: clojure">(defn section-to-html [section]
  2934. (html [:tr
  2935. [:td {:class &quot;docs&quot;} (docs-to-html
  2936. (if (= (:type section) :comment)
  2937. (:raw section)
  2938. (:docstring section)))]
  2939. [:td {:class &quot;codes&quot;} (if (= (:type section) :code)
  2940. (codes-to-html (:raw section)))]]))</pre></td></tr><tr><td class="docs">
  2941. </td><td class="codes"><pre class="brush: clojure">(defn dependencies-html [deps &amp; header-name]
  2942. (when-let [deps (seq deps)]
  2943. (let [header-name (or header-name &quot;dependencies&quot;)]
  2944. (html [:div {:class &quot;dependencies&quot;}
  2945. [:h3 header-name]
  2946. [:table
  2947. (map #(html [:tr
  2948. [:td {:class &quot;dep-name&quot;} (str (first %))]
  2949. [:td {:class &quot;dotted&quot;} [:hr]]
  2950. [:td {:class &quot;dep-version&quot;} (second %)]])
  2951. deps)]]))))</pre></td></tr><tr><td class="docs"><h1>Load Optional Resources</h1>
  2952. <p>Use external Javascript and CSS in your documentation. For example:
  2953. To format Latex math equations, download the
  2954. <a href="http://www.mathjax.org/">MathJax</a> Javascript library to the docs
  2955. directory and then add</p>
  2956. <pre><code>:marginalia {:javascript ["mathjax/MathJax.js"]}
  2957. </code></pre>
  2958. <p>to project.clj. Below is a simple example of both inline and block
  2959. formatted equations.</p>
  2960. <p>When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are
  2961. $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$</p>
  2962. </td><td class="codes"></td></tr><tr><td class="docs"><p>Generate script and link tags for optional external javascript and css.</p>
  2963. </td><td class="codes"><pre class="brush: clojure">(defn opt-resources-html
  2964. [project-info]
  2965. (let [options (:marginalia project-info)
  2966. javascript (:javascript options)
  2967. css (:css options)]
  2968. (html (concat
  2969. (when javascript
  2970. (map #(vector :script {:type &quot;text/javascript&quot; :src %}) javascript))
  2971. (when css
  2972. (map #(vector :link {:tyle &quot;text/css&quot; :rel &quot;stylesheet&quot; :href %}) css))))))</pre></td></tr><tr><td class="docs"><p>Is &lt;h1/&gt; overloaded? Maybe we should consider redistributing
  2973. header numbers instead of adding classes to all the h1 tags.</p>
  2974. </td><td class="codes"><pre class="brush: clojure">(defn header-html [project-info]
  2975. (html
  2976. [:tr
  2977. [:td {:class &quot;docs&quot;}
  2978. [:div {:class &quot;header&quot;}
  2979. [:h1 {:class &quot;project-name&quot;} (:name project-info)]
  2980. [:h2 {:class &quot;project-version&quot;} (:version project-info)]
  2981. [:br]
  2982. (md (:description project-info))]
  2983. (dependencies-html (:dependencies project-info))
  2984. (dependencies-html (:dev-dependencies project-info) &quot;dev dependencies&quot;)]
  2985. [:td {:class &quot;codes&quot;
  2986. :style &quot;text-align: center; vertical-align: middle;color: #666;padding-right:20px&quot;}
  2987. [:br]
  2988. [:br]
  2989. [:br]
  2990. &quot;(this space intentionally left almost blank)&quot;]]))</pre></td></tr><tr><td class="docs"><p>Creates an 'a' tag pointing to the <code>namespace-name</code>, either as an anchor (if
  2991. <code>anchor?</code> is true) or as a link to a separate <code>$namespace-name.html</code> file.
  2992. If <code>attrs</code> aren't empty, they are added to the resulting tag.</p>
  2993. </td><td class="codes"><pre class="brush: clojure">(defn link-to-namespace
  2994. [namespace-name anchor? &amp; attrs]
  2995. [:a (into {:href (if anchor?
  2996. (str &quot;#&quot; namespace-name)
  2997. (str namespace-name &quot;.html&quot;))}
  2998. attrs)
  2999. namespace-name])</pre></td></tr><tr><td class="docs"><p>This is a hack, as in the case when <code>anchor?</code> is false, the link will contain
  3000. a reference to <code>toc.html</code> which might not even exist.</p>
  3001. </td><td class="codes"><pre class="brush: clojure">(defn link-to-toc
  3002. [anchor?]
  3003. (link-to-namespace &quot;toc&quot; anchor? {:class &quot;toc-link&quot;}))</pre></td></tr><tr><td class="docs">
  3004. </td><td class="codes"><pre class="brush: clojure">(defn toc-html [props docs]
  3005. (html
  3006. [:tr
  3007. [:td {:class &quot;docs&quot;}
  3008. [:div {:class &quot;toc&quot;}
  3009. [:a {:name &quot;toc&quot;} [:h3 &quot;namespaces&quot;]]
  3010. [:ul
  3011. (map #(vector :li (link-to-namespace (:ns %) (:uberdoc? props)))
  3012. docs)]]]
  3013. [:td {:class &quot;codes&quot;} &quot;&amp;nbsp;&quot;]]))</pre></td></tr><tr><td class="docs">
  3014. </td><td class="codes"><pre class="brush: clojure">(defn floating-toc-html [docs]
  3015. [:div {:id &quot;floating-toc&quot;}
  3016. [:ul
  3017. (map #(vector :li {:class &quot;floating-toc-li&quot;
  3018. :id (str &quot;floating-toc_&quot; (:ns %))}
  3019. (:ns %))
  3020. docs)]])</pre></td></tr><tr><td class="docs">
  3021. </td><td class="codes"><pre class="brush: clojure">(defn groups-html [props doc]
  3022. (html
  3023. [:tr
  3024. [:td {:class &quot;docs&quot;}
  3025. [:div {:class &quot;docs-header&quot;}
  3026. [:a {:class &quot;anchor&quot; :name (:ns doc) :href (str &quot;#&quot; (:ns doc))}
  3027. [:h1 {:class &quot;project-name&quot;}
  3028. (:ns doc)]
  3029. (link-to-toc (:uberdoc? props))]]]
  3030. [:td {:class &quot;codes&quot;}]]
  3031. (map section-to-html (:groups doc))
  3032. [:tr
  3033. [:td {:class &quot;spacer docs&quot;} &quot;&amp;nbsp;&quot;]
  3034. [:td {:class &quot;codes&quot;}]]))</pre></td></tr><tr><td class="docs">
  3035. </td><td class="codes"><pre class="brush: clojure">(def reset-css
  3036. (css [:html {:margin 0 :padding 0}]
  3037. [:h1 {:margin 0 :padding 0}]
  3038. [:h2 {:margin 0 :padding 0}]
  3039. [:h3 {:margin 0 :padding 0}]
  3040. [:h4 {:margin 0 :padding 0}]
  3041. [:a {:color &quot;#261A3B&quot;}]
  3042. [:a:visited {:color &quot;#261A3B&quot;}]))</pre></td></tr><tr><td class="docs">
  3043. </td><td class="codes"><pre class="brush: clojure">(def header-css
  3044. (css [:.header {:margin-top &quot;30px&quot;}]
  3045. [:h1.project-name {:font-size &quot;34px&quot;
  3046. :display &quot;inline&quot;}]
  3047. [:h2.project-version {:font-size &quot;18px&quot;
  3048. :margin-top 0
  3049. :display &quot;inline&quot;
  3050. :margin-left &quot;10px&quot;}]
  3051. [:.toc-link {:font-size &quot;12px&quot;
  3052. :margin-left &quot;10px&quot;
  3053. :color &quot;#252519&quot;
  3054. :text-decoration &quot;none&quot;}]
  3055. [:.toc-link:hover {:color &quot;#5050A6&quot;}]
  3056. [:.toc :h1 {:font-size &quot;34px&quot;
  3057. :margin 0}]
  3058. [:.docs-header {:border-bottom &quot;dotted #aaa 1px&quot;
  3059. :padding-bottom &quot;10px&quot;
  3060. :margin-bottom &quot;25px&quot;}]
  3061. [:.toc :h1 {:font-size &quot;24px&quot;}]
  3062. [:.toc {:border-bottom &quot;solid #bbb 1px&quot;
  3063. :margin-bottom &quot;40px&quot;}]
  3064. [:.toc :ul {:margin-left &quot;20px&quot;
  3065. :padding-left &quot;0px&quot;
  3066. :padding-top 0
  3067. :margin-top 0}]
  3068. [:.toc :li {:list-style-type &quot;none&quot;
  3069. :padding-left 0}]
  3070. [:.dependencies {}]
  3071. [:.dependencies :table {:font-size &quot;16px&quot;
  3072. :width &quot;99.99%&quot;
  3073. :border &quot;none&quot;
  3074. :margin-left &quot;20px&quot;}]
  3075. [:.dependencies :td {:padding-right &quot;20px;&quot;
  3076. :white-space &quot;nowrap&quot;}]
  3077. [:.dependencies :.dotted {:width &quot;99%&quot;}]
  3078. [:.dependencies :.dotted :hr {:height 0
  3079. :noshade &quot;noshade&quot;
  3080. :color &quot;transparent&quot;
  3081. :background-color &quot;transparent&quot;
  3082. :border-bottom &quot;dotted #bbb 1px&quot;
  3083. :border-top &quot;none&quot;
  3084. :border-left &quot;none&quot;
  3085. :border-right &quot;none&quot;
  3086. :margin-bottom &quot;-6px&quot;}]
  3087. [:.dependencies :.dep-version {:text-align &quot;right&quot;}]
  3088. [:.plugins :ul {:margin-left &quot;20px&quot;
  3089. :padding-left &quot;0px&quot;
  3090. :padding-top 0
  3091. :margin-top 0}]
  3092. [:.plugins :li {:list-style-type &quot;none&quot;
  3093. :padding-left 0}]
  3094. [:.header :p {:margin-left &quot;20px&quot;}]))</pre></td></tr><tr><td class="docs">
  3095. </td><td class="codes"><pre class="brush: clojure">(def floating-toc-css
  3096. (css [:#floating-toc {:position &quot;fixed&quot;
  3097. :top &quot;10px&quot;
  3098. :right &quot;20px&quot;
  3099. :height &quot;20px&quot;
  3100. :overflow &quot;hidden&quot;
  3101. :text-align &quot;right&quot;}]
  3102. [:#floating-toc :li {:list-style-type &quot;none&quot;
  3103. :margin 0
  3104. :padding 0}]))</pre></td></tr><tr><td class="docs">
  3105. </td><td class="codes"><pre class="brush: clojure">(def general-css
  3106. (css
  3107. [:body {:margin 0
  3108. :padding 0
  3109. :font-family &quot;'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;&quot;
  3110. :font-size &quot;16px&quot;
  3111. :color &quot;#252519&quot;
  3112. :background-color &quot;#F5F5FF&quot;}]
  3113. [:h1 {:font-size &quot;20px&quot;
  3114. :margin-top 0}]
  3115. [:a.anchor {:text-decoration &quot;none&quot;
  3116. :color &quot;#252519&quot;}]
  3117. [:a.anchor:hover {:color &quot;#5050A6&quot;}]
  3118. [:table {:border-spacing 0
  3119. :border-bottom &quot;solid #ddd 1px;&quot;
  3120. :margin-bottom &quot;10px&quot;}]
  3121. [:code {:display &quot;inline&quot;}]
  3122. [:p {:margin-top &quot;8px&quot;}]
  3123. [:tr {:margin &quot;0px&quot;
  3124. :padding &quot;0px&quot;}]
  3125. [:td.docs {:width &quot;410px&quot;
  3126. :max-width &quot;410px&quot;
  3127. :vertical-align &quot;top&quot;
  3128. :margin &quot;0px&quot;
  3129. :padding-left &quot;55px&quot;
  3130. :padding-right &quot;20px&quot;
  3131. :border &quot;none&quot;
  3132. :background-color &quot;#FFF&quot;}]
  3133. [:td.docs :pre {:font-size &quot;12px&quot;
  3134. :overflow &quot;hidden&quot;}]
  3135. [:td.codes {:width &quot;55%&quot;
  3136. :background-color &quot;#F5F5FF&quot;
  3137. :vertical-align &quot;top&quot;
  3138. :margin &quot;0px&quot;
  3139. :padding-left &quot;20px&quot;
  3140. :border &quot;none&quot;
  3141. :overflow &quot;hidden&quot;
  3142. :font-size &quot;10pt&quot;
  3143. :border-left &quot;solid #E5E5EE 1px&quot;}]
  3144. [:td.spacer {:padding-bottom &quot;40px&quot;}]
  3145. [:pre :code {:display &quot;block&quot;
  3146. :padding &quot;4px&quot;}]
  3147. [:code {:background-color &quot;ghostWhite&quot;
  3148. :border &quot;solid #DEDEDE 1px&quot;
  3149. :padding-left &quot;3px&quot;
  3150. :padding-right &quot;3px&quot;
  3151. :font-size &quot;14px&quot;}]
  3152. [:.syntaxhighlighter :code {:font-size &quot;13px&quot;}]
  3153. [:.footer {:text-align &quot;center&quot;}]))</pre></td></tr><tr><td class="docs"><p>Notice that we're inlining the css &amp; javascript for <a href="http://alexgorbatchev.com/SyntaxHighlighter/">SyntaxHighlighter</a> (<code>inline-js</code>
  3154. &amp; <code>inline-css</code>) to be able to package the output as a single file (uberdoc if you will). It goes without
  3155. saying that all this is WIP and will prabably change in the future.</p>
  3156. </td><td class="codes"><pre class="brush: clojure">(defn page-template
  3157. [project-metadata opt-resources header toc content]
  3158. (html
  3159. (doctype :html5)
  3160. [:html
  3161. [:head
  3162. [:meta {:http-equiv &quot;Content-Type&quot; :content &quot;text/html&quot; :charset &quot;utf-8&quot;}]
  3163. [:meta {:name &quot;description&quot; :content (:description project-metadata)}]
  3164. (inline-css (str *resources* &quot;shCore.css&quot;))
  3165. (css
  3166. [:.syntaxhighlighter {:overflow &quot;hidden !important&quot;}])
  3167. (inline-css (str *resources* &quot;shThemeMarginalia.css&quot;))
  3168. reset-css
  3169. header-css
  3170. floating-toc-css
  3171. general-css
  3172. (inline-js (str *resources* &quot;jquery-1.4.4.min.js&quot;))
  3173. (inline-js (str *resources* &quot;xregexp-min.js&quot;))
  3174. (inline-js (str *resources* &quot;shCore.js&quot;))
  3175. (inline-js (str *resources* &quot;shBrushClojure.js&quot;))
  3176. opt-resources
  3177. [:title (:name project-metadata) &quot; -- Marginalia&quot;]]
  3178. [:body
  3179. [:table
  3180. header
  3181. toc
  3182. content]
  3183. [:div {:class &quot;footer&quot;}
  3184. &quot;Generated by &quot;
  3185. [:a {:href &quot;https://github.com/fogus/marginalia&quot;} &quot;Marginalia&quot;]
  3186. &quot;.&amp;nbsp;&amp;nbsp;&quot;
  3187. &quot;Syntax highlighting provided by Alex Gorbatchev's &quot;
  3188. [:a {:href &quot;http://alexgorbatchev.com/SyntaxHighlighter/&quot;}
  3189. &quot;SyntaxHighlighter&quot;]
  3190. #_floating-toc]
  3191. [:script {:type &quot;text/javascript&quot;}
  3192. &quot;SyntaxHighlighter.defaults['gutter'] = false;
  3193. SyntaxHighlighter.all()&quot;]]]))</pre></td></tr><tr><td class="docs"><p>Syntax highlighting is done a bit differently than docco. Instead of embedding
  3194. the higlighting metadata on the parse / html gen phase, we use <a href="http://alexgorbatchev.com/SyntaxHighlighter/">SyntaxHighlighter</a>
  3195. to do it in javascript.</p>
  3196. </td><td class="codes"></td></tr><tr><td class="docs"><p>This generates a stand alone html file (think <code>lein uberjar</code>).
  3197. It's probably the only var consumers will use.</p>
  3198. </td><td class="codes"><pre class="brush: clojure">(defn uberdoc-html
  3199. [project-metadata docs]
  3200. (page-template
  3201. project-metadata
  3202. (opt-resources-html project-metadata)
  3203. (header-html project-metadata)
  3204. (toc-html {:uberdoc? true} docs)
  3205. (map #(groups-html {:uberdoc? true} %) docs)))</pre></td></tr><tr><td class="docs">
  3206. </td><td class="codes"><pre class="brush: clojure">(defn index-html
  3207. [project-metadata docs]
  3208. (page-template
  3209. project-metadata
  3210. (opt-resources-html project-metadata)
  3211. (header-html project-metadata)
  3212. (toc-html {:uberdoc? false} docs))) ;; no contents</pre></td></tr><tr><td class="docs"><p>no contents</p>
  3213. </td><td class="codes"></td></tr><tr><td class="docs">
  3214. </td><td class="codes"><pre class="brush: clojure">(defn single-page-html
  3215. [project-metadata doc all-docs]
  3216. (page-template
  3217. project-metadata
  3218. (opt-resources-html project-metadata)
  3219. ;; no header
  3220. ;; no toc
  3221. (groups-html {:uberdoc? false} doc)))</pre></td></tr><tr><td class="spacer docs">&nbsp;</td><td class="codes" /></tr><tr><td class="docs"><div class="docs-header"><a class="anchor" href="#marginalia.main" name="marginalia.main"><h1 class="project-name">marginalia.main</h1><a class="toc-link" href="#toc">toc</a></a></div></td><td class="codes" /></tr><tr><td class="docs">
  3222. </td><td class="codes"><pre class="brush: clojure">(ns marginalia.main
  3223. (:use [marginalia.html :only [*resources*]]
  3224. [marginalia.core :only [run-marginalia]])
  3225. (:gen-class))</pre></td></tr><tr><td class="docs"><p>The main entry point into Marginalia.</p>
  3226. </td><td class="codes"><pre class="brush: clojure">(defn -main
  3227. [&amp; sources]
  3228. (binding [*resources* &quot;&quot;]
  3229. (run-marginalia sources)))</pre></td></tr><tr><td class="docs"><h1>Example Usage</h1>
  3230. </td><td class="codes"><pre class="brush: clojure">(comment
  3231. ;; Command line example
  3232. (-main &quot;./src/marginalia/core.clj&quot; &quot;./src/marginalia/html.clj&quot;)
  3233. ;; This will find all marginalia source files, and then generate an uberdoc.
  3234. (apply -main (find-clojure-file-paths &quot;./src&quot;))
  3235. ;; Move these to tests
  3236. (merge-line {:docstring-text &quot;hello world&quot; :line 3} {:docs [&quot;stuff&quot;]})
  3237. (merge-line {:code-text &quot;(defn asdf&quot; :line 4} {:docs [&quot;stuff&quot;]})
  3238. (merge-line {:docs-text &quot;There's only one method in this module&quot;, :line 4} {}))</pre></td></tr><tr><td class="spacer docs">&nbsp;</td><td class="codes" /></tr><tr><td class="docs"><div class="docs-header"><a class="anchor" href="#marginalia.parser" name="marginalia.parser"><h1 class="project-name">marginalia.parser</h1><a class="toc-link" href="#toc">toc</a></a></div></td><td class="codes" /></tr><tr><td class="docs"><p>Provides the parsing facilities for Marginalia.</p>
  3239. <p>This file contains the complete Marginalia parser.
  3240. It leverages the Clojure reader instead of implementing a complete
  3241. Clojure parsing solution.</p>
  3242. </td><td class="codes"><pre class="brush: clojure">(ns marginalia.parser
  3243. (:refer-clojure :exclude [replace])
  3244. (:use [clojure [string :only (join replace)]]))</pre></td></tr><tr><td class="docs"><p>Access to private or protected field. field-name is a symbol or
  3245. keyword.</p>
  3246. <p>Extracted from clojure.contrib.reflect</p>
  3247. </td><td class="codes"><pre class="brush: clojure">(defn get-field
  3248. [klass field-name obj]
  3249. (-&gt; klass (.getDeclaredField (name field-name))
  3250. (doto (.setAccessible true))
  3251. (.get obj)))</pre></td></tr><tr><td class="docs"><p>Calls a private or protected method.</p>
  3252. <p> params is a vector of classes which correspond to the arguments to
  3253. the method e</p>
  3254. <p> obj is nil for static methods, the instance object otherwise.</p>
  3255. <p> The method-name is given a symbol or a keyword (something Named).</p>
  3256. <p>Extracted from clojure.contrib.reflect</p>
  3257. </td><td class="codes"><pre class="brush: clojure">(defn call-method
  3258. [klass method-name params obj &amp; args]
  3259. (-&gt; klass (.getDeclaredMethod (name method-name)
  3260. (into-array Class params))
  3261. (doto (.setAccessible true))
  3262. (.invoke obj (into-array Object args))))</pre></td></tr><tr><td class="docs">
  3263. </td><td class="codes"><pre class="brush: clojure">(defrecord Comment [content])</pre></td></tr><tr><td class="docs">
  3264. </td><td class="codes"><pre class="brush: clojure">(defmethod print-method Comment [comment ^String out]
  3265. (.write out (str \&quot; (.content comment) \&quot;)))</pre></td></tr><tr><td class="docs">
  3266. </td><td class="codes"><pre class="brush: clojure">(def top-level-comments (atom []))
  3267. (def sub-level-comments (atom []))</pre></td></tr><tr><td class="docs">
  3268. </td><td class="codes"><pre class="brush: clojure">(def ^{:dynamic true} *comments* nil)</pre></td></tr><tr><td class="docs">
  3269. </td><td class="codes"><pre class="brush: clojure">(defn read-comment [reader semicolon]
  3270. (let [sb (StringBuilder.)]
  3271. (.append sb semicolon)
  3272. (loop [c (.read reader)]
  3273. (let [ch (char c)]
  3274. (if (or (= ch \newline)
  3275. (= ch \return))
  3276. (let [line (dec (.getLineNumber reader))]
  3277. (swap! *comments* conj
  3278. {:form (Comment. (.toString sb))
  3279. :start line
  3280. :end line})
  3281. reader)
  3282. (do
  3283. (.append sb (Character/toString ch))
  3284. (recur (.read reader))))))))</pre></td></tr><tr><td class="docs">
  3285. </td><td class="codes"><pre class="brush: clojure">(defn set-comment-reader [reader]
  3286. (aset (get-field clojure.lang.LispReader :macros nil)
  3287. (int \;)
  3288. reader))</pre></td></tr><tr><td class="docs">
  3289. </td><td class="codes"><pre class="brush: clojure">(defrecord DoubleColonKeyword [content])</pre></td></tr><tr><td class="docs">
  3290. </td><td class="codes"><pre class="brush: clojure">(defmethod print-method DoubleColonKeyword [dck ^java.io.Writer out]
  3291. (.write out (str \: (.content dck))))</pre></td></tr><tr><td class="docs">
  3292. </td><td class="codes"><pre class="brush: clojure">(defmethod print-dup DoubleColonKeyword [dck ^java.io.Writer out]
  3293. (print-method dck out))</pre></td></tr><tr><td class="docs">
  3294. </td><td class="codes"><pre class="brush: clojure">(defn ^:private read-token [reader c]
  3295. (call-method clojure.lang.LispReader :readToken
  3296. [java.io.PushbackReader Character/TYPE]
  3297. nil reader c))</pre></td></tr><tr><td class="docs">
  3298. </td><td class="codes"><pre class="brush: clojure">(defn ^:private match-symbol [s]
  3299. (call-method clojure.lang.LispReader :matchSymbol
  3300. [String]
  3301. nil s))</pre></td></tr><tr><td class="docs">
  3302. </td><td class="codes"><pre class="brush: clojure">(defn read-keyword [reader colon]
  3303. (let [c (.read reader)]
  3304. (if (= (int \:) c)
  3305. (-&gt; (read-token reader (char c))
  3306. match-symbol
  3307. DoubleColonKeyword.)
  3308. (do (.unread reader c)
  3309. (-&gt; (read-token reader colon)
  3310. match-symbol)))))</pre></td></tr><tr><td class="docs">
  3311. </td><td class="codes"><pre class="brush: clojure">(defn set-keyword-reader [reader]
  3312. (aset (get-field clojure.lang.LispReader :macros nil)
  3313. (int \:)
  3314. reader))</pre></td></tr><tr><td class="docs">
  3315. </td><td class="codes"><pre class="brush: clojure">(defn skip-spaces-and-comments [rdr]
  3316. (loop [c (.read rdr)]
  3317. (cond (= c -1) nil
  3318. (= (char c) \;)
  3319. (do (read-comment rdr \;)
  3320. (recur (.read rdr)))
  3321. (#{\space \tab \return \newline \,} (char c))
  3322. (recur (.read rdr))
  3323. :else (.unread rdr c))))</pre></td></tr><tr><td class="docs">
  3324. </td><td class="codes"><pre class="brush: clojure">(defn parse* [reader]
  3325. (take-while
  3326. :form
  3327. (flatten
  3328. (repeatedly
  3329. (fn []
  3330. (binding [*comments* top-level-comments]
  3331. (skip-spaces-and-comments reader))
  3332. (let [start (.getLineNumber reader)
  3333. form (binding [*comments* sub-level-comments]
  3334. (try (. clojure.lang.LispReader
  3335. (read reader false nil false))
  3336. (catch Exception ex
  3337. (let [msg (str &quot;Problem parsing near line &quot; start
  3338. &quot; &lt;&quot; (.readLine reader) &quot;&gt;&quot;
  3339. &quot; original reported cause is &quot;
  3340. (.getCause ex) &quot; -- &quot;
  3341. (.getMessage ex))
  3342. e (RuntimeException. msg)]
  3343. (.setStackTrace e (.getStackTrace ex))
  3344. (throw e)))))
  3345. end (.getLineNumber reader)
  3346. code {:form form :start start :end end}
  3347. comments @top-level-comments]
  3348. (swap! top-level-comments (constantly []))
  3349. (if (empty? comments)
  3350. [code]
  3351. (vec (concat comments [code])))))))))</pre></td></tr><tr><td class="docs">
  3352. </td><td class="codes"><pre class="brush: clojure">(defn strip-docstring [docstring raw]
  3353. (-&gt; raw
  3354. (replace (str \&quot; (-&gt; docstring
  3355. str
  3356. (replace &quot;\ &quot;\\\))
  3357. \&quot;))
  3358. (replace #&quot;#?\^\{\s*:doc\s*\}&quot; )
  3359. (replace #&quot;\n\s*\n&quot; &quot;\n&quot;)
  3360. (replace #&quot;\n\s*\)&quot; &quot;)&quot;)))</pre></td></tr><tr><td class="docs">
  3361. </td><td class="codes"><pre class="brush: clojure">(defn get-var-docstring [nspace-sym sym]
  3362. (let [s (if nspace-sym
  3363. (symbol (str nspace-sym) (str sym))
  3364. (symbol (str sym)))]
  3365. (try
  3366. (-&gt; `(var ~s) eval meta :doc)
  3367. ;; HACK: to handle types
  3368. (catch Exception _))))</pre></td></tr><tr><td class="docs">
  3369. </td><td class="codes"><pre class="brush: clojure">(defmulti dispatch-form (fn [form _ _]
  3370. (if (seq? form) (first form) form)))</pre></td></tr><tr><td class="docs">
  3371. </td><td class="codes"><pre class="brush: clojure">(defn- extract-common-docstring
  3372. [form raw nspace-sym]
  3373. (let [sym (second form)]
  3374. (if (symbol? sym)
  3375. (let [maybe-metadocstring (:doc (meta sym))]
  3376. (do
  3377. (when (= 'ns (first form))
  3378. (try (require sym)
  3379. (catch Exception _)))
  3380. (let [nspace (find-ns sym)
  3381. [maybe-ds remainder] (let [[_ _ ? &amp; more?] form] [? more?])
  3382. docstring (if (and (string? maybe-ds) remainder)
  3383. maybe-ds
  3384. (if (= (first form) 'ns)
  3385. (if (not maybe-metadocstring)
  3386. (when (string? maybe-ds) maybe-ds)
  3387. maybe-metadocstring)
  3388. (if-let [ds maybe-metadocstring]
  3389. ds
  3390. (when nspace
  3391. (-&gt; nspace meta :doc)
  3392. (get-var-docstring nspace-sym sym)))))]
  3393. [docstring
  3394. (strip-docstring docstring raw)
  3395. (if (or (= 'ns (first form)) nspace) sym nspace-sym)])))
  3396. [nil raw nspace-sym])))</pre></td></tr><tr><td class="docs">
  3397. </td><td class="codes"><pre class="brush: clojure">(defn- extract-impl-docstring
  3398. [fn-body]
  3399. (filter string? (rest fn-body)))</pre></td></tr><tr><td class="docs">
  3400. </td><td class="codes"><pre class="brush: clojure">(defn- extract-internal-docstrings
  3401. [body]
  3402. (mapcat #(extract-impl-docstring %)
  3403. body))</pre></td></tr><tr><td class="docs">
  3404. </td><td class="codes"><pre class="brush: clojure">(defmethod dispatch-form 'defprotocol
  3405. [form raw nspace-sym]
  3406. (let [[ds r s] (extract-common-docstring form raw nspace-sym)]
  3407. (let [internal-dses (if ds
  3408. (extract-internal-docstrings (nthnext form 3))
  3409. (extract-internal-docstrings (nthnext form 2)))]
  3410. (with-meta
  3411. [ds r s]
  3412. {:internal-docstrings internal-dses}))))</pre></td></tr><tr><td class="docs">
  3413. </td><td class="codes"><pre class="brush: clojure">(defmethod dispatch-form 'ns
  3414. [form raw nspace-sym]
  3415. (extract-common-docstring form raw nspace-sym))</pre></td></tr><tr><td class="docs">
  3416. </td><td class="codes"><pre class="brush: clojure">(defmethod dispatch-form 'def
  3417. [form raw nspace-sym]
  3418. (extract-common-docstring form raw nspace-sym))</pre></td></tr><tr><td class="docs">
  3419. </td><td class="codes"><pre class="brush: clojure">(defmethod dispatch-form 'defn
  3420. [form raw nspace-sym]
  3421. (extract-common-docstring form raw nspace-sym))</pre></td></tr><tr><td class="docs">
  3422. </td><td class="codes"><pre class="brush: clojure">(defmethod dispatch-form 'defn-
  3423. [form raw nspace-sym]
  3424. (extract-common-docstring form raw nspace-sym))</pre></td></tr><tr><td class="docs">
  3425. </td><td class="codes"><pre class="brush: clojure">(defmethod dispatch-form 'defmulti
  3426. [form raw nspace-sym]
  3427. (extract-common-docstring form raw nspace-sym))</pre></td></tr><tr><td class="docs">
  3428. </td><td class="codes"><pre class="brush: clojure">(defmethod dispatch-form 'defmethod
  3429. [form raw nspace-sym]
  3430. [nil raw nspace-sym])</pre></td></tr><tr><td class="docs">
  3431. </td><td class="codes"><pre class="brush: clojure">(defn dispatch-inner-form
  3432. [form raw nspace-sym]
  3433. (conj
  3434. (reduce (fn [[adoc araw] inner-form]
  3435. (if (seq? inner-form)
  3436. (let [[d r] (dispatch-form inner-form
  3437. araw
  3438. nspace-sym)]
  3439. [(str adoc d) r])
  3440. [adoc araw]))
  3441. [nil raw]
  3442. form)
  3443. nspace-sym))</pre></td></tr><tr><td class="docs">
  3444. </td><td class="codes"><pre class="brush: clojure">(defn- dispatch-literal
  3445. [form raw nspace-sym]
  3446. [nil raw])</pre></td></tr><tr><td class="docs">
  3447. </td><td class="codes"><pre class="brush: clojure">(defmethod dispatch-form :default
  3448. [form raw nspace-sym]
  3449. ;; Strings which are inlined into clojure files outside of forms are parsed
  3450. ;; as `String` instances, while numbers - as `Number` subclasses.
  3451. (cond (or (string? form) (number? form) (keyword? form))
  3452. (dispatch-literal form raw nspace-sym)
  3453. (and (first form)
  3454. (.isInstance clojure.lang.Named (first form))
  3455. (re-find #&quot;^def&quot; (-&gt; form first name)))
  3456. (extract-common-docstring form raw nspace-sym)
  3457. :else
  3458. (dispatch-inner-form form raw nspace-sym)))</pre></td></tr><tr><td class="docs">
  3459. </td><td class="codes"><pre class="brush: clojure">(defn extract-docstring [m raw nspace-sym]
  3460. (let [raw (join &quot;\n&quot; (subvec raw (-&gt; m :start dec) (:end m)))
  3461. form (:form m)]
  3462. (dispatch-form form raw nspace-sym)))</pre></td></tr><tr><td class="docs">
  3463. </td><td class="codes"><pre class="brush: clojure">(defn- -&gt;str [m]
  3464. (-&gt; (-&gt; m :form .content)
  3465. (replace #&quot;^;+\s(\s*)&quot; &quot;$1&quot;)
  3466. (replace #&quot;^;+&quot; )))</pre></td></tr><tr><td class="docs">
  3467. </td><td class="codes"><pre class="brush: clojure">(defn merge-comments [f s]
  3468. {:form (Comment. (str (-&gt;str f) &quot;\n&quot; (-&gt;str s)))
  3469. :start (:start f)
  3470. :end (:end s)})</pre></td></tr><tr><td class="docs">
  3471. </td><td class="codes"><pre class="brush: clojure">(defn comment? [o]
  3472. (-&gt;&gt; o :form (instance? Comment)))</pre></td></tr><tr><td class="docs">
  3473. </td><td class="codes"><pre class="brush: clojure">(defn code? [o]
  3474. (and (-&gt;&gt; o :form (instance? Comment) not)
  3475. (-&gt;&gt; o :form nil? not)))</pre></td></tr><tr><td class="docs">
  3476. </td><td class="codes"><pre class="brush: clojure">(defn adjacent? [f s]
  3477. (= (-&gt; f :end) (-&gt; s :start dec)))</pre></td></tr><tr><td class="docs">
  3478. </td><td class="codes"><pre class="brush: clojure">(defn arrange-in-sections [parsed-code raw-code]
  3479. (loop [sections []
  3480. f (first parsed-code)
  3481. s (second parsed-code)
  3482. nn (nnext parsed-code)
  3483. nspace nil]
  3484. (if f
  3485. (cond
  3486. ;; ignore comments with only one semicolon
  3487. (and (comment? f) (re-find #&quot;^;\s&quot; (-&gt; f :form .content)))
  3488. (recur sections s (first nn) (next nn) nspace)
  3489. ;; merging comments block
  3490. (and (comment? f) (comment? s) (adjacent? f s))
  3491. (recur sections (merge-comments f s)
  3492. (first nn) (next nn)
  3493. nspace)
  3494. ;; merging adjacent code blocks
  3495. (and (code? f) (code? s) (adjacent? f s))
  3496. (let [[fdoc fcode nspace] (extract-docstring f raw-code nspace)
  3497. [sdoc scode _] (extract-docstring s raw-code nspace)]
  3498. (recur sections (assoc s
  3499. :type :code
  3500. :raw (str (or (:raw f) fcode) &quot;\n&quot; scode)
  3501. :docstring (str (or (:docstring f) fdoc) &quot;\n\n&quot; sdoc))
  3502. (first nn) (next nn) nspace))
  3503. ;; adjacent comments are added as extra documentation to code block
  3504. (and (comment? f) (code? s) (adjacent? f s))
  3505. (let [[doc code nspace] (extract-docstring s raw-code nspace)]
  3506. (recur sections (assoc s
  3507. :type :code
  3508. :raw code
  3509. :docstring (str doc &quot;\n\n&quot; (-&gt;str f)))
  3510. (first nn) (next nn) nspace))
  3511. ;; adding comment section
  3512. (comment? f)
  3513. (recur (conj sections (assoc f :type :comment :raw (-&gt;str f)))
  3514. s
  3515. (first nn) (next nn)
  3516. nspace)
  3517. ;; adding code section
  3518. :else
  3519. (let [[doc code nspace] (extract-docstring f raw-code nspace)]
  3520. (recur (conj sections (if (= (:type f) :code)
  3521. f
  3522. {:type :code
  3523. :raw code
  3524. :docstring doc}))
  3525. s (first nn) (next nn) nspace)))
  3526. sections)))</pre></td></tr><tr><td class="docs">
  3527. </td><td class="codes"><pre class="brush: clojure">(defn parse [source-string]
  3528. (let [make-reader #(java.io.BufferedReader.
  3529. (java.io.StringReader. (str source-string &quot;\n&quot;)))
  3530. lines (vec (line-seq (make-reader)))
  3531. reader (clojure.lang.LineNumberingPushbackReader. (make-reader))
  3532. old-cmt-rdr (aget (get-field clojure.lang.LispReader :macros nil) (int \;))]
  3533. (try
  3534. (set-comment-reader read-comment)
  3535. (set-keyword-reader read-keyword)
  3536. (let [parsed-code (-&gt; reader parse* doall)]
  3537. (set-comment-reader old-cmt-rdr)
  3538. (set-keyword-reader nil)
  3539. (arrange-in-sections parsed-code lines))
  3540. (catch Exception e
  3541. (set-comment-reader old-cmt-rdr)
  3542. (set-keyword-reader nil)
  3543. (throw e)))))</pre></td></tr><tr><td class="docs">
  3544. </td><td class="codes"><pre class="brush: clojure">(defn parse-file [file]
  3545. (parse (slurp file)))</pre></td></tr><tr><td class="spacer docs">&nbsp;</td><td class="codes" /></tr><tr><td class="docs"><div class="docs-header"><a class="anchor" href="#problem-cases.general" name="problem-cases.general"><h1 class="project-name">problem-cases.general</h1><a class="toc-link" href="#toc">toc</a></a></div></td><td class="codes" /></tr><tr><td class="docs"><p>A place to examine poor parser behavior. These should go in tests when they get written.</p>
  3546. </td><td class="codes"><pre class="brush: clojure">(ns problem-cases.general)</pre></td></tr><tr><td class="docs">
  3547. </td><td class="codes"><pre class="brush: clojure">[::foo]</pre></td></tr><tr><td class="docs">
  3548. </td><td class="codes"><pre class="brush: clojure">{:foo 43}
  3549. {::foo 42}</pre></td></tr><tr><td class="docs"><p>private docstring</p>
  3550. </td><td class="codes"><pre class="brush: clojure">(defn ^:private private-fn [])</pre></td></tr><tr><td class="docs"><p>docstring</p>
  3551. </td><td class="codes"><pre class="brush: clojure">(defn public-fn []
  3552. (let [x (private-fn)]
  3553. (count x)))</pre></td></tr><tr><td class="docs"><p>Should have only this comment in the left margin.
  3554. See <a href="https://github.com/fogus/marginalia/issues/#issue/4">https://github.com/fogus/marginalia/issues/#issue/4</a></p>
  3555. </td><td class="codes"></td></tr><tr><td class="docs">
  3556. </td><td class="codes"><pre class="brush: clojure">(defn parse-bool [v] (condp = (.trim (str v))
  3557. &quot;0&quot; false
  3558. &quot;1&quot; true
  3559. &quot;throw exception here&quot;))</pre></td></tr><tr><td class="docs"><p>Here is a docstring. It should be to the left.</p>
  3560. </td><td class="codes"><pre class="brush: clojure">(defn a-function
  3561. [x]
  3562. (* x x))</pre></td></tr><tr><td class="docs"><p>Here is a docstring. It should be to the left.</p>
  3563. </td><td class="codes"><pre class="brush: clojure">(defn b-function
  3564. [x]
  3565. &quot;Here is just a string. It should be to the right.&quot;
  3566. (* x x))</pre></td></tr><tr><td class="docs"><p>Defines a relation... duh!</p>
  3567. </td><td class="codes"><pre class="brush: clojure">(defprotocol Relation
  3568. (select [this predicate]
  3569. &quot;Confines the query to rows for which the predicate is true
  3570. Ex. (select (table :users) (where (= :id 5)))&quot;)
  3571. (join [this table2 join_on]
  3572. &quot;Joins two tables on join_on
  3573. Ex. (join (table :one) (table :two) :id)
  3574. (join (table :one) (table :two)
  3575. (where (= :one.col :two.col)))&quot;))</pre></td></tr><tr><td class="docs"><p>This is a defmulti docstring, it should also be on the left</p>
  3576. </td><td class="codes"><pre class="brush: clojure">(defmulti bazfoo
  3577. class)</pre></td></tr><tr><td class="docs">
  3578. </td><td class="codes"><pre class="brush: clojure">(defmethod bazfoo String [s]
  3579. &quot;This is a defmethod docstring. It should be on the left.&quot;
  3580. (vec (seq s)))</pre></td></tr><tr><td class="docs">
  3581. </td><td class="codes"><pre class="brush: clojure">(bazfoo &quot;abc&quot;)</pre></td></tr><tr><td class="docs"><p>This is a protocol docstring. It should be on the left.</p>
  3582. </td><td class="codes"><pre class="brush: clojure">(defprotocol Foo
  3583. (lookup [cache e])
  3584. (has? [cache e] )
  3585. (hit [cache e])
  3586. (miss [cache e ret]))</pre></td></tr><tr><td class="docs"><p>This is also a docstring via metadata. It should be on the left.</p>
  3587. </td><td class="codes"><pre class="brush: clojure">(def
  3588. a 42)</pre></td></tr><tr><td class="docs"><p>This is also a docstring via metadata. It should be on the left.</p>
  3589. </td><td class="codes"><pre class="brush: clojure">(def
  3590. b 42)</pre></td></tr><tr><td class="docs"><p>This is also a docstring via metadata. It should be on the left.</p>
  3591. </td><td class="codes"><pre class="brush: clojure">(def
  3592. c
  3593. &quot;This is just a value. It should be on the right.&quot;)</pre></td></tr><tr><td class="docs"><p>From <a href="https://github.com/joshua-choi/fnparse">fnparse</a></p>
  3594. </td><td class="codes"></td></tr><tr><td class="docs"><p>Padded on the front with optional whitespace.</p>
  3595. </td><td class="codes"><pre class="brush: clojure">(comment
  3596. (do-template [rule-name token]
  3597. (h/defrule rule-name
  3598. (h/lit token))
  3599. &lt;escape-char-start&gt; \\
  3600. &lt;str-delimiter&gt; \&quot;
  3601. &lt;value-separator&gt; \,
  3602. &lt;name-separator&gt; \:
  3603. &lt;array-start&gt; \[
  3604. &lt;array-end&gt; \]
  3605. &lt;object-start&gt; \{
  3606. &lt;object-end&gt; \}))</pre></td></tr><tr><td class="docs"><p>Issue #26: Angle-bracket in Function Name Breaks Layout</p>
  3607. </td><td class="codes"><pre class="brush: clojure">(defn &lt;test [] nil)</pre></td></tr><tr><td class="docs"><p><is this working?</p>
  3608. </td><td class="codes"><pre class="brush: clojure">(defn test-html-entities-in-doc
  3609. []
  3610. nil)</pre></td></tr><tr><td class="docs">
  3611. </td><td class="codes"><pre class="brush: clojure">(defmulti kompile identity)</pre></td></tr><tr><td class="docs">
  3612. </td><td class="codes"><pre class="brush: clojure">(defmethod kompile [:standard]
  3613. [_]
  3614. &quot;GENERATED ALWAYS AS IDENTITY&quot;)</pre></td></tr><tr><td class="docs"><p><code>strict-eval-op-fn</code> is used to define functions of the above pattern for fuctions such as <code>+</code>, <code>*</code>, etc. Cljs special forms defined this way are applyable, such as <code>(apply + [1 2 3])</code>.</p>
  3615. <p> Resulting expressions are wrapped in an anonymous function and, down the line, <code>call</code>ed, like so:</p>
  3616. <pre><code> (+ 1 2 3) -&gt; (function(){...}.call(this, 1 2 3)
  3617. </code></pre>
  3618. </td><td class="codes"><pre class="brush: clojure">(defn strict-eval-op-fn
  3619. [op inc-ind-str ind-str op nl]
  3620. (ind-str
  3621. &quot;(function() {&quot; nl
  3622. (inc-ind-str
  3623. &quot;var _out = arguments[0];&quot; nl
  3624. &quot;for(var _i=1; _i&lt;arguments.length; _i++) {&quot; nl
  3625. (inc-ind-str
  3626. &quot;_out = _out &quot; op &quot; arguments[_i];&quot;)
  3627. nl
  3628. &quot;}&quot; nl
  3629. &quot;return _out;&quot;)
  3630. nl
  3631. &quot;})&quot;))</pre></td></tr><tr><td class="docs">
  3632. </td><td class="codes"><pre class="brush: clojure">'(defn special-forms []
  3633. {'def handle-def
  3634. 'fn handle-fn
  3635. 'fn* handle-fn
  3636. 'set! handle-set
  3637. 'let handle-let
  3638. 'defn handle-defn
  3639. 'aget handle-aget
  3640. 'aset handle-aset
  3641. 'if handle-if
  3642. 'while handle-while
  3643. 'when handle-when
  3644. 'doto handle-doto
  3645. '-&gt; handle--&gt;
  3646. '-&gt;&gt; handle--&gt;&gt;
  3647. 'not handle-not
  3648. 'do handle-do
  3649. 'cond handle-cond
  3650. '= (make-lazy-op '==)
  3651. '&gt; (make-lazy-op '&gt;)
  3652. '&lt; (make-lazy-op '&lt;)
  3653. '&gt;= (make-lazy-op '&gt;=)
  3654. '&lt;= (make-lazy-op '&lt;=)
  3655. 'or (make-lazy-op '||)
  3656. 'and (make-lazy-op '&amp;&amp;)
  3657. 'doseq handle-doseq
  3658. 'instanceof handle-instanceof
  3659. 'gensym handle-gensym
  3660. 'gensym-str handle-gensym-str})</pre></td></tr><tr><td class="docs">
  3661. </td><td class="codes"><pre class="brush: clojure">'(defn greater [a b]
  3662. (&gt;= a b))</pre></td></tr><tr><td class="docs">
  3663. </td><td class="codes"><pre class="brush: clojure">'(fact
  3664. (greater 2 1) =&gt; truthy)</pre></td></tr><tr><td class="docs">
  3665. </td><td class="codes"><pre class="brush: clojure">'(file-&gt;tickets commits)</pre></td></tr><tr><td class="docs">
  3666. </td><td class="codes"><pre class="brush: clojure">(defmulti ns-kw-mm identity)
  3667. (defmethod ns-kw-mm ::foo [_] :problem-cases.general/foo)
  3668. (defmethod ns-kw-mm :user/foo [_] :user/foo)
  3669. (defmethod ns-kw-mm :foo [_] :foo)</pre></td></tr><tr><td class="spacer docs">&nbsp;</td><td class="codes" /></tr></table><div class="footer">Generated by <a href="https://github.com/fogus/marginalia">Marginalia</a>.&nbsp;&nbsp;Syntax highlighting provided by Alex Gorbatchev's <a href="http://alexgorbatchev.com/SyntaxHighlighter/">SyntaxHighlighter</a></div><script type="text/javascript">SyntaxHighlighter.defaults['gutter'] = false;
  3670. SyntaxHighlighter.all()</script></body></html>