選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

pskov_1.0.0.html 288KB

5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
5年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915
  1. <!DOCTYPE html>
  2. <html>
  3. <meta charset="utf-8">
  4. <head>
  5. <style>
  6. #header
  7. {
  8. background: #856d51;
  9. padding: 0.7em;
  10. text-align: left;
  11. }
  12. #header a
  13. {
  14. color: white;
  15. text-decoration: none;
  16. padding: 0.5em 1em 0.5em 1em;
  17. }
  18. #title
  19. {
  20. color: #433729;
  21. }
  22. html
  23. {
  24. font-family: sans-serif;
  25. }
  26. body
  27. {
  28. line-height: 1.5em;
  29. }
  30. body
  31. {
  32. background: #FAFAFA;
  33. }
  34. table
  35. {
  36. border-collapse: collapse;
  37. width: 100%;
  38. }
  39. table, th, td
  40. {
  41. border: 1px solid #aaa;
  42. padding: 0.5em;
  43. margin-top: 0.5em;
  44. margin-bottom: 0.5em;
  45. }
  46. code, pre
  47. {
  48. font-family: monospace, serif;
  49. font-size: 1em;
  50. color: #7f0a0c;
  51. background: #f5f5f5;
  52. white-space: pre-wrap;
  53. }
  54. .contents
  55. {
  56. background: #FFFFFF;
  57. width: 720px;
  58. padding: 1em;
  59. margin-top: 2em;
  60. margin-bottom: 2em;
  61. border: 1px solid #E0E0E0;
  62. text-align: left;
  63. color: #444;
  64. }
  65. table
  66. {
  67. border-collapse: collapse;
  68. width: 100%;
  69. }
  70. table, th, td
  71. {
  72. border: 1px solid #aaa;
  73. padding: 0.5em;
  74. margin-top: 0.5em;
  75. margin-bottom: 0.5em;
  76. }
  77. .error
  78. {
  79. color: red;
  80. }
  81. .section
  82. {
  83. text-align: center;
  84. font-weight: bold;
  85. }
  86. </style>
  87. <title>
  88. pskov_1.0.0
  89. </title>
  90. </head>
  91. <body>
  92. <div id="header">
  93. <strong id="title">PSKOV</strong>
  94. <a href="pskov_1.0.0.html">Tool</a>
  95. <a href="education.html">Education</a>
  96. </div>
  97. <center><h1>
  98. PSKOV 1.0.0 (2019-06)
  99. </h1></center>
  100. <center><div class="contents">
  101. <p>
  102. <strong>PSKOV</strong> is a static site generator that runs in your web browser.
  103. What you see now has also been generated with <strong>PSKOV</strong>.
  104. If you're new to <strong>PSKOV</strong>, visit <a href="education.html">education page</a>.
  105. </p>
  106. <table>
  107. <tr>
  108. <td colspan="2" class="section">
  109. <a href="http://opengamestudio.org/lfsa">Local file system access</a>
  110. </td>
  111. </tr>
  112. <tr>
  113. <td>Path:</td>
  114. <td id="lfsaPath">Updating...</td>
  115. </tr>
  116. <tr>
  117. <td colspan="2" class="section">
  118. Configuration
  119. <button type="button" onclick="window.pskovTool.saveCfg()">Save</button>
  120. </td>
  121. </tr>
  122. <tr>
  123. <td>Input directory:</td>
  124. <td><input id="input"></input></td>
  125. </tr>
  126. <tr>
  127. <td>Item template:</td>
  128. <td><input id="item"></input></td>
  129. </tr>
  130. <tr>
  131. <td>Preview template:</td>
  132. <td><input id="preview"></input></td>
  133. </tr>
  134. <tr>
  135. <td>Index template:</td>
  136. <td><input id="index"></input></td>
  137. </tr>
  138. <tr>
  139. <td>Pagination 'Previous' template:</td>
  140. <td><input id="paginationPrev"></input></td>
  141. </tr>
  142. <tr>
  143. <td>Pagination 'Next' template:</td>
  144. <td><input id="paginationNext"></input></td>
  145. </tr>
  146. <tr>
  147. <td>Pagination 'Previous/Next' template:</td>
  148. <td><input id="paginationPrevNext"></input></td>
  149. </tr>
  150. <tr>
  151. <td>Preview characters limit:</td>
  152. <td><input id="previewSize"></input></td>
  153. </tr>
  154. <tr>
  155. <td>Preview ending string:</td>
  156. <td><input id="previewEnding"></input></td>
  157. </tr>
  158. <tr>
  159. <td>Previews per page:</td>
  160. <td><input id="previewsPerPage"></input></td>
  161. </tr>
  162. <tr>
  163. <td>Preview page base name:</td>
  164. <td><input id="previewPageBaseName"></input></td>
  165. </tr>
  166. <tr>
  167. <td colspan="2" class="section">
  168. News
  169. <button type="button" onclick="window.pskovTool.generateNews()">Generate</button>
  170. </td>
  171. </tr>
  172. <tr>
  173. <td colspan="2" class="section">Log</td>
  174. </tr>
  175. <tr>
  176. <td id="log" colspan="2"></td>
  177. </tr>
  178. </table>
  179. </div></center>
  180. <script type="text/javascript">
  181. <!-- showdown.js -->
  182. ;/*! showdown v 2.0.0-alpha1 - 24-10-2018 */
  183. (function(){
  184. /**
  185. * Created by Tivie on 13-07-2015.
  186. */
  187. function getDefaultOpts (simple) {
  188. 'use strict';
  189. var defaultOptions = {
  190. omitExtraWLInCodeBlocks: {
  191. defaultValue: false,
  192. describe: 'Omit the default extra whiteline added to code blocks',
  193. type: 'boolean'
  194. },
  195. noHeaderId: {
  196. defaultValue: false,
  197. describe: 'Turn on/off generated header id',
  198. type: 'boolean'
  199. },
  200. prefixHeaderId: {
  201. defaultValue: false,
  202. describe: 'Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to true will add a generic \'section-\' prefix',
  203. type: 'string'
  204. },
  205. rawPrefixHeaderId: {
  206. defaultValue: false,
  207. describe: 'Setting this option to true will prevent showdown from modifying the prefix. This might result in malformed IDs (if, for instance, the " char is used in the prefix)',
  208. type: 'boolean'
  209. },
  210. ghCompatibleHeaderId: {
  211. defaultValue: false,
  212. describe: 'Generate header ids compatible with github style (spaces are replaced with dashes, a bunch of non alphanumeric chars are removed)',
  213. type: 'boolean'
  214. },
  215. rawHeaderId: {
  216. defaultValue: false,
  217. describe: 'Remove only spaces, \' and " from generated header ids (including prefixes), replacing them with dashes (-). WARNING: This might result in malformed ids',
  218. type: 'boolean'
  219. },
  220. headerLevelStart: {
  221. defaultValue: false,
  222. describe: 'The header blocks level start',
  223. type: 'integer'
  224. },
  225. parseImgDimensions: {
  226. defaultValue: false,
  227. describe: 'Turn on/off image dimension parsing',
  228. type: 'boolean'
  229. },
  230. simplifiedAutoLink: {
  231. defaultValue: false,
  232. describe: 'Turn on/off GFM autolink style',
  233. type: 'boolean'
  234. },
  235. literalMidWordUnderscores: {
  236. defaultValue: false,
  237. describe: 'Parse midword underscores as literal underscores',
  238. type: 'boolean'
  239. },
  240. literalMidWordAsterisks: {
  241. defaultValue: false,
  242. describe: 'Parse midword asterisks as literal asterisks',
  243. type: 'boolean'
  244. },
  245. strikethrough: {
  246. defaultValue: false,
  247. describe: 'Turn on/off strikethrough support',
  248. type: 'boolean'
  249. },
  250. tables: {
  251. defaultValue: false,
  252. describe: 'Turn on/off tables support',
  253. type: 'boolean'
  254. },
  255. tablesHeaderId: {
  256. defaultValue: false,
  257. describe: 'Add an id to table headers',
  258. type: 'boolean'
  259. },
  260. ghCodeBlocks: {
  261. defaultValue: true,
  262. describe: 'Turn on/off GFM fenced code blocks support',
  263. type: 'boolean'
  264. },
  265. tasklists: {
  266. defaultValue: false,
  267. describe: 'Turn on/off GFM tasklist support',
  268. type: 'boolean'
  269. },
  270. smoothLivePreview: {
  271. defaultValue: false,
  272. describe: 'Prevents weird effects in live previews due to incomplete input',
  273. type: 'boolean'
  274. },
  275. smartIndentationFix: {
  276. defaultValue: false,
  277. description: 'Tries to smartly fix indentation in es6 strings',
  278. type: 'boolean'
  279. },
  280. disableForced4SpacesIndentedSublists: {
  281. defaultValue: false,
  282. description: 'Disables the requirement of indenting nested sublists by 4 spaces',
  283. type: 'boolean'
  284. },
  285. simpleLineBreaks: {
  286. defaultValue: false,
  287. description: 'Parses simple line breaks as <br> (GFM Style)',
  288. type: 'boolean'
  289. },
  290. requireSpaceBeforeHeadingText: {
  291. defaultValue: false,
  292. description: 'Makes adding a space between `#` and the header text mandatory (GFM Style)',
  293. type: 'boolean'
  294. },
  295. ghMentions: {
  296. defaultValue: false,
  297. description: 'Enables github @mentions',
  298. type: 'boolean'
  299. },
  300. ghMentionsLink: {
  301. defaultValue: 'https://github.com/{u}',
  302. description: 'Changes the link generated by @mentions. Only applies if ghMentions option is enabled.',
  303. type: 'string'
  304. },
  305. encodeEmails: {
  306. defaultValue: true,
  307. description: 'Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities',
  308. type: 'boolean'
  309. },
  310. openLinksInNewWindow: {
  311. defaultValue: false,
  312. description: 'Open all links in new windows',
  313. type: 'boolean'
  314. },
  315. backslashEscapesHTMLTags: {
  316. defaultValue: false,
  317. description: 'Support for HTML Tag escaping. ex: \<div>foo\</div>',
  318. type: 'boolean'
  319. },
  320. emoji: {
  321. defaultValue: false,
  322. description: 'Enable emoji support. Ex: `this is a :smile: emoji`',
  323. type: 'boolean'
  324. },
  325. underline: {
  326. defaultValue: false,
  327. description: 'Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, underscores no longer parses into `<em>` and `<strong>`',
  328. type: 'boolean'
  329. },
  330. completeHTMLDocument: {
  331. defaultValue: false,
  332. description: 'Outputs a complete html document, including `<html>`, `<head>` and `<body>` tags',
  333. type: 'boolean'
  334. },
  335. metadata: {
  336. defaultValue: false,
  337. description: 'Enable support for document metadata (defined at the top of the document between `«««` and `»»»` or between `---` and `---`).',
  338. type: 'boolean'
  339. },
  340. splitAdjacentBlockquotes: {
  341. defaultValue: false,
  342. description: 'Split adjacent blockquote blocks',
  343. type: 'boolean'
  344. }
  345. };
  346. if (simple === false) {
  347. return JSON.parse(JSON.stringify(defaultOptions));
  348. }
  349. var ret = {};
  350. for (var opt in defaultOptions) {
  351. if (defaultOptions.hasOwnProperty(opt)) {
  352. ret[opt] = defaultOptions[opt].defaultValue;
  353. }
  354. }
  355. return ret;
  356. }
  357. function allOptionsOn () {
  358. 'use strict';
  359. var options = getDefaultOpts(true),
  360. ret = {};
  361. for (var opt in options) {
  362. if (options.hasOwnProperty(opt)) {
  363. ret[opt] = true;
  364. }
  365. }
  366. return ret;
  367. }
  368. /**
  369. * Created by Tivie on 06-01-2015.
  370. */
  371. // Private properties
  372. var showdown = {},
  373. parsers = {},
  374. extensions = {},
  375. globalOptions = getDefaultOpts(true),
  376. setFlavor = 'vanilla',
  377. flavor = {
  378. github: {
  379. omitExtraWLInCodeBlocks: true,
  380. simplifiedAutoLink: true,
  381. literalMidWordUnderscores: true,
  382. strikethrough: true,
  383. tables: true,
  384. tablesHeaderId: true,
  385. ghCodeBlocks: true,
  386. tasklists: true,
  387. disableForced4SpacesIndentedSublists: true,
  388. simpleLineBreaks: true,
  389. requireSpaceBeforeHeadingText: true,
  390. ghCompatibleHeaderId: true,
  391. ghMentions: true,
  392. backslashEscapesHTMLTags: true,
  393. emoji: true,
  394. splitAdjacentBlockquotes: true
  395. },
  396. original: {
  397. noHeaderId: true,
  398. ghCodeBlocks: false
  399. },
  400. ghost: {
  401. omitExtraWLInCodeBlocks: true,
  402. parseImgDimensions: true,
  403. simplifiedAutoLink: true,
  404. literalMidWordUnderscores: true,
  405. strikethrough: true,
  406. tables: true,
  407. tablesHeaderId: true,
  408. ghCodeBlocks: true,
  409. tasklists: true,
  410. smoothLivePreview: true,
  411. simpleLineBreaks: true,
  412. requireSpaceBeforeHeadingText: true,
  413. ghMentions: false,
  414. encodeEmails: true
  415. },
  416. vanilla: getDefaultOpts(true),
  417. allOn: allOptionsOn()
  418. };
  419. /**
  420. * helper namespace
  421. * @type {{}}
  422. */
  423. showdown.helper = {};
  424. /**
  425. * TODO LEGACY SUPPORT CODE
  426. * @type {{}}
  427. */
  428. showdown.extensions = {};
  429. /**
  430. * Set a global option
  431. * @static
  432. * @param {string} key
  433. * @param {*} value
  434. * @returns {showdown}
  435. */
  436. showdown.setOption = function (key, value) {
  437. 'use strict';
  438. globalOptions[key] = value;
  439. return this;
  440. };
  441. /**
  442. * Get a global option
  443. * @static
  444. * @param {string} key
  445. * @returns {*}
  446. */
  447. showdown.getOption = function (key) {
  448. 'use strict';
  449. return globalOptions[key];
  450. };
  451. /**
  452. * Get the global options
  453. * @static
  454. * @returns {{}}
  455. */
  456. showdown.getOptions = function () {
  457. 'use strict';
  458. return globalOptions;
  459. };
  460. /**
  461. * Reset global options to the default values
  462. * @static
  463. */
  464. showdown.resetOptions = function () {
  465. 'use strict';
  466. globalOptions = getDefaultOpts(true);
  467. };
  468. /**
  469. * Set the flavor showdown should use as default
  470. * @param {string} name
  471. */
  472. showdown.setFlavor = function (name) {
  473. 'use strict';
  474. if (!flavor.hasOwnProperty(name)) {
  475. throw Error(name + ' flavor was not found');
  476. }
  477. showdown.resetOptions();
  478. var preset = flavor[name];
  479. setFlavor = name;
  480. for (var option in preset) {
  481. if (preset.hasOwnProperty(option)) {
  482. globalOptions[option] = preset[option];
  483. }
  484. }
  485. };
  486. /**
  487. * Get the currently set flavor
  488. * @returns {string}
  489. */
  490. showdown.getFlavor = function () {
  491. 'use strict';
  492. return setFlavor;
  493. };
  494. /**
  495. * Get the options of a specified flavor. Returns undefined if the flavor was not found
  496. * @param {string} name Name of the flavor
  497. * @returns {{}|undefined}
  498. */
  499. showdown.getFlavorOptions = function (name) {
  500. 'use strict';
  501. if (flavor.hasOwnProperty(name)) {
  502. return flavor[name];
  503. }
  504. };
  505. /**
  506. * Get the default options
  507. * @static
  508. * @param {boolean} [simple=true]
  509. * @returns {{}}
  510. */
  511. showdown.getDefaultOptions = function (simple) {
  512. 'use strict';
  513. return getDefaultOpts(simple);
  514. };
  515. /**
  516. * Get or set a subParser
  517. *
  518. * subParser(name) - Get a registered subParser
  519. * subParser(name, func) - Register a subParser
  520. * @static
  521. * @param {string} name
  522. * @param {function} [func]
  523. * @returns {*}
  524. */
  525. showdown.subParser = function (name, func) {
  526. 'use strict';
  527. if (showdown.helper.isString(name)) {
  528. if (typeof func !== 'undefined') {
  529. parsers[name] = func;
  530. } else {
  531. if (parsers.hasOwnProperty(name)) {
  532. return parsers[name];
  533. } else {
  534. throw Error('SubParser named ' + name + ' not registered!');
  535. }
  536. }
  537. } else {
  538. throw Error('showdown.subParser function first argument must be a string (the name of the subparser)');
  539. }
  540. };
  541. /**
  542. * Gets or registers an extension
  543. * @static
  544. * @param {string} name
  545. * @param {object|function=} ext
  546. * @returns {*}
  547. */
  548. showdown.extension = function (name, ext) {
  549. 'use strict';
  550. if (!showdown.helper.isString(name)) {
  551. throw Error('Extension \'name\' must be a string');
  552. }
  553. name = showdown.helper.stdExtName(name);
  554. // Getter
  555. if (showdown.helper.isUndefined(ext)) {
  556. if (!extensions.hasOwnProperty(name)) {
  557. throw Error('Extension named ' + name + ' is not registered!');
  558. }
  559. return extensions[name];
  560. // Setter
  561. } else {
  562. // Expand extension if it's wrapped in a function
  563. if (typeof ext === 'function') {
  564. ext = ext();
  565. }
  566. // Ensure extension is an array
  567. if (!showdown.helper.isArray(ext)) {
  568. ext = [ext];
  569. }
  570. var validExtension = validate(ext, name);
  571. if (validExtension.valid) {
  572. extensions[name] = ext;
  573. } else {
  574. throw Error(validExtension.error);
  575. }
  576. }
  577. };
  578. /**
  579. * Gets all extensions registered
  580. * @returns {{}}
  581. */
  582. showdown.getAllExtensions = function () {
  583. 'use strict';
  584. return extensions;
  585. };
  586. /**
  587. * Remove an extension
  588. * @param {string} name
  589. */
  590. showdown.removeExtension = function (name) {
  591. 'use strict';
  592. delete extensions[name];
  593. };
  594. /**
  595. * Removes all extensions
  596. */
  597. showdown.resetExtensions = function () {
  598. 'use strict';
  599. extensions = {};
  600. };
  601. /**
  602. * Validate extension
  603. * @param {array} extension
  604. * @param {string} name
  605. * @returns {{valid: boolean, error: string}}
  606. */
  607. function validate (extension, name) {
  608. 'use strict';
  609. var errMsg = (name) ? 'Error in ' + name + ' extension->' : 'Error in unnamed extension',
  610. ret = {
  611. valid: true,
  612. error: ''
  613. };
  614. if (!showdown.helper.isArray(extension)) {
  615. extension = [extension];
  616. }
  617. for (var i = 0; i < extension.length; ++i) {
  618. var baseMsg = errMsg + ' sub-extension ' + i + ': ',
  619. ext = extension[i];
  620. if (typeof ext !== 'object') {
  621. ret.valid = false;
  622. ret.error = baseMsg + 'must be an object, but ' + typeof ext + ' given';
  623. return ret;
  624. }
  625. if (!showdown.helper.isString(ext.type)) {
  626. ret.valid = false;
  627. ret.error = baseMsg + 'property "type" must be a string, but ' + typeof ext.type + ' given';
  628. return ret;
  629. }
  630. var type = ext.type = ext.type.toLowerCase();
  631. // normalize extension type
  632. if (type === 'language') {
  633. type = ext.type = 'lang';
  634. }
  635. if (type === 'html') {
  636. type = ext.type = 'output';
  637. }
  638. if (type !== 'lang' && type !== 'output' && type !== 'listener') {
  639. ret.valid = false;
  640. ret.error = baseMsg + 'type ' + type + ' is not recognized. Valid values: "lang/language", "output/html" or "listener"';
  641. return ret;
  642. }
  643. if (type === 'listener') {
  644. if (showdown.helper.isUndefined(ext.listeners)) {
  645. ret.valid = false;
  646. ret.error = baseMsg + '. Extensions of type "listener" must have a property called "listeners"';
  647. return ret;
  648. }
  649. } else {
  650. if (showdown.helper.isUndefined(ext.filter) && showdown.helper.isUndefined(ext.regex)) {
  651. ret.valid = false;
  652. ret.error = baseMsg + type + ' extensions must define either a "regex" property or a "filter" method';
  653. return ret;
  654. }
  655. }
  656. if (ext.listeners) {
  657. if (typeof ext.listeners !== 'object') {
  658. ret.valid = false;
  659. ret.error = baseMsg + '"listeners" property must be an object but ' + typeof ext.listeners + ' given';
  660. return ret;
  661. }
  662. for (var ln in ext.listeners) {
  663. if (ext.listeners.hasOwnProperty(ln)) {
  664. if (typeof ext.listeners[ln] !== 'function') {
  665. ret.valid = false;
  666. ret.error = baseMsg + '"listeners" property must be an hash of [event name]: [callback]. listeners.' + ln +
  667. ' must be a function but ' + typeof ext.listeners[ln] + ' given';
  668. return ret;
  669. }
  670. }
  671. }
  672. }
  673. if (ext.filter) {
  674. if (typeof ext.filter !== 'function') {
  675. ret.valid = false;
  676. ret.error = baseMsg + '"filter" must be a function, but ' + typeof ext.filter + ' given';
  677. return ret;
  678. }
  679. } else if (ext.regex) {
  680. if (showdown.helper.isString(ext.regex)) {
  681. ext.regex = new RegExp(ext.regex, 'g');
  682. }
  683. if (!(ext.regex instanceof RegExp)) {
  684. ret.valid = false;
  685. ret.error = baseMsg + '"regex" property must either be a string or a RegExp object, but ' + typeof ext.regex + ' given';
  686. return ret;
  687. }
  688. if (showdown.helper.isUndefined(ext.replace)) {
  689. ret.valid = false;
  690. ret.error = baseMsg + '"regex" extensions must implement a replace string or function';
  691. return ret;
  692. }
  693. }
  694. }
  695. return ret;
  696. }
  697. /**
  698. * Validate extension
  699. * @param {object} ext
  700. * @returns {boolean}
  701. */
  702. showdown.validateExtension = function (ext) {
  703. 'use strict';
  704. var validateExtension = validate(ext, null);
  705. if (!validateExtension.valid) {
  706. console.warn(validateExtension.error);
  707. return false;
  708. }
  709. return true;
  710. };
  711. /**
  712. * showdownjs helper functions
  713. */
  714. if (!showdown.hasOwnProperty('helper')) {
  715. showdown.helper = {};
  716. }
  717. if (typeof this.document === 'undefined' && typeof this.window === 'undefined') {
  718. var jsdom = require('jsdom');
  719. this.window = new jsdom.JSDOM('', {}).window; // jshint ignore:line
  720. }
  721. showdown.helper.document = this.window.document;
  722. /**
  723. * Check if var is string
  724. * @static
  725. * @param {string} a
  726. * @returns {boolean}
  727. */
  728. showdown.helper.isString = function (a) {
  729. 'use strict';
  730. return (typeof a === 'string' || a instanceof String);
  731. };
  732. /**
  733. * Check if var is a function
  734. * @static
  735. * @param {*} a
  736. * @returns {boolean}
  737. */
  738. showdown.helper.isFunction = function (a) {
  739. 'use strict';
  740. var getType = {};
  741. return a && getType.toString.call(a) === '[object Function]';
  742. };
  743. /**
  744. * isArray helper function
  745. * @static
  746. * @param {*} a
  747. * @returns {boolean}
  748. */
  749. showdown.helper.isArray = function (a) {
  750. 'use strict';
  751. return Array.isArray(a);
  752. };
  753. /**
  754. * Check if value is undefined
  755. * @static
  756. * @param {*} value The value to check.
  757. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  758. */
  759. showdown.helper.isUndefined = function (value) {
  760. 'use strict';
  761. return typeof value === 'undefined';
  762. };
  763. /**
  764. * ForEach helper function
  765. * Iterates over Arrays and Objects (own properties only)
  766. * @static
  767. * @param {*} obj
  768. * @param {function} callback Accepts 3 params: 1. value, 2. key, 3. the original array/object
  769. */
  770. showdown.helper.forEach = function (obj, callback) {
  771. 'use strict';
  772. // check if obj is defined
  773. if (showdown.helper.isUndefined(obj)) {
  774. throw new Error('obj param is required');
  775. }
  776. if (showdown.helper.isUndefined(callback)) {
  777. throw new Error('callback param is required');
  778. }
  779. if (!showdown.helper.isFunction(callback)) {
  780. throw new Error('callback param must be a function/closure');
  781. }
  782. if (typeof obj.forEach === 'function') {
  783. obj.forEach(callback);
  784. } else if (showdown.helper.isArray(obj)) {
  785. for (var i = 0; i < obj.length; i++) {
  786. callback(obj[i], i, obj);
  787. }
  788. } else if (typeof (obj) === 'object') {
  789. for (var prop in obj) {
  790. if (obj.hasOwnProperty(prop)) {
  791. callback(obj[prop], prop, obj);
  792. }
  793. }
  794. } else {
  795. throw new Error('obj does not seem to be an array or an iterable object');
  796. }
  797. };
  798. /**
  799. * Standardidize extension name
  800. * @static
  801. * @param {string} s extension name
  802. * @returns {string}
  803. */
  804. showdown.helper.stdExtName = function (s) {
  805. 'use strict';
  806. return s.replace(/[_?*+\/\\.^-]/g, '').replace(/\s/g, '').toLowerCase();
  807. };
  808. function escapeCharactersCallback (wholeMatch, m1) {
  809. 'use strict';
  810. var charCodeToEscape = m1.charCodeAt(0);
  811. return '¨E' + charCodeToEscape + 'E';
  812. }
  813. /**
  814. * Callback used to escape characters when passing through String.replace
  815. * @static
  816. * @param {string} wholeMatch
  817. * @param {string} m1
  818. * @returns {string}
  819. */
  820. showdown.helper.escapeCharactersCallback = escapeCharactersCallback;
  821. /**
  822. * Escape characters in a string
  823. * @static
  824. * @param {string} text
  825. * @param {string} charsToEscape
  826. * @param {boolean} afterBackslash
  827. * @returns {XML|string|void|*}
  828. */
  829. showdown.helper.escapeCharacters = function (text, charsToEscape, afterBackslash) {
  830. 'use strict';
  831. // First we have to escape the escape characters so that
  832. // we can build a character class out of them
  833. var regexString = '([' + charsToEscape.replace(/([\[\]\\])/g, '\\$1') + '])';
  834. if (afterBackslash) {
  835. regexString = '\\\\' + regexString;
  836. }
  837. var regex = new RegExp(regexString, 'g');
  838. text = text.replace(regex, escapeCharactersCallback);
  839. return text;
  840. };
  841. var rgxFindMatchPos = function (str, left, right, flags) {
  842. 'use strict';
  843. var f = flags || '',
  844. g = f.indexOf('g') > -1,
  845. x = new RegExp(left + '|' + right, 'g' + f.replace(/g/g, '')),
  846. l = new RegExp(left, f.replace(/g/g, '')),
  847. pos = [],
  848. t, s, m, start, end;
  849. do {
  850. t = 0;
  851. while ((m = x.exec(str))) {
  852. if (l.test(m[0])) {
  853. if (!(t++)) {
  854. s = x.lastIndex;
  855. start = s - m[0].length;
  856. }
  857. } else if (t) {
  858. if (!--t) {
  859. end = m.index + m[0].length;
  860. var obj = {
  861. left: {start: start, end: s},
  862. match: {start: s, end: m.index},
  863. right: {start: m.index, end: end},
  864. wholeMatch: {start: start, end: end}
  865. };
  866. pos.push(obj);
  867. if (!g) {
  868. return pos;
  869. }
  870. }
  871. }
  872. }
  873. } while (t && (x.lastIndex = s));
  874. return pos;
  875. };
  876. /**
  877. * matchRecursiveRegExp
  878. *
  879. * (c) 2007 Steven Levithan <stevenlevithan.com>
  880. * MIT License
  881. *
  882. * Accepts a string to search, a left and right format delimiter
  883. * as regex patterns, and optional regex flags. Returns an array
  884. * of matches, allowing nested instances of left/right delimiters.
  885. * Use the "g" flag to return all matches, otherwise only the
  886. * first is returned. Be careful to ensure that the left and
  887. * right format delimiters produce mutually exclusive matches.
  888. * Backreferences are not supported within the right delimiter
  889. * due to how it is internally combined with the left delimiter.
  890. * When matching strings whose format delimiters are unbalanced
  891. * to the left or right, the output is intentionally as a
  892. * conventional regex library with recursion support would
  893. * produce, e.g. "<<x>" and "<x>>" both produce ["x"] when using
  894. * "<" and ">" as the delimiters (both strings contain a single,
  895. * balanced instance of "<x>").
  896. *
  897. * examples:
  898. * matchRecursiveRegExp("test", "\\(", "\\)")
  899. * returns: []
  900. * matchRecursiveRegExp("<t<<e>><s>>t<>", "<", ">", "g")
  901. * returns: ["t<<e>><s>", ""]
  902. * matchRecursiveRegExp("<div id=\"x\">test</div>", "<div\\b[^>]*>", "</div>", "gi")
  903. * returns: ["test"]
  904. */
  905. showdown.helper.matchRecursiveRegExp = function (str, left, right, flags) {
  906. 'use strict';
  907. var matchPos = rgxFindMatchPos (str, left, right, flags),
  908. results = [];
  909. for (var i = 0; i < matchPos.length; ++i) {
  910. results.push([
  911. str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end),
  912. str.slice(matchPos[i].match.start, matchPos[i].match.end),
  913. str.slice(matchPos[i].left.start, matchPos[i].left.end),
  914. str.slice(matchPos[i].right.start, matchPos[i].right.end)
  915. ]);
  916. }
  917. return results;
  918. };
  919. /**
  920. *
  921. * @param {string} str
  922. * @param {string|function} replacement
  923. * @param {string} left
  924. * @param {string} right
  925. * @param {string} flags
  926. * @returns {string}
  927. */
  928. showdown.helper.replaceRecursiveRegExp = function (str, replacement, left, right, flags) {
  929. 'use strict';
  930. if (!showdown.helper.isFunction(replacement)) {
  931. var repStr = replacement;
  932. replacement = function () {
  933. return repStr;
  934. };
  935. }
  936. var matchPos = rgxFindMatchPos(str, left, right, flags),
  937. finalStr = str,
  938. lng = matchPos.length;
  939. if (lng > 0) {
  940. var bits = [];
  941. if (matchPos[0].wholeMatch.start !== 0) {
  942. bits.push(str.slice(0, matchPos[0].wholeMatch.start));
  943. }
  944. for (var i = 0; i < lng; ++i) {
  945. bits.push(
  946. replacement(
  947. str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end),
  948. str.slice(matchPos[i].match.start, matchPos[i].match.end),
  949. str.slice(matchPos[i].left.start, matchPos[i].left.end),
  950. str.slice(matchPos[i].right.start, matchPos[i].right.end)
  951. )
  952. );
  953. if (i < lng - 1) {
  954. bits.push(str.slice(matchPos[i].wholeMatch.end, matchPos[i + 1].wholeMatch.start));
  955. }
  956. }
  957. if (matchPos[lng - 1].wholeMatch.end < str.length) {
  958. bits.push(str.slice(matchPos[lng - 1].wholeMatch.end));
  959. }
  960. finalStr = bits.join('');
  961. }
  962. return finalStr;
  963. };
  964. /**
  965. * Returns the index within the passed String object of the first occurrence of the specified regex,
  966. * starting the search at fromIndex. Returns -1 if the value is not found.
  967. *
  968. * @param {string} str string to search
  969. * @param {RegExp} regex Regular expression to search
  970. * @param {int} [fromIndex = 0] Index to start the search
  971. * @returns {Number}
  972. * @throws InvalidArgumentError
  973. */
  974. showdown.helper.regexIndexOf = function (str, regex, fromIndex) {
  975. 'use strict';
  976. if (!showdown.helper.isString(str)) {
  977. throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string';
  978. }
  979. if (regex instanceof RegExp === false) {
  980. throw 'InvalidArgumentError: second parameter of showdown.helper.regexIndexOf function must be an instance of RegExp';
  981. }
  982. var indexOf = str.substring(fromIndex || 0).search(regex);
  983. return (indexOf >= 0) ? (indexOf + (fromIndex || 0)) : indexOf;
  984. };
  985. /**
  986. * Splits the passed string object at the defined index, and returns an array composed of the two substrings
  987. * @param {string} str string to split
  988. * @param {int} index index to split string at
  989. * @returns {[string,string]}
  990. * @throws InvalidArgumentError
  991. */
  992. showdown.helper.splitAtIndex = function (str, index) {
  993. 'use strict';
  994. if (!showdown.helper.isString(str)) {
  995. throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string';
  996. }
  997. return [str.substring(0, index), str.substring(index)];
  998. };
  999. /**
  1000. * Obfuscate an e-mail address through the use of Character Entities,
  1001. * transforming ASCII characters into their equivalent decimal or hex entities.
  1002. *
  1003. * Since it has a random component, subsequent calls to this function produce different results
  1004. *
  1005. * @param {string} mail
  1006. * @returns {string}
  1007. */
  1008. showdown.helper.encodeEmailAddress = function (mail) {
  1009. 'use strict';
  1010. var encode = [
  1011. function (ch) {
  1012. return '&#' + ch.charCodeAt(0) + ';';
  1013. },
  1014. function (ch) {
  1015. return '&#x' + ch.charCodeAt(0).toString(16) + ';';
  1016. },
  1017. function (ch) {
  1018. return ch;
  1019. }
  1020. ];
  1021. mail = mail.replace(/./g, function (ch) {
  1022. if (ch === '@') {
  1023. // this *must* be encoded. I insist.
  1024. ch = encode[Math.floor(Math.random() * 2)](ch);
  1025. } else {
  1026. var r = Math.random();
  1027. // roughly 10% raw, 45% hex, 45% dec
  1028. ch = (
  1029. r > 0.9 ? encode[2](ch) : r > 0.45 ? encode[1](ch) : encode[0](ch)
  1030. );
  1031. }
  1032. return ch;
  1033. });
  1034. return mail;
  1035. };
  1036. /**
  1037. *
  1038. * @param str
  1039. * @param targetLength
  1040. * @param padString
  1041. * @returns {string}
  1042. */
  1043. showdown.helper.padEnd = function padEnd (str, targetLength, padString) {
  1044. 'use strict';
  1045. /*jshint bitwise: false*/
  1046. // eslint-disable-next-line space-infix-ops
  1047. targetLength = targetLength>>0; //floor if number or convert non-number to 0;
  1048. /*jshint bitwise: true*/
  1049. padString = String(padString || ' ');
  1050. if (str.length > targetLength) {
  1051. return String(str);
  1052. } else {
  1053. targetLength = targetLength - str.length;
  1054. if (targetLength > padString.length) {
  1055. padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed
  1056. }
  1057. return String(str) + padString.slice(0,targetLength);
  1058. }
  1059. };
  1060. /**
  1061. * Unescape HTML entities
  1062. * @param txt
  1063. * @returns {string}
  1064. */
  1065. showdown.helper.unescapeHTMLEntities = function (txt) {
  1066. 'use strict';
  1067. return txt
  1068. .replace(/&quot;/g, '"')
  1069. .replace(/&lt;/g, '<')
  1070. .replace(/&gt;/g, '>')
  1071. .replace(/&amp;/g, '&');
  1072. };
  1073. showdown.helper._hashHTMLSpan = function (html, globals) {
  1074. return '¨C' + (globals.gHtmlSpans.push(html) - 1) + 'C';
  1075. };
  1076. /**
  1077. * Showdown's Event Object
  1078. * @param {string} name Name of the event
  1079. * @param {string} text Text
  1080. * @param {{}} params optional. params of the event
  1081. * @constructor
  1082. */
  1083. showdown.helper.Event = function (name, text, params) {
  1084. 'use strict';
  1085. var regexp = params.regexp || null;
  1086. var matches = params.matches || {};
  1087. var options = params.options || {};
  1088. var converter = params.converter || null;
  1089. var globals = params.globals || {};
  1090. /**
  1091. * Get the name of the event
  1092. * @returns {string}
  1093. */
  1094. this.getName = function () {
  1095. return name;
  1096. };
  1097. this.getEventName = function () {
  1098. return name;
  1099. };
  1100. this._stopExecution = false;
  1101. this.parsedText = params.parsedText || null;
  1102. this.getRegexp = function () {
  1103. return regexp;
  1104. };
  1105. this.getOptions = function () {
  1106. return options;
  1107. };
  1108. this.getConverter = function () {
  1109. return converter;
  1110. };
  1111. this.getGlobals = function () {
  1112. return globals;
  1113. };
  1114. this.getCapturedText = function () {
  1115. return text;
  1116. };
  1117. this.getText = function () {
  1118. return text;
  1119. };
  1120. this.setText = function (newText) {
  1121. text = newText;
  1122. };
  1123. this.getMatches = function () {
  1124. return matches;
  1125. };
  1126. this.setMatches = function (newMatches) {
  1127. matches = newMatches;
  1128. };
  1129. this.preventDefault = function (bool) {
  1130. this._stopExecution = !bool;
  1131. };
  1132. };
  1133. /**
  1134. * POLYFILLS
  1135. */
  1136. // use this instead of builtin is undefined for IE8 compatibility
  1137. if (typeof(console) === 'undefined') {
  1138. console = {
  1139. warn: function (msg) {
  1140. 'use strict';
  1141. alert(msg);
  1142. },
  1143. log: function (msg) {
  1144. 'use strict';
  1145. alert(msg);
  1146. },
  1147. error: function (msg) {
  1148. 'use strict';
  1149. throw msg;
  1150. }
  1151. };
  1152. }
  1153. /**
  1154. * Common regexes.
  1155. * We declare some common regexes to improve performance
  1156. */
  1157. showdown.helper.regexes = {
  1158. asteriskDashTildeAndColon: /([*_:~])/g,
  1159. asteriskDashAndTilde: /([*_~])/g
  1160. };
  1161. /**
  1162. * EMOJIS LIST
  1163. */
  1164. showdown.helper.emojis = {
  1165. '+1':'\ud83d\udc4d',
  1166. '-1':'\ud83d\udc4e',
  1167. '100':'\ud83d\udcaf',
  1168. '1234':'\ud83d\udd22',
  1169. '1st_place_medal':'\ud83e\udd47',
  1170. '2nd_place_medal':'\ud83e\udd48',
  1171. '3rd_place_medal':'\ud83e\udd49',
  1172. '8ball':'\ud83c\udfb1',
  1173. 'a':'\ud83c\udd70\ufe0f',
  1174. 'ab':'\ud83c\udd8e',
  1175. 'abc':'\ud83d\udd24',
  1176. 'abcd':'\ud83d\udd21',
  1177. 'accept':'\ud83c\ude51',
  1178. 'aerial_tramway':'\ud83d\udea1',
  1179. 'airplane':'\u2708\ufe0f',
  1180. 'alarm_clock':'\u23f0',
  1181. 'alembic':'\u2697\ufe0f',
  1182. 'alien':'\ud83d\udc7d',
  1183. 'ambulance':'\ud83d\ude91',
  1184. 'amphora':'\ud83c\udffa',
  1185. 'anchor':'\u2693\ufe0f',
  1186. 'angel':'\ud83d\udc7c',
  1187. 'anger':'\ud83d\udca2',
  1188. 'angry':'\ud83d\ude20',
  1189. 'anguished':'\ud83d\ude27',
  1190. 'ant':'\ud83d\udc1c',
  1191. 'apple':'\ud83c\udf4e',
  1192. 'aquarius':'\u2652\ufe0f',
  1193. 'aries':'\u2648\ufe0f',
  1194. 'arrow_backward':'\u25c0\ufe0f',
  1195. 'arrow_double_down':'\u23ec',
  1196. 'arrow_double_up':'\u23eb',
  1197. 'arrow_down':'\u2b07\ufe0f',
  1198. 'arrow_down_small':'\ud83d\udd3d',
  1199. 'arrow_forward':'\u25b6\ufe0f',
  1200. 'arrow_heading_down':'\u2935\ufe0f',
  1201. 'arrow_heading_up':'\u2934\ufe0f',
  1202. 'arrow_left':'\u2b05\ufe0f',
  1203. 'arrow_lower_left':'\u2199\ufe0f',
  1204. 'arrow_lower_right':'\u2198\ufe0f',
  1205. 'arrow_right':'\u27a1\ufe0f',
  1206. 'arrow_right_hook':'\u21aa\ufe0f',
  1207. 'arrow_up':'\u2b06\ufe0f',
  1208. 'arrow_up_down':'\u2195\ufe0f',
  1209. 'arrow_up_small':'\ud83d\udd3c',
  1210. 'arrow_upper_left':'\u2196\ufe0f',
  1211. 'arrow_upper_right':'\u2197\ufe0f',
  1212. 'arrows_clockwise':'\ud83d\udd03',
  1213. 'arrows_counterclockwise':'\ud83d\udd04',
  1214. 'art':'\ud83c\udfa8',
  1215. 'articulated_lorry':'\ud83d\ude9b',
  1216. 'artificial_satellite':'\ud83d\udef0',
  1217. 'astonished':'\ud83d\ude32',
  1218. 'athletic_shoe':'\ud83d\udc5f',
  1219. 'atm':'\ud83c\udfe7',
  1220. 'atom_symbol':'\u269b\ufe0f',
  1221. 'avocado':'\ud83e\udd51',
  1222. 'b':'\ud83c\udd71\ufe0f',
  1223. 'baby':'\ud83d\udc76',
  1224. 'baby_bottle':'\ud83c\udf7c',
  1225. 'baby_chick':'\ud83d\udc24',
  1226. 'baby_symbol':'\ud83d\udebc',
  1227. 'back':'\ud83d\udd19',
  1228. 'bacon':'\ud83e\udd53',
  1229. 'badminton':'\ud83c\udff8',
  1230. 'baggage_claim':'\ud83d\udec4',
  1231. 'baguette_bread':'\ud83e\udd56',
  1232. 'balance_scale':'\u2696\ufe0f',
  1233. 'balloon':'\ud83c\udf88',
  1234. 'ballot_box':'\ud83d\uddf3',
  1235. 'ballot_box_with_check':'\u2611\ufe0f',
  1236. 'bamboo':'\ud83c\udf8d',
  1237. 'banana':'\ud83c\udf4c',
  1238. 'bangbang':'\u203c\ufe0f',
  1239. 'bank':'\ud83c\udfe6',
  1240. 'bar_chart':'\ud83d\udcca',
  1241. 'barber':'\ud83d\udc88',
  1242. 'baseball':'\u26be\ufe0f',
  1243. 'basketball':'\ud83c\udfc0',
  1244. 'basketball_man':'\u26f9\ufe0f',
  1245. 'basketball_woman':'\u26f9\ufe0f&zwj;\u2640\ufe0f',
  1246. 'bat':'\ud83e\udd87',
  1247. 'bath':'\ud83d\udec0',
  1248. 'bathtub':'\ud83d\udec1',
  1249. 'battery':'\ud83d\udd0b',
  1250. 'beach_umbrella':'\ud83c\udfd6',
  1251. 'bear':'\ud83d\udc3b',
  1252. 'bed':'\ud83d\udecf',
  1253. 'bee':'\ud83d\udc1d',
  1254. 'beer':'\ud83c\udf7a',
  1255. 'beers':'\ud83c\udf7b',
  1256. 'beetle':'\ud83d\udc1e',
  1257. 'beginner':'\ud83d\udd30',
  1258. 'bell':'\ud83d\udd14',
  1259. 'bellhop_bell':'\ud83d\udece',
  1260. 'bento':'\ud83c\udf71',
  1261. 'biking_man':'\ud83d\udeb4',
  1262. 'bike':'\ud83d\udeb2',
  1263. 'biking_woman':'\ud83d\udeb4&zwj;\u2640\ufe0f',
  1264. 'bikini':'\ud83d\udc59',
  1265. 'biohazard':'\u2623\ufe0f',
  1266. 'bird':'\ud83d\udc26',
  1267. 'birthday':'\ud83c\udf82',
  1268. 'black_circle':'\u26ab\ufe0f',
  1269. 'black_flag':'\ud83c\udff4',
  1270. 'black_heart':'\ud83d\udda4',
  1271. 'black_joker':'\ud83c\udccf',
  1272. 'black_large_square':'\u2b1b\ufe0f',
  1273. 'black_medium_small_square':'\u25fe\ufe0f',
  1274. 'black_medium_square':'\u25fc\ufe0f',
  1275. 'black_nib':'\u2712\ufe0f',
  1276. 'black_small_square':'\u25aa\ufe0f',
  1277. 'black_square_button':'\ud83d\udd32',
  1278. 'blonde_man':'\ud83d\udc71',
  1279. 'blonde_woman':'\ud83d\udc71&zwj;\u2640\ufe0f',
  1280. 'blossom':'\ud83c\udf3c',
  1281. 'blowfish':'\ud83d\udc21',
  1282. 'blue_book':'\ud83d\udcd8',
  1283. 'blue_car':'\ud83d\ude99',
  1284. 'blue_heart':'\ud83d\udc99',
  1285. 'blush':'\ud83d\ude0a',
  1286. 'boar':'\ud83d\udc17',
  1287. 'boat':'\u26f5\ufe0f',
  1288. 'bomb':'\ud83d\udca3',
  1289. 'book':'\ud83d\udcd6',
  1290. 'bookmark':'\ud83d\udd16',
  1291. 'bookmark_tabs':'\ud83d\udcd1',
  1292. 'books':'\ud83d\udcda',
  1293. 'boom':'\ud83d\udca5',
  1294. 'boot':'\ud83d\udc62',
  1295. 'bouquet':'\ud83d\udc90',
  1296. 'bowing_man':'\ud83d\ude47',
  1297. 'bow_and_arrow':'\ud83c\udff9',
  1298. 'bowing_woman':'\ud83d\ude47&zwj;\u2640\ufe0f',
  1299. 'bowling':'\ud83c\udfb3',
  1300. 'boxing_glove':'\ud83e\udd4a',
  1301. 'boy':'\ud83d\udc66',
  1302. 'bread':'\ud83c\udf5e',
  1303. 'bride_with_veil':'\ud83d\udc70',
  1304. 'bridge_at_night':'\ud83c\udf09',
  1305. 'briefcase':'\ud83d\udcbc',
  1306. 'broken_heart':'\ud83d\udc94',
  1307. 'bug':'\ud83d\udc1b',
  1308. 'building_construction':'\ud83c\udfd7',
  1309. 'bulb':'\ud83d\udca1',
  1310. 'bullettrain_front':'\ud83d\ude85',
  1311. 'bullettrain_side':'\ud83d\ude84',
  1312. 'burrito':'\ud83c\udf2f',
  1313. 'bus':'\ud83d\ude8c',
  1314. 'business_suit_levitating':'\ud83d\udd74',
  1315. 'busstop':'\ud83d\ude8f',
  1316. 'bust_in_silhouette':'\ud83d\udc64',
  1317. 'busts_in_silhouette':'\ud83d\udc65',
  1318. 'butterfly':'\ud83e\udd8b',
  1319. 'cactus':'\ud83c\udf35',
  1320. 'cake':'\ud83c\udf70',
  1321. 'calendar':'\ud83d\udcc6',
  1322. 'call_me_hand':'\ud83e\udd19',
  1323. 'calling':'\ud83d\udcf2',
  1324. 'camel':'\ud83d\udc2b',
  1325. 'camera':'\ud83d\udcf7',
  1326. 'camera_flash':'\ud83d\udcf8',
  1327. 'camping':'\ud83c\udfd5',
  1328. 'cancer':'\u264b\ufe0f',
  1329. 'candle':'\ud83d\udd6f',
  1330. 'candy':'\ud83c\udf6c',
  1331. 'canoe':'\ud83d\udef6',
  1332. 'capital_abcd':'\ud83d\udd20',
  1333. 'capricorn':'\u2651\ufe0f',
  1334. 'car':'\ud83d\ude97',
  1335. 'card_file_box':'\ud83d\uddc3',
  1336. 'card_index':'\ud83d\udcc7',
  1337. 'card_index_dividers':'\ud83d\uddc2',
  1338. 'carousel_horse':'\ud83c\udfa0',
  1339. 'carrot':'\ud83e\udd55',
  1340. 'cat':'\ud83d\udc31',
  1341. 'cat2':'\ud83d\udc08',
  1342. 'cd':'\ud83d\udcbf',
  1343. 'chains':'\u26d3',
  1344. 'champagne':'\ud83c\udf7e',
  1345. 'chart':'\ud83d\udcb9',
  1346. 'chart_with_downwards_trend':'\ud83d\udcc9',
  1347. 'chart_with_upwards_trend':'\ud83d\udcc8',
  1348. 'checkered_flag':'\ud83c\udfc1',
  1349. 'cheese':'\ud83e\uddc0',
  1350. 'cherries':'\ud83c\udf52',
  1351. 'cherry_blossom':'\ud83c\udf38',
  1352. 'chestnut':'\ud83c\udf30',
  1353. 'chicken':'\ud83d\udc14',
  1354. 'children_crossing':'\ud83d\udeb8',
  1355. 'chipmunk':'\ud83d\udc3f',
  1356. 'chocolate_bar':'\ud83c\udf6b',
  1357. 'christmas_tree':'\ud83c\udf84',
  1358. 'church':'\u26ea\ufe0f',
  1359. 'cinema':'\ud83c\udfa6',
  1360. 'circus_tent':'\ud83c\udfaa',
  1361. 'city_sunrise':'\ud83c\udf07',
  1362. 'city_sunset':'\ud83c\udf06',
  1363. 'cityscape':'\ud83c\udfd9',
  1364. 'cl':'\ud83c\udd91',
  1365. 'clamp':'\ud83d\udddc',
  1366. 'clap':'\ud83d\udc4f',
  1367. 'clapper':'\ud83c\udfac',
  1368. 'classical_building':'\ud83c\udfdb',
  1369. 'clinking_glasses':'\ud83e\udd42',
  1370. 'clipboard':'\ud83d\udccb',
  1371. 'clock1':'\ud83d\udd50',
  1372. 'clock10':'\ud83d\udd59',
  1373. 'clock1030':'\ud83d\udd65',
  1374. 'clock11':'\ud83d\udd5a',
  1375. 'clock1130':'\ud83d\udd66',
  1376. 'clock12':'\ud83d\udd5b',
  1377. 'clock1230':'\ud83d\udd67',
  1378. 'clock130':'\ud83d\udd5c',
  1379. 'clock2':'\ud83d\udd51',
  1380. 'clock230':'\ud83d\udd5d',
  1381. 'clock3':'\ud83d\udd52',
  1382. 'clock330':'\ud83d\udd5e',
  1383. 'clock4':'\ud83d\udd53',
  1384. 'clock430':'\ud83d\udd5f',
  1385. 'clock5':'\ud83d\udd54',
  1386. 'clock530':'\ud83d\udd60',
  1387. 'clock6':'\ud83d\udd55',
  1388. 'clock630':'\ud83d\udd61',
  1389. 'clock7':'\ud83d\udd56',
  1390. 'clock730':'\ud83d\udd62',
  1391. 'clock8':'\ud83d\udd57',
  1392. 'clock830':'\ud83d\udd63',
  1393. 'clock9':'\ud83d\udd58',
  1394. 'clock930':'\ud83d\udd64',
  1395. 'closed_book':'\ud83d\udcd5',
  1396. 'closed_lock_with_key':'\ud83d\udd10',
  1397. 'closed_umbrella':'\ud83c\udf02',
  1398. 'cloud':'\u2601\ufe0f',
  1399. 'cloud_with_lightning':'\ud83c\udf29',
  1400. 'cloud_with_lightning_and_rain':'\u26c8',
  1401. 'cloud_with_rain':'\ud83c\udf27',
  1402. 'cloud_with_snow':'\ud83c\udf28',
  1403. 'clown_face':'\ud83e\udd21',
  1404. 'clubs':'\u2663\ufe0f',
  1405. 'cocktail':'\ud83c\udf78',
  1406. 'coffee':'\u2615\ufe0f',
  1407. 'coffin':'\u26b0\ufe0f',
  1408. 'cold_sweat':'\ud83d\ude30',
  1409. 'comet':'\u2604\ufe0f',
  1410. 'computer':'\ud83d\udcbb',
  1411. 'computer_mouse':'\ud83d\uddb1',
  1412. 'confetti_ball':'\ud83c\udf8a',
  1413. 'confounded':'\ud83d\ude16',
  1414. 'confused':'\ud83d\ude15',
  1415. 'congratulations':'\u3297\ufe0f',
  1416. 'construction':'\ud83d\udea7',
  1417. 'construction_worker_man':'\ud83d\udc77',
  1418. 'construction_worker_woman':'\ud83d\udc77&zwj;\u2640\ufe0f',
  1419. 'control_knobs':'\ud83c\udf9b',
  1420. 'convenience_store':'\ud83c\udfea',
  1421. 'cookie':'\ud83c\udf6a',
  1422. 'cool':'\ud83c\udd92',
  1423. 'policeman':'\ud83d\udc6e',
  1424. 'copyright':'\u00a9\ufe0f',
  1425. 'corn':'\ud83c\udf3d',
  1426. 'couch_and_lamp':'\ud83d\udecb',
  1427. 'couple':'\ud83d\udc6b',
  1428. 'couple_with_heart_woman_man':'\ud83d\udc91',
  1429. 'couple_with_heart_man_man':'\ud83d\udc68&zwj;\u2764\ufe0f&zwj;\ud83d\udc68',
  1430. 'couple_with_heart_woman_woman':'\ud83d\udc69&zwj;\u2764\ufe0f&zwj;\ud83d\udc69',
  1431. 'couplekiss_man_man':'\ud83d\udc68&zwj;\u2764\ufe0f&zwj;\ud83d\udc8b&zwj;\ud83d\udc68',
  1432. 'couplekiss_man_woman':'\ud83d\udc8f',
  1433. 'couplekiss_woman_woman':'\ud83d\udc69&zwj;\u2764\ufe0f&zwj;\ud83d\udc8b&zwj;\ud83d\udc69',
  1434. 'cow':'\ud83d\udc2e',
  1435. 'cow2':'\ud83d\udc04',
  1436. 'cowboy_hat_face':'\ud83e\udd20',
  1437. 'crab':'\ud83e\udd80',
  1438. 'crayon':'\ud83d\udd8d',
  1439. 'credit_card':'\ud83d\udcb3',
  1440. 'crescent_moon':'\ud83c\udf19',
  1441. 'cricket':'\ud83c\udfcf',
  1442. 'crocodile':'\ud83d\udc0a',
  1443. 'croissant':'\ud83e\udd50',
  1444. 'crossed_fingers':'\ud83e\udd1e',
  1445. 'crossed_flags':'\ud83c\udf8c',
  1446. 'crossed_swords':'\u2694\ufe0f',
  1447. 'crown':'\ud83d\udc51',
  1448. 'cry':'\ud83d\ude22',
  1449. 'crying_cat_face':'\ud83d\ude3f',
  1450. 'crystal_ball':'\ud83d\udd2e',
  1451. 'cucumber':'\ud83e\udd52',
  1452. 'cupid':'\ud83d\udc98',
  1453. 'curly_loop':'\u27b0',
  1454. 'currency_exchange':'\ud83d\udcb1',
  1455. 'curry':'\ud83c\udf5b',
  1456. 'custard':'\ud83c\udf6e',
  1457. 'customs':'\ud83d\udec3',
  1458. 'cyclone':'\ud83c\udf00',
  1459. 'dagger':'\ud83d\udde1',
  1460. 'dancer':'\ud83d\udc83',
  1461. 'dancing_women':'\ud83d\udc6f',
  1462. 'dancing_men':'\ud83d\udc6f&zwj;\u2642\ufe0f',
  1463. 'dango':'\ud83c\udf61',
  1464. 'dark_sunglasses':'\ud83d\udd76',
  1465. 'dart':'\ud83c\udfaf',
  1466. 'dash':'\ud83d\udca8',
  1467. 'date':'\ud83d\udcc5',
  1468. 'deciduous_tree':'\ud83c\udf33',
  1469. 'deer':'\ud83e\udd8c',
  1470. 'department_store':'\ud83c\udfec',
  1471. 'derelict_house':'\ud83c\udfda',
  1472. 'desert':'\ud83c\udfdc',
  1473. 'desert_island':'\ud83c\udfdd',
  1474. 'desktop_computer':'\ud83d\udda5',
  1475. 'male_detective':'\ud83d\udd75\ufe0f',
  1476. 'diamond_shape_with_a_dot_inside':'\ud83d\udca0',
  1477. 'diamonds':'\u2666\ufe0f',
  1478. 'disappointed':'\ud83d\ude1e',
  1479. 'disappointed_relieved':'\ud83d\ude25',
  1480. 'dizzy':'\ud83d\udcab',
  1481. 'dizzy_face':'\ud83d\ude35',
  1482. 'do_not_litter':'\ud83d\udeaf',
  1483. 'dog':'\ud83d\udc36',
  1484. 'dog2':'\ud83d\udc15',
  1485. 'dollar':'\ud83d\udcb5',
  1486. 'dolls':'\ud83c\udf8e',
  1487. 'dolphin':'\ud83d\udc2c',
  1488. 'door':'\ud83d\udeaa',
  1489. 'doughnut':'\ud83c\udf69',
  1490. 'dove':'\ud83d\udd4a',
  1491. 'dragon':'\ud83d\udc09',
  1492. 'dragon_face':'\ud83d\udc32',
  1493. 'dress':'\ud83d\udc57',
  1494. 'dromedary_camel':'\ud83d\udc2a',
  1495. 'drooling_face':'\ud83e\udd24',
  1496. 'droplet':'\ud83d\udca7',
  1497. 'drum':'\ud83e\udd41',
  1498. 'duck':'\ud83e\udd86',
  1499. 'dvd':'\ud83d\udcc0',
  1500. 'e-mail':'\ud83d\udce7',
  1501. 'eagle':'\ud83e\udd85',
  1502. 'ear':'\ud83d\udc42',
  1503. 'ear_of_rice':'\ud83c\udf3e',
  1504. 'earth_africa':'\ud83c\udf0d',
  1505. 'earth_americas':'\ud83c\udf0e',
  1506. 'earth_asia':'\ud83c\udf0f',
  1507. 'egg':'\ud83e\udd5a',
  1508. 'eggplant':'\ud83c\udf46',
  1509. 'eight_pointed_black_star':'\u2734\ufe0f',
  1510. 'eight_spoked_asterisk':'\u2733\ufe0f',
  1511. 'electric_plug':'\ud83d\udd0c',
  1512. 'elephant':'\ud83d\udc18',
  1513. 'email':'\u2709\ufe0f',
  1514. 'end':'\ud83d\udd1a',
  1515. 'envelope_with_arrow':'\ud83d\udce9',
  1516. 'euro':'\ud83d\udcb6',
  1517. 'european_castle':'\ud83c\udff0',
  1518. 'european_post_office':'\ud83c\udfe4',
  1519. 'evergreen_tree':'\ud83c\udf32',
  1520. 'exclamation':'\u2757\ufe0f',
  1521. 'expressionless':'\ud83d\ude11',
  1522. 'eye':'\ud83d\udc41',
  1523. 'eye_speech_bubble':'\ud83d\udc41&zwj;\ud83d\udde8',
  1524. 'eyeglasses':'\ud83d\udc53',
  1525. 'eyes':'\ud83d\udc40',
  1526. 'face_with_head_bandage':'\ud83e\udd15',
  1527. 'face_with_thermometer':'\ud83e\udd12',
  1528. 'fist_oncoming':'\ud83d\udc4a',
  1529. 'factory':'\ud83c\udfed',
  1530. 'fallen_leaf':'\ud83c\udf42',
  1531. 'family_man_woman_boy':'\ud83d\udc6a',
  1532. 'family_man_boy':'\ud83d\udc68&zwj;\ud83d\udc66',
  1533. 'family_man_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1534. 'family_man_girl':'\ud83d\udc68&zwj;\ud83d\udc67',
  1535. 'family_man_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1536. 'family_man_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1537. 'family_man_man_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc66',
  1538. 'family_man_man_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1539. 'family_man_man_girl':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67',
  1540. 'family_man_man_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1541. 'family_man_man_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1542. 'family_man_woman_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1543. 'family_man_woman_girl':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67',
  1544. 'family_man_woman_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1545. 'family_man_woman_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1546. 'family_woman_boy':'\ud83d\udc69&zwj;\ud83d\udc66',
  1547. 'family_woman_boy_boy':'\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1548. 'family_woman_girl':'\ud83d\udc69&zwj;\ud83d\udc67',
  1549. 'family_woman_girl_boy':'\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1550. 'family_woman_girl_girl':'\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1551. 'family_woman_woman_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc66',
  1552. 'family_woman_woman_boy_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1553. 'family_woman_woman_girl':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67',
  1554. 'family_woman_woman_girl_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1555. 'family_woman_woman_girl_girl':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1556. 'fast_forward':'\u23e9',
  1557. 'fax':'\ud83d\udce0',
  1558. 'fearful':'\ud83d\ude28',
  1559. 'feet':'\ud83d\udc3e',
  1560. 'female_detective':'\ud83d\udd75\ufe0f&zwj;\u2640\ufe0f',
  1561. 'ferris_wheel':'\ud83c\udfa1',
  1562. 'ferry':'\u26f4',
  1563. 'field_hockey':'\ud83c\udfd1',
  1564. 'file_cabinet':'\ud83d\uddc4',
  1565. 'file_folder':'\ud83d\udcc1',
  1566. 'film_projector':'\ud83d\udcfd',
  1567. 'film_strip':'\ud83c\udf9e',
  1568. 'fire':'\ud83d\udd25',
  1569. 'fire_engine':'\ud83d\ude92',
  1570. 'fireworks':'\ud83c\udf86',
  1571. 'first_quarter_moon':'\ud83c\udf13',
  1572. 'first_quarter_moon_with_face':'\ud83c\udf1b',
  1573. 'fish':'\ud83d\udc1f',
  1574. 'fish_cake':'\ud83c\udf65',
  1575. 'fishing_pole_and_fish':'\ud83c\udfa3',
  1576. 'fist_raised':'\u270a',
  1577. 'fist_left':'\ud83e\udd1b',
  1578. 'fist_right':'\ud83e\udd1c',
  1579. 'flags':'\ud83c\udf8f',
  1580. 'flashlight':'\ud83d\udd26',
  1581. 'fleur_de_lis':'\u269c\ufe0f',
  1582. 'flight_arrival':'\ud83d\udeec',
  1583. 'flight_departure':'\ud83d\udeeb',
  1584. 'floppy_disk':'\ud83d\udcbe',
  1585. 'flower_playing_cards':'\ud83c\udfb4',
  1586. 'flushed':'\ud83d\ude33',
  1587. 'fog':'\ud83c\udf2b',
  1588. 'foggy':'\ud83c\udf01',
  1589. 'football':'\ud83c\udfc8',
  1590. 'footprints':'\ud83d\udc63',
  1591. 'fork_and_knife':'\ud83c\udf74',
  1592. 'fountain':'\u26f2\ufe0f',
  1593. 'fountain_pen':'\ud83d\udd8b',
  1594. 'four_leaf_clover':'\ud83c\udf40',
  1595. 'fox_face':'\ud83e\udd8a',
  1596. 'framed_picture':'\ud83d\uddbc',
  1597. 'free':'\ud83c\udd93',
  1598. 'fried_egg':'\ud83c\udf73',
  1599. 'fried_shrimp':'\ud83c\udf64',
  1600. 'fries':'\ud83c\udf5f',
  1601. 'frog':'\ud83d\udc38',
  1602. 'frowning':'\ud83d\ude26',
  1603. 'frowning_face':'\u2639\ufe0f',
  1604. 'frowning_man':'\ud83d\ude4d&zwj;\u2642\ufe0f',
  1605. 'frowning_woman':'\ud83d\ude4d',
  1606. 'middle_finger':'\ud83d\udd95',
  1607. 'fuelpump':'\u26fd\ufe0f',
  1608. 'full_moon':'\ud83c\udf15',
  1609. 'full_moon_with_face':'\ud83c\udf1d',
  1610. 'funeral_urn':'\u26b1\ufe0f',
  1611. 'game_die':'\ud83c\udfb2',
  1612. 'gear':'\u2699\ufe0f',
  1613. 'gem':'\ud83d\udc8e',
  1614. 'gemini':'\u264a\ufe0f',
  1615. 'ghost':'\ud83d\udc7b',
  1616. 'gift':'\ud83c\udf81',
  1617. 'gift_heart':'\ud83d\udc9d',
  1618. 'girl':'\ud83d\udc67',
  1619. 'globe_with_meridians':'\ud83c\udf10',
  1620. 'goal_net':'\ud83e\udd45',
  1621. 'goat':'\ud83d\udc10',
  1622. 'golf':'\u26f3\ufe0f',
  1623. 'golfing_man':'\ud83c\udfcc\ufe0f',
  1624. 'golfing_woman':'\ud83c\udfcc\ufe0f&zwj;\u2640\ufe0f',
  1625. 'gorilla':'\ud83e\udd8d',
  1626. 'grapes':'\ud83c\udf47',
  1627. 'green_apple':'\ud83c\udf4f',
  1628. 'green_book':'\ud83d\udcd7',
  1629. 'green_heart':'\ud83d\udc9a',
  1630. 'green_salad':'\ud83e\udd57',
  1631. 'grey_exclamation':'\u2755',
  1632. 'grey_question':'\u2754',
  1633. 'grimacing':'\ud83d\ude2c',
  1634. 'grin':'\ud83d\ude01',
  1635. 'grinning':'\ud83d\ude00',
  1636. 'guardsman':'\ud83d\udc82',
  1637. 'guardswoman':'\ud83d\udc82&zwj;\u2640\ufe0f',
  1638. 'guitar':'\ud83c\udfb8',
  1639. 'gun':'\ud83d\udd2b',
  1640. 'haircut_woman':'\ud83d\udc87',
  1641. 'haircut_man':'\ud83d\udc87&zwj;\u2642\ufe0f',
  1642. 'hamburger':'\ud83c\udf54',
  1643. 'hammer':'\ud83d\udd28',
  1644. 'hammer_and_pick':'\u2692',
  1645. 'hammer_and_wrench':'\ud83d\udee0',
  1646. 'hamster':'\ud83d\udc39',
  1647. 'hand':'\u270b',
  1648. 'handbag':'\ud83d\udc5c',
  1649. 'handshake':'\ud83e\udd1d',
  1650. 'hankey':'\ud83d\udca9',
  1651. 'hatched_chick':'\ud83d\udc25',
  1652. 'hatching_chick':'\ud83d\udc23',
  1653. 'headphones':'\ud83c\udfa7',
  1654. 'hear_no_evil':'\ud83d\ude49',
  1655. 'heart':'\u2764\ufe0f',
  1656. 'heart_decoration':'\ud83d\udc9f',
  1657. 'heart_eyes':'\ud83d\ude0d',
  1658. 'heart_eyes_cat':'\ud83d\ude3b',
  1659. 'heartbeat':'\ud83d\udc93',
  1660. 'heartpulse':'\ud83d\udc97',
  1661. 'hearts':'\u2665\ufe0f',
  1662. 'heavy_check_mark':'\u2714\ufe0f',
  1663. 'heavy_division_sign':'\u2797',
  1664. 'heavy_dollar_sign':'\ud83d\udcb2',
  1665. 'heavy_heart_exclamation':'\u2763\ufe0f',
  1666. 'heavy_minus_sign':'\u2796',
  1667. 'heavy_multiplication_x':'\u2716\ufe0f',
  1668. 'heavy_plus_sign':'\u2795',
  1669. 'helicopter':'\ud83d\ude81',
  1670. 'herb':'\ud83c\udf3f',
  1671. 'hibiscus':'\ud83c\udf3a',
  1672. 'high_brightness':'\ud83d\udd06',
  1673. 'high_heel':'\ud83d\udc60',
  1674. 'hocho':'\ud83d\udd2a',
  1675. 'hole':'\ud83d\udd73',
  1676. 'honey_pot':'\ud83c\udf6f',
  1677. 'horse':'\ud83d\udc34',
  1678. 'horse_racing':'\ud83c\udfc7',
  1679. 'hospital':'\ud83c\udfe5',
  1680. 'hot_pepper':'\ud83c\udf36',
  1681. 'hotdog':'\ud83c\udf2d',
  1682. 'hotel':'\ud83c\udfe8',
  1683. 'hotsprings':'\u2668\ufe0f',
  1684. 'hourglass':'\u231b\ufe0f',
  1685. 'hourglass_flowing_sand':'\u23f3',
  1686. 'house':'\ud83c\udfe0',
  1687. 'house_with_garden':'\ud83c\udfe1',
  1688. 'houses':'\ud83c\udfd8',
  1689. 'hugs':'\ud83e\udd17',
  1690. 'hushed':'\ud83d\ude2f',
  1691. 'ice_cream':'\ud83c\udf68',
  1692. 'ice_hockey':'\ud83c\udfd2',
  1693. 'ice_skate':'\u26f8',
  1694. 'icecream':'\ud83c\udf66',
  1695. 'id':'\ud83c\udd94',
  1696. 'ideograph_advantage':'\ud83c\ude50',
  1697. 'imp':'\ud83d\udc7f',
  1698. 'inbox_tray':'\ud83d\udce5',
  1699. 'incoming_envelope':'\ud83d\udce8',
  1700. 'tipping_hand_woman':'\ud83d\udc81',
  1701. 'information_source':'\u2139\ufe0f',
  1702. 'innocent':'\ud83d\ude07',
  1703. 'interrobang':'\u2049\ufe0f',
  1704. 'iphone':'\ud83d\udcf1',
  1705. 'izakaya_lantern':'\ud83c\udfee',
  1706. 'jack_o_lantern':'\ud83c\udf83',
  1707. 'japan':'\ud83d\uddfe',
  1708. 'japanese_castle':'\ud83c\udfef',
  1709. 'japanese_goblin':'\ud83d\udc7a',
  1710. 'japanese_ogre':'\ud83d\udc79',
  1711. 'jeans':'\ud83d\udc56',
  1712. 'joy':'\ud83d\ude02',
  1713. 'joy_cat':'\ud83d\ude39',
  1714. 'joystick':'\ud83d\udd79',
  1715. 'kaaba':'\ud83d\udd4b',
  1716. 'key':'\ud83d\udd11',
  1717. 'keyboard':'\u2328\ufe0f',
  1718. 'keycap_ten':'\ud83d\udd1f',
  1719. 'kick_scooter':'\ud83d\udef4',
  1720. 'kimono':'\ud83d\udc58',
  1721. 'kiss':'\ud83d\udc8b',
  1722. 'kissing':'\ud83d\ude17',
  1723. 'kissing_cat':'\ud83d\ude3d',
  1724. 'kissing_closed_eyes':'\ud83d\ude1a',
  1725. 'kissing_heart':'\ud83d\ude18',
  1726. 'kissing_smiling_eyes':'\ud83d\ude19',
  1727. 'kiwi_fruit':'\ud83e\udd5d',
  1728. 'koala':'\ud83d\udc28',
  1729. 'koko':'\ud83c\ude01',
  1730. 'label':'\ud83c\udff7',
  1731. 'large_blue_circle':'\ud83d\udd35',
  1732. 'large_blue_diamond':'\ud83d\udd37',
  1733. 'large_orange_diamond':'\ud83d\udd36',
  1734. 'last_quarter_moon':'\ud83c\udf17',
  1735. 'last_quarter_moon_with_face':'\ud83c\udf1c',
  1736. 'latin_cross':'\u271d\ufe0f',
  1737. 'laughing':'\ud83d\ude06',
  1738. 'leaves':'\ud83c\udf43',
  1739. 'ledger':'\ud83d\udcd2',
  1740. 'left_luggage':'\ud83d\udec5',
  1741. 'left_right_arrow':'\u2194\ufe0f',
  1742. 'leftwards_arrow_with_hook':'\u21a9\ufe0f',
  1743. 'lemon':'\ud83c\udf4b',
  1744. 'leo':'\u264c\ufe0f',
  1745. 'leopard':'\ud83d\udc06',
  1746. 'level_slider':'\ud83c\udf9a',
  1747. 'libra':'\u264e\ufe0f',
  1748. 'light_rail':'\ud83d\ude88',
  1749. 'link':'\ud83d\udd17',
  1750. 'lion':'\ud83e\udd81',
  1751. 'lips':'\ud83d\udc44',
  1752. 'lipstick':'\ud83d\udc84',
  1753. 'lizard':'\ud83e\udd8e',
  1754. 'lock':'\ud83d\udd12',
  1755. 'lock_with_ink_pen':'\ud83d\udd0f',
  1756. 'lollipop':'\ud83c\udf6d',
  1757. 'loop':'\u27bf',
  1758. 'loud_sound':'\ud83d\udd0a',
  1759. 'loudspeaker':'\ud83d\udce2',
  1760. 'love_hotel':'\ud83c\udfe9',
  1761. 'love_letter':'\ud83d\udc8c',
  1762. 'low_brightness':'\ud83d\udd05',
  1763. 'lying_face':'\ud83e\udd25',
  1764. 'm':'\u24c2\ufe0f',
  1765. 'mag':'\ud83d\udd0d',
  1766. 'mag_right':'\ud83d\udd0e',
  1767. 'mahjong':'\ud83c\udc04\ufe0f',
  1768. 'mailbox':'\ud83d\udceb',
  1769. 'mailbox_closed':'\ud83d\udcea',
  1770. 'mailbox_with_mail':'\ud83d\udcec',
  1771. 'mailbox_with_no_mail':'\ud83d\udced',
  1772. 'man':'\ud83d\udc68',
  1773. 'man_artist':'\ud83d\udc68&zwj;\ud83c\udfa8',
  1774. 'man_astronaut':'\ud83d\udc68&zwj;\ud83d\ude80',
  1775. 'man_cartwheeling':'\ud83e\udd38&zwj;\u2642\ufe0f',
  1776. 'man_cook':'\ud83d\udc68&zwj;\ud83c\udf73',
  1777. 'man_dancing':'\ud83d\udd7a',
  1778. 'man_facepalming':'\ud83e\udd26&zwj;\u2642\ufe0f',
  1779. 'man_factory_worker':'\ud83d\udc68&zwj;\ud83c\udfed',
  1780. 'man_farmer':'\ud83d\udc68&zwj;\ud83c\udf3e',
  1781. 'man_firefighter':'\ud83d\udc68&zwj;\ud83d\ude92',
  1782. 'man_health_worker':'\ud83d\udc68&zwj;\u2695\ufe0f',
  1783. 'man_in_tuxedo':'\ud83e\udd35',
  1784. 'man_judge':'\ud83d\udc68&zwj;\u2696\ufe0f',
  1785. 'man_juggling':'\ud83e\udd39&zwj;\u2642\ufe0f',
  1786. 'man_mechanic':'\ud83d\udc68&zwj;\ud83d\udd27',
  1787. 'man_office_worker':'\ud83d\udc68&zwj;\ud83d\udcbc',
  1788. 'man_pilot':'\ud83d\udc68&zwj;\u2708\ufe0f',
  1789. 'man_playing_handball':'\ud83e\udd3e&zwj;\u2642\ufe0f',
  1790. 'man_playing_water_polo':'\ud83e\udd3d&zwj;\u2642\ufe0f',
  1791. 'man_scientist':'\ud83d\udc68&zwj;\ud83d\udd2c',
  1792. 'man_shrugging':'\ud83e\udd37&zwj;\u2642\ufe0f',
  1793. 'man_singer':'\ud83d\udc68&zwj;\ud83c\udfa4',
  1794. 'man_student':'\ud83d\udc68&zwj;\ud83c\udf93',
  1795. 'man_teacher':'\ud83d\udc68&zwj;\ud83c\udfeb',
  1796. 'man_technologist':'\ud83d\udc68&zwj;\ud83d\udcbb',
  1797. 'man_with_gua_pi_mao':'\ud83d\udc72',
  1798. 'man_with_turban':'\ud83d\udc73',
  1799. 'tangerine':'\ud83c\udf4a',
  1800. 'mans_shoe':'\ud83d\udc5e',
  1801. 'mantelpiece_clock':'\ud83d\udd70',
  1802. 'maple_leaf':'\ud83c\udf41',
  1803. 'martial_arts_uniform':'\ud83e\udd4b',
  1804. 'mask':'\ud83d\ude37',
  1805. 'massage_woman':'\ud83d\udc86',
  1806. 'massage_man':'\ud83d\udc86&zwj;\u2642\ufe0f',
  1807. 'meat_on_bone':'\ud83c\udf56',
  1808. 'medal_military':'\ud83c\udf96',
  1809. 'medal_sports':'\ud83c\udfc5',
  1810. 'mega':'\ud83d\udce3',
  1811. 'melon':'\ud83c\udf48',
  1812. 'memo':'\ud83d\udcdd',
  1813. 'men_wrestling':'\ud83e\udd3c&zwj;\u2642\ufe0f',
  1814. 'menorah':'\ud83d\udd4e',
  1815. 'mens':'\ud83d\udeb9',
  1816. 'metal':'\ud83e\udd18',
  1817. 'metro':'\ud83d\ude87',
  1818. 'microphone':'\ud83c\udfa4',
  1819. 'microscope':'\ud83d\udd2c',
  1820. 'milk_glass':'\ud83e\udd5b',
  1821. 'milky_way':'\ud83c\udf0c',
  1822. 'minibus':'\ud83d\ude90',
  1823. 'minidisc':'\ud83d\udcbd',
  1824. 'mobile_phone_off':'\ud83d\udcf4',
  1825. 'money_mouth_face':'\ud83e\udd11',
  1826. 'money_with_wings':'\ud83d\udcb8',
  1827. 'moneybag':'\ud83d\udcb0',
  1828. 'monkey':'\ud83d\udc12',
  1829. 'monkey_face':'\ud83d\udc35',
  1830. 'monorail':'\ud83d\ude9d',
  1831. 'moon':'\ud83c\udf14',
  1832. 'mortar_board':'\ud83c\udf93',
  1833. 'mosque':'\ud83d\udd4c',
  1834. 'motor_boat':'\ud83d\udee5',
  1835. 'motor_scooter':'\ud83d\udef5',
  1836. 'motorcycle':'\ud83c\udfcd',
  1837. 'motorway':'\ud83d\udee3',
  1838. 'mount_fuji':'\ud83d\uddfb',
  1839. 'mountain':'\u26f0',
  1840. 'mountain_biking_man':'\ud83d\udeb5',
  1841. 'mountain_biking_woman':'\ud83d\udeb5&zwj;\u2640\ufe0f',
  1842. 'mountain_cableway':'\ud83d\udea0',
  1843. 'mountain_railway':'\ud83d\ude9e',
  1844. 'mountain_snow':'\ud83c\udfd4',
  1845. 'mouse':'\ud83d\udc2d',
  1846. 'mouse2':'\ud83d\udc01',
  1847. 'movie_camera':'\ud83c\udfa5',
  1848. 'moyai':'\ud83d\uddff',
  1849. 'mrs_claus':'\ud83e\udd36',
  1850. 'muscle':'\ud83d\udcaa',
  1851. 'mushroom':'\ud83c\udf44',
  1852. 'musical_keyboard':'\ud83c\udfb9',
  1853. 'musical_note':'\ud83c\udfb5',
  1854. 'musical_score':'\ud83c\udfbc',
  1855. 'mute':'\ud83d\udd07',
  1856. 'nail_care':'\ud83d\udc85',
  1857. 'name_badge':'\ud83d\udcdb',
  1858. 'national_park':'\ud83c\udfde',
  1859. 'nauseated_face':'\ud83e\udd22',
  1860. 'necktie':'\ud83d\udc54',
  1861. 'negative_squared_cross_mark':'\u274e',
  1862. 'nerd_face':'\ud83e\udd13',
  1863. 'neutral_face':'\ud83d\ude10',
  1864. 'new':'\ud83c\udd95',
  1865. 'new_moon':'\ud83c\udf11',
  1866. 'new_moon_with_face':'\ud83c\udf1a',
  1867. 'newspaper':'\ud83d\udcf0',
  1868. 'newspaper_roll':'\ud83d\uddde',
  1869. 'next_track_button':'\u23ed',
  1870. 'ng':'\ud83c\udd96',
  1871. 'no_good_man':'\ud83d\ude45&zwj;\u2642\ufe0f',
  1872. 'no_good_woman':'\ud83d\ude45',
  1873. 'night_with_stars':'\ud83c\udf03',
  1874. 'no_bell':'\ud83d\udd15',
  1875. 'no_bicycles':'\ud83d\udeb3',
  1876. 'no_entry':'\u26d4\ufe0f',
  1877. 'no_entry_sign':'\ud83d\udeab',
  1878. 'no_mobile_phones':'\ud83d\udcf5',
  1879. 'no_mouth':'\ud83d\ude36',
  1880. 'no_pedestrians':'\ud83d\udeb7',
  1881. 'no_smoking':'\ud83d\udead',
  1882. 'non-potable_water':'\ud83d\udeb1',
  1883. 'nose':'\ud83d\udc43',
  1884. 'notebook':'\ud83d\udcd3',
  1885. 'notebook_with_decorative_cover':'\ud83d\udcd4',
  1886. 'notes':'\ud83c\udfb6',
  1887. 'nut_and_bolt':'\ud83d\udd29',
  1888. 'o':'\u2b55\ufe0f',
  1889. 'o2':'\ud83c\udd7e\ufe0f',
  1890. 'ocean':'\ud83c\udf0a',
  1891. 'octopus':'\ud83d\udc19',
  1892. 'oden':'\ud83c\udf62',
  1893. 'office':'\ud83c\udfe2',
  1894. 'oil_drum':'\ud83d\udee2',
  1895. 'ok':'\ud83c\udd97',
  1896. 'ok_hand':'\ud83d\udc4c',
  1897. 'ok_man':'\ud83d\ude46&zwj;\u2642\ufe0f',
  1898. 'ok_woman':'\ud83d\ude46',
  1899. 'old_key':'\ud83d\udddd',
  1900. 'older_man':'\ud83d\udc74',
  1901. 'older_woman':'\ud83d\udc75',
  1902. 'om':'\ud83d\udd49',
  1903. 'on':'\ud83d\udd1b',
  1904. 'oncoming_automobile':'\ud83d\ude98',
  1905. 'oncoming_bus':'\ud83d\ude8d',
  1906. 'oncoming_police_car':'\ud83d\ude94',
  1907. 'oncoming_taxi':'\ud83d\ude96',
  1908. 'open_file_folder':'\ud83d\udcc2',
  1909. 'open_hands':'\ud83d\udc50',
  1910. 'open_mouth':'\ud83d\ude2e',
  1911. 'open_umbrella':'\u2602\ufe0f',
  1912. 'ophiuchus':'\u26ce',
  1913. 'orange_book':'\ud83d\udcd9',
  1914. 'orthodox_cross':'\u2626\ufe0f',
  1915. 'outbox_tray':'\ud83d\udce4',
  1916. 'owl':'\ud83e\udd89',
  1917. 'ox':'\ud83d\udc02',
  1918. 'package':'\ud83d\udce6',
  1919. 'page_facing_up':'\ud83d\udcc4',
  1920. 'page_with_curl':'\ud83d\udcc3',
  1921. 'pager':'\ud83d\udcdf',
  1922. 'paintbrush':'\ud83d\udd8c',
  1923. 'palm_tree':'\ud83c\udf34',
  1924. 'pancakes':'\ud83e\udd5e',
  1925. 'panda_face':'\ud83d\udc3c',
  1926. 'paperclip':'\ud83d\udcce',
  1927. 'paperclips':'\ud83d\udd87',
  1928. 'parasol_on_ground':'\u26f1',
  1929. 'parking':'\ud83c\udd7f\ufe0f',
  1930. 'part_alternation_mark':'\u303d\ufe0f',
  1931. 'partly_sunny':'\u26c5\ufe0f',
  1932. 'passenger_ship':'\ud83d\udef3',
  1933. 'passport_control':'\ud83d\udec2',
  1934. 'pause_button':'\u23f8',
  1935. 'peace_symbol':'\u262e\ufe0f',
  1936. 'peach':'\ud83c\udf51',
  1937. 'peanuts':'\ud83e\udd5c',
  1938. 'pear':'\ud83c\udf50',
  1939. 'pen':'\ud83d\udd8a',
  1940. 'pencil2':'\u270f\ufe0f',
  1941. 'penguin':'\ud83d\udc27',
  1942. 'pensive':'\ud83d\ude14',
  1943. 'performing_arts':'\ud83c\udfad',
  1944. 'persevere':'\ud83d\ude23',
  1945. 'person_fencing':'\ud83e\udd3a',
  1946. 'pouting_woman':'\ud83d\ude4e',
  1947. 'phone':'\u260e\ufe0f',
  1948. 'pick':'\u26cf',
  1949. 'pig':'\ud83d\udc37',
  1950. 'pig2':'\ud83d\udc16',
  1951. 'pig_nose':'\ud83d\udc3d',
  1952. 'pill':'\ud83d\udc8a',
  1953. 'pineapple':'\ud83c\udf4d',
  1954. 'ping_pong':'\ud83c\udfd3',
  1955. 'pisces':'\u2653\ufe0f',
  1956. 'pizza':'\ud83c\udf55',
  1957. 'place_of_worship':'\ud83d\uded0',
  1958. 'plate_with_cutlery':'\ud83c\udf7d',
  1959. 'play_or_pause_button':'\u23ef',
  1960. 'point_down':'\ud83d\udc47',
  1961. 'point_left':'\ud83d\udc48',
  1962. 'point_right':'\ud83d\udc49',
  1963. 'point_up':'\u261d\ufe0f',
  1964. 'point_up_2':'\ud83d\udc46',
  1965. 'police_car':'\ud83d\ude93',
  1966. 'policewoman':'\ud83d\udc6e&zwj;\u2640\ufe0f',
  1967. 'poodle':'\ud83d\udc29',
  1968. 'popcorn':'\ud83c\udf7f',
  1969. 'post_office':'\ud83c\udfe3',
  1970. 'postal_horn':'\ud83d\udcef',
  1971. 'postbox':'\ud83d\udcee',
  1972. 'potable_water':'\ud83d\udeb0',
  1973. 'potato':'\ud83e\udd54',
  1974. 'pouch':'\ud83d\udc5d',
  1975. 'poultry_leg':'\ud83c\udf57',
  1976. 'pound':'\ud83d\udcb7',
  1977. 'rage':'\ud83d\ude21',
  1978. 'pouting_cat':'\ud83d\ude3e',
  1979. 'pouting_man':'\ud83d\ude4e&zwj;\u2642\ufe0f',
  1980. 'pray':'\ud83d\ude4f',
  1981. 'prayer_beads':'\ud83d\udcff',
  1982. 'pregnant_woman':'\ud83e\udd30',
  1983. 'previous_track_button':'\u23ee',
  1984. 'prince':'\ud83e\udd34',
  1985. 'princess':'\ud83d\udc78',
  1986. 'printer':'\ud83d\udda8',
  1987. 'purple_heart':'\ud83d\udc9c',
  1988. 'purse':'\ud83d\udc5b',
  1989. 'pushpin':'\ud83d\udccc',
  1990. 'put_litter_in_its_place':'\ud83d\udeae',
  1991. 'question':'\u2753',
  1992. 'rabbit':'\ud83d\udc30',
  1993. 'rabbit2':'\ud83d\udc07',
  1994. 'racehorse':'\ud83d\udc0e',
  1995. 'racing_car':'\ud83c\udfce',
  1996. 'radio':'\ud83d\udcfb',
  1997. 'radio_button':'\ud83d\udd18',
  1998. 'radioactive':'\u2622\ufe0f',
  1999. 'railway_car':'\ud83d\ude83',
  2000. 'railway_track':'\ud83d\udee4',
  2001. 'rainbow':'\ud83c\udf08',
  2002. 'rainbow_flag':'\ud83c\udff3\ufe0f&zwj;\ud83c\udf08',
  2003. 'raised_back_of_hand':'\ud83e\udd1a',
  2004. 'raised_hand_with_fingers_splayed':'\ud83d\udd90',
  2005. 'raised_hands':'\ud83d\ude4c',
  2006. 'raising_hand_woman':'\ud83d\ude4b',
  2007. 'raising_hand_man':'\ud83d\ude4b&zwj;\u2642\ufe0f',
  2008. 'ram':'\ud83d\udc0f',
  2009. 'ramen':'\ud83c\udf5c',
  2010. 'rat':'\ud83d\udc00',
  2011. 'record_button':'\u23fa',
  2012. 'recycle':'\u267b\ufe0f',
  2013. 'red_circle':'\ud83d\udd34',
  2014. 'registered':'\u00ae\ufe0f',
  2015. 'relaxed':'\u263a\ufe0f',
  2016. 'relieved':'\ud83d\ude0c',
  2017. 'reminder_ribbon':'\ud83c\udf97',
  2018. 'repeat':'\ud83d\udd01',
  2019. 'repeat_one':'\ud83d\udd02',
  2020. 'rescue_worker_helmet':'\u26d1',
  2021. 'restroom':'\ud83d\udebb',
  2022. 'revolving_hearts':'\ud83d\udc9e',
  2023. 'rewind':'\u23ea',
  2024. 'rhinoceros':'\ud83e\udd8f',
  2025. 'ribbon':'\ud83c\udf80',
  2026. 'rice':'\ud83c\udf5a',
  2027. 'rice_ball':'\ud83c\udf59',
  2028. 'rice_cracker':'\ud83c\udf58',
  2029. 'rice_scene':'\ud83c\udf91',
  2030. 'right_anger_bubble':'\ud83d\uddef',
  2031. 'ring':'\ud83d\udc8d',
  2032. 'robot':'\ud83e\udd16',
  2033. 'rocket':'\ud83d\ude80',
  2034. 'rofl':'\ud83e\udd23',
  2035. 'roll_eyes':'\ud83d\ude44',
  2036. 'roller_coaster':'\ud83c\udfa2',
  2037. 'rooster':'\ud83d\udc13',
  2038. 'rose':'\ud83c\udf39',
  2039. 'rosette':'\ud83c\udff5',
  2040. 'rotating_light':'\ud83d\udea8',
  2041. 'round_pushpin':'\ud83d\udccd',
  2042. 'rowing_man':'\ud83d\udea3',
  2043. 'rowing_woman':'\ud83d\udea3&zwj;\u2640\ufe0f',
  2044. 'rugby_football':'\ud83c\udfc9',
  2045. 'running_man':'\ud83c\udfc3',
  2046. 'running_shirt_with_sash':'\ud83c\udfbd',
  2047. 'running_woman':'\ud83c\udfc3&zwj;\u2640\ufe0f',
  2048. 'sa':'\ud83c\ude02\ufe0f',
  2049. 'sagittarius':'\u2650\ufe0f',
  2050. 'sake':'\ud83c\udf76',
  2051. 'sandal':'\ud83d\udc61',
  2052. 'santa':'\ud83c\udf85',
  2053. 'satellite':'\ud83d\udce1',
  2054. 'saxophone':'\ud83c\udfb7',
  2055. 'school':'\ud83c\udfeb',
  2056. 'school_satchel':'\ud83c\udf92',
  2057. 'scissors':'\u2702\ufe0f',
  2058. 'scorpion':'\ud83e\udd82',
  2059. 'scorpius':'\u264f\ufe0f',
  2060. 'scream':'\ud83d\ude31',
  2061. 'scream_cat':'\ud83d\ude40',
  2062. 'scroll':'\ud83d\udcdc',
  2063. 'seat':'\ud83d\udcba',
  2064. 'secret':'\u3299\ufe0f',
  2065. 'see_no_evil':'\ud83d\ude48',
  2066. 'seedling':'\ud83c\udf31',
  2067. 'selfie':'\ud83e\udd33',
  2068. 'shallow_pan_of_food':'\ud83e\udd58',
  2069. 'shamrock':'\u2618\ufe0f',
  2070. 'shark':'\ud83e\udd88',
  2071. 'shaved_ice':'\ud83c\udf67',
  2072. 'sheep':'\ud83d\udc11',
  2073. 'shell':'\ud83d\udc1a',
  2074. 'shield':'\ud83d\udee1',
  2075. 'shinto_shrine':'\u26e9',
  2076. 'ship':'\ud83d\udea2',
  2077. 'shirt':'\ud83d\udc55',
  2078. 'shopping':'\ud83d\udecd',
  2079. 'shopping_cart':'\ud83d\uded2',
  2080. 'shower':'\ud83d\udebf',
  2081. 'shrimp':'\ud83e\udd90',
  2082. 'signal_strength':'\ud83d\udcf6',
  2083. 'six_pointed_star':'\ud83d\udd2f',
  2084. 'ski':'\ud83c\udfbf',
  2085. 'skier':'\u26f7',
  2086. 'skull':'\ud83d\udc80',
  2087. 'skull_and_crossbones':'\u2620\ufe0f',
  2088. 'sleeping':'\ud83d\ude34',
  2089. 'sleeping_bed':'\ud83d\udecc',
  2090. 'sleepy':'\ud83d\ude2a',
  2091. 'slightly_frowning_face':'\ud83d\ude41',
  2092. 'slightly_smiling_face':'\ud83d\ude42',
  2093. 'slot_machine':'\ud83c\udfb0',
  2094. 'small_airplane':'\ud83d\udee9',
  2095. 'small_blue_diamond':'\ud83d\udd39',
  2096. 'small_orange_diamond':'\ud83d\udd38',
  2097. 'small_red_triangle':'\ud83d\udd3a',
  2098. 'small_red_triangle_down':'\ud83d\udd3b',
  2099. 'smile':'\ud83d\ude04',
  2100. 'smile_cat':'\ud83d\ude38',
  2101. 'smiley':'\ud83d\ude03',
  2102. 'smiley_cat':'\ud83d\ude3a',
  2103. 'smiling_imp':'\ud83d\ude08',
  2104. 'smirk':'\ud83d\ude0f',
  2105. 'smirk_cat':'\ud83d\ude3c',
  2106. 'smoking':'\ud83d\udeac',
  2107. 'snail':'\ud83d\udc0c',
  2108. 'snake':'\ud83d\udc0d',
  2109. 'sneezing_face':'\ud83e\udd27',
  2110. 'snowboarder':'\ud83c\udfc2',
  2111. 'snowflake':'\u2744\ufe0f',
  2112. 'snowman':'\u26c4\ufe0f',
  2113. 'snowman_with_snow':'\u2603\ufe0f',
  2114. 'sob':'\ud83d\ude2d',
  2115. 'soccer':'\u26bd\ufe0f',
  2116. 'soon':'\ud83d\udd1c',
  2117. 'sos':'\ud83c\udd98',
  2118. 'sound':'\ud83d\udd09',
  2119. 'space_invader':'\ud83d\udc7e',
  2120. 'spades':'\u2660\ufe0f',
  2121. 'spaghetti':'\ud83c\udf5d',
  2122. 'sparkle':'\u2747\ufe0f',
  2123. 'sparkler':'\ud83c\udf87',
  2124. 'sparkles':'\u2728',
  2125. 'sparkling_heart':'\ud83d\udc96',
  2126. 'speak_no_evil':'\ud83d\ude4a',
  2127. 'speaker':'\ud83d\udd08',
  2128. 'speaking_head':'\ud83d\udde3',
  2129. 'speech_balloon':'\ud83d\udcac',
  2130. 'speedboat':'\ud83d\udea4',
  2131. 'spider':'\ud83d\udd77',
  2132. 'spider_web':'\ud83d\udd78',
  2133. 'spiral_calendar':'\ud83d\uddd3',
  2134. 'spiral_notepad':'\ud83d\uddd2',
  2135. 'spoon':'\ud83e\udd44',
  2136. 'squid':'\ud83e\udd91',
  2137. 'stadium':'\ud83c\udfdf',
  2138. 'star':'\u2b50\ufe0f',
  2139. 'star2':'\ud83c\udf1f',
  2140. 'star_and_crescent':'\u262a\ufe0f',
  2141. 'star_of_david':'\u2721\ufe0f',
  2142. 'stars':'\ud83c\udf20',
  2143. 'station':'\ud83d\ude89',
  2144. 'statue_of_liberty':'\ud83d\uddfd',
  2145. 'steam_locomotive':'\ud83d\ude82',
  2146. 'stew':'\ud83c\udf72',
  2147. 'stop_button':'\u23f9',
  2148. 'stop_sign':'\ud83d\uded1',
  2149. 'stopwatch':'\u23f1',
  2150. 'straight_ruler':'\ud83d\udccf',
  2151. 'strawberry':'\ud83c\udf53',
  2152. 'stuck_out_tongue':'\ud83d\ude1b',
  2153. 'stuck_out_tongue_closed_eyes':'\ud83d\ude1d',
  2154. 'stuck_out_tongue_winking_eye':'\ud83d\ude1c',
  2155. 'studio_microphone':'\ud83c\udf99',
  2156. 'stuffed_flatbread':'\ud83e\udd59',
  2157. 'sun_behind_large_cloud':'\ud83c\udf25',
  2158. 'sun_behind_rain_cloud':'\ud83c\udf26',
  2159. 'sun_behind_small_cloud':'\ud83c\udf24',
  2160. 'sun_with_face':'\ud83c\udf1e',
  2161. 'sunflower':'\ud83c\udf3b',
  2162. 'sunglasses':'\ud83d\ude0e',
  2163. 'sunny':'\u2600\ufe0f',
  2164. 'sunrise':'\ud83c\udf05',
  2165. 'sunrise_over_mountains':'\ud83c\udf04',
  2166. 'surfing_man':'\ud83c\udfc4',
  2167. 'surfing_woman':'\ud83c\udfc4&zwj;\u2640\ufe0f',
  2168. 'sushi':'\ud83c\udf63',
  2169. 'suspension_railway':'\ud83d\ude9f',
  2170. 'sweat':'\ud83d\ude13',
  2171. 'sweat_drops':'\ud83d\udca6',
  2172. 'sweat_smile':'\ud83d\ude05',
  2173. 'sweet_potato':'\ud83c\udf60',
  2174. 'swimming_man':'\ud83c\udfca',
  2175. 'swimming_woman':'\ud83c\udfca&zwj;\u2640\ufe0f',
  2176. 'symbols':'\ud83d\udd23',
  2177. 'synagogue':'\ud83d\udd4d',
  2178. 'syringe':'\ud83d\udc89',
  2179. 'taco':'\ud83c\udf2e',
  2180. 'tada':'\ud83c\udf89',
  2181. 'tanabata_tree':'\ud83c\udf8b',
  2182. 'taurus':'\u2649\ufe0f',
  2183. 'taxi':'\ud83d\ude95',
  2184. 'tea':'\ud83c\udf75',
  2185. 'telephone_receiver':'\ud83d\udcde',
  2186. 'telescope':'\ud83d\udd2d',
  2187. 'tennis':'\ud83c\udfbe',
  2188. 'tent':'\u26fa\ufe0f',
  2189. 'thermometer':'\ud83c\udf21',
  2190. 'thinking':'\ud83e\udd14',
  2191. 'thought_balloon':'\ud83d\udcad',
  2192. 'ticket':'\ud83c\udfab',
  2193. 'tickets':'\ud83c\udf9f',
  2194. 'tiger':'\ud83d\udc2f',
  2195. 'tiger2':'\ud83d\udc05',
  2196. 'timer_clock':'\u23f2',
  2197. 'tipping_hand_man':'\ud83d\udc81&zwj;\u2642\ufe0f',
  2198. 'tired_face':'\ud83d\ude2b',
  2199. 'tm':'\u2122\ufe0f',
  2200. 'toilet':'\ud83d\udebd',
  2201. 'tokyo_tower':'\ud83d\uddfc',
  2202. 'tomato':'\ud83c\udf45',
  2203. 'tongue':'\ud83d\udc45',
  2204. 'top':'\ud83d\udd1d',
  2205. 'tophat':'\ud83c\udfa9',
  2206. 'tornado':'\ud83c\udf2a',
  2207. 'trackball':'\ud83d\uddb2',
  2208. 'tractor':'\ud83d\ude9c',
  2209. 'traffic_light':'\ud83d\udea5',
  2210. 'train':'\ud83d\ude8b',
  2211. 'train2':'\ud83d\ude86',
  2212. 'tram':'\ud83d\ude8a',
  2213. 'triangular_flag_on_post':'\ud83d\udea9',
  2214. 'triangular_ruler':'\ud83d\udcd0',
  2215. 'trident':'\ud83d\udd31',
  2216. 'triumph':'\ud83d\ude24',
  2217. 'trolleybus':'\ud83d\ude8e',
  2218. 'trophy':'\ud83c\udfc6',
  2219. 'tropical_drink':'\ud83c\udf79',
  2220. 'tropical_fish':'\ud83d\udc20',
  2221. 'truck':'\ud83d\ude9a',
  2222. 'trumpet':'\ud83c\udfba',
  2223. 'tulip':'\ud83c\udf37',
  2224. 'tumbler_glass':'\ud83e\udd43',
  2225. 'turkey':'\ud83e\udd83',
  2226. 'turtle':'\ud83d\udc22',
  2227. 'tv':'\ud83d\udcfa',
  2228. 'twisted_rightwards_arrows':'\ud83d\udd00',
  2229. 'two_hearts':'\ud83d\udc95',
  2230. 'two_men_holding_hands':'\ud83d\udc6c',
  2231. 'two_women_holding_hands':'\ud83d\udc6d',
  2232. 'u5272':'\ud83c\ude39',
  2233. 'u5408':'\ud83c\ude34',
  2234. 'u55b6':'\ud83c\ude3a',
  2235. 'u6307':'\ud83c\ude2f\ufe0f',
  2236. 'u6708':'\ud83c\ude37\ufe0f',
  2237. 'u6709':'\ud83c\ude36',
  2238. 'u6e80':'\ud83c\ude35',
  2239. 'u7121':'\ud83c\ude1a\ufe0f',
  2240. 'u7533':'\ud83c\ude38',
  2241. 'u7981':'\ud83c\ude32',
  2242. 'u7a7a':'\ud83c\ude33',
  2243. 'umbrella':'\u2614\ufe0f',
  2244. 'unamused':'\ud83d\ude12',
  2245. 'underage':'\ud83d\udd1e',
  2246. 'unicorn':'\ud83e\udd84',
  2247. 'unlock':'\ud83d\udd13',
  2248. 'up':'\ud83c\udd99',
  2249. 'upside_down_face':'\ud83d\ude43',
  2250. 'v':'\u270c\ufe0f',
  2251. 'vertical_traffic_light':'\ud83d\udea6',
  2252. 'vhs':'\ud83d\udcfc',
  2253. 'vibration_mode':'\ud83d\udcf3',
  2254. 'video_camera':'\ud83d\udcf9',
  2255. 'video_game':'\ud83c\udfae',
  2256. 'violin':'\ud83c\udfbb',
  2257. 'virgo':'\u264d\ufe0f',
  2258. 'volcano':'\ud83c\udf0b',
  2259. 'volleyball':'\ud83c\udfd0',
  2260. 'vs':'\ud83c\udd9a',
  2261. 'vulcan_salute':'\ud83d\udd96',
  2262. 'walking_man':'\ud83d\udeb6',
  2263. 'walking_woman':'\ud83d\udeb6&zwj;\u2640\ufe0f',
  2264. 'waning_crescent_moon':'\ud83c\udf18',
  2265. 'waning_gibbous_moon':'\ud83c\udf16',
  2266. 'warning':'\u26a0\ufe0f',
  2267. 'wastebasket':'\ud83d\uddd1',
  2268. 'watch':'\u231a\ufe0f',
  2269. 'water_buffalo':'\ud83d\udc03',
  2270. 'watermelon':'\ud83c\udf49',
  2271. 'wave':'\ud83d\udc4b',
  2272. 'wavy_dash':'\u3030\ufe0f',
  2273. 'waxing_crescent_moon':'\ud83c\udf12',
  2274. 'wc':'\ud83d\udebe',
  2275. 'weary':'\ud83d\ude29',
  2276. 'wedding':'\ud83d\udc92',
  2277. 'weight_lifting_man':'\ud83c\udfcb\ufe0f',
  2278. 'weight_lifting_woman':'\ud83c\udfcb\ufe0f&zwj;\u2640\ufe0f',
  2279. 'whale':'\ud83d\udc33',
  2280. 'whale2':'\ud83d\udc0b',
  2281. 'wheel_of_dharma':'\u2638\ufe0f',
  2282. 'wheelchair':'\u267f\ufe0f',
  2283. 'white_check_mark':'\u2705',
  2284. 'white_circle':'\u26aa\ufe0f',
  2285. 'white_flag':'\ud83c\udff3\ufe0f',
  2286. 'white_flower':'\ud83d\udcae',
  2287. 'white_large_square':'\u2b1c\ufe0f',
  2288. 'white_medium_small_square':'\u25fd\ufe0f',
  2289. 'white_medium_square':'\u25fb\ufe0f',
  2290. 'white_small_square':'\u25ab\ufe0f',
  2291. 'white_square_button':'\ud83d\udd33',
  2292. 'wilted_flower':'\ud83e\udd40',
  2293. 'wind_chime':'\ud83c\udf90',
  2294. 'wind_face':'\ud83c\udf2c',
  2295. 'wine_glass':'\ud83c\udf77',
  2296. 'wink':'\ud83d\ude09',
  2297. 'wolf':'\ud83d\udc3a',
  2298. 'woman':'\ud83d\udc69',
  2299. 'woman_artist':'\ud83d\udc69&zwj;\ud83c\udfa8',
  2300. 'woman_astronaut':'\ud83d\udc69&zwj;\ud83d\ude80',
  2301. 'woman_cartwheeling':'\ud83e\udd38&zwj;\u2640\ufe0f',
  2302. 'woman_cook':'\ud83d\udc69&zwj;\ud83c\udf73',
  2303. 'woman_facepalming':'\ud83e\udd26&zwj;\u2640\ufe0f',
  2304. 'woman_factory_worker':'\ud83d\udc69&zwj;\ud83c\udfed',
  2305. 'woman_farmer':'\ud83d\udc69&zwj;\ud83c\udf3e',
  2306. 'woman_firefighter':'\ud83d\udc69&zwj;\ud83d\ude92',
  2307. 'woman_health_worker':'\ud83d\udc69&zwj;\u2695\ufe0f',
  2308. 'woman_judge':'\ud83d\udc69&zwj;\u2696\ufe0f',
  2309. 'woman_juggling':'\ud83e\udd39&zwj;\u2640\ufe0f',
  2310. 'woman_mechanic':'\ud83d\udc69&zwj;\ud83d\udd27',
  2311. 'woman_office_worker':'\ud83d\udc69&zwj;\ud83d\udcbc',
  2312. 'woman_pilot':'\ud83d\udc69&zwj;\u2708\ufe0f',
  2313. 'woman_playing_handball':'\ud83e\udd3e&zwj;\u2640\ufe0f',
  2314. 'woman_playing_water_polo':'\ud83e\udd3d&zwj;\u2640\ufe0f',
  2315. 'woman_scientist':'\ud83d\udc69&zwj;\ud83d\udd2c',
  2316. 'woman_shrugging':'\ud83e\udd37&zwj;\u2640\ufe0f',
  2317. 'woman_singer':'\ud83d\udc69&zwj;\ud83c\udfa4',
  2318. 'woman_student':'\ud83d\udc69&zwj;\ud83c\udf93',
  2319. 'woman_teacher':'\ud83d\udc69&zwj;\ud83c\udfeb',
  2320. 'woman_technologist':'\ud83d\udc69&zwj;\ud83d\udcbb',
  2321. 'woman_with_turban':'\ud83d\udc73&zwj;\u2640\ufe0f',
  2322. 'womans_clothes':'\ud83d\udc5a',
  2323. 'womans_hat':'\ud83d\udc52',
  2324. 'women_wrestling':'\ud83e\udd3c&zwj;\u2640\ufe0f',
  2325. 'womens':'\ud83d\udeba',
  2326. 'world_map':'\ud83d\uddfa',
  2327. 'worried':'\ud83d\ude1f',
  2328. 'wrench':'\ud83d\udd27',
  2329. 'writing_hand':'\u270d\ufe0f',
  2330. 'x':'\u274c',
  2331. 'yellow_heart':'\ud83d\udc9b',
  2332. 'yen':'\ud83d\udcb4',
  2333. 'yin_yang':'\u262f\ufe0f',
  2334. 'yum':'\ud83d\ude0b',
  2335. 'zap':'\u26a1\ufe0f',
  2336. 'zipper_mouth_face':'\ud83e\udd10',
  2337. 'zzz':'\ud83d\udca4',
  2338. /* special emojis :P */
  2339. 'octocat': '<img width="20" height="20" align="absmiddle" src="https://assets-cdn.github.com/images/icons/emoji/octocat.png">',
  2340. 'showdown': '<img width="20" height="20" align="absmiddle" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAS1BMVEX///8jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS3b1q3b1q3b1q3b1q3b1q3b1q3b1q3b1q0565CIAAAAGXRSTlMAQHCAYCCw/+DQwPCQUBAwoHCAEP+wwFBgS2fvBgAAAUZJREFUeAHs1cGy7BAUheFFsEDw/k97VTq3T6ge2EmdM+pvrP6Iwd74XV9Kb52xuMU4/uc1YNgZLFOeV8FGdhGrNk5SEgUyPxAEdj4LlMRDyhVAMVEa2M7TBSeVZAFPdqHgzSZJwPKgcLFLAooHDJo4EDCw4gAtBoJA5UFj4Ng5LOGLwVXZuoIlji/jeQHFk7+baHxrCjeUwB9+s88KndvlhcyBN5BSkYNQIVVb4pV+Npm7hhuKDs/uMP5KxT3WzSNNLIuuoDpMmuAVMruMSeDyQBi24DTr43LAY7ILA1QYaWkgfHzFthYYzg67SQsCbB8GhJUEGCtO9n0rSaCLxgJQjS/JSgMTg2eBDEHAJ+H350AsjYNYscrErgI2e/l+mdR967TCX/v6N0EhPECYCP0i+IAoYQOE8BogNhQMEMdrgAQWHaMAAGi5I5euoY9NAAAAAElFTkSuQmCC">'
  2341. };
  2342. /**
  2343. * These are all the transformations that form block-level
  2344. * tags like paragraphs, headers, and list items.
  2345. */
  2346. showdown.subParser('makehtml.blockGamut', function (text, options, globals) {
  2347. 'use strict';
  2348. text = globals.converter._dispatch('makehtml.blockGamut.before', text, options, globals).getText();
  2349. // we parse blockquotes first so that we can have headings and hrs
  2350. // inside blockquotes
  2351. text = showdown.subParser('makehtml.blockQuotes')(text, options, globals);
  2352. text = showdown.subParser('makehtml.headers')(text, options, globals);
  2353. // Do Horizontal Rules:
  2354. text = showdown.subParser('makehtml.horizontalRule')(text, options, globals);
  2355. text = showdown.subParser('makehtml.lists')(text, options, globals);
  2356. text = showdown.subParser('makehtml.codeBlocks')(text, options, globals);
  2357. text = showdown.subParser('makehtml.tables')(text, options, globals);
  2358. // We already ran _HashHTMLBlocks() before, in Markdown(), but that
  2359. // was to escape raw HTML in the original Markdown source. This time,
  2360. // we're escaping the markup we've just created, so that we don't wrap
  2361. // <p> tags around block-level tags.
  2362. text = showdown.subParser('makehtml.hashHTMLBlocks')(text, options, globals);
  2363. text = showdown.subParser('makehtml.paragraphs')(text, options, globals);
  2364. text = globals.converter._dispatch('makehtml.blockGamut.after', text, options, globals).getText();
  2365. return text;
  2366. });
  2367. showdown.subParser('makehtml.blockQuotes', function (text, options, globals) {
  2368. 'use strict';
  2369. text = globals.converter._dispatch('makehtml.blockQuotes.before', text, options, globals).getText();
  2370. // add a couple extra lines after the text and endtext mark
  2371. text = text + '\n\n';
  2372. var rgx = /(^ {0,3}>[ \t]?.+\n(.+\n)*\n*)+/gm;
  2373. if (options.splitAdjacentBlockquotes) {
  2374. rgx = /^ {0,3}>[\s\S]*?(?:\n\n)/gm;
  2375. }
  2376. text = text.replace(rgx, function (bq) {
  2377. // attacklab: hack around Konqueror 3.5.4 bug:
  2378. // "----------bug".replace(/^-/g,"") == "bug"
  2379. bq = bq.replace(/^[ \t]*>[ \t]?/gm, ''); // trim one level of quoting
  2380. // attacklab: clean up hack
  2381. bq = bq.replace(/¨0/g, '');
  2382. bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines
  2383. bq = showdown.subParser('makehtml.githubCodeBlocks')(bq, options, globals);
  2384. bq = showdown.subParser('makehtml.blockGamut')(bq, options, globals); // recurse
  2385. bq = bq.replace(/(^|\n)/g, '$1 ');
  2386. // These leading spaces screw with <pre> content, so we need to fix that:
  2387. bq = bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm, function (wholeMatch, m1) {
  2388. var pre = m1;
  2389. // attacklab: hack around Konqueror 3.5.4 bug:
  2390. pre = pre.replace(/^ /mg, '¨0');
  2391. pre = pre.replace(/¨0/g, '');
  2392. return pre;
  2393. });
  2394. return showdown.subParser('makehtml.hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals);
  2395. });
  2396. text = globals.converter._dispatch('makehtml.blockQuotes.after', text, options, globals).getText();
  2397. return text;
  2398. });
  2399. /**
  2400. * Process Markdown `<pre><code>` blocks.
  2401. */
  2402. showdown.subParser('makehtml.codeBlocks', function (text, options, globals) {
  2403. 'use strict';
  2404. text = globals.converter._dispatch('makehtml.codeBlocks.before', text, options, globals).getText();
  2405. // sentinel workarounds for lack of \A and \Z, safari\khtml bug
  2406. text += '¨0';
  2407. var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=¨0))/g;
  2408. text = text.replace(pattern, function (wholeMatch, m1, m2) {
  2409. var codeblock = m1,
  2410. nextChar = m2,
  2411. end = '\n';
  2412. codeblock = showdown.subParser('makehtml.outdent')(codeblock, options, globals);
  2413. codeblock = showdown.subParser('makehtml.encodeCode')(codeblock, options, globals);
  2414. codeblock = showdown.subParser('makehtml.detab')(codeblock, options, globals);
  2415. codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
  2416. codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing newlines
  2417. if (options.omitExtraWLInCodeBlocks) {
  2418. end = '';
  2419. }
  2420. codeblock = '<pre><code>' + codeblock + end + '</code></pre>';
  2421. return showdown.subParser('makehtml.hashBlock')(codeblock, options, globals) + nextChar;
  2422. });
  2423. // strip sentinel
  2424. text = text.replace(/¨0/, '');
  2425. text = globals.converter._dispatch('makehtml.codeBlocks.after', text, options, globals).getText();
  2426. return text;
  2427. });
  2428. /**
  2429. *
  2430. * * Backtick quotes are used for <code></code> spans.
  2431. *
  2432. * * You can use multiple backticks as the delimiters if you want to
  2433. * include literal backticks in the code span. So, this input:
  2434. *
  2435. * Just type ``foo `bar` baz`` at the prompt.
  2436. *
  2437. * Will translate to:
  2438. *
  2439. * <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
  2440. *
  2441. * There's no arbitrary limit to the number of backticks you
  2442. * can use as delimters. If you need three consecutive backticks
  2443. * in your code, use four for delimiters, etc.
  2444. *
  2445. * * You can use spaces to get literal backticks at the edges:
  2446. *
  2447. * ... type `` `bar` `` ...
  2448. *
  2449. * Turns to:
  2450. *
  2451. * ... type <code>`bar`</code> ...
  2452. */
  2453. showdown.subParser('makehtml.codeSpans', function (text, options, globals) {
  2454. 'use strict';
  2455. text = globals.converter._dispatch('makehtml.codeSpans.before', text, options, globals).getText();
  2456. if (typeof(text) === 'undefined') {
  2457. text = '';
  2458. }
  2459. text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
  2460. function (wholeMatch, m1, m2, m3) {
  2461. var c = m3;
  2462. c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
  2463. c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
  2464. c = showdown.subParser('makehtml.encodeCode')(c, options, globals);
  2465. c = m1 + '<code>' + c + '</code>';
  2466. c = showdown.subParser('makehtml.hashHTMLSpans')(c, options, globals);
  2467. return c;
  2468. }
  2469. );
  2470. text = globals.converter._dispatch('makehtml.codeSpans.after', text, options, globals).getText();
  2471. return text;
  2472. });
  2473. /**
  2474. * Create a full HTML document from the processed markdown
  2475. */
  2476. showdown.subParser('makehtml.completeHTMLDocument', function (text, options, globals) {
  2477. 'use strict';
  2478. if (!options.completeHTMLDocument) {
  2479. return text;
  2480. }
  2481. text = globals.converter._dispatch('makehtml.completeHTMLDocument.before', text, options, globals).getText();
  2482. var doctype = 'html',
  2483. doctypeParsed = '<!DOCTYPE HTML>\n',
  2484. title = '',
  2485. charset = '<meta charset="utf-8">\n',
  2486. lang = '',
  2487. metadata = '';
  2488. if (typeof globals.metadata.parsed.doctype !== 'undefined') {
  2489. doctypeParsed = '<!DOCTYPE ' + globals.metadata.parsed.doctype + '>\n';
  2490. doctype = globals.metadata.parsed.doctype.toString().toLowerCase();
  2491. if (doctype === 'html' || doctype === 'html5') {
  2492. charset = '<meta charset="utf-8">';
  2493. }
  2494. }
  2495. for (var meta in globals.metadata.parsed) {
  2496. if (globals.metadata.parsed.hasOwnProperty(meta)) {
  2497. switch (meta.toLowerCase()) {
  2498. case 'doctype':
  2499. break;
  2500. case 'title':
  2501. title = '<title>' + globals.metadata.parsed.title + '</title>\n';
  2502. break;
  2503. case 'charset':
  2504. if (doctype === 'html' || doctype === 'html5') {
  2505. charset = '<meta charset="' + globals.metadata.parsed.charset + '">\n';
  2506. } else {
  2507. charset = '<meta name="charset" content="' + globals.metadata.parsed.charset + '">\n';
  2508. }
  2509. break;
  2510. case 'language':
  2511. case 'lang':
  2512. lang = ' lang="' + globals.metadata.parsed[meta] + '"';
  2513. metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n';
  2514. break;
  2515. default:
  2516. metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n';
  2517. }
  2518. }
  2519. }
  2520. text = doctypeParsed + '<html' + lang + '>\n<head>\n' + title + charset + metadata + '</head>\n<body>\n' + text.trim() + '\n</body>\n</html>';
  2521. text = globals.converter._dispatch('makehtml.completeHTMLDocument.after', text, options, globals).getText();
  2522. return text;
  2523. });
  2524. /**
  2525. * Convert all tabs to spaces
  2526. */
  2527. showdown.subParser('makehtml.detab', function (text, options, globals) {
  2528. 'use strict';
  2529. text = globals.converter._dispatch('makehtml.detab.before', text, options, globals).getText();
  2530. // expand first n-1 tabs
  2531. text = text.replace(/\t(?=\t)/g, ' '); // g_tab_width
  2532. // replace the nth with two sentinels
  2533. text = text.replace(/\t/g, '¨A¨B');
  2534. // use the sentinel to anchor our regex so it doesn't explode
  2535. text = text.replace(/¨B(.+?)¨A/g, function (wholeMatch, m1) {
  2536. var leadingText = m1,
  2537. numSpaces = 4 - leadingText.length % 4; // g_tab_width
  2538. // there *must* be a better way to do this:
  2539. for (var i = 0; i < numSpaces; i++) {
  2540. leadingText += ' ';
  2541. }
  2542. return leadingText;
  2543. });
  2544. // clean up sentinels
  2545. text = text.replace(/¨A/g, ' '); // g_tab_width
  2546. text = text.replace(/¨B/g, '');
  2547. text = globals.converter._dispatch('makehtml.detab.after', text, options, globals).getText();
  2548. return text;
  2549. });
  2550. showdown.subParser('makehtml.ellipsis', function (text, options, globals) {
  2551. 'use strict';
  2552. text = globals.converter._dispatch('makehtml.ellipsis.before', text, options, globals).getText();
  2553. text = text.replace(/\.\.\./g, '…');
  2554. text = globals.converter._dispatch('makehtml.ellipsis.after', text, options, globals).getText();
  2555. return text;
  2556. });
  2557. /**
  2558. * These are all the transformations that occur *within* block-level
  2559. * tags like paragraphs, headers, and list items.
  2560. */
  2561. showdown.subParser('makehtml.emoji', function (text, options, globals) {
  2562. 'use strict';
  2563. if (!options.emoji) {
  2564. return text;
  2565. }
  2566. text = globals.converter._dispatch('makehtml.emoji.before', text, options, globals).getText();
  2567. var emojiRgx = /:([\S]+?):/g;
  2568. text = text.replace(emojiRgx, function (wm, emojiCode) {
  2569. if (showdown.helper.emojis.hasOwnProperty(emojiCode)) {
  2570. return showdown.helper.emojis[emojiCode];
  2571. }
  2572. return wm;
  2573. });
  2574. text = globals.converter._dispatch('makehtml.emoji.after', text, options, globals).getText();
  2575. return text;
  2576. });
  2577. /**
  2578. * Smart processing for ampersands and angle brackets that need to be encoded.
  2579. */
  2580. showdown.subParser('makehtml.encodeAmpsAndAngles', function (text, options, globals) {
  2581. 'use strict';
  2582. text = globals.converter._dispatch('makehtml.encodeAmpsAndAngles.before', text, options, globals).getText();
  2583. // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
  2584. // http://bumppo.net/projects/amputator/
  2585. text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, '&amp;');
  2586. // Encode naked <'s
  2587. text = text.replace(/<(?![a-z\/?$!])/gi, '&lt;');
  2588. // Encode <
  2589. text = text.replace(/</g, '&lt;');
  2590. // Encode >
  2591. text = text.replace(/>/g, '&gt;');
  2592. text = globals.converter._dispatch('makehtml.encodeAmpsAndAngles.after', text, options, globals).getText();
  2593. return text;
  2594. });
  2595. /**
  2596. * Returns the string, with after processing the following backslash escape sequences.
  2597. *
  2598. * attacklab: The polite way to do this is with the new escapeCharacters() function:
  2599. *
  2600. * text = escapeCharacters(text,"\\",true);
  2601. * text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
  2602. *
  2603. * ...but we're sidestepping its use of the (slow) RegExp constructor
  2604. * as an optimization for Firefox. This function gets called a LOT.
  2605. */
  2606. showdown.subParser('makehtml.encodeBackslashEscapes', function (text, options, globals) {
  2607. 'use strict';
  2608. text = globals.converter._dispatch('makehtml.encodeBackslashEscapes.before', text, options, globals).getText();
  2609. text = text.replace(/\\(\\)/g, showdown.helper.escapeCharactersCallback);
  2610. text = text.replace(/\\([`*_{}\[\]()>#+.!~=|:-])/g, showdown.helper.escapeCharactersCallback);
  2611. text = globals.converter._dispatch('makehtml.encodeBackslashEscapes.after', text, options, globals).getText();
  2612. return text;
  2613. });
  2614. /**
  2615. * Encode/escape certain characters inside Markdown code runs.
  2616. * The point is that in code, these characters are literals,
  2617. * and lose their special Markdown meanings.
  2618. */
  2619. showdown.subParser('makehtml.encodeCode', function (text, options, globals) {
  2620. 'use strict';
  2621. text = globals.converter._dispatch('makehtml.encodeCode.before', text, options, globals).getText();
  2622. // Encode all ampersands; HTML entities are not
  2623. // entities within a Markdown code span.
  2624. text = text
  2625. .replace(/&/g, '&amp;')
  2626. // Do the angle bracket song and dance:
  2627. .replace(/</g, '&lt;')
  2628. .replace(/>/g, '&gt;')
  2629. // Now, escape characters that are magic in Markdown:
  2630. .replace(/([*_{}\[\]\\=~-])/g, showdown.helper.escapeCharactersCallback);
  2631. text = globals.converter._dispatch('makehtml.encodeCode.after', text, options, globals).getText();
  2632. return text;
  2633. });
  2634. /**
  2635. * Within tags -- meaning between < and > -- encode [\ ` * _ ~ =] so they
  2636. * don't conflict with their use in Markdown for code, italics and strong.
  2637. */
  2638. showdown.subParser('makehtml.escapeSpecialCharsWithinTagAttributes', function (text, options, globals) {
  2639. 'use strict';
  2640. text = globals.converter._dispatch('makehtml.escapeSpecialCharsWithinTagAttributes.before', text, options, globals).getText();
  2641. // Build a regex to find HTML tags.
  2642. var tags = /<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi,
  2643. comments = /<!(--(?:(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>/gi;
  2644. text = text.replace(tags, function (wholeMatch) {
  2645. return wholeMatch
  2646. .replace(/(.)<\/?code>(?=.)/g, '$1`')
  2647. .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
  2648. });
  2649. text = text.replace(comments, function (wholeMatch) {
  2650. return wholeMatch
  2651. .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
  2652. });
  2653. text = globals.converter._dispatch('makehtml.escapeSpecialCharsWithinTagAttributes.after', text, options, globals).getText();
  2654. return text;
  2655. });
  2656. /**
  2657. * Handle github codeblocks prior to running HashHTML so that
  2658. * HTML contained within the codeblock gets escaped properly
  2659. * Example:
  2660. * ```ruby
  2661. * def hello_world(x)
  2662. * puts "Hello, #{x}"
  2663. * end
  2664. * ```
  2665. */
  2666. showdown.subParser('makehtml.githubCodeBlocks', function (text, options, globals) {
  2667. 'use strict';
  2668. // early exit if option is not enabled
  2669. if (!options.ghCodeBlocks) {
  2670. return text;
  2671. }
  2672. text = globals.converter._dispatch('makehtml.githubCodeBlocks.before', text, options, globals).getText();
  2673. text += '¨0';
  2674. text = text.replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g, function (wholeMatch, delim, language, codeblock) {
  2675. var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';
  2676. // First parse the github code block
  2677. codeblock = showdown.subParser('makehtml.encodeCode')(codeblock, options, globals);
  2678. codeblock = showdown.subParser('makehtml.detab')(codeblock, options, globals);
  2679. codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
  2680. codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
  2681. codeblock = '<pre><code' + (language ? ' class="' + language + ' language-' + language + '"' : '') + '>' + codeblock + end + '</code></pre>';
  2682. codeblock = showdown.subParser('makehtml.hashBlock')(codeblock, options, globals);
  2683. // Since GHCodeblocks can be false positives, we need to
  2684. // store the primitive text and the parsed text in a global var,
  2685. // and then return a token
  2686. return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
  2687. });
  2688. // attacklab: strip sentinel
  2689. text = text.replace(/¨0/, '');
  2690. return globals.converter._dispatch('makehtml.githubCodeBlocks.after', text, options, globals).getText();
  2691. });
  2692. showdown.subParser('makehtml.hashBlock', function (text, options, globals) {
  2693. 'use strict';
  2694. text = globals.converter._dispatch('makehtml.hashBlock.before', text, options, globals).getText();
  2695. text = text.replace(/(^\n+|\n+$)/g, '');
  2696. text = '\n\n¨K' + (globals.gHtmlBlocks.push(text) - 1) + 'K\n\n';
  2697. text = globals.converter._dispatch('makehtml.hashBlock.after', text, options, globals).getText();
  2698. return text;
  2699. });
  2700. /**
  2701. * Hash and escape <code> elements that should not be parsed as markdown
  2702. */
  2703. showdown.subParser('makehtml.hashCodeTags', function (text, options, globals) {
  2704. 'use strict';
  2705. text = globals.converter._dispatch('makehtml.hashCodeTags.before', text, options, globals).getText();
  2706. var repFunc = function (wholeMatch, match, left, right) {
  2707. var codeblock = left + showdown.subParser('makehtml.encodeCode')(match, options, globals) + right;
  2708. return '¨C' + (globals.gHtmlSpans.push(codeblock) - 1) + 'C';
  2709. };
  2710. // Hash naked <code>
  2711. text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '<code\\b[^>]*>', '</code>', 'gim');
  2712. text = globals.converter._dispatch('makehtml.hashCodeTags.after', text, options, globals).getText();
  2713. return text;
  2714. });
  2715. showdown.subParser('makehtml.hashElement', function (text, options, globals) {
  2716. 'use strict';
  2717. return function (wholeMatch, m1) {
  2718. var blockText = m1;
  2719. // Undo double lines
  2720. blockText = blockText.replace(/\n\n/g, '\n');
  2721. blockText = blockText.replace(/^\n/, '');
  2722. // strip trailing blank lines
  2723. blockText = blockText.replace(/\n+$/g, '');
  2724. // Replace the element text with a marker ("¨KxK" where x is its key)
  2725. blockText = '\n\n¨K' + (globals.gHtmlBlocks.push(blockText) - 1) + 'K\n\n';
  2726. return blockText;
  2727. };
  2728. });
  2729. showdown.subParser('makehtml.hashHTMLBlocks', function (text, options, globals) {
  2730. 'use strict';
  2731. text = globals.converter._dispatch('makehtml.hashHTMLBlocks.before', text, options, globals).getText();
  2732. var blockTags = [
  2733. 'pre',
  2734. 'div',
  2735. 'h1',
  2736. 'h2',
  2737. 'h3',
  2738. 'h4',
  2739. 'h5',
  2740. 'h6',
  2741. 'blockquote',
  2742. 'table',
  2743. 'dl',
  2744. 'ol',
  2745. 'ul',
  2746. 'script',
  2747. 'noscript',
  2748. 'form',
  2749. 'fieldset',
  2750. 'iframe',
  2751. 'math',
  2752. 'style',
  2753. 'section',
  2754. 'header',
  2755. 'footer',
  2756. 'nav',
  2757. 'article',
  2758. 'aside',
  2759. 'address',
  2760. 'audio',
  2761. 'canvas',
  2762. 'figure',
  2763. 'hgroup',
  2764. 'output',
  2765. 'video',
  2766. 'p'
  2767. ],
  2768. repFunc = function (wholeMatch, match, left, right) {
  2769. var txt = wholeMatch;
  2770. // check if this html element is marked as markdown
  2771. // if so, it's contents should be parsed as markdown
  2772. if (left.search(/\bmarkdown\b/) !== -1) {
  2773. txt = left + globals.converter.makeHtml(match) + right;
  2774. }
  2775. return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
  2776. };
  2777. if (options.backslashEscapesHTMLTags) {
  2778. // encode backslash escaped HTML tags
  2779. text = text.replace(/\\<(\/?[^>]+?)>/g, function (wm, inside) {
  2780. return '&lt;' + inside + '&gt;';
  2781. });
  2782. }
  2783. // hash HTML Blocks
  2784. for (var i = 0; i < blockTags.length; ++i) {
  2785. var opTagPos,
  2786. rgx1 = new RegExp('^ {0,3}(<' + blockTags[i] + '\\b[^>]*>)', 'im'),
  2787. patLeft = '<' + blockTags[i] + '\\b[^>]*>',
  2788. patRight = '</' + blockTags[i] + '>';
  2789. // 1. Look for the first position of the first opening HTML tag in the text
  2790. while ((opTagPos = showdown.helper.regexIndexOf(text, rgx1)) !== -1) {
  2791. // if the HTML tag is \ escaped, we need to escape it and break
  2792. //2. Split the text in that position
  2793. var subTexts = showdown.helper.splitAtIndex(text, opTagPos),
  2794. //3. Match recursively
  2795. newSubText1 = showdown.helper.replaceRecursiveRegExp(subTexts[1], repFunc, patLeft, patRight, 'im');
  2796. // prevent an infinite loop
  2797. if (newSubText1 === subTexts[1]) {
  2798. break;
  2799. }
  2800. text = subTexts[0].concat(newSubText1);
  2801. }
  2802. }
  2803. // HR SPECIAL CASE
  2804. text = text.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,
  2805. showdown.subParser('makehtml.hashElement')(text, options, globals));
  2806. // Special case for standalone HTML comments
  2807. text = showdown.helper.replaceRecursiveRegExp(text, function (txt) {
  2808. return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
  2809. }, '^ {0,3}<!--', '-->', 'gm');
  2810. // PHP and ASP-style processor instructions (<?...?> and <%...%>)
  2811. text = text.replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,
  2812. showdown.subParser('makehtml.hashElement')(text, options, globals));
  2813. text = globals.converter._dispatch('makehtml.hashHTMLBlocks.after', text, options, globals).getText();
  2814. return text;
  2815. });
  2816. /**
  2817. * Hash span elements that should not be parsed as markdown
  2818. */
  2819. showdown.subParser('makehtml.hashHTMLSpans', function (text, options, globals) {
  2820. 'use strict';
  2821. text = globals.converter._dispatch('makehtml.hashHTMLSpans.before', text, options, globals).getText();
  2822. // Hash Self Closing tags
  2823. text = text.replace(/<[^>]+?\/>/gi, function (wm) {
  2824. return showdown.helper._hashHTMLSpan(wm, globals);
  2825. });
  2826. // Hash tags without properties
  2827. text = text.replace(/<([^>]+?)>[\s\S]*?<\/\1>/g, function (wm) {
  2828. return showdown.helper._hashHTMLSpan(wm, globals);
  2829. });
  2830. // Hash tags with properties
  2831. text = text.replace(/<([^>]+?)\s[^>]+?>[\s\S]*?<\/\1>/g, function (wm) {
  2832. return showdown.helper._hashHTMLSpan(wm, globals);
  2833. });
  2834. // Hash self closing tags without />
  2835. text = text.replace(/<[^>]+?>/gi, function (wm) {
  2836. return showdown.helper._hashHTMLSpan(wm, globals);
  2837. });
  2838. text = globals.converter._dispatch('makehtml.hashHTMLSpans.after', text, options, globals).getText();
  2839. return text;
  2840. });
  2841. /**
  2842. * Unhash HTML spans
  2843. */
  2844. showdown.subParser('makehtml.unhashHTMLSpans', function (text, options, globals) {
  2845. 'use strict';
  2846. text = globals.converter._dispatch('makehtml.unhashHTMLSpans.before', text, options, globals).getText();
  2847. for (var i = 0; i < globals.gHtmlSpans.length; ++i) {
  2848. var repText = globals.gHtmlSpans[i],
  2849. // limiter to prevent infinite loop (assume 10 as limit for recurse)
  2850. limit = 0;
  2851. while (/¨C(\d+)C/.test(repText)) {
  2852. var num = RegExp.$1;
  2853. repText = repText.replace('¨C' + num + 'C', globals.gHtmlSpans[num]);
  2854. if (limit === 10) {
  2855. console.error('maximum nesting of 10 spans reached!!!');
  2856. break;
  2857. }
  2858. ++limit;
  2859. }
  2860. text = text.replace('¨C' + i + 'C', repText);
  2861. }
  2862. text = globals.converter._dispatch('makehtml.unhashHTMLSpans.after', text, options, globals).getText();
  2863. return text;
  2864. });
  2865. /**
  2866. * Hash and escape <pre><code> elements that should not be parsed as markdown
  2867. */
  2868. showdown.subParser('makehtml.hashPreCodeTags', function (text, options, globals) {
  2869. 'use strict';
  2870. text = globals.converter._dispatch('makehtml.hashPreCodeTags.before', text, options, globals).getText();
  2871. var repFunc = function (wholeMatch, match, left, right) {
  2872. // encode html entities
  2873. var codeblock = left + showdown.subParser('makehtml.encodeCode')(match, options, globals) + right;
  2874. return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
  2875. };
  2876. // Hash <pre><code>
  2877. text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^ {0,3}<pre\\b[^>]*>\\s*<code\\b[^>]*>', '^ {0,3}</code>\\s*</pre>', 'gim');
  2878. text = globals.converter._dispatch('makehtml.hashPreCodeTags.after', text, options, globals).getText();
  2879. return text;
  2880. });
  2881. showdown.subParser('makehtml.headers', function (text, options, globals) {
  2882. 'use strict';
  2883. text = globals.converter._dispatch('makehtml.headers.before', text, options, globals).getText();
  2884. var headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart),
  2885. // Set text-style headers:
  2886. // Header 1
  2887. // ========
  2888. //
  2889. // Header 2
  2890. // --------
  2891. //
  2892. setextRegexH1 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm,
  2893. setextRegexH2 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm;
  2894. text = text.replace(setextRegexH1, function (wholeMatch, m1) {
  2895. var spanGamut = showdown.subParser('makehtml.spanGamut')(m1, options, globals),
  2896. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
  2897. hLevel = headerLevelStart,
  2898. hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
  2899. return showdown.subParser('makehtml.hashBlock')(hashBlock, options, globals);
  2900. });
  2901. text = text.replace(setextRegexH2, function (matchFound, m1) {
  2902. var spanGamut = showdown.subParser('makehtml.spanGamut')(m1, options, globals),
  2903. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
  2904. hLevel = headerLevelStart + 1,
  2905. hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
  2906. return showdown.subParser('makehtml.hashBlock')(hashBlock, options, globals);
  2907. });
  2908. // atx-style headers:
  2909. // # Header 1
  2910. // ## Header 2
  2911. // ## Header 2 with closing hashes ##
  2912. // ...
  2913. // ###### Header 6
  2914. //
  2915. var atxStyle = (options.requireSpaceBeforeHeadingText) ? /^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm : /^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm;
  2916. text = text.replace(atxStyle, function (wholeMatch, m1, m2) {
  2917. var hText = m2;
  2918. if (options.customizedHeaderId) {
  2919. hText = m2.replace(/\s?\{([^{]+?)}\s*$/, '');
  2920. }
  2921. var span = showdown.subParser('makehtml.spanGamut')(hText, options, globals),
  2922. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',
  2923. hLevel = headerLevelStart - 1 + m1.length,
  2924. header = '<h' + hLevel + hID + '>' + span + '</h' + hLevel + '>';
  2925. return showdown.subParser('makehtml.hashBlock')(header, options, globals);
  2926. });
  2927. function headerId (m) {
  2928. var title,
  2929. prefix;
  2930. // It is separate from other options to allow combining prefix and customized
  2931. if (options.customizedHeaderId) {
  2932. var match = m.match(/\{([^{]+?)}\s*$/);
  2933. if (match && match[1]) {
  2934. m = match[1];
  2935. }
  2936. }
  2937. title = m;
  2938. // Prefix id to prevent causing inadvertent pre-existing style matches.
  2939. if (showdown.helper.isString(options.prefixHeaderId)) {
  2940. prefix = options.prefixHeaderId;
  2941. } else if (options.prefixHeaderId === true) {
  2942. prefix = 'section-';
  2943. } else {
  2944. prefix = '';
  2945. }
  2946. if (!options.rawPrefixHeaderId) {
  2947. title = prefix + title;
  2948. }
  2949. if (options.ghCompatibleHeaderId) {
  2950. title = title
  2951. .replace(/ /g, '-')
  2952. // replace previously escaped chars (&, ¨ and $)
  2953. .replace(/&amp;/g, '')
  2954. .replace(/¨T/g, '')
  2955. .replace(/¨D/g, '')
  2956. // replace rest of the chars (&~$ are repeated as they might have been escaped)
  2957. // borrowed from github's redcarpet (some they should produce similar results)
  2958. .replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g, '')
  2959. .toLowerCase();
  2960. } else if (options.rawHeaderId) {
  2961. title = title
  2962. .replace(/ /g, '-')
  2963. // replace previously escaped chars (&, ¨ and $)
  2964. .replace(/&amp;/g, '&')
  2965. .replace(/¨T/g, '¨')
  2966. .replace(/¨D/g, '$')
  2967. // replace " and '
  2968. .replace(/["']/g, '-')
  2969. .toLowerCase();
  2970. } else {
  2971. title = title
  2972. .replace(/[^\w]/g, '')
  2973. .toLowerCase();
  2974. }
  2975. if (options.rawPrefixHeaderId) {
  2976. title = prefix + title;
  2977. }
  2978. if (globals.hashLinkCounts[title]) {
  2979. title = title + '-' + (globals.hashLinkCounts[title]++);
  2980. } else {
  2981. globals.hashLinkCounts[title] = 1;
  2982. }
  2983. return title;
  2984. }
  2985. text = globals.converter._dispatch('makehtml.headers.after', text, options, globals).getText();
  2986. return text;
  2987. });
  2988. /**
  2989. * Turn Markdown horizontal rule shortcuts into <hr /> tags.
  2990. *
  2991. * Any 3 or more unindented consecutive hyphens, asterisks or underscores with or without a space beetween them
  2992. * in a single line is considered a horizontal rule
  2993. */
  2994. showdown.subParser('makehtml.horizontalRule', function (text, options, globals) {
  2995. 'use strict';
  2996. text = globals.converter._dispatch('makehtml.horizontalRule.before', text, options, globals).getText();
  2997. var key = showdown.subParser('makehtml.hashBlock')('<hr />', options, globals);
  2998. text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, key);
  2999. text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, key);
  3000. text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, key);
  3001. text = globals.converter._dispatch('makehtml.horizontalRule.after', text, options, globals).getText();
  3002. return text;
  3003. });
  3004. /**
  3005. * Turn Markdown image shortcuts into <img> tags.
  3006. */
  3007. showdown.subParser('makehtml.images', function (text, options, globals) {
  3008. 'use strict';
  3009. text = globals.converter._dispatch('makehtml.images.before', text, options, globals).getText();
  3010. var inlineRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,
  3011. crazyRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g,
  3012. base64RegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,
  3013. referenceRegExp = /!\[([^\]]*?)] ?(?:\n *)?\[([\s\S]*?)]()()()()()/g,
  3014. refShortcutRegExp = /!\[([^\[\]]+)]()()()()()/g;
  3015. function writeImageTagBase64 (wholeMatch, altText, linkId, url, width, height, m5, title) {
  3016. url = url.replace(/\s/g, '');
  3017. return writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title);
  3018. }
  3019. function writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title) {
  3020. var gUrls = globals.gUrls,
  3021. gTitles = globals.gTitles,
  3022. gDims = globals.gDimensions;
  3023. linkId = linkId.toLowerCase();
  3024. if (!title) {
  3025. title = '';
  3026. }
  3027. // Special case for explicit empty url
  3028. if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) {
  3029. url = '';
  3030. } else if (url === '' || url === null) {
  3031. if (linkId === '' || linkId === null) {
  3032. // lower-case and turn embedded newlines into spaces
  3033. linkId = altText.toLowerCase().replace(/ ?\n/g, ' ');
  3034. }
  3035. url = '#' + linkId;
  3036. if (!showdown.helper.isUndefined(gUrls[linkId])) {
  3037. url = gUrls[linkId];
  3038. if (!showdown.helper.isUndefined(gTitles[linkId])) {
  3039. title = gTitles[linkId];
  3040. }
  3041. if (!showdown.helper.isUndefined(gDims[linkId])) {
  3042. width = gDims[linkId].width;
  3043. height = gDims[linkId].height;
  3044. }
  3045. } else {
  3046. return wholeMatch;
  3047. }
  3048. }
  3049. altText = altText
  3050. .replace(/"/g, '&quot;')
  3051. //altText = showdown.helper.escapeCharacters(altText, '*_', false);
  3052. .replace(showdown.helper.regexes.asteriskDashTildeAndColon, showdown.helper.escapeCharactersCallback);
  3053. //url = showdown.helper.escapeCharacters(url, '*_', false);
  3054. url = url.replace(showdown.helper.regexes.asteriskDashTildeAndColon, showdown.helper.escapeCharactersCallback);
  3055. var result = '<img src="' + url + '" alt="' + altText + '"';
  3056. if (title && showdown.helper.isString(title)) {
  3057. title = title
  3058. .replace(/"/g, '&quot;')
  3059. //title = showdown.helper.escapeCharacters(title, '*_', false);
  3060. .replace(showdown.helper.regexes.asteriskDashTildeAndColon, showdown.helper.escapeCharactersCallback);
  3061. result += ' title="' + title + '"';
  3062. }
  3063. if (width && height) {
  3064. width = (width === '*') ? 'auto' : width;
  3065. height = (height === '*') ? 'auto' : height;
  3066. result += ' width="' + width + '"';
  3067. result += ' height="' + height + '"';
  3068. }
  3069. result += ' />';
  3070. return result;
  3071. }
  3072. // First, handle reference-style labeled images: ![alt text][id]
  3073. text = text.replace(referenceRegExp, writeImageTag);
  3074. // Next, handle inline images: ![alt text](url =<width>x<height> "optional title")
  3075. // base64 encoded images
  3076. text = text.replace(base64RegExp, writeImageTagBase64);
  3077. // cases with crazy urls like ./image/cat1).png
  3078. text = text.replace(crazyRegExp, writeImageTag);
  3079. // normal cases
  3080. text = text.replace(inlineRegExp, writeImageTag);
  3081. // handle reference-style shortcuts: ![img text]
  3082. text = text.replace(refShortcutRegExp, writeImageTag);
  3083. text = globals.converter._dispatch('makehtml.images.after', text, options, globals).getText();
  3084. return text;
  3085. });
  3086. showdown.subParser('makehtml.italicsAndBold', function (text, options, globals) {
  3087. 'use strict';
  3088. text = globals.converter._dispatch('makehtml.italicsAndBold.before', text, options, globals).getText();
  3089. // it's faster to have 3 separate regexes for each case than have just one
  3090. // because of backtracing, in some cases, it could lead to an exponential effect
  3091. // called "catastrophic backtrace". Ominous!
  3092. function parseInside (txt, left, right) {
  3093. return left + txt + right;
  3094. }
  3095. // Parse underscores
  3096. if (options.literalMidWordUnderscores) {
  3097. text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
  3098. return parseInside (txt, '<strong><em>', '</em></strong>');
  3099. });
  3100. text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) {
  3101. return parseInside (txt, '<strong>', '</strong>');
  3102. });
  3103. text = text.replace(/\b_(\S[\s\S]*?)_\b/g, function (wm, txt) {
  3104. return parseInside (txt, '<em>', '</em>');
  3105. });
  3106. } else {
  3107. text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) {
  3108. return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
  3109. });
  3110. text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
  3111. return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
  3112. });
  3113. text = text.replace(/_([^\s_][\s\S]*?)_/g, function (wm, m) {
  3114. // !/^_[^_]/.test(m) - test if it doesn't start with __ (since it seems redundant, we removed it)
  3115. return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
  3116. });
  3117. }
  3118. // Now parse asterisks
  3119. /*
  3120. if (options.literalMidWordAsterisks) {
  3121. text = text.replace(/([^*]|^)\B\*\*\*(\S[\s\S]+?)\*\*\*\B(?!\*)/g, function (wm, lead, txt) {
  3122. return parseInside (txt, lead + '<strong><em>', '</em></strong>');
  3123. });
  3124. text = text.replace(/([^*]|^)\B\*\*(\S[\s\S]+?)\*\*\B(?!\*)/g, function (wm, lead, txt) {
  3125. return parseInside (txt, lead + '<strong>', '</strong>');
  3126. });
  3127. text = text.replace(/([^*]|^)\B\*(\S[\s\S]+?)\*\B(?!\*)/g, function (wm, lead, txt) {
  3128. return parseInside (txt, lead + '<em>', '</em>');
  3129. });
  3130. } else {
  3131. */
  3132. text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
  3133. return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
  3134. });
  3135. text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) {
  3136. return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
  3137. });
  3138. text = text.replace(/\*([^\s*][\s\S]*?)\*/g, function (wm, m) {
  3139. // !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it)
  3140. return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
  3141. });
  3142. //}
  3143. text = globals.converter._dispatch('makehtml.italicsAndBold.after', text, options, globals).getText();
  3144. return text;
  3145. });
  3146. ////
  3147. // makehtml/links.js
  3148. // Copyright (c) 2018 ShowdownJS
  3149. //
  3150. // Transforms MD links into `<a>` html anchors
  3151. //
  3152. // A link contains link text (the visible text), a link destination (the URI that is the link destination), and
  3153. // optionally a link title. There are two basic kinds of links in Markdown.
  3154. // In inline links the destination and title are given immediately after the link text.
  3155. // In reference links the destination and title are defined elsewhere in the document.
  3156. //
  3157. // ***Author:***
  3158. // - Estevão Soares dos Santos (Tivie) <https://github.com/tivie>
  3159. ////
  3160. (function () {
  3161. /**
  3162. * Helper function: Wrapper function to pass as second replace parameter
  3163. *
  3164. * @param {RegExp} rgx
  3165. * @param {string} evtRootName
  3166. * @param {{}} options
  3167. * @param {{}} globals
  3168. * @returns {Function}
  3169. */
  3170. function replaceAnchorTag (rgx, evtRootName, options, globals, emptyCase) {
  3171. emptyCase = !!emptyCase;
  3172. return function (wholeMatch, text, id, url, m5, m6, title) {
  3173. // bail we we find 2 newlines somewhere
  3174. if (/\n\n/.test(wholeMatch)) {
  3175. return wholeMatch;
  3176. }
  3177. var evt = createEvent(rgx, evtRootName + '.captureStart', wholeMatch, text, id, url, title, options, globals);
  3178. return writeAnchorTag(evt, options, globals, emptyCase);
  3179. };
  3180. }
  3181. /**
  3182. * TODO Normalize this
  3183. * Helper function: Create a capture event
  3184. * @param {RegExp} rgx
  3185. * @param {String} evtName Event name
  3186. * @param {String} wholeMatch
  3187. * @param {String} text
  3188. * @param {String} id
  3189. * @param {String} url
  3190. * @param {String} title
  3191. * @param {{}} options
  3192. * @param {{}} globals
  3193. * @returns {showdown.helper.Event|*}
  3194. */
  3195. function createEvent (rgx, evtName, wholeMatch, text, id, url, title, options, globals) {
  3196. return globals.converter._dispatch(evtName, wholeMatch, options, globals, {
  3197. regexp: rgx,
  3198. matches: {
  3199. wholeMatch: wholeMatch,
  3200. text: text,
  3201. id: id,
  3202. url: url,
  3203. title: title
  3204. }
  3205. });
  3206. }
  3207. /**
  3208. * Helper Function: Normalize and write an anchor tag based on passed parameters
  3209. * @param evt
  3210. * @param options
  3211. * @param globals
  3212. * @param {boolean} emptyCase
  3213. * @returns {string}
  3214. */
  3215. function writeAnchorTag (evt, options, globals, emptyCase) {
  3216. var wholeMatch = evt.getMatches().wholeMatch;
  3217. var text = evt.getMatches().text;
  3218. var id = evt.getMatches().id;
  3219. var url = evt.getMatches().url;
  3220. var title = evt.getMatches().title;
  3221. var target = '';
  3222. if (!title) {
  3223. title = '';
  3224. }
  3225. id = (id) ? id.toLowerCase() : '';
  3226. if (emptyCase) {
  3227. url = '';
  3228. } else if (!url) {
  3229. if (!id) {
  3230. // lower-case and turn embedded newlines into spaces
  3231. id = text.toLowerCase().replace(/ ?\n/g, ' ');
  3232. }
  3233. url = '#' + id;
  3234. if (!showdown.helper.isUndefined(globals.gUrls[id])) {
  3235. url = globals.gUrls[id];
  3236. if (!showdown.helper.isUndefined(globals.gTitles[id])) {
  3237. title = globals.gTitles[id];
  3238. }
  3239. } else {
  3240. return wholeMatch;
  3241. }
  3242. }
  3243. //url = showdown.helper.escapeCharacters(url, '*_:~', false); // replaced line to improve performance
  3244. url = url.replace(showdown.helper.regexes.asteriskDashTildeAndColon, showdown.helper.escapeCharactersCallback);
  3245. if (title !== '' && title !== null) {
  3246. title = title.replace(/"/g, '&quot;');
  3247. //title = showdown.helper.escapeCharacters(title, '*_', false); // replaced line to improve performance
  3248. title = title.replace(showdown.helper.regexes.asteriskDashTildeAndColon, showdown.helper.escapeCharactersCallback);
  3249. title = ' title="' + title + '"';
  3250. }
  3251. // optionLinksInNewWindow only applies
  3252. // to external links. Hash links (#) open in same page
  3253. if (options.openLinksInNewWindow && !/^#/.test(url)) {
  3254. // escaped _
  3255. target = ' target="¨E95Eblank"';
  3256. }
  3257. // Text can be a markdown element, so we run through the appropriate parsers
  3258. text = showdown.subParser('makehtml.codeSpans')(text, options, globals);
  3259. text = showdown.subParser('makehtml.emoji')(text, options, globals);
  3260. text = showdown.subParser('makehtml.underline')(text, options, globals);
  3261. text = showdown.subParser('makehtml.italicsAndBold')(text, options, globals);
  3262. text = showdown.subParser('makehtml.strikethrough')(text, options, globals);
  3263. text = showdown.subParser('makehtml.ellipsis')(text, options, globals);
  3264. text = showdown.subParser('makehtml.hashHTMLSpans')(text, options, globals);
  3265. //evt = createEvent(rgx, evtRootName + '.captureEnd', wholeMatch, text, id, url, title, options, globals);
  3266. var result = '<a href="' + url + '"' + title + target + '>' + text + '</a>';
  3267. //evt = createEvent(rgx, evtRootName + '.beforeHash', wholeMatch, text, id, url, title, options, globals);
  3268. result = showdown.subParser('makehtml.hashHTMLSpans')(result, options, globals);
  3269. return result;
  3270. }
  3271. var evtRootName = 'makehtml.links';
  3272. /**
  3273. * Turn Markdown link shortcuts into XHTML <a> tags.
  3274. */
  3275. showdown.subParser('makehtml.links', function (text, options, globals) {
  3276. text = globals.converter._dispatch(evtRootName + '.start', text, options, globals).getText();
  3277. // 1. Handle reference-style links: [link text] [id]
  3278. text = showdown.subParser('makehtml.links.reference')(text, options, globals);
  3279. // 2. Handle inline-style links: [link text](url "optional title")
  3280. text = showdown.subParser('makehtml.links.inline')(text, options, globals);
  3281. // 3. Handle reference-style shortcuts: [link text]
  3282. // These must come last in case there's a [link text][1] or [link text](/foo)
  3283. text = showdown.subParser('makehtml.links.referenceShortcut')(text, options, globals);
  3284. // 4. Handle angle brackets links -> `<http://example.com/>`
  3285. // Must come after links, because you can use < and > delimiters in inline links like [this](<url>).
  3286. text = showdown.subParser('makehtml.links.angleBrackets')(text, options, globals);
  3287. // 5. Handle GithubMentions (if option is enabled)
  3288. text = showdown.subParser('makehtml.links.ghMentions')(text, options, globals);
  3289. // 6. Handle <a> tags and img tags
  3290. text = text.replace(/<a\s[^>]*>[\s\S]*<\/a>/g, function (wholeMatch) {
  3291. return showdown.helper._hashHTMLSpan(wholeMatch, globals);
  3292. });
  3293. text = text.replace(/<img\s[^>]*\/?>/g, function (wholeMatch) {
  3294. return showdown.helper._hashHTMLSpan(wholeMatch, globals);
  3295. });
  3296. // 7. Handle naked links (if option is enabled)
  3297. text = showdown.subParser('makehtml.links.naked')(text, options, globals);
  3298. text = globals.converter._dispatch(evtRootName + '.end', text, options, globals).getText();
  3299. return text;
  3300. });
  3301. /**
  3302. * TODO WRITE THIS DOCUMENTATION
  3303. */
  3304. showdown.subParser('makehtml.links.inline', function (text, options, globals) {
  3305. var evtRootName = evtRootName + '.inline';
  3306. text = globals.converter._dispatch(evtRootName + '.start', text, options, globals).getText();
  3307. // 1. Look for empty cases: []() and [empty]() and []("title")
  3308. var rgxEmpty = /\[(.*?)]()()()()\(<? ?>? ?(?:["'](.*)["'])?\)/g;
  3309. text = text.replace(rgxEmpty, replaceAnchorTag(rgxEmpty, evtRootName, options, globals, true));
  3310. // 2. Look for cases with crazy urls like ./image/cat1).png
  3311. var rgxCrazy = /\[((?:\[[^\]]*]|[^\[\]])*)]()\s?\([ \t]?<([^>]*)>(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g;
  3312. text = text.replace(rgxCrazy, replaceAnchorTag(rgxCrazy, evtRootName, options, globals));
  3313. // 3. inline links with no title or titles wrapped in ' or ":
  3314. // [text](url.com) || [text](<url.com>) || [text](url.com "title") || [text](<url.com> "title")
  3315. //var rgx2 = /\[[ ]*[\s]?[ ]*([^\n\[\]]*?)[ ]*[\s]?[ ]*] ?()\(<?[ ]*[\s]?[ ]*([^\s'"]*)>?(?:[ ]*[\n]?[ ]*()(['"])(.*?)\5)?[ ]*[\s]?[ ]*\)/; // this regex is too slow!!!
  3316. var rgx2 = /\[([\S ]*?)]\s?()\( *<?([^\s'"]*?(?:\([\S]*?\)[\S]*?)?)>?\s*(?:()(['"])(.*?)\5)? *\)/g;
  3317. text = text.replace(rgx2, replaceAnchorTag(rgx2, evtRootName, options, globals));
  3318. // 4. inline links with titles wrapped in (): [foo](bar.com (title))
  3319. var rgx3 = /\[([\S ]*?)]\s?()\( *<?([^\s'"]*?(?:\([\S]*?\)[\S]*?)?)>?\s+()()\((.*?)\) *\)/g;
  3320. text = text.replace(rgx3, replaceAnchorTag(rgx3, evtRootName, options, globals));
  3321. text = globals.converter._dispatch(evtRootName + '.end', text, options, globals).getText();
  3322. return text;
  3323. });
  3324. /**
  3325. * TODO WRITE THIS DOCUMENTATION
  3326. */
  3327. showdown.subParser('makehtml.links.reference', function (text, options, globals) {
  3328. var evtRootName = evtRootName + '.reference';
  3329. text = globals.converter._dispatch(evtRootName + '.start', text, options, globals).getText();
  3330. var rgx = /\[((?:\[[^\]]*]|[^\[\]])*)] ?(?:\n *)?\[(.*?)]()()()()/g;
  3331. text = text.replace(rgx, replaceAnchorTag(rgx, evtRootName, options, globals));
  3332. text = globals.converter._dispatch(evtRootName + '.end', text, options, globals).getText();
  3333. return text;
  3334. });
  3335. /**
  3336. * TODO WRITE THIS DOCUMENTATION
  3337. */
  3338. showdown.subParser('makehtml.links.referenceShortcut', function (text, options, globals) {
  3339. var evtRootName = evtRootName + '.referenceShortcut';
  3340. text = globals.converter._dispatch(evtRootName + '.start', text, options, globals).getText();
  3341. var rgx = /\[([^\[\]]+)]()()()()()/g;
  3342. text = text.replace(rgx, replaceAnchorTag(rgx, evtRootName, options, globals));
  3343. text = globals.converter._dispatch(evtRootName + '.end', text, options, globals).getText();
  3344. return text;
  3345. });
  3346. /**
  3347. * TODO WRITE THIS DOCUMENTATION
  3348. */
  3349. showdown.subParser('makehtml.links.ghMentions', function (text, options, globals) {
  3350. var evtRootName = evtRootName + 'ghMentions';
  3351. if (!options.ghMentions) {
  3352. return text;
  3353. }
  3354. text = globals.converter._dispatch(evtRootName + '.start', text, options, globals).getText();
  3355. var rgx = /(^|\s)(\\)?(@([a-z\d]+(?:[a-z\d._-]+?[a-z\d]+)*))/gi;
  3356. text = text.replace(rgx, function (wholeMatch, st, escape, mentions, username) {
  3357. // bail if the mentions was escaped
  3358. if (escape === '\\') {
  3359. return st + mentions;
  3360. }
  3361. // check if options.ghMentionsLink is a string
  3362. // TODO Validation should be done at initialization not at runtime
  3363. if (!showdown.helper.isString(options.ghMentionsLink)) {
  3364. throw new Error('ghMentionsLink option must be a string');
  3365. }
  3366. var url = options.ghMentionsLink.replace(/{u}/g, username);
  3367. var evt = createEvent(rgx, evtRootName + '.captureStart', wholeMatch, mentions, null, url, null, options, globals);
  3368. // captureEnd Event is triggered inside writeAnchorTag function
  3369. return st + writeAnchorTag(evt, options, globals);
  3370. });
  3371. text = globals.converter._dispatch(evtRootName + '.end', text, options, globals).getText();
  3372. return text;
  3373. });
  3374. /**
  3375. * TODO WRITE THIS DOCUMENTATION
  3376. */
  3377. showdown.subParser('makehtml.links.angleBrackets', function (text, options, globals) {
  3378. var evtRootName = 'makehtml.links.angleBrackets';
  3379. text = globals.converter._dispatch(evtRootName + '.start', text, options, globals).getText();
  3380. // 1. Parse links first
  3381. var urlRgx = /<(((?:https?|ftp):\/\/|www\.)[^'">\s]+)>/gi;
  3382. text = text.replace(urlRgx, function (wholeMatch, url, urlStart) {
  3383. var text = url;
  3384. url = (urlStart === 'www.') ? 'http://' + url : url;
  3385. var evt = createEvent(urlRgx, evtRootName + '.captureStart', wholeMatch, text, null, url, null, options, globals);
  3386. return writeAnchorTag(evt, options, globals);
  3387. });
  3388. // 2. Then Mail Addresses
  3389. var mailRgx = /<(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi;
  3390. text = text.replace(mailRgx, function (wholeMatch, mail) {
  3391. var url = 'mailto:';
  3392. mail = showdown.subParser('makehtml.unescapeSpecialChars')(mail, options, globals);
  3393. if (options.encodeEmails) {
  3394. url = showdown.helper.encodeEmailAddress(url + mail);
  3395. mail = showdown.helper.encodeEmailAddress(mail);
  3396. } else {
  3397. url = url + mail;
  3398. }
  3399. var evt = createEvent(mailRgx, evtRootName + '.captureStart', wholeMatch, mail, null, url, null, options, globals);
  3400. return writeAnchorTag(evt, options, globals);
  3401. });
  3402. text = globals.converter._dispatch(evtRootName + '.end', text, options, globals).getText();
  3403. return text;
  3404. });
  3405. /**
  3406. * TODO MAKE THIS WORK (IT'S NOT ACTIVATED)
  3407. * TODO WRITE THIS DOCUMENTATION
  3408. */
  3409. showdown.subParser('makehtml.links.naked', function (text, options, globals) {
  3410. if (!options.simplifiedAutoLink) {
  3411. return text;
  3412. }
  3413. var evtRootName = 'makehtml.links.naked';
  3414. text = globals.converter._dispatch(evtRootName + '.start', text, options, globals).getText();
  3415. // 2. Now we check for
  3416. // we also include leading markdown magic chars [_*~] for cases like __https://www.google.com/foobar__
  3417. var urlRgx = /([_*~]*?)(((?:https?|ftp):\/\/|www\.)[^\s<>"'`´.-][^\s<>"'`´]*?\.[a-z\d.]+[^\s<>"']*)\1/gi;
  3418. text = text.replace(urlRgx, function (wholeMatch, leadingMDChars, url, urlPrefix) {
  3419. // we now will start traversing the url from the front to back, looking for punctuation chars [_*~,;:.!?\)\]]
  3420. var len = url.length;
  3421. var suffix = '';
  3422. for (var i = len - 1; i >= 0; --i) {
  3423. var char = url.charAt(i);
  3424. if (/[_*~,;:.!?]/.test(char)) {
  3425. // it's a punctuation char
  3426. // we remove it from the url
  3427. url = url.slice(0, -1);
  3428. // and prepend it to the suffix
  3429. suffix = char + suffix;
  3430. } else if (/\)/.test(char)) {
  3431. var opPar = url.match(/\(/g) || [];
  3432. var clPar = url.match(/\)/g);
  3433. // it's a curved parenthesis so we need to check for "balance" (kinda)
  3434. if (opPar.length < clPar.length) {
  3435. // there are more closing Parenthesis than opening so chop it!!!!!
  3436. url = url.slice(0, -1);
  3437. // and prepend it to the suffix
  3438. suffix = char + suffix;
  3439. } else {
  3440. // it's (kinda) balanced so our work is done
  3441. break;
  3442. }
  3443. } else if (/]/.test(char)) {
  3444. var opPar2 = url.match(/\[/g) || [];
  3445. var clPar2 = url.match(/\]/g);
  3446. // it's a squared parenthesis so we need to check for "balance" (kinda)
  3447. if (opPar2.length < clPar2.length) {
  3448. // there are more closing Parenthesis than opening so chop it!!!!!
  3449. url = url.slice(0, -1);
  3450. // and prepend it to the suffix
  3451. suffix = char + suffix;
  3452. } else {
  3453. // it's (kinda) balanced so our work is done
  3454. break;
  3455. }
  3456. } else {
  3457. // it's not a punctuation or a parenthesis so our work is done
  3458. break;
  3459. }
  3460. }
  3461. // we copy the treated url to the text variable
  3462. var text = url;
  3463. // finally, if it's a www shortcut, we prepend http
  3464. url = (urlPrefix === 'www.') ? 'http://' + url : url;
  3465. // url part is done so let's take care of text now
  3466. // we need to escape the text (because of links such as www.example.com/foo__bar__baz)
  3467. text = text.replace(showdown.helper.regexes.asteriskDashTildeAndColon, showdown.helper.escapeCharactersCallback);
  3468. // finally we dispatch the event
  3469. var evt = createEvent(urlRgx, evtRootName + '.captureStart', wholeMatch, text, null, url, null, options, globals);
  3470. // and return the link tag, with the leadingMDChars and suffix. The leadingMDChars are added at the end too because
  3471. // we consumed those characters in the regexp
  3472. return leadingMDChars + writeAnchorTag(evt, options, globals) + suffix + leadingMDChars;
  3473. });
  3474. // 2. Then mails
  3475. var mailRgx = /(^|\s)(?:mailto:)?([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?=$|\s)/gmi;
  3476. text = text.replace(mailRgx, function (wholeMatch, leadingChar, mail) {
  3477. var url = 'mailto:';
  3478. mail = showdown.subParser('makehtml.unescapeSpecialChars')(mail, options, globals);
  3479. if (options.encodeEmails) {
  3480. url = showdown.helper.encodeEmailAddress(url + mail);
  3481. mail = showdown.helper.encodeEmailAddress(mail);
  3482. } else {
  3483. url = url + mail;
  3484. }
  3485. var evt = createEvent(mailRgx, evtRootName + '.captureStart', wholeMatch, mail, null, url, null, options, globals);
  3486. return leadingChar + writeAnchorTag(evt, options, globals);
  3487. });
  3488. text = globals.converter._dispatch(evtRootName + '.end', text, options, globals).getText();
  3489. return text;
  3490. });
  3491. })();
  3492. /**
  3493. * Form HTML ordered (numbered) and unordered (bulleted) lists.
  3494. */
  3495. showdown.subParser('makehtml.lists', function (text, options, globals) {
  3496. 'use strict';
  3497. /**
  3498. * Process the contents of a single ordered or unordered list, splitting it
  3499. * into individual list items.
  3500. * @param {string} listStr
  3501. * @param {boolean} trimTrailing
  3502. * @returns {string}
  3503. */
  3504. function processListItems (listStr, trimTrailing) {
  3505. // The $g_list_level global keeps track of when we're inside a list.
  3506. // Each time we enter a list, we increment it; when we leave a list,
  3507. // we decrement. If it's zero, we're not in a list anymore.
  3508. //
  3509. // We do this because when we're not inside a list, we want to treat
  3510. // something like this:
  3511. //
  3512. // I recommend upgrading to version
  3513. // 8. Oops, now this line is treated
  3514. // as a sub-list.
  3515. //
  3516. // As a single paragraph, despite the fact that the second line starts
  3517. // with a digit-period-space sequence.
  3518. //
  3519. // Whereas when we're inside a list (or sub-list), that line will be
  3520. // treated as the start of a sub-list. What a kludge, huh? This is
  3521. // an aspect of Markdown's syntax that's hard to parse perfectly
  3522. // without resorting to mind-reading. Perhaps the solution is to
  3523. // change the syntax rules such that sub-lists must start with a
  3524. // starting cardinal number; e.g. "1." or "a.".
  3525. globals.gListLevel++;
  3526. // trim trailing blank lines:
  3527. listStr = listStr.replace(/\n{2,}$/, '\n');
  3528. // attacklab: add sentinel to emulate \z
  3529. listStr += '¨0';
  3530. var rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm,
  3531. isParagraphed = (/\n[ \t]*\n(?!¨0)/.test(listStr));
  3532. // Since version 1.5, nesting sublists requires 4 spaces (or 1 tab) indentation,
  3533. // which is a syntax breaking change
  3534. // activating this option reverts to old behavior
  3535. // This will be removed in version 2.0
  3536. if (options.disableForced4SpacesIndentedSublists) {
  3537. rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm;
  3538. }
  3539. listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
  3540. checked = (checked && checked.trim() !== '');
  3541. var item = showdown.subParser('makehtml.outdent')(m4, options, globals),
  3542. bulletStyle = '';
  3543. // Support for github tasklists
  3544. if (taskbtn && options.tasklists) {
  3545. bulletStyle = ' class="task-list-item" style="list-style-type: none;"';
  3546. item = item.replace(/^[ \t]*\[(x|X| )?]/m, function () {
  3547. var otp = '<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"';
  3548. if (checked) {
  3549. otp += ' checked';
  3550. }
  3551. otp += '>';
  3552. return otp;
  3553. });
  3554. }
  3555. // ISSUE #312
  3556. // This input: - - - a
  3557. // causes trouble to the parser, since it interprets it as:
  3558. // <ul><li><li><li>a</li></li></li></ul>
  3559. // instead of:
  3560. // <ul><li>- - a</li></ul>
  3561. // So, to prevent it, we will put a marker (¨A)in the beginning of the line
  3562. // Kind of hackish/monkey patching, but seems more effective than overcomplicating the list parser
  3563. item = item.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g, function (wm2) {
  3564. return '¨A' + wm2;
  3565. });
  3566. // SPECIAL CASE: an heading followed by a paragraph of text that is not separated by a double newline
  3567. // or/nor indented. ex:
  3568. //
  3569. // - # foo
  3570. // bar is great
  3571. //
  3572. // While this does now follow the spec per se, not allowing for this might cause confusion since
  3573. // header blocks don't need double newlines after
  3574. if (/^#+.+\n.+/.test(item)) {
  3575. item = item.replace(/^(#+.+)$/m, '$1\n');
  3576. }
  3577. // m1 - Leading line or
  3578. // Has a double return (multi paragraph)
  3579. if (m1 || (item.search(/\n{2,}/) > -1)) {
  3580. item = showdown.subParser('makehtml.githubCodeBlocks')(item, options, globals);
  3581. item = showdown.subParser('makehtml.blockGamut')(item, options, globals);
  3582. } else {
  3583. // Recursion for sub-lists:
  3584. item = showdown.subParser('makehtml.lists')(item, options, globals);
  3585. item = item.replace(/\n$/, ''); // chomp(item)
  3586. item = showdown.subParser('makehtml.hashHTMLBlocks')(item, options, globals);
  3587. // Colapse double linebreaks
  3588. item = item.replace(/\n\n+/g, '\n\n');
  3589. if (isParagraphed) {
  3590. item = showdown.subParser('makehtml.paragraphs')(item, options, globals);
  3591. } else {
  3592. item = showdown.subParser('makehtml.spanGamut')(item, options, globals);
  3593. }
  3594. }
  3595. // now we need to remove the marker (¨A)
  3596. item = item.replace('¨A', '');
  3597. // we can finally wrap the line in list item tags
  3598. item = '<li' + bulletStyle + '>' + item + '</li>\n';
  3599. return item;
  3600. });
  3601. // attacklab: strip sentinel
  3602. listStr = listStr.replace(/¨0/g, '');
  3603. globals.gListLevel--;
  3604. if (trimTrailing) {
  3605. listStr = listStr.replace(/\s+$/, '');
  3606. }
  3607. return listStr;
  3608. }
  3609. function styleStartNumber (list, listType) {
  3610. // check if ol and starts by a number different than 1
  3611. if (listType === 'ol') {
  3612. var res = list.match(/^ *(\d+)\./);
  3613. if (res && res[1] !== '1') {
  3614. return ' start="' + res[1] + '"';
  3615. }
  3616. }
  3617. return '';
  3618. }
  3619. /**
  3620. * Check and parse consecutive lists (better fix for issue #142)
  3621. * @param {string} list
  3622. * @param {string} listType
  3623. * @param {boolean} trimTrailing
  3624. * @returns {string}
  3625. */
  3626. function parseConsecutiveLists (list, listType, trimTrailing) {
  3627. // check if we caught 2 or more consecutive lists by mistake
  3628. // we use the counterRgx, meaning if listType is UL we look for OL and vice versa
  3629. var olRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?\d+\.[ \t]/gm : /^ {0,3}\d+\.[ \t]/gm,
  3630. ulRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?[*+-][ \t]/gm : /^ {0,3}[*+-][ \t]/gm,
  3631. counterRxg = (listType === 'ul') ? olRgx : ulRgx,
  3632. result = '';
  3633. if (list.search(counterRxg) !== -1) {
  3634. (function parseCL (txt) {
  3635. var pos = txt.search(counterRxg),
  3636. style = styleStartNumber(list, listType);
  3637. if (pos !== -1) {
  3638. // slice
  3639. result += '\n\n<' + listType + style + '>\n' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>\n';
  3640. // invert counterType and listType
  3641. listType = (listType === 'ul') ? 'ol' : 'ul';
  3642. counterRxg = (listType === 'ul') ? olRgx : ulRgx;
  3643. //recurse
  3644. parseCL(txt.slice(pos));
  3645. } else {
  3646. result += '\n\n<' + listType + style + '>\n' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n';
  3647. }
  3648. })(list);
  3649. } else {
  3650. var style = styleStartNumber(list, listType);
  3651. result = '\n\n<' + listType + style + '>\n' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n';
  3652. }
  3653. return result;
  3654. }
  3655. // Start of list parsing
  3656. var subListRgx = /^(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
  3657. var mainListRgx = /(\n\n|^\n?)(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
  3658. text = globals.converter._dispatch('lists.before', text, options, globals).getText();
  3659. // add sentinel to hack around khtml/safari bug:
  3660. // http://bugs.webkit.org/show_bug.cgi?id=11231
  3661. text += '¨0';
  3662. if (globals.gListLevel) {
  3663. text = text.replace(subListRgx, function (wholeMatch, list, m2) {
  3664. var listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
  3665. return parseConsecutiveLists(list, listType, true);
  3666. });
  3667. } else {
  3668. text = text.replace(mainListRgx, function (wholeMatch, m1, list, m3) {
  3669. var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
  3670. return parseConsecutiveLists(list, listType, false);
  3671. });
  3672. }
  3673. // strip sentinel
  3674. text = text.replace(/¨0/, '');
  3675. text = globals.converter._dispatch('makehtml.lists.after', text, options, globals).getText();
  3676. return text;
  3677. });
  3678. /**
  3679. * Parse metadata at the top of the document
  3680. */
  3681. showdown.subParser('makehtml.metadata', function (text, options, globals) {
  3682. 'use strict';
  3683. if (!options.metadata) {
  3684. return text;
  3685. }
  3686. text = globals.converter._dispatch('makehtml.metadata.before', text, options, globals).getText();
  3687. function parseMetadataContents (content) {
  3688. // raw is raw so it's not changed in any way
  3689. globals.metadata.raw = content;
  3690. // escape chars forbidden in html attributes
  3691. // double quotes
  3692. content = content
  3693. // ampersand first
  3694. .replace(/&/g, '&amp;')
  3695. // double quotes
  3696. .replace(/"/g, '&quot;');
  3697. content = content.replace(/\n {4}/g, ' ');
  3698. content.replace(/^([\S ]+): +([\s\S]+?)$/gm, function (wm, key, value) {
  3699. globals.metadata.parsed[key] = value;
  3700. return '';
  3701. });
  3702. }
  3703. text = text.replace(/^\s*«««+(\S*?)\n([\s\S]+?)\n»»»+\n/, function (wholematch, format, content) {
  3704. parseMetadataContents(content);
  3705. return '¨M';
  3706. });
  3707. text = text.replace(/^\s*---+(\S*?)\n([\s\S]+?)\n---+\n/, function (wholematch, format, content) {
  3708. if (format) {
  3709. globals.metadata.format = format;
  3710. }
  3711. parseMetadataContents(content);
  3712. return '¨M';
  3713. });
  3714. text = text.replace(/¨M/g, '');
  3715. text = globals.converter._dispatch('makehtml.metadata.after', text, options, globals).getText();
  3716. return text;
  3717. });
  3718. /**
  3719. * Remove one level of line-leading tabs or spaces
  3720. */
  3721. showdown.subParser('makehtml.outdent', function (text, options, globals) {
  3722. 'use strict';
  3723. text = globals.converter._dispatch('makehtml.outdent.before', text, options, globals).getText();
  3724. // attacklab: hack around Konqueror 3.5.4 bug:
  3725. // "----------bug".replace(/^-/g,"") == "bug"
  3726. text = text.replace(/^(\t|[ ]{1,4})/gm, '¨0'); // attacklab: g_tab_width
  3727. // attacklab: clean up hack
  3728. text = text.replace(/¨0/g, '');
  3729. text = globals.converter._dispatch('makehtml.outdent.after', text, options, globals).getText();
  3730. return text;
  3731. });
  3732. /**
  3733. *
  3734. */
  3735. showdown.subParser('makehtml.paragraphs', function (text, options, globals) {
  3736. 'use strict';
  3737. text = globals.converter._dispatch('makehtml.paragraphs.before', text, options, globals).getText();
  3738. // Strip leading and trailing lines:
  3739. text = text.replace(/^\n+/g, '');
  3740. text = text.replace(/\n+$/g, '');
  3741. var grafs = text.split(/\n{2,}/g),
  3742. grafsOut = [],
  3743. end = grafs.length; // Wrap <p> tags
  3744. for (var i = 0; i < end; i++) {
  3745. var str = grafs[i];
  3746. // if this is an HTML marker, copy it
  3747. if (str.search(/¨(K|G)(\d+)\1/g) >= 0) {
  3748. grafsOut.push(str);
  3749. // test for presence of characters to prevent empty lines being parsed
  3750. // as paragraphs (resulting in undesired extra empty paragraphs)
  3751. } else if (str.search(/\S/) >= 0) {
  3752. str = showdown.subParser('makehtml.spanGamut')(str, options, globals);
  3753. str = str.replace(/^([ \t]*)/g, '<p>');
  3754. str += '</p>';
  3755. grafsOut.push(str);
  3756. }
  3757. }
  3758. /** Unhashify HTML blocks */
  3759. end = grafsOut.length;
  3760. for (i = 0; i < end; i++) {
  3761. var blockText = '',
  3762. grafsOutIt = grafsOut[i],
  3763. codeFlag = false;
  3764. // if this is a marker for an html block...
  3765. // use RegExp.test instead of string.search because of QML bug
  3766. while (/¨(K|G)(\d+)\1/.test(grafsOutIt)) {
  3767. var delim = RegExp.$1,
  3768. num = RegExp.$2;
  3769. if (delim === 'K') {
  3770. blockText = globals.gHtmlBlocks[num];
  3771. } else {
  3772. // we need to check if ghBlock is a false positive
  3773. if (codeFlag) {
  3774. // use encoded version of all text
  3775. blockText = showdown.subParser('makehtml.encodeCode')(globals.ghCodeBlocks[num].text, options, globals);
  3776. } else {
  3777. blockText = globals.ghCodeBlocks[num].codeblock;
  3778. }
  3779. }
  3780. blockText = blockText.replace(/\$/g, '$$$$'); // Escape any dollar signs
  3781. grafsOutIt = grafsOutIt.replace(/(\n\n)?¨(K|G)\d+\2(\n\n)?/, blockText);
  3782. // Check if grafsOutIt is a pre->code
  3783. if (/^<pre\b[^>]*>\s*<code\b[^>]*>/.test(grafsOutIt)) {
  3784. codeFlag = true;
  3785. }
  3786. }
  3787. grafsOut[i] = grafsOutIt;
  3788. }
  3789. text = grafsOut.join('\n');
  3790. // Strip leading and trailing lines:
  3791. text = text.replace(/^\n+/g, '');
  3792. text = text.replace(/\n+$/g, '');
  3793. return globals.converter._dispatch('makehtml.paragraphs.after', text, options, globals).getText();
  3794. });
  3795. /**
  3796. * Run extension
  3797. */
  3798. showdown.subParser('makehtml.runExtension', function (ext, text, options, globals) {
  3799. 'use strict';
  3800. if (ext.filter) {
  3801. text = ext.filter(text, globals.converter, options);
  3802. } else if (ext.regex) {
  3803. // TODO remove this when old extension loading mechanism is deprecated
  3804. var re = ext.regex;
  3805. if (!(re instanceof RegExp)) {
  3806. re = new RegExp(re, 'g');
  3807. }
  3808. text = text.replace(re, ext.replace);
  3809. }
  3810. return text;
  3811. });
  3812. /**
  3813. * These are all the transformations that occur *within* block-level
  3814. * tags like paragraphs, headers, and list items.
  3815. */
  3816. showdown.subParser('makehtml.spanGamut', function (text, options, globals) {
  3817. 'use strict';
  3818. text = globals.converter._dispatch('makehtml.span.before', text, options, globals).getText();
  3819. text = showdown.subParser('makehtml.codeSpans')(text, options, globals);
  3820. text = showdown.subParser('makehtml.escapeSpecialCharsWithinTagAttributes')(text, options, globals);
  3821. text = showdown.subParser('makehtml.encodeBackslashEscapes')(text, options, globals);
  3822. // Process link and image tags. Images must come first,
  3823. // because ![foo][f] looks like a link.
  3824. text = showdown.subParser('makehtml.images')(text, options, globals);
  3825. text = globals.converter._dispatch('smakehtml.links.before', text, options, globals).getText();
  3826. text = showdown.subParser('makehtml.links')(text, options, globals);
  3827. text = globals.converter._dispatch('smakehtml.links.after', text, options, globals).getText();
  3828. //text = showdown.subParser('makehtml.autoLinks')(text, options, globals);
  3829. //text = showdown.subParser('makehtml.simplifiedAutoLinks')(text, options, globals);
  3830. text = showdown.subParser('makehtml.emoji')(text, options, globals);
  3831. text = showdown.subParser('makehtml.underline')(text, options, globals);
  3832. text = showdown.subParser('makehtml.italicsAndBold')(text, options, globals);
  3833. text = showdown.subParser('makehtml.strikethrough')(text, options, globals);
  3834. text = showdown.subParser('makehtml.ellipsis')(text, options, globals);
  3835. // we need to hash HTML tags inside spans
  3836. text = showdown.subParser('makehtml.hashHTMLSpans')(text, options, globals);
  3837. // now we encode amps and angles
  3838. text = showdown.subParser('makehtml.encodeAmpsAndAngles')(text, options, globals);
  3839. // Do hard breaks
  3840. if (options.simpleLineBreaks) {
  3841. // GFM style hard breaks
  3842. // only add line breaks if the text does not contain a block (special case for lists)
  3843. if (!/\n\n¨K/.test(text)) {
  3844. text = text.replace(/\n+/g, '<br />\n');
  3845. }
  3846. } else {
  3847. // Vanilla hard breaks
  3848. text = text.replace(/ +\n/g, '<br />\n');
  3849. }
  3850. text = globals.converter._dispatch('makehtml.spanGamut.after', text, options, globals).getText();
  3851. return text;
  3852. });
  3853. showdown.subParser('makehtml.strikethrough', function (text, options, globals) {
  3854. 'use strict';
  3855. if (options.strikethrough) {
  3856. text = globals.converter._dispatch('makehtml.strikethrough.before', text, options, globals).getText();
  3857. text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function (wm, txt) { return '<del>' + txt + '</del>'; });
  3858. text = globals.converter._dispatch('makehtml.strikethrough.after', text, options, globals).getText();
  3859. }
  3860. return text;
  3861. });
  3862. /**
  3863. * Strips link definitions from text, stores the URLs and titles in
  3864. * hash references.
  3865. * Link defs are in the form: ^[id]: url "optional title"
  3866. */
  3867. showdown.subParser('makehtml.stripLinkDefinitions', function (text, options, globals) {
  3868. 'use strict';
  3869. var regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm,
  3870. base64Regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[))/gm;
  3871. // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
  3872. text += '¨0';
  3873. var replaceFunc = function (wholeMatch, linkId, url, width, height, blankLines, title) {
  3874. linkId = linkId.toLowerCase();
  3875. if (url.match(/^data:.+?\/.+?;base64,/)) {
  3876. // remove newlines
  3877. globals.gUrls[linkId] = url.replace(/\s/g, '');
  3878. } else {
  3879. globals.gUrls[linkId] = showdown.subParser('makehtml.encodeAmpsAndAngles')(url, options, globals); // Link IDs are case-insensitive
  3880. }
  3881. if (blankLines) {
  3882. // Oops, found blank lines, so it's not a title.
  3883. // Put back the parenthetical statement we stole.
  3884. return blankLines + title;
  3885. } else {
  3886. if (title) {
  3887. globals.gTitles[linkId] = title.replace(/"|'/g, '&quot;');
  3888. }
  3889. if (options.parseImgDimensions && width && height) {
  3890. globals.gDimensions[linkId] = {
  3891. width: width,
  3892. height: height
  3893. };
  3894. }
  3895. }
  3896. // Completely remove the definition from the text
  3897. return '';
  3898. };
  3899. // first we try to find base64 link references
  3900. text = text.replace(base64Regex, replaceFunc);
  3901. text = text.replace(regex, replaceFunc);
  3902. // attacklab: strip sentinel
  3903. text = text.replace(/¨0/, '');
  3904. return text;
  3905. });
  3906. showdown.subParser('makehtml.tables', function (text, options, globals) {
  3907. 'use strict';
  3908. if (!options.tables) {
  3909. return text;
  3910. }
  3911. var tableRgx = /^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨0)/gm,
  3912. //singeColTblRgx = /^ {0,3}\|.+\|\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n(?: {0,3}\|.+\|\n)+(?:\n\n|¨0)/gm;
  3913. singeColTblRgx = /^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|¨0)/gm;
  3914. function parseStyles (sLine) {
  3915. if (/^:[ \t]*--*$/.test(sLine)) {
  3916. return ' style="text-align:left;"';
  3917. } else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
  3918. return ' style="text-align:right;"';
  3919. } else if (/^:[ \t]*--*[ \t]*:$/.test(sLine)) {
  3920. return ' style="text-align:center;"';
  3921. } else {
  3922. return '';
  3923. }
  3924. }
  3925. function parseHeaders (header, style) {
  3926. var id = '';
  3927. header = header.trim();
  3928. // support both tablesHeaderId and tableHeaderId due to error in documentation so we don't break backwards compatibility
  3929. if (options.tablesHeaderId || options.tableHeaderId) {
  3930. id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"';
  3931. }
  3932. header = showdown.subParser('makehtml.spanGamut')(header, options, globals);
  3933. return '<th' + id + style + '>' + header + '</th>\n';
  3934. }
  3935. function parseCells (cell, style) {
  3936. var subText = showdown.subParser('makehtml.spanGamut')(cell, options, globals);
  3937. return '<td' + style + '>' + subText + '</td>\n';
  3938. }
  3939. function buildTable (headers, cells) {
  3940. var tb = '<table>\n<thead>\n<tr>\n',
  3941. tblLgn = headers.length;
  3942. for (var i = 0; i < tblLgn; ++i) {
  3943. tb += headers[i];
  3944. }
  3945. tb += '</tr>\n</thead>\n<tbody>\n';
  3946. for (i = 0; i < cells.length; ++i) {
  3947. tb += '<tr>\n';
  3948. for (var ii = 0; ii < tblLgn; ++ii) {
  3949. tb += cells[i][ii];
  3950. }
  3951. tb += '</tr>\n';
  3952. }
  3953. tb += '</tbody>\n</table>\n';
  3954. return tb;
  3955. }
  3956. function parseTable (rawTable) {
  3957. var i, tableLines = rawTable.split('\n');
  3958. for (i = 0; i < tableLines.length; ++i) {
  3959. // strip wrong first and last column if wrapped tables are used
  3960. if (/^ {0,3}\|/.test(tableLines[i])) {
  3961. tableLines[i] = tableLines[i].replace(/^ {0,3}\|/, '');
  3962. }
  3963. if (/\|[ \t]*$/.test(tableLines[i])) {
  3964. tableLines[i] = tableLines[i].replace(/\|[ \t]*$/, '');
  3965. }
  3966. // parse code spans first, but we only support one line code spans
  3967. tableLines[i] = showdown.subParser('makehtml.codeSpans')(tableLines[i], options, globals);
  3968. }
  3969. var rawHeaders = tableLines[0].split('|').map(function (s) { return s.trim();}),
  3970. rawStyles = tableLines[1].split('|').map(function (s) { return s.trim();}),
  3971. rawCells = [],
  3972. headers = [],
  3973. styles = [],
  3974. cells = [];
  3975. tableLines.shift();
  3976. tableLines.shift();
  3977. for (i = 0; i < tableLines.length; ++i) {
  3978. if (tableLines[i].trim() === '') {
  3979. continue;
  3980. }
  3981. rawCells.push(
  3982. tableLines[i]
  3983. .split('|')
  3984. .map(function (s) {
  3985. return s.trim();
  3986. })
  3987. );
  3988. }
  3989. if (rawHeaders.length < rawStyles.length) {
  3990. return rawTable;
  3991. }
  3992. for (i = 0; i < rawStyles.length; ++i) {
  3993. styles.push(parseStyles(rawStyles[i]));
  3994. }
  3995. for (i = 0; i < rawHeaders.length; ++i) {
  3996. if (showdown.helper.isUndefined(styles[i])) {
  3997. styles[i] = '';
  3998. }
  3999. headers.push(parseHeaders(rawHeaders[i], styles[i]));
  4000. }
  4001. for (i = 0; i < rawCells.length; ++i) {
  4002. var row = [];
  4003. for (var ii = 0; ii < headers.length; ++ii) {
  4004. if (showdown.helper.isUndefined(rawCells[i][ii])) {
  4005. }
  4006. row.push(parseCells(rawCells[i][ii], styles[ii]));
  4007. }
  4008. cells.push(row);
  4009. }
  4010. return buildTable(headers, cells);
  4011. }
  4012. text = globals.converter._dispatch('makehtml.tables.before', text, options, globals).getText();
  4013. // find escaped pipe characters
  4014. text = text.replace(/\\(\|)/g, showdown.helper.escapeCharactersCallback);
  4015. // parse multi column tables
  4016. text = text.replace(tableRgx, parseTable);
  4017. // parse one column tables
  4018. text = text.replace(singeColTblRgx, parseTable);
  4019. text = globals.converter._dispatch('makehtml.tables.after', text, options, globals).getText();
  4020. return text;
  4021. });
  4022. showdown.subParser('makehtml.underline', function (text, options, globals) {
  4023. 'use strict';
  4024. if (!options.underline) {
  4025. return text;
  4026. }
  4027. text = globals.converter._dispatch('makehtml.underline.before', text, options, globals).getText();
  4028. if (options.literalMidWordUnderscores) {
  4029. text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
  4030. return '<u>' + txt + '</u>';
  4031. });
  4032. text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) {
  4033. return '<u>' + txt + '</u>';
  4034. });
  4035. } else {
  4036. text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) {
  4037. return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm;
  4038. });
  4039. text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
  4040. return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm;
  4041. });
  4042. }
  4043. // escape remaining underscores to prevent them being parsed by italic and bold
  4044. text = text.replace(/(_)/g, showdown.helper.escapeCharactersCallback);
  4045. text = globals.converter._dispatch('makehtml.underline.after', text, options, globals).getText();
  4046. return text;
  4047. });
  4048. /**
  4049. * Swap back in all the special characters we've hidden.
  4050. */
  4051. showdown.subParser('makehtml.unescapeSpecialChars', function (text, options, globals) {
  4052. 'use strict';
  4053. text = globals.converter._dispatch('makehtml.unescapeSpecialChars.before', text, options, globals).getText();
  4054. text = text.replace(/¨E(\d+)E/g, function (wholeMatch, m1) {
  4055. var charCodeToReplace = parseInt(m1);
  4056. return String.fromCharCode(charCodeToReplace);
  4057. });
  4058. text = globals.converter._dispatch('makehtml.unescapeSpecialChars.after', text, options, globals).getText();
  4059. return text;
  4060. });
  4061. showdown.subParser('makeMarkdown.blockquote', function (node, globals) {
  4062. 'use strict';
  4063. var txt = '';
  4064. if (node.hasChildNodes()) {
  4065. var children = node.childNodes,
  4066. childrenLength = children.length;
  4067. for (var i = 0; i < childrenLength; ++i) {
  4068. var innerTxt = showdown.subParser('makeMarkdown.node')(children[i], globals);
  4069. if (innerTxt === '') {
  4070. continue;
  4071. }
  4072. txt += innerTxt;
  4073. }
  4074. }
  4075. // cleanup
  4076. txt = txt.trim();
  4077. txt = '> ' + txt.split('\n').join('\n> ');
  4078. return txt;
  4079. });
  4080. showdown.subParser('makeMarkdown.codeBlock', function (node, globals) {
  4081. 'use strict';
  4082. var lang = node.getAttribute('language'),
  4083. num = node.getAttribute('precodenum');
  4084. return '```' + lang + '\n' + globals.preList[num] + '\n```';
  4085. });
  4086. showdown.subParser('makeMarkdown.codeSpan', function (node) {
  4087. 'use strict';
  4088. return '`' + node.innerHTML + '`';
  4089. });
  4090. showdown.subParser('makeMarkdown.emphasis', function (node, globals) {
  4091. 'use strict';
  4092. var txt = '';
  4093. if (node.hasChildNodes()) {
  4094. txt += '*';
  4095. var children = node.childNodes,
  4096. childrenLength = children.length;
  4097. for (var i = 0; i < childrenLength; ++i) {
  4098. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4099. }
  4100. txt += '*';
  4101. }
  4102. return txt;
  4103. });
  4104. showdown.subParser('makeMarkdown.header', function (node, globals, headerLevel) {
  4105. 'use strict';
  4106. var headerMark = new Array(headerLevel + 1).join('#'),
  4107. txt = '';
  4108. if (node.hasChildNodes()) {
  4109. txt = headerMark + ' ';
  4110. var children = node.childNodes,
  4111. childrenLength = children.length;
  4112. for (var i = 0; i < childrenLength; ++i) {
  4113. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4114. }
  4115. }
  4116. return txt;
  4117. });
  4118. showdown.subParser('makeMarkdown.hr', function () {
  4119. 'use strict';
  4120. return '---';
  4121. });
  4122. showdown.subParser('makeMarkdown.image', function (node) {
  4123. 'use strict';
  4124. var txt = '';
  4125. if (node.hasAttribute('src')) {
  4126. txt += '![' + node.getAttribute('alt') + '](';
  4127. txt += '<' + node.getAttribute('src') + '>';
  4128. if (node.hasAttribute('width') && node.hasAttribute('height')) {
  4129. txt += ' =' + node.getAttribute('width') + 'x' + node.getAttribute('height');
  4130. }
  4131. if (node.hasAttribute('title')) {
  4132. txt += ' "' + node.getAttribute('title') + '"';
  4133. }
  4134. txt += ')';
  4135. }
  4136. return txt;
  4137. });
  4138. showdown.subParser('makeMarkdown.links', function (node, globals) {
  4139. 'use strict';
  4140. var txt = '';
  4141. if (node.hasChildNodes() && node.hasAttribute('href')) {
  4142. var children = node.childNodes,
  4143. childrenLength = children.length;
  4144. txt = '[';
  4145. for (var i = 0; i < childrenLength; ++i) {
  4146. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4147. }
  4148. txt += '](';
  4149. txt += '<' + node.getAttribute('href') + '>';
  4150. if (node.hasAttribute('title')) {
  4151. txt += ' "' + node.getAttribute('title') + '"';
  4152. }
  4153. txt += ')';
  4154. }
  4155. return txt;
  4156. });
  4157. showdown.subParser('makeMarkdown.list', function (node, globals, type) {
  4158. 'use strict';
  4159. var txt = '';
  4160. if (!node.hasChildNodes()) {
  4161. return '';
  4162. }
  4163. var listItems = node.childNodes,
  4164. listItemsLenght = listItems.length,
  4165. listNum = node.getAttribute('start') || 1;
  4166. for (var i = 0; i < listItemsLenght; ++i) {
  4167. if (typeof listItems[i].tagName === 'undefined' || listItems[i].tagName.toLowerCase() !== 'li') {
  4168. continue;
  4169. }
  4170. // define the bullet to use in list
  4171. var bullet = '';
  4172. if (type === 'ol') {
  4173. bullet = listNum.toString() + '. ';
  4174. } else {
  4175. bullet = '- ';
  4176. }
  4177. // parse list item
  4178. txt += bullet + showdown.subParser('makeMarkdown.listItem')(listItems[i], globals);
  4179. ++listNum;
  4180. }
  4181. return txt.trim();
  4182. });
  4183. showdown.subParser('makeMarkdown.listItem', function (node, globals) {
  4184. 'use strict';
  4185. var listItemTxt = '';
  4186. var children = node.childNodes,
  4187. childrenLenght = children.length;
  4188. for (var i = 0; i < childrenLenght; ++i) {
  4189. listItemTxt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4190. }
  4191. // if it's only one liner, we need to add a newline at the end
  4192. if (!/\n$/.test(listItemTxt)) {
  4193. listItemTxt += '\n';
  4194. } else {
  4195. // it's multiparagraph, so we need to indent
  4196. listItemTxt = listItemTxt
  4197. .split('\n')
  4198. .join('\n ')
  4199. .replace(/^ {4}$/gm, '')
  4200. .replace(/\n\n+/g, '\n\n');
  4201. }
  4202. return listItemTxt;
  4203. });
  4204. showdown.subParser('makeMarkdown.node', function (node, globals, spansOnly) {
  4205. 'use strict';
  4206. spansOnly = spansOnly || false;
  4207. var txt = '';
  4208. // edge case of text without wrapper paragraph
  4209. if (node.nodeType === 3) {
  4210. return showdown.subParser('makeMarkdown.txt')(node, globals);
  4211. }
  4212. // HTML comment
  4213. if (node.nodeType === 8) {
  4214. return '<!--' + node.data + '-->\n\n';
  4215. }
  4216. // process only node elements
  4217. if (node.nodeType !== 1) {
  4218. return '';
  4219. }
  4220. var tagName = node.tagName.toLowerCase();
  4221. switch (tagName) {
  4222. //
  4223. // BLOCKS
  4224. //
  4225. case 'h1':
  4226. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 1) + '\n\n'; }
  4227. break;
  4228. case 'h2':
  4229. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 2) + '\n\n'; }
  4230. break;
  4231. case 'h3':
  4232. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 3) + '\n\n'; }
  4233. break;
  4234. case 'h4':
  4235. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 4) + '\n\n'; }
  4236. break;
  4237. case 'h5':
  4238. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 5) + '\n\n'; }
  4239. break;
  4240. case 'h6':
  4241. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 6) + '\n\n'; }
  4242. break;
  4243. case 'p':
  4244. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.paragraph')(node, globals) + '\n\n'; }
  4245. break;
  4246. case 'blockquote':
  4247. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.blockquote')(node, globals) + '\n\n'; }
  4248. break;
  4249. case 'hr':
  4250. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.hr')(node, globals) + '\n\n'; }
  4251. break;
  4252. case 'ol':
  4253. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ol') + '\n\n'; }
  4254. break;
  4255. case 'ul':
  4256. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ul') + '\n\n'; }
  4257. break;
  4258. case 'precode':
  4259. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.codeBlock')(node, globals) + '\n\n'; }
  4260. break;
  4261. case 'pre':
  4262. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.pre')(node, globals) + '\n\n'; }
  4263. break;
  4264. case 'table':
  4265. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.table')(node, globals) + '\n\n'; }
  4266. break;
  4267. //
  4268. // SPANS
  4269. //
  4270. case 'code':
  4271. txt = showdown.subParser('makeMarkdown.codeSpan')(node, globals);
  4272. break;
  4273. case 'em':
  4274. case 'i':
  4275. txt = showdown.subParser('makeMarkdown.emphasis')(node, globals);
  4276. break;
  4277. case 'strong':
  4278. case 'b':
  4279. txt = showdown.subParser('makeMarkdown.strong')(node, globals);
  4280. break;
  4281. case 'del':
  4282. txt = showdown.subParser('makeMarkdown.strikethrough')(node, globals);
  4283. break;
  4284. case 'a':
  4285. txt = showdown.subParser('makeMarkdown.links')(node, globals);
  4286. break;
  4287. case 'img':
  4288. txt = showdown.subParser('makeMarkdown.image')(node, globals);
  4289. break;
  4290. default:
  4291. txt = node.outerHTML + '\n\n';
  4292. }
  4293. // common normalization
  4294. // TODO eventually
  4295. return txt;
  4296. });
  4297. showdown.subParser('makeMarkdown.paragraph', function (node, globals) {
  4298. 'use strict';
  4299. var txt = '';
  4300. if (node.hasChildNodes()) {
  4301. var children = node.childNodes,
  4302. childrenLength = children.length;
  4303. for (var i = 0; i < childrenLength; ++i) {
  4304. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4305. }
  4306. }
  4307. // some text normalization
  4308. txt = txt.trim();
  4309. return txt;
  4310. });
  4311. showdown.subParser('makeMarkdown.pre', function (node, globals) {
  4312. 'use strict';
  4313. var num = node.getAttribute('prenum');
  4314. return '<pre>' + globals.preList[num] + '</pre>';
  4315. });
  4316. showdown.subParser('makeMarkdown.strikethrough', function (node, globals) {
  4317. 'use strict';
  4318. var txt = '';
  4319. if (node.hasChildNodes()) {
  4320. txt += '~~';
  4321. var children = node.childNodes,
  4322. childrenLength = children.length;
  4323. for (var i = 0; i < childrenLength; ++i) {
  4324. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4325. }
  4326. txt += '~~';
  4327. }
  4328. return txt;
  4329. });
  4330. showdown.subParser('makeMarkdown.strong', function (node, globals) {
  4331. 'use strict';
  4332. var txt = '';
  4333. if (node.hasChildNodes()) {
  4334. txt += '**';
  4335. var children = node.childNodes,
  4336. childrenLength = children.length;
  4337. for (var i = 0; i < childrenLength; ++i) {
  4338. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4339. }
  4340. txt += '**';
  4341. }
  4342. return txt;
  4343. });
  4344. showdown.subParser('makeMarkdown.table', function (node, globals) {
  4345. 'use strict';
  4346. var txt = '',
  4347. tableArray = [[], []],
  4348. headings = node.querySelectorAll('thead>tr>th'),
  4349. rows = node.querySelectorAll('tbody>tr'),
  4350. i, ii;
  4351. for (i = 0; i < headings.length; ++i) {
  4352. var headContent = showdown.subParser('makeMarkdown.tableCell')(headings[i], globals),
  4353. allign = '---';
  4354. if (headings[i].hasAttribute('style')) {
  4355. var style = headings[i].getAttribute('style').toLowerCase().replace(/\s/g, '');
  4356. switch (style) {
  4357. case 'text-align:left;':
  4358. allign = ':---';
  4359. break;
  4360. case 'text-align:right;':
  4361. allign = '---:';
  4362. break;
  4363. case 'text-align:center;':
  4364. allign = ':---:';
  4365. break;
  4366. }
  4367. }
  4368. tableArray[0][i] = headContent.trim();
  4369. tableArray[1][i] = allign;
  4370. }
  4371. for (i = 0; i < rows.length; ++i) {
  4372. var r = tableArray.push([]) - 1,
  4373. cols = rows[i].getElementsByTagName('td');
  4374. for (ii = 0; ii < headings.length; ++ii) {
  4375. var cellContent = ' ';
  4376. if (typeof cols[ii] !== 'undefined') {
  4377. cellContent = showdown.subParser('makeMarkdown.tableCell')(cols[ii], globals);
  4378. }
  4379. tableArray[r].push(cellContent);
  4380. }
  4381. }
  4382. var cellSpacesCount = 3;
  4383. for (i = 0; i < tableArray.length; ++i) {
  4384. for (ii = 0; ii < tableArray[i].length; ++ii) {
  4385. var strLen = tableArray[i][ii].length;
  4386. if (strLen > cellSpacesCount) {
  4387. cellSpacesCount = strLen;
  4388. }
  4389. }
  4390. }
  4391. for (i = 0; i < tableArray.length; ++i) {
  4392. for (ii = 0; ii < tableArray[i].length; ++ii) {
  4393. if (i === 1) {
  4394. if (tableArray[i][ii].slice(-1) === ':') {
  4395. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii].slice(-1), cellSpacesCount - 1, '-') + ':';
  4396. } else {
  4397. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount, '-');
  4398. }
  4399. } else {
  4400. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount);
  4401. }
  4402. }
  4403. txt += '| ' + tableArray[i].join(' | ') + ' |\n';
  4404. }
  4405. return txt.trim();
  4406. });
  4407. showdown.subParser('makeMarkdown.tableCell', function (node, globals) {
  4408. 'use strict';
  4409. var txt = '';
  4410. if (!node.hasChildNodes()) {
  4411. return '';
  4412. }
  4413. var children = node.childNodes,
  4414. childrenLength = children.length;
  4415. for (var i = 0; i < childrenLength; ++i) {
  4416. txt += showdown.subParser('makeMarkdown.node')(children[i], globals, true);
  4417. }
  4418. return txt.trim();
  4419. });
  4420. showdown.subParser('makeMarkdown.txt', function (node) {
  4421. 'use strict';
  4422. var txt = node.nodeValue;
  4423. // multiple spaces are collapsed
  4424. txt = txt.replace(/ +/g, ' ');
  4425. // replace the custom ¨NBSP; with a space
  4426. txt = txt.replace(/¨NBSP;/g, ' ');
  4427. // ", <, > and & should replace escaped html entities
  4428. txt = showdown.helper.unescapeHTMLEntities(txt);
  4429. // escape markdown magic characters
  4430. // emphasis, strong and strikethrough - can appear everywhere
  4431. // we also escape pipe (|) because of tables
  4432. // and escape ` because of code blocks and spans
  4433. txt = txt.replace(/([*_~|`])/g, '\\$1');
  4434. // escape > because of blockquotes
  4435. txt = txt.replace(/^(\s*)>/g, '\\$1>');
  4436. // hash character, only troublesome at the beginning of a line because of headers
  4437. txt = txt.replace(/^#/gm, '\\#');
  4438. // horizontal rules
  4439. txt = txt.replace(/^(\s*)([-=]{3,})(\s*)$/, '$1\\$2$3');
  4440. // dot, because of ordered lists, only troublesome at the beginning of a line when preceded by an integer
  4441. txt = txt.replace(/^( {0,3}\d+)\./gm, '$1\\.');
  4442. // +, * and -, at the beginning of a line becomes a list, so we need to escape them also (asterisk was already escaped)
  4443. txt = txt.replace(/^( {0,3})([+-])/gm, '$1\\$2');
  4444. // images and links, ] followed by ( is problematic, so we escape it
  4445. txt = txt.replace(/]([\s]*)\(/g, '\\]$1\\(');
  4446. // reference URIs must also be escaped
  4447. txt = txt.replace(/^ {0,3}\[([\S \t]*?)]:/gm, '\\[$1]:');
  4448. return txt;
  4449. });
  4450. /**
  4451. * Created by Estevao on 31-05-2015.
  4452. */
  4453. /**
  4454. * Showdown Converter class
  4455. * @class
  4456. * @param {object} [converterOptions]
  4457. * @returns {Converter}
  4458. */
  4459. showdown.Converter = function (converterOptions) {
  4460. 'use strict';
  4461. var
  4462. /**
  4463. * Options used by this converter
  4464. * @private
  4465. * @type {{}}
  4466. */
  4467. options = {},
  4468. /**
  4469. * Language extensions used by this converter
  4470. * @private
  4471. * @type {Array}
  4472. */
  4473. langExtensions = [],
  4474. /**
  4475. * Output modifiers extensions used by this converter
  4476. * @private
  4477. * @type {Array}
  4478. */
  4479. outputModifiers = [],
  4480. /**
  4481. * Event listeners
  4482. * @private
  4483. * @type {{}}
  4484. */
  4485. listeners = {},
  4486. /**
  4487. * The flavor set in this converter
  4488. */
  4489. setConvFlavor = setFlavor,
  4490. /**
  4491. * Metadata of the document
  4492. * @type {{parsed: {}, raw: string, format: string}}
  4493. */
  4494. metadata = {
  4495. parsed: {},
  4496. raw: '',
  4497. format: ''
  4498. };
  4499. _constructor();
  4500. /**
  4501. * Converter constructor
  4502. * @private
  4503. */
  4504. function _constructor () {
  4505. converterOptions = converterOptions || {};
  4506. for (var gOpt in globalOptions) {
  4507. if (globalOptions.hasOwnProperty(gOpt)) {
  4508. options[gOpt] = globalOptions[gOpt];
  4509. }
  4510. }
  4511. // Merge options
  4512. if (typeof converterOptions === 'object') {
  4513. for (var opt in converterOptions) {
  4514. if (converterOptions.hasOwnProperty(opt)) {
  4515. options[opt] = converterOptions[opt];
  4516. }
  4517. }
  4518. } else {
  4519. throw Error('Converter expects the passed parameter to be an object, but ' + typeof converterOptions +
  4520. ' was passed instead.');
  4521. }
  4522. if (options.extensions) {
  4523. showdown.helper.forEach(options.extensions, _parseExtension);
  4524. }
  4525. }
  4526. /**
  4527. * Parse extension
  4528. * @param {*} ext
  4529. * @param {string} [name='']
  4530. * @private
  4531. */
  4532. function _parseExtension (ext, name) {
  4533. name = name || null;
  4534. // If it's a string, the extension was previously loaded
  4535. if (showdown.helper.isString(ext)) {
  4536. ext = showdown.helper.stdExtName(ext);
  4537. name = ext;
  4538. // LEGACY_SUPPORT CODE
  4539. if (showdown.extensions[ext]) {
  4540. console.warn('DEPRECATION WARNING: ' + ext + ' is an old extension that uses a deprecated loading method.' +
  4541. 'Please inform the developer that the extension should be updated!');
  4542. legacyExtensionLoading(showdown.extensions[ext], ext);
  4543. return;
  4544. // END LEGACY SUPPORT CODE
  4545. } else if (!showdown.helper.isUndefined(extensions[ext])) {
  4546. ext = extensions[ext];
  4547. } else {
  4548. throw Error('Extension "' + ext + '" could not be loaded. It was either not found or is not a valid extension.');
  4549. }
  4550. }
  4551. if (typeof ext === 'function') {
  4552. ext = ext();
  4553. }
  4554. if (!showdown.helper.isArray(ext)) {
  4555. ext = [ext];
  4556. }
  4557. var validExt = validate(ext, name);
  4558. if (!validExt.valid) {
  4559. throw Error(validExt.error);
  4560. }
  4561. for (var i = 0; i < ext.length; ++i) {
  4562. switch (ext[i].type) {
  4563. case 'lang':
  4564. langExtensions.push(ext[i]);
  4565. break;
  4566. case 'output':
  4567. outputModifiers.push(ext[i]);
  4568. break;
  4569. }
  4570. if (ext[i].hasOwnProperty('listeners')) {
  4571. for (var ln in ext[i].listeners) {
  4572. if (ext[i].listeners.hasOwnProperty(ln)) {
  4573. listen(ln, ext[i].listeners[ln]);
  4574. }
  4575. }
  4576. }
  4577. }
  4578. }
  4579. /**
  4580. * LEGACY_SUPPORT
  4581. * @param {*} ext
  4582. * @param {string} name
  4583. */
  4584. function legacyExtensionLoading (ext, name) {
  4585. if (typeof ext === 'function') {
  4586. ext = ext(new showdown.Converter());
  4587. }
  4588. if (!showdown.helper.isArray(ext)) {
  4589. ext = [ext];
  4590. }
  4591. var valid = validate(ext, name);
  4592. if (!valid.valid) {
  4593. throw Error(valid.error);
  4594. }
  4595. for (var i = 0; i < ext.length; ++i) {
  4596. switch (ext[i].type) {
  4597. case 'lang':
  4598. langExtensions.push(ext[i]);
  4599. break;
  4600. case 'output':
  4601. outputModifiers.push(ext[i]);
  4602. break;
  4603. default:// should never reach here
  4604. throw Error('Extension loader error: Type unrecognized!!!');
  4605. }
  4606. }
  4607. }
  4608. /**
  4609. * Listen to an event
  4610. * @param {string} name
  4611. * @param {function} callback
  4612. */
  4613. function listen (name, callback) {
  4614. if (!showdown.helper.isString(name)) {
  4615. throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given');
  4616. }
  4617. if (typeof callback !== 'function') {
  4618. throw Error('Invalid argument in converter.listen() method: callback must be a function, but ' + typeof callback + ' given');
  4619. }
  4620. name = name.toLowerCase();
  4621. if (!listeners.hasOwnProperty(name)) {
  4622. listeners[name] = [];
  4623. }
  4624. listeners[name].push(callback);
  4625. }
  4626. function rTrimInputText (text) {
  4627. var rsp = text.match(/^\s*/)[0].length,
  4628. rgx = new RegExp('^\\s{0,' + rsp + '}', 'gm');
  4629. return text.replace(rgx, '');
  4630. }
  4631. /**
  4632. *
  4633. * @param {string} evtName Event name
  4634. * @param {string} text Text
  4635. * @param {{}} options Converter Options
  4636. * @param {{}} globals Converter globals
  4637. * @param {{}} pParams extra params for event
  4638. * @returns showdown.helper.Event
  4639. * @private
  4640. */
  4641. this._dispatch = function dispatch (evtName, text, options, globals, pParams) {
  4642. evtName = evtName.toLowerCase();
  4643. var params = pParams || {};
  4644. params.converter = this;
  4645. params.text = text;
  4646. params.options = options;
  4647. params.globals = globals;
  4648. var event = new showdown.helper.Event(evtName, text, params);
  4649. if (listeners.hasOwnProperty(evtName)) {
  4650. for (var ei = 0; ei < listeners[evtName].length; ++ei) {
  4651. var nText = listeners[evtName][ei](event);
  4652. if (nText && typeof nText !== 'undefined') {
  4653. event.setText(nText);
  4654. }
  4655. }
  4656. }
  4657. return event;
  4658. };
  4659. /**
  4660. * Listen to an event
  4661. * @param {string} name
  4662. * @param {function} callback
  4663. * @returns {showdown.Converter}
  4664. */
  4665. this.listen = function (name, callback) {
  4666. listen(name, callback);
  4667. return this;
  4668. };
  4669. /**
  4670. * Converts a markdown string into HTML string
  4671. * @param {string} text
  4672. * @returns {*}
  4673. */
  4674. this.makeHtml = function (text) {
  4675. //check if text is not falsy
  4676. if (!text) {
  4677. return text;
  4678. }
  4679. var globals = {
  4680. gHtmlBlocks: [],
  4681. gHtmlMdBlocks: [],
  4682. gHtmlSpans: [],
  4683. gUrls: {},
  4684. gTitles: {},
  4685. gDimensions: {},
  4686. gListLevel: 0,
  4687. hashLinkCounts: {},
  4688. langExtensions: langExtensions,
  4689. outputModifiers: outputModifiers,
  4690. converter: this,
  4691. ghCodeBlocks: [],
  4692. metadata: {
  4693. parsed: {},
  4694. raw: '',
  4695. format: ''
  4696. }
  4697. };
  4698. // This lets us use ¨ trema as an escape char to avoid md5 hashes
  4699. // The choice of character is arbitrary; anything that isn't
  4700. // magic in Markdown will work.
  4701. text = text.replace(/¨/g, '¨T');
  4702. // Replace $ with ¨D
  4703. // RegExp interprets $ as a special character
  4704. // when it's in a replacement string
  4705. text = text.replace(/\$/g, '¨D');
  4706. // Standardize line endings
  4707. text = text.replace(/\r\n/g, '\n'); // DOS to Unix
  4708. text = text.replace(/\r/g, '\n'); // Mac to Unix
  4709. // Stardardize line spaces
  4710. text = text.replace(/\u00A0/g, '&nbsp;');
  4711. if (options.smartIndentationFix) {
  4712. text = rTrimInputText(text);
  4713. }
  4714. // Make sure text begins and ends with a couple of newlines:
  4715. text = '\n\n' + text + '\n\n';
  4716. // detab
  4717. text = showdown.subParser('makehtml.detab')(text, options, globals);
  4718. /**
  4719. * Strip any lines consisting only of spaces and tabs.
  4720. * This makes subsequent regexs easier to write, because we can
  4721. * match consecutive blank lines with /\n+/ instead of something
  4722. * contorted like /[ \t]*\n+/
  4723. */
  4724. text = text.replace(/^[ \t]+$/mg, '');
  4725. //run languageExtensions
  4726. showdown.helper.forEach(langExtensions, function (ext) {
  4727. text = showdown.subParser('makehtml.runExtension')(ext, text, options, globals);
  4728. });
  4729. // run the sub parsers
  4730. text = showdown.subParser('makehtml.metadata')(text, options, globals);
  4731. text = showdown.subParser('makehtml.hashPreCodeTags')(text, options, globals);
  4732. text = showdown.subParser('makehtml.githubCodeBlocks')(text, options, globals);
  4733. text = showdown.subParser('makehtml.hashHTMLBlocks')(text, options, globals);
  4734. text = showdown.subParser('makehtml.hashCodeTags')(text, options, globals);
  4735. text = showdown.subParser('makehtml.stripLinkDefinitions')(text, options, globals);
  4736. text = showdown.subParser('makehtml.blockGamut')(text, options, globals);
  4737. text = showdown.subParser('makehtml.unhashHTMLSpans')(text, options, globals);
  4738. text = showdown.subParser('makehtml.unescapeSpecialChars')(text, options, globals);
  4739. // attacklab: Restore dollar signs
  4740. text = text.replace(/¨D/g, '$$');
  4741. // attacklab: Restore tremas
  4742. text = text.replace(/¨T/g, '¨');
  4743. // render a complete html document instead of a partial if the option is enabled
  4744. text = showdown.subParser('makehtml.completeHTMLDocument')(text, options, globals);
  4745. // Run output modifiers
  4746. showdown.helper.forEach(outputModifiers, function (ext) {
  4747. text = showdown.subParser('makehtml.runExtension')(ext, text, options, globals);
  4748. });
  4749. // update metadata
  4750. metadata = globals.metadata;
  4751. return text;
  4752. };
  4753. /**
  4754. * Converts an HTML string into a markdown string
  4755. * @param src
  4756. * @returns {string}
  4757. */
  4758. this.makeMarkdown = function (src) {
  4759. // replace \r\n with \n
  4760. src = src.replace(/\r\n/g, '\n');
  4761. src = src.replace(/\r/g, '\n'); // old macs
  4762. // due to an edge case, we need to find this: > <
  4763. // to prevent removing of non silent white spaces
  4764. // ex: <em>this is</em> <strong>sparta</strong>
  4765. src = src.replace(/>[ \t]+</, '>¨NBSP;<');
  4766. var doc = showdown.helper.document.createElement('div');
  4767. doc.innerHTML = src;
  4768. var globals = {
  4769. preList: substitutePreCodeTags(doc)
  4770. };
  4771. // remove all newlines and collapse spaces
  4772. clean(doc);
  4773. // some stuff, like accidental reference links must now be escaped
  4774. // TODO
  4775. // doc.innerHTML = doc.innerHTML.replace(/\[[\S\t ]]/);
  4776. var nodes = doc.childNodes,
  4777. mdDoc = '';
  4778. for (var i = 0; i < nodes.length; i++) {
  4779. mdDoc += showdown.subParser('makeMarkdown.node')(nodes[i], globals);
  4780. }
  4781. function clean (node) {
  4782. for (var n = 0; n < node.childNodes.length; ++n) {
  4783. var child = node.childNodes[n];
  4784. if (child.nodeType === 3) {
  4785. if (!/\S/.test(child.nodeValue)) {
  4786. node.removeChild(child);
  4787. --n;
  4788. } else {
  4789. child.nodeValue = child.nodeValue.split('\n').join(' ');
  4790. child.nodeValue = child.nodeValue.replace(/(\s)+/g, '$1');
  4791. }
  4792. } else if (child.nodeType === 1) {
  4793. clean(child);
  4794. }
  4795. }
  4796. }
  4797. // find all pre tags and replace contents with placeholder
  4798. // we need this so that we can remove all indentation from html
  4799. // to ease up parsing
  4800. function substitutePreCodeTags (doc) {
  4801. var pres = doc.querySelectorAll('pre'),
  4802. presPH = [];
  4803. for (var i = 0; i < pres.length; ++i) {
  4804. if (pres[i].childElementCount === 1 && pres[i].firstChild.tagName.toLowerCase() === 'code') {
  4805. var content = pres[i].firstChild.innerHTML.trim(),
  4806. language = pres[i].firstChild.getAttribute('data-language') || '';
  4807. // if data-language attribute is not defined, then we look for class language-*
  4808. if (language === '') {
  4809. var classes = pres[i].firstChild.className.split(' ');
  4810. for (var c = 0; c < classes.length; ++c) {
  4811. var matches = classes[c].match(/^language-(.+)$/);
  4812. if (matches !== null) {
  4813. language = matches[1];
  4814. break;
  4815. }
  4816. }
  4817. }
  4818. // unescape html entities in content
  4819. content = showdown.helper.unescapeHTMLEntities(content);
  4820. presPH.push(content);
  4821. pres[i].outerHTML = '<precode language="' + language + '" precodenum="' + i.toString() + '"></precode>';
  4822. } else {
  4823. presPH.push(pres[i].innerHTML);
  4824. pres[i].innerHTML = '';
  4825. pres[i].setAttribute('prenum', i.toString());
  4826. }
  4827. }
  4828. return presPH;
  4829. }
  4830. return mdDoc;
  4831. };
  4832. /**
  4833. * Set an option of this Converter instance
  4834. * @param {string} key
  4835. * @param {*} value
  4836. */
  4837. this.setOption = function (key, value) {
  4838. options[key] = value;
  4839. };
  4840. /**
  4841. * Get the option of this Converter instance
  4842. * @param {string} key
  4843. * @returns {*}
  4844. */
  4845. this.getOption = function (key) {
  4846. return options[key];
  4847. };
  4848. /**
  4849. * Get the options of this Converter instance
  4850. * @returns {{}}
  4851. */
  4852. this.getOptions = function () {
  4853. return options;
  4854. };
  4855. /**
  4856. * Add extension to THIS converter
  4857. * @param {{}} extension
  4858. * @param {string} [name=null]
  4859. */
  4860. this.addExtension = function (extension, name) {
  4861. name = name || null;
  4862. _parseExtension(extension, name);
  4863. };
  4864. /**
  4865. * Use a global registered extension with THIS converter
  4866. * @param {string} extensionName Name of the previously registered extension
  4867. */
  4868. this.useExtension = function (extensionName) {
  4869. _parseExtension(extensionName);
  4870. };
  4871. /**
  4872. * Set the flavor THIS converter should use
  4873. * @param {string} name
  4874. */
  4875. this.setFlavor = function (name) {
  4876. if (!flavor.hasOwnProperty(name)) {
  4877. throw Error(name + ' flavor was not found');
  4878. }
  4879. var preset = flavor[name];
  4880. setConvFlavor = name;
  4881. for (var option in preset) {
  4882. if (preset.hasOwnProperty(option)) {
  4883. options[option] = preset[option];
  4884. }
  4885. }
  4886. };
  4887. /**
  4888. * Get the currently set flavor of this converter
  4889. * @returns {string}
  4890. */
  4891. this.getFlavor = function () {
  4892. return setConvFlavor;
  4893. };
  4894. /**
  4895. * Remove an extension from THIS converter.
  4896. * Note: This is a costly operation. It's better to initialize a new converter
  4897. * and specify the extensions you wish to use
  4898. * @param {Array} extension
  4899. */
  4900. this.removeExtension = function (extension) {
  4901. if (!showdown.helper.isArray(extension)) {
  4902. extension = [extension];
  4903. }
  4904. for (var a = 0; a < extension.length; ++a) {
  4905. var ext = extension[a];
  4906. for (var i = 0; i < langExtensions.length; ++i) {
  4907. if (langExtensions[i] === ext) {
  4908. langExtensions[i].splice(i, 1);
  4909. }
  4910. }
  4911. for (var ii = 0; ii < outputModifiers.length; ++i) {
  4912. if (outputModifiers[ii] === ext) {
  4913. outputModifiers[ii].splice(i, 1);
  4914. }
  4915. }
  4916. }
  4917. };
  4918. /**
  4919. * Get all extension of THIS converter
  4920. * @returns {{language: Array, output: Array}}
  4921. */
  4922. this.getAllExtensions = function () {
  4923. return {
  4924. language: langExtensions,
  4925. output: outputModifiers
  4926. };
  4927. };
  4928. /**
  4929. * Get the metadata of the previously parsed document
  4930. * @param raw
  4931. * @returns {string|{}}
  4932. */
  4933. this.getMetadata = function (raw) {
  4934. if (raw) {
  4935. return metadata.raw;
  4936. } else {
  4937. return metadata.parsed;
  4938. }
  4939. };
  4940. /**
  4941. * Get the metadata format of the previously parsed document
  4942. * @returns {string}
  4943. */
  4944. this.getMetadataFormat = function () {
  4945. return metadata.format;
  4946. };
  4947. /**
  4948. * Private: set a single key, value metadata pair
  4949. * @param {string} key
  4950. * @param {string} value
  4951. */
  4952. this._setMetadataPair = function (key, value) {
  4953. metadata.parsed[key] = value;
  4954. };
  4955. /**
  4956. * Private: set metadata format
  4957. * @param {string} format
  4958. */
  4959. this._setMetadataFormat = function (format) {
  4960. metadata.format = format;
  4961. };
  4962. /**
  4963. * Private: set metadata raw text
  4964. * @param {string} raw
  4965. */
  4966. this._setMetadataRaw = function (raw) {
  4967. metadata.raw = raw;
  4968. };
  4969. };
  4970. var root = this;
  4971. // AMD Loader
  4972. if (typeof define === 'function' && define.amd) {
  4973. define(function () {
  4974. 'use strict';
  4975. return showdown;
  4976. });
  4977. // CommonJS/nodeJS Loader
  4978. } else if (typeof module !== 'undefined' && module.exports) {
  4979. module.exports = showdown;
  4980. // Regular Browser loader
  4981. } else {
  4982. root.showdown = showdown;
  4983. }
  4984. }).call(this);
  4985. //# sourceMappingURL=showdown.js.map
  4986. <!-- Reusable -->
  4987. // Topic: ES6 String contains, starts with, ends with to ES5
  4988. // Source: https://gist.github.com/hamiltondanielb/a174bc415fdd71966de1
  4989. String.prototype.endsWith = String.prototype.endsWith || function(suffix) {
  4990. return this.indexOf(suffix, this.length - suffix.length) >= 0;
  4991. };
  4992. // Topic: ES6 String contains, starts with, ends with to ES5
  4993. // Source: https://gist.github.com/hamiltondanielb/a174bc415fdd71966de1
  4994. String.prototype.startsWith = String.prototype.startsWith || function(prefix) {
  4995. return this.indexOf(prefix) === 0;
  4996. };
  4997. // Topic: JavaScript equivalent to printf/String.Format
  4998. // Source: https://stackoverflow.com/a/4673436
  4999. function formatString() {
  5000. // Topic: How to shift “arguments”?
  5001. // Source: https://stackoverflow.com/questions/4775895/how-to-shift-arguments
  5002. var args = Array.prototype.slice.call(arguments);
  5003. var str = args.shift();
  5004. return str.replace(/{(\d+)}/g, function(match, number) {
  5005. return typeof args[number] != 'undefined'
  5006. ? args[number]
  5007. : match
  5008. ;
  5009. });
  5010. };
  5011. function fileExists(fileName, fileList)
  5012. {
  5013. for (var id in fileList)
  5014. {
  5015. var file = fileList[id];
  5016. if (file.path === fileName)
  5017. {
  5018. return true;
  5019. }
  5020. }
  5021. return false;
  5022. }
  5023. // Topic: Create GUID / UUID in JavaScript?
  5024. // Source: https://stackoverflow.com/a/2117523
  5025. function generateUUID()
  5026. {
  5027. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(
  5028. /[xy]/g,
  5029. function(c)
  5030. {
  5031. var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
  5032. return v.toString(16);
  5033. }
  5034. );
  5035. }
  5036. function LOG(message)
  5037. {
  5038. var log = document.getElementById("log");
  5039. var now = new Date();
  5040. log.innerHTML += now.toISOString() + " " + message + "<br>";
  5041. }
  5042. function parseINI(contents)
  5043. {
  5044. var cfg = { };
  5045. var lines = contents.split(/\r\n|\r|\n/);
  5046. for (var id in lines)
  5047. {
  5048. var line = lines[id];
  5049. var keyAndValue = line.split(/=/);
  5050. if (keyAndValue.length == 2)
  5051. {
  5052. var key = keyAndValue[0].trim();
  5053. var value = keyAndValue[1].trim();
  5054. cfg[key] = value;
  5055. }
  5056. }
  5057. return cfg;
  5058. }
  5059. // ReporterSubscription class.
  5060. function ReporterSubscription(id, callback, reporter)
  5061. {
  5062. this.id = id;
  5063. this.callback = callback;
  5064. this.reporter = reporter;
  5065. }
  5066. // Reporter class.
  5067. function Reporter(name)
  5068. {
  5069. this.name =
  5070. (typeof name !== "undefined") ?
  5071. name :
  5072. "";
  5073. this.subscriptions = [];
  5074. }
  5075. Reporter.prototype.report = function()
  5076. {
  5077. for (var id in this.subscriptions)
  5078. {
  5079. var subscription = this.subscriptions[id];
  5080. subscription.callback();
  5081. }
  5082. }
  5083. Reporter.prototype.subscribe = function(callback)
  5084. {
  5085. var id = generateUUID();
  5086. var subscription = new ReporterSubscription(id, callback, this);
  5087. this.subscriptions.push(subscription);
  5088. return subscription;
  5089. }
  5090. <!-- LFSA -->
  5091. // LFSA class to communicate with local-file-system-access instance.
  5092. function LFSA()
  5093. {
  5094. this.host = "http://127.0.0.1";
  5095. this.port = 8000;
  5096. }
  5097. LFSA.prototype.get = function(url, successCallback, failureCallback)
  5098. {
  5099. var req = new XMLHttpRequest();
  5100. req.onreadystatechange = function()
  5101. {
  5102. if (this.readyState == 4)
  5103. {
  5104. if (this.status == 200)
  5105. {
  5106. //console.log("get.successCallback.responseText: '" + this.responseText + "'");
  5107. successCallback(this.responseText);
  5108. }
  5109. else
  5110. {
  5111. failureCallback();
  5112. }
  5113. }
  5114. }
  5115. const prefix = this.host + ":" + this.port;
  5116. const addr = prefix + url;
  5117. //console.log("GET addr: '" + addr + "'");
  5118. req.open("GET", addr);
  5119. req.send();
  5120. }
  5121. LFSA.prototype.requestPath = function(successCallback, failureCallback)
  5122. {
  5123. this.get("/path", successCallback, failureCallback);
  5124. }
  5125. LFSA.prototype.post = function(url, data, successCallback, failureCallback)
  5126. {
  5127. var req = new XMLHttpRequest();
  5128. req.onreadystatechange = function()
  5129. {
  5130. if (this.readyState == 4)
  5131. {
  5132. if (this.status == 200)
  5133. {
  5134. //console.log("POST.successCallback.responseText: '" + this.responseText + "'");
  5135. successCallback(this.responseText);
  5136. }
  5137. else
  5138. {
  5139. failureCallback();
  5140. }
  5141. }
  5142. }
  5143. const prefix = this.host + ":" + this.port;
  5144. const addr = prefix + url;
  5145. //console.log("POST addr: '" + addr + "'");
  5146. req.open("POST", addr);
  5147. req.send(data);
  5148. }
  5149. LFSA.prototype.requestFileList = function(dir, successCallback, failureCallback)
  5150. {
  5151. this.post(
  5152. "/list",
  5153. dir,
  5154. function(response)
  5155. {
  5156. var json = JSON.parse(response);
  5157. successCallback(json);
  5158. },
  5159. failureCallback
  5160. );
  5161. }
  5162. LFSA.prototype.requestFile = function(path, successCallback, failureCallback)
  5163. {
  5164. this.post(
  5165. "/read",
  5166. path,
  5167. successCallback,
  5168. failureCallback
  5169. );
  5170. }
  5171. LFSA.prototype.base64encode = function(str)
  5172. {
  5173. // Topic: javascript atob returning 'String contains an invalid character'
  5174. // Source: https://stackoverflow.com/a/9786592
  5175. return btoa(unescape(encodeURIComponent(str)));
  5176. }
  5177. LFSA.prototype.saveFile = function(path, contents, successCallback, failureCallback)
  5178. {
  5179. var data = {};
  5180. data["path"] = path;
  5181. data["contents"] = this.base64encode(contents);
  5182. var datastr = JSON.stringify(data);
  5183. this.post(
  5184. "/write",
  5185. datastr,
  5186. successCallback,
  5187. failureCallback
  5188. );
  5189. }
  5190. // FileOperation class is used for bulk read/write LFSA operations.
  5191. function FileOperation()
  5192. {
  5193. this.path = null;
  5194. this.contents = null;
  5195. this.isSuccessful = null;
  5196. }
  5197. LFSA.prototype.requestFiles = function(operations, processCallback, completionCallback)
  5198. {
  5199. var self = this;
  5200. // Prepare operation queue.
  5201. var queue = [];
  5202. for (var id in operations)
  5203. {
  5204. var operation = operations[id];
  5205. queue.push(operation);
  5206. }
  5207. // Currently processed operation.
  5208. var operation = null;
  5209. // Function to read single file.
  5210. function process()
  5211. {
  5212. // Continue.
  5213. if (queue.length > 0)
  5214. {
  5215. operation = queue.shift();
  5216. self.requestFile(operation.path, success, failure);
  5217. if (processCallback)
  5218. {
  5219. processCallback();
  5220. }
  5221. }
  5222. // Interrupt.
  5223. else
  5224. {
  5225. if (completionCallback)
  5226. {
  5227. completionCallback();
  5228. }
  5229. }
  5230. }
  5231. var success = function(contents)
  5232. {
  5233. operation.contents = contents;
  5234. operation.isSuccessful = true;
  5235. process();
  5236. }
  5237. var failure = function()
  5238. {
  5239. operation.isSuccessful = false;
  5240. process();
  5241. }
  5242. // Start processing.
  5243. process();
  5244. }
  5245. LFSA.prototype.saveFiles = function(operations, processCallback, completionCallback)
  5246. {
  5247. var self = this;
  5248. // Prepare operation queue.
  5249. var queue = [];
  5250. for (var id in operations)
  5251. {
  5252. var operation = operations[id];
  5253. queue.push(operation);
  5254. }
  5255. // Currently processed operation.
  5256. var operation = null;
  5257. // Function to save single file.
  5258. function process()
  5259. {
  5260. // Continue.
  5261. if (queue.length > 0)
  5262. {
  5263. operation = queue.shift();
  5264. self.saveFile(operation.path, operation.contents, success, failure);
  5265. if (processCallback)
  5266. {
  5267. processCallback();
  5268. }
  5269. }
  5270. // Interrupt.
  5271. else
  5272. {
  5273. if (completionCallback)
  5274. {
  5275. completionCallback();
  5276. }
  5277. }
  5278. }
  5279. var success = function()
  5280. {
  5281. operation.isSuccessful = true;
  5282. process();
  5283. }
  5284. var failure = function()
  5285. {
  5286. operation.isSuccessful = false;
  5287. process();
  5288. }
  5289. // Start processing.
  5290. process();
  5291. }
  5292. <!-- Common -->
  5293. // NewsItem class.
  5294. function NewsItem()
  5295. {
  5296. this.date = null;
  5297. this.slug = null;
  5298. this.contents = "";
  5299. // Currently unused properties.
  5300. this.lang = null;
  5301. this.category = null;
  5302. }
  5303. // PreviewPage class.
  5304. function PreviewPage()
  5305. {
  5306. this.items = [];
  5307. this.previews = [];
  5308. }
  5309. <!-- Cfg -->
  5310. // Cfg class.
  5311. function Cfg()
  5312. {
  5313. var self = this;
  5314. this.lfsa = null;
  5315. this.cfg = {};
  5316. this.cfgChanged = new Reporter();
  5317. this.fileName = "pskov.cfg";
  5318. this.logTranslations = {};
  5319. this.logTranslations["FILE_EXISTS"] = "'{0}' file exists: '{1}'";
  5320. this.logTranslations["FILE_DOES_NOT_EXIST"] = "ERROR '{0}' file does not exist";
  5321. this.logTranslations["FILE_CHECK_FAILED"] = "ERROR Could not check if '{0}' file exists because LFSA request failed";
  5322. this.logTranslations["COULD_NOT_READ"] = "ERROR Could not read '{0}' file";
  5323. this.logTranslations["SAVED"] = "Saved configuration";
  5324. this.logTranslations["SAVING"] = "Saving configuration into '{0}' file...";
  5325. this.logTranslations["COULD_NOT_SAVE"] = "ERROR Could not save '{0}' file";
  5326. this.exists = false;
  5327. this.existsChanged = new Reporter();
  5328. this.existsChanged.subscribe(function(){
  5329. self.LOG("FILE_EXISTS", self.fileName, self.exists)
  5330. });
  5331. this.saved = new Reporter();
  5332. }
  5333. // Cfg's startup sequence.
  5334. Cfg.prototype.run = function()
  5335. {
  5336. var self = this;
  5337. this.checkExistence();
  5338. this.existsChanged.subscribe(function(){
  5339. self.load();
  5340. });
  5341. this.cfgChanged.subscribe(function(){
  5342. self.display();
  5343. });
  5344. this.saved.subscribe(function(){
  5345. self.load();
  5346. });
  5347. this.saved.subscribe(function(){
  5348. self.LOG("SAVED");
  5349. });
  5350. this.cfgChanged.subscribe(function(){
  5351. self.cfg["output"] = self.cfg["input"];
  5352. });
  5353. }
  5354. Cfg.prototype.LOG = function()
  5355. {
  5356. var args = Array.prototype.slice.call(arguments);
  5357. var translationKey = args.shift();
  5358. var message = "Cfg ";
  5359. if (translationKey in this.logTranslations)
  5360. {
  5361. args.unshift(this.logTranslations[translationKey]);
  5362. // Topic: Converting an array to a function arguments list
  5363. // Source: https://stackoverflow.com/a/1316389
  5364. message += formatString.apply(null, args);
  5365. }
  5366. else
  5367. {
  5368. message += translationKey + " " + args.join(" ");
  5369. }
  5370. LOG(message);
  5371. }
  5372. Cfg.prototype.checkExistence = function()
  5373. {
  5374. var self = this;
  5375. var success = function(fileList)
  5376. {
  5377. var exists = fileExists(self.fileName, fileList);
  5378. if (!exists)
  5379. {
  5380. self.LOG("FILE_DOES_NOT_EXIST", self.fileName)
  5381. return;
  5382. }
  5383. // Report.
  5384. self.exists = true;
  5385. self.existsChanged.report();
  5386. }
  5387. var failure = function()
  5388. {
  5389. self.LOG("FILE_CHECK_FAILED", self.fileName)
  5390. }
  5391. this.lfsa.requestFileList("", success, failure);
  5392. }
  5393. Cfg.prototype.load = function()
  5394. {
  5395. var self = this;
  5396. var success = function(contents)
  5397. {
  5398. self.cfg = parseINI(contents);
  5399. self.cfgChanged.report();
  5400. }
  5401. var failure = function()
  5402. {
  5403. self.LOG("COULD_NOT_READ", self.fileName);
  5404. }
  5405. this.lfsa.requestFile(this.fileName, success, failure);
  5406. }
  5407. Cfg.prototype.display = function()
  5408. {
  5409. var input = document.getElementById("input");
  5410. input.value = this.cfg["input"];
  5411. var item = document.getElementById("item");
  5412. item.value = this.cfg["item"];
  5413. var preview = document.getElementById("preview");
  5414. preview.value = this.cfg["preview"];
  5415. var index = document.getElementById("index");
  5416. index.value = this.cfg["index"];
  5417. var paginationPrev = document.getElementById("paginationPrev");
  5418. paginationPrev.value = this.cfg["paginationPrev"];
  5419. var paginationNext = document.getElementById("paginationNext");
  5420. paginationNext.value = this.cfg["paginationNext"];
  5421. var paginationPrevNext = document.getElementById("paginationPrevNext");
  5422. paginationPrevNext.value = this.cfg["paginationPrevNext"];
  5423. var previewSize = document.getElementById("previewSize");
  5424. previewSize.value = this.cfg["previewSize"];
  5425. var previewEnding = document.getElementById("previewEnding");
  5426. previewEnding.value = this.cfg["previewEnding"];
  5427. var previewsPerPage = document.getElementById("previewsPerPage");
  5428. previewsPerPage.value = this.cfg["previewsPerPage"];
  5429. var previewPageBaseName = document.getElementById("previewPageBaseName");
  5430. previewPageBaseName.value = this.cfg["previewPageBaseName"];
  5431. }
  5432. Cfg.prototype.save = function()
  5433. {
  5434. var cfgFile = "";
  5435. this.LOG("SAVING", this.fileName);
  5436. var input = document.getElementById("input");
  5437. cfgFile += "input = " + input.value + "\n";
  5438. var item = document.getElementById("item");
  5439. cfgFile += "item = " + item.value + "\n";
  5440. var preview = document.getElementById("preview");
  5441. cfgFile += "preview = " + preview.value + "\n";
  5442. var index = document.getElementById("index");
  5443. cfgFile += "index = " + index.value + "\n";
  5444. var paginationPrev = document.getElementById("paginationPrev");
  5445. cfgFile += "paginationPrev = " + paginationPrev.value + "\n";
  5446. var paginationNext = document.getElementById("paginationNext");
  5447. cfgFile += "paginationNext = " + paginationNext.value + "\n";
  5448. var paginationPrevNext = document.getElementById("paginationPrevNext");
  5449. cfgFile += "paginationPrevNext = " + paginationPrevNext.value + "\n";
  5450. var previewSize = document.getElementById("previewSize");
  5451. cfgFile += "previewSize = " + previewSize.value + "\n";
  5452. var previewEnding = document.getElementById("previewEnding");
  5453. cfgFile += "previewEnding = " + previewEnding.value + "\n";
  5454. var previewsPerPage = document.getElementById("previewsPerPage");
  5455. cfgFile += "previewsPerPage = " + previewsPerPage.value + "\n";
  5456. var previewPageBaseName = document.getElementById("previewPageBaseName");
  5457. cfgFile += "previewPageBaseName = " + previewPageBaseName.value + "\n";
  5458. var self = this;
  5459. var success = function()
  5460. {
  5461. self.saved.report();
  5462. }
  5463. var failure = function()
  5464. {
  5465. self.LOG("COULD_NOT_SAVE", self.fileName);
  5466. }
  5467. this.lfsa.saveFile(this.fileName, cfgFile, success, failure);
  5468. }
  5469. <!-- News -->
  5470. // News class.
  5471. function News()
  5472. {
  5473. var self = this;
  5474. this.cfg = null;
  5475. this.lfsa = null;
  5476. this.logTranslations = {};
  5477. this.logTranslations["TEMPLATE_IS_MISSING"] = "WARNING '{0}' template is missing";
  5478. this.logTranslations["READ_TEMPLATES"] = "Read '{0}' templates";
  5479. this.logTranslations["NO_MARKDOWNS"] = "ERROR No markdown files were found";
  5480. this.logTranslations["READ_MARKDOWNS"] = "Read '{0}' markdown files";
  5481. this.logTranslations["PARSED_MARKDOWNS"] = "Parsed '{0}' markdown files";
  5482. this.logTranslations["SAVED_NEWS_ITEMS"] = "Saved news items";
  5483. this.logTranslations["GENERATED_PREVIEWS"] = "Generated '{0}' previews";
  5484. this.logTranslations["GENERATED_PREVIEW_PAGES"] = "Generated '{0}' preview pages";
  5485. this.logTranslations["PAGINATED_PREVIEW_PAGES"] = "Preview pages have been linked";
  5486. this.logTranslations["SAVED_PREVIEW_PAGES"] = "Saved preview pages";
  5487. this.logTranslations["COULD_NOT_LOCATE_INPUT_FILES"] = "ERROR Could not locate input files because LFSA request failed";
  5488. this.inputFiles = [];
  5489. this.inputFilesChanged = new Reporter();
  5490. this.markdownFiles = [];
  5491. this.markdownFilesChanged = new Reporter();
  5492. this.markdownFilesChanged.subscribe(function(){
  5493. if (self.markdownFiles.length == 0)
  5494. {
  5495. self.LOG("NO_MARKDOWNS");
  5496. }
  5497. });
  5498. this.markdownFileContents = [];
  5499. this.markdownFileContentsChanged = new Reporter();
  5500. this.markdownFileContentsChanged.subscribe(function(){
  5501. self.LOG("READ_MARKDOWNS", self.markdownFileContents.length);
  5502. });
  5503. this.newsItems = [];
  5504. this.newsItemsChanged = new Reporter();
  5505. this.newsItemsChanged.subscribe(function(){
  5506. self.LOG("PARSED_MARKDOWNS", self.newsItems.length);
  5507. });
  5508. this.templatesToLocate = [
  5509. "item",
  5510. "preview",
  5511. "index",
  5512. "paginationPrev",
  5513. "paginationNext",
  5514. "paginationPrevNext"
  5515. ]
  5516. // Name -> File name.
  5517. this.templates = {};
  5518. // File name -> Name.
  5519. this.templateNames = {};
  5520. this.templatesChanged = new Reporter();
  5521. this.templateContents = {};
  5522. this.templateContentsChanged = new Reporter();
  5523. this.templateContentsChanged.subscribe(function(){
  5524. self.LOG("READ_TEMPLATES", Object.keys(self.templateContents).length);
  5525. });
  5526. this.savedItems = new Reporter();
  5527. this.previews = [];
  5528. this.previewsChanged = new Reporter();
  5529. this.previewPages = [];
  5530. this.previewPagesChanged = new Reporter();
  5531. this.paginatedPreviewPages = [];
  5532. this.paginatedPreviewPagesChanged = new Reporter();
  5533. this.savedPreviewPages = new Reporter();
  5534. this.finished = new Reporter();
  5535. this.inputFilesChanged.subscribe(function(){
  5536. self.locateMarkdownFiles();
  5537. });
  5538. this.templateContentsChanged.subscribe(function(){
  5539. self.readMarkdownFiles();
  5540. });
  5541. this.markdownFileContentsChanged.subscribe(function(){
  5542. self.parseMarkdownFiles();
  5543. });
  5544. this.inputFilesChanged.subscribe(function(){
  5545. self.locateTemplates();
  5546. });
  5547. this.newsItemsChanged.subscribe(function(){
  5548. self.saveItems();
  5549. });
  5550. this.savedItems.subscribe(function(){
  5551. self.LOG("SAVED_NEWS_ITEMS");
  5552. });
  5553. this.savedItems.subscribe(function(){
  5554. self.generatePreviewsIfTemplatesExist();
  5555. });
  5556. this.previewsChanged.subscribe(function(){
  5557. self.LOG("GENERATED_PREVIEWS", self.previews.length);
  5558. });
  5559. this.previewsChanged.subscribe(function(){
  5560. self.generatePreviewPages();
  5561. });
  5562. this.previewPagesChanged.subscribe(function(){
  5563. self.LOG("GENERATED_PREVIEW_PAGES", self.previewPages.length);
  5564. });
  5565. this.previewPagesChanged.subscribe(function(){
  5566. self.paginatePreviewPages();
  5567. });
  5568. this.paginatedPreviewPagesChanged.subscribe(function(){
  5569. self.LOG("PAGINATED_PREVIEW_PAGES");
  5570. });
  5571. this.paginatedPreviewPagesChanged.subscribe(function(){
  5572. self.savePreviewPages();
  5573. });
  5574. this.savedPreviewPages.subscribe(function(){
  5575. self.LOG("SAVED_PREVIEW_PAGES");
  5576. });
  5577. this.templatesChanged.subscribe(function(){
  5578. self.generateUponCounter(2);
  5579. });
  5580. this.markdownFilesChanged.subscribe(function(){
  5581. self.generateUponCounter(2);
  5582. });
  5583. this.savedPreviewPages.subscribe(function(){
  5584. self.finished.report();
  5585. });
  5586. }
  5587. News.prototype.run = function()
  5588. {
  5589. var self = this;
  5590. }
  5591. News.prototype.generate = function()
  5592. {
  5593. this.generationCounter = 0;
  5594. this.locateInputFiles();
  5595. }
  5596. News.prototype.generateUponCounter = function(limit)
  5597. {
  5598. this.generationCounter += 1;
  5599. if (this.generationCounter == limit)
  5600. {
  5601. this.readTemplates();
  5602. }
  5603. }
  5604. News.prototype.LOG = function()
  5605. {
  5606. var args = Array.prototype.slice.call(arguments);
  5607. var translationKey = args.shift();
  5608. var message = "News ";
  5609. if (translationKey in this.logTranslations)
  5610. {
  5611. args.unshift(this.logTranslations[translationKey]);
  5612. // Topic: Converting an array to a function arguments list
  5613. // Source: https://stackoverflow.com/a/1316389
  5614. message += formatString.apply(null, args);
  5615. }
  5616. else
  5617. {
  5618. message += translationKey + " " + args.join(" ");
  5619. }
  5620. LOG(message);
  5621. }
  5622. News.prototype.locateInputFiles = function()
  5623. {
  5624. var self = this;
  5625. var success = function(fileList)
  5626. {
  5627. self.inputFiles = fileList;
  5628. self.inputFilesChanged.report();
  5629. }
  5630. var failure = function()
  5631. {
  5632. self.LOG("COULD_NOT_LOCATE_INPUT_FILES");
  5633. }
  5634. var path = this.cfg["input"];
  5635. this.lfsa.requestFileList(path, success, failure);
  5636. }
  5637. News.prototype.locateMarkdownFiles = function()
  5638. {
  5639. var files = [];
  5640. for (var id in this.inputFiles)
  5641. {
  5642. var file = this.inputFiles[id];
  5643. if (file.path.endsWith(".md"))
  5644. {
  5645. files.push(file.path);
  5646. }
  5647. }
  5648. // Sort by name descending, effectively making latest news the first ones.
  5649. files.sort();
  5650. files.reverse();
  5651. // Report.
  5652. this.markdownFiles = files;
  5653. this.markdownFilesChanged.report();
  5654. }
  5655. News.prototype.readMarkdownFiles = function()
  5656. {
  5657. var self = this;
  5658. // Prepare.
  5659. var dir = this.cfg["input"] + "/";
  5660. var operations = [];
  5661. for (var id in this.markdownFiles)
  5662. {
  5663. var fileName = this.markdownFiles[id];
  5664. var path = dir + fileName;
  5665. var operation = new FileOperation();
  5666. operation.path = path;
  5667. operations.push(operation);
  5668. }
  5669. var completion = function()
  5670. {
  5671. var fileContents = [];
  5672. for (var id in operations)
  5673. {
  5674. var operation = operations[id];
  5675. fileContents.push(operation.contents);
  5676. }
  5677. self.markdownFileContents = fileContents;
  5678. self.markdownFileContentsChanged.report();
  5679. }
  5680. // Read.
  5681. this.lfsa.requestFiles(operations, null, completion);
  5682. }
  5683. News.prototype.parseMarkdownFiles = function()
  5684. {
  5685. var items = []
  5686. for (var id in this.markdownFileContents)
  5687. {
  5688. var fileName = this.markdownFiles[id];
  5689. var contents = this.markdownFileContents[id];
  5690. var item = this.parseNewsItem(contents, fileName);
  5691. items.push(item);
  5692. }
  5693. // Report.
  5694. this.newsItems = items;
  5695. this.newsItemsChanged.report();
  5696. }
  5697. News.prototype.parseNewsItem = function(contents, fileName)
  5698. {
  5699. var newsItem = new NewsItem();
  5700. var lines = contents.split(/\r?\n/);
  5701. for (var id in lines)
  5702. {
  5703. var ln = lines[id];
  5704. if (ln.startsWith("Title:"))
  5705. {
  5706. newsItem.title = ln.replace("Title:", "").trim();
  5707. }
  5708. else if (ln.startsWith("Date:"))
  5709. {
  5710. newsItem.date = ln.replace("Date:", "").trim();
  5711. }
  5712. else if (ln.startsWith("Slug:"))
  5713. {
  5714. newsItem.slug = ln.replace("Slug:", "").trim();
  5715. }
  5716. else if (ln.startsWith("Category:"))
  5717. {
  5718. newsItem.category = ln.replace("Category:", "").trim();
  5719. }
  5720. else if (ln.startsWith("Lang:"))
  5721. {
  5722. newsItem.lang = ln.replace("Lang:", "").trim();
  5723. }
  5724. // Contents.
  5725. else
  5726. {
  5727. newsItem.contents += ln + "\n";
  5728. }
  5729. }
  5730. return newsItem;
  5731. }
  5732. News.prototype.locateTemplates = function()
  5733. {
  5734. var self = this;
  5735. var templates = {};
  5736. var templateNames = {};
  5737. function locateTemplate(name)
  5738. {
  5739. var fileName = self.cfg[name];
  5740. if (fileExists(fileName, self.inputFiles))
  5741. {
  5742. templates[name] = fileName;
  5743. templateNames[fileName] = name;
  5744. }
  5745. else
  5746. {
  5747. self.LOG("TEMPLATE_IS_MISSING", name);
  5748. }
  5749. }
  5750. for (var id in this.templatesToLocate)
  5751. {
  5752. var name = this.templatesToLocate[id];
  5753. locateTemplate(name);
  5754. }
  5755. // Report.
  5756. this.templates = templates;
  5757. this.templateNames = templateNames;
  5758. this.templatesChanged.report();
  5759. }
  5760. News.prototype.readTemplates = function()
  5761. {
  5762. var self = this;
  5763. // Prepare.
  5764. var dir = this.cfg["input"] + "/";
  5765. var operations = [];
  5766. for (var name in this.templates)
  5767. {
  5768. var fileName = this.templates[name];
  5769. var path = dir + fileName;
  5770. var operation = new FileOperation();
  5771. operation.path = path;
  5772. operations.push(operation);
  5773. }
  5774. var completion = function()
  5775. {
  5776. var templateContents = {};
  5777. for (var id in operations)
  5778. {
  5779. var operation = operations[id];
  5780. var fileName = operation.path.replace(dir, "")
  5781. var name = self.templateNames[fileName];
  5782. templateContents[name] = operation.contents;
  5783. }
  5784. self.templateContents = templateContents;
  5785. self.templateContentsChanged.report();
  5786. }
  5787. // Read.
  5788. this.lfsa.requestFiles(operations, null, completion);
  5789. }
  5790. News.prototype.saveItems = function()
  5791. {
  5792. var self = this;
  5793. // Prepare.
  5794. var operations = [];
  5795. for (var id in this.newsItems)
  5796. {
  5797. var newsItem = this.newsItems[id];
  5798. var fileName = newsItem.slug + ".html";
  5799. var contents = this.newsItemContents(newsItem, fileName)
  5800. var path = this.cfg["output"] + "/" + fileName;
  5801. var operation = new FileOperation();
  5802. operation.path = path;
  5803. operation.contents = contents;
  5804. operations.push(operation);
  5805. }
  5806. // Save.
  5807. this.lfsa.saveFiles(
  5808. operations,
  5809. null,
  5810. function()
  5811. {
  5812. self.savedItems.report();
  5813. }
  5814. );
  5815. }
  5816. News.prototype.newsItemContents = function(item, fileName)
  5817. {
  5818. var contents = this.templateContents["item"];
  5819. contents = contents.replace(/PSKOV_ITEM_TITLE/g, item.title);
  5820. contents = contents.replace(/PSKOV_ITEM_DATE/g, item.date);
  5821. contents = contents.replace(/PSKOV_ITEM_URL/g, fileName);
  5822. // Convert Markdown to HTML.
  5823. var converter = new showdown.Converter();
  5824. converter.setOption("tables", true);
  5825. var html = converter.makeHtml(item.contents);
  5826. contents = contents.replace(/PSKOV_ITEM_CONTENTS/g, html);
  5827. return contents;
  5828. }
  5829. News.prototype.generatePreviews = function()
  5830. {
  5831. var previews = []
  5832. for (var id in this.newsItems)
  5833. {
  5834. var item = this.newsItems[id];
  5835. var preview = this.newsItemPreview(item);
  5836. previews.push(preview);
  5837. }
  5838. this.previews = previews;
  5839. this.previewsChanged.report();
  5840. }
  5841. News.prototype.lineIsLink = function(ln)
  5842. {
  5843. return ln.search(/^\[.+\]:.+/) != -1;
  5844. }
  5845. News.prototype.newsItemPreview = function(newsItem)
  5846. {
  5847. // 1. Get news item content lines that have approximately `previewSize` characters.
  5848. // 2. Append `previewEnding` string.
  5849. // 3. Append links section.
  5850. // 4. Convert resulting preview into HTML.
  5851. // Contents section.
  5852. var contents = "";
  5853. const limit = this.cfg["previewSize"];
  5854. var lines = newsItem.contents.split(/\r?\n/);
  5855. for (var id in lines)
  5856. {
  5857. var ln = lines[id];
  5858. if (!this.lineIsLink(ln))
  5859. {
  5860. contents += "\n" + ln;
  5861. if (contents.length >= limit)
  5862. {
  5863. break;
  5864. }
  5865. }
  5866. }
  5867. // Ending.
  5868. contents += this.cfg["previewEnding"];
  5869. // Links section.
  5870. var links = "";
  5871. for (var id in lines)
  5872. {
  5873. var ln = lines[id];
  5874. if (this.lineIsLink(ln))
  5875. {
  5876. links += ln + "\n";
  5877. }
  5878. }
  5879. // Convert.
  5880. var preview = contents + "\n\n\n" + links;
  5881. var converter = new showdown.Converter();
  5882. converter.setOption("tables", true);
  5883. var html = converter.makeHtml(preview);
  5884. return html;
  5885. }
  5886. News.prototype.generatePreviewsIfTemplatesExist = function()
  5887. {
  5888. // Find out if any of the templates does not exist.
  5889. var ok = true;
  5890. for (var id in this.templatesToLocate)
  5891. {
  5892. var name = this.templatesToLocate[id];
  5893. if (!(name in this.templates))
  5894. {
  5895. ok = false;
  5896. break;
  5897. }
  5898. }
  5899. // Generate previews if all templates exist.
  5900. if (ok)
  5901. {
  5902. this.generatePreviews();
  5903. }
  5904. // Report finish otherwise.
  5905. else
  5906. {
  5907. this.finished.report();
  5908. }
  5909. }
  5910. News.prototype.previewPageName = function(id)
  5911. {
  5912. /* Generate file names like this:
  5913. * <basename>.html for id = 0
  5914. * <basename>2.html for id = 1
  5915. * <basename>3.html for id = 2
  5916. * etc..
  5917. */
  5918. var result = this.cfg["previewPageBaseName"];
  5919. if (id > 0)
  5920. {
  5921. result += Number(id) + 1;
  5922. }
  5923. return result + ".html";
  5924. }
  5925. News.prototype.generatePreviewPages = function()
  5926. {
  5927. var previewPages = [];
  5928. var pages = this.splitPreviewsIntoPages();
  5929. for (var id in pages)
  5930. {
  5931. var page = pages[id];
  5932. var previewPage = this.generatePreviewPage(page);
  5933. previewPages.push(previewPage);
  5934. }
  5935. this.previewPages = previewPages;
  5936. this.previewPagesChanged.report();
  5937. }
  5938. News.prototype.generatePreviewPage = function(page)
  5939. {
  5940. var previewsContents = "";
  5941. for (var id in page.items)
  5942. {
  5943. var item = page.items[id];
  5944. var preview = page.previews[id];
  5945. var html = this.convertPreviewToHTML(preview, item);
  5946. previewsContents += html;
  5947. }
  5948. var contents = this.templateContents["index"];
  5949. contents = contents.replace(/PSKOV_PREVIEWS/g, previewsContents);
  5950. return contents;
  5951. }
  5952. News.prototype.convertPreviewToHTML = function(preview, item)
  5953. {
  5954. var contents = this.templateContents["preview"];
  5955. contents = contents.replace(/PSKOV_ITEM_TITLE/g, item.title);
  5956. contents = contents.replace(/PSKOV_ITEM_DATE/g, item.date);
  5957. var fileName = item.slug + ".html";
  5958. contents = contents.replace(/PSKOV_ITEM_URL/g, fileName);
  5959. // Convert Markdown to HTML.
  5960. var converter = new showdown.Converter();
  5961. converter.setOption("tables", true);
  5962. var html = converter.makeHtml(preview);
  5963. contents = contents.replace(/PSKOV_PREVIEW/g, html);
  5964. return contents;
  5965. }
  5966. News.prototype.splitPreviewsIntoPages = function()
  5967. {
  5968. var pages = [];
  5969. var items = [];
  5970. var previews = [];
  5971. function createPage()
  5972. {
  5973. var page = new PreviewPage();
  5974. page.items = items.slice();
  5975. page.previews = previews.slice();
  5976. pages.push(page);
  5977. items = [];
  5978. previews = [];
  5979. }
  5980. var previewsPerPage = this.cfg["previewsPerPage"];
  5981. for (var id in this.newsItems)
  5982. {
  5983. var item = this.newsItems[id];
  5984. var preview = this.previews[id];
  5985. items.push(item);
  5986. previews.push(preview);
  5987. // Paginate.
  5988. if (items.length == previewsPerPage)
  5989. {
  5990. createPage();
  5991. }
  5992. }
  5993. // Create last page.
  5994. if (items.length > 0)
  5995. {
  5996. createPage();
  5997. }
  5998. return pages;
  5999. }
  6000. News.prototype.paginatePreviewPages = function()
  6001. {
  6002. var paginatedPreviewPages = [];
  6003. var count = this.previewPages.length;
  6004. for (var id in this.previewPages)
  6005. {
  6006. var pageId = Number(id);
  6007. var contents = this.previewPages[id];
  6008. var prevPageExists = (pageId > 0);
  6009. var nextPageExists = (pageId + 1 < count);
  6010. var paginationSection = null;
  6011. if (prevPageExists && nextPageExists)
  6012. {
  6013. var prevURL = this.previewPageName(pageId - 1);
  6014. var nextURL = this.previewPageName(pageId + 1);
  6015. paginationSection = this.templateContents["paginationPrevNext"];
  6016. paginationSection = paginationSection.replace(/PSKOV_PREV_PAGE_URL/g, prevURL);
  6017. paginationSection = paginationSection.replace(/PSKOV_NEXT_PAGE_URL/g, nextURL);
  6018. }
  6019. else if (prevPageExists)
  6020. {
  6021. var prevURL = this.previewPageName(pageId - 1);
  6022. paginationSection = this.templateContents["paginationPrev"];
  6023. paginationSection = paginationSection.replace(/PSKOV_PREV_PAGE_URL/g, prevURL);
  6024. }
  6025. else if (nextPageExists)
  6026. {
  6027. var nextURL = this.previewPageName(pageId + 1);
  6028. paginationSection = this.templateContents["paginationNext"];
  6029. paginationSection = paginationSection.replace(/PSKOV_NEXT_PAGE_URL/g, nextURL);
  6030. }
  6031. contents = contents.replace(/PSKOV_PAGINATION/g, paginationSection);
  6032. contents = contents.replace(/PSKOV_PAGE_ID/g, pageId + 1);
  6033. contents = contents.replace(/PSKOV_PAGES_COUNT/g, count);
  6034. var url = this.previewPageName(pageId);
  6035. contents = contents.replace(/PSKOV_INDEX_URL/g, url);
  6036. paginatedPreviewPages.push(contents);
  6037. }
  6038. this.paginatedPreviewPages = paginatedPreviewPages;
  6039. this.paginatedPreviewPagesChanged.report();
  6040. }
  6041. News.prototype.savePreviewPages = function()
  6042. {
  6043. var self = this;
  6044. // Prepare.
  6045. var dir = this.cfg["output"] + "/";
  6046. var operations = [];
  6047. for (var id in this.paginatedPreviewPages)
  6048. {
  6049. var fileName = this.previewPageName(id);
  6050. var path = dir + fileName;
  6051. var contents = this.paginatedPreviewPages[id];
  6052. var operation = new FileOperation();
  6053. operation.path = path;
  6054. operation.contents = contents;
  6055. operations.push(operation);
  6056. }
  6057. // Save.
  6058. this.lfsa.saveFiles(
  6059. operations,
  6060. null,
  6061. function()
  6062. {
  6063. self.savedPreviewPages.report();
  6064. }
  6065. );
  6066. }
  6067. <!-- Tool -->
  6068. // Tool class.
  6069. function Tool()
  6070. {
  6071. var self = this;
  6072. this.logTranslations = {};
  6073. this.logTranslations["GEN_NEWS"] = "Generating news for directory '{0}'";
  6074. this.logTranslations["FINISH_GEN_NEWS"] = "Finished generating news for all directories";
  6075. this.errorMessage = "<span class='error'>Error</span>";
  6076. this.lfsa = new LFSA();
  6077. this.cfg = new Cfg();
  6078. this.cfg.lfsa = this.lfsa;
  6079. this.news = new News();
  6080. this.news.finished.subscribe(function(){
  6081. // Continue processing.
  6082. self.processNewsGeneration();
  6083. });
  6084. }
  6085. // Tool's startup sequence.
  6086. Tool.prototype.run = function()
  6087. {
  6088. var self = this;
  6089. this.refreshLFSAPath();
  6090. this.cfg.run();
  6091. // Execute news startup sequence each time cfg is changed.
  6092. this.cfg.cfgChanged.subscribe(function(){
  6093. self.news.lfsa = self.lfsa;
  6094. self.news.cfg = self.cfg.cfg;
  6095. self.news.run();
  6096. });
  6097. }
  6098. Tool.prototype.LOG = function()
  6099. {
  6100. var args = Array.prototype.slice.call(arguments);
  6101. var translationKey = args.shift();
  6102. var message = "Tool ";
  6103. if (translationKey in this.logTranslations)
  6104. {
  6105. args.unshift(this.logTranslations[translationKey]);
  6106. // Topic: Converting an array to a function arguments list
  6107. // Source: https://stackoverflow.com/a/1316389
  6108. message += formatString.apply(null, args);
  6109. }
  6110. else
  6111. {
  6112. message += translationKey + " " + args.join(" ");
  6113. }
  6114. LOG(message);
  6115. }
  6116. Tool.prototype.refreshLFSAPath = function()
  6117. {
  6118. var self = this;
  6119. var lfsaPath = document.getElementById("lfsaPath");
  6120. var success = function(response)
  6121. {
  6122. lfsaPath.innerHTML = response;
  6123. }
  6124. var failure = function()
  6125. {
  6126. lfsaPath.innerHTML = self.errorMessage;
  6127. }
  6128. this.lfsa.requestPath(success, failure);
  6129. }
  6130. Tool.prototype.saveCfg = function()
  6131. {
  6132. this.cfg.save();
  6133. }
  6134. Tool.prototype.generateNews = function()
  6135. {
  6136. // Keep original 'input' to restore it after generation.
  6137. this.originalInput = this.cfg.cfg["input"];
  6138. // Get news dirs by splitting input by ";".
  6139. this.newsDirs = this.cfg.cfg["input"].split(/;/);
  6140. // Start processing.
  6141. this.processNewsGeneration();
  6142. }
  6143. Tool.prototype.processNewsGeneration = function()
  6144. {
  6145. if (this.newsDirs.length > 0)
  6146. {
  6147. var dir = this.newsDirs.shift();
  6148. this.LOG("GEN_NEWS", dir);
  6149. this.cfg.cfg["input"] = dir;
  6150. this.cfg.cfg["output"] = this.cfg.cfg["input"];
  6151. this.news.generate();
  6152. }
  6153. else
  6154. {
  6155. this.LOG("FINISH_GEN_NEWS");
  6156. // Restore original 'input'.
  6157. this.cfg.cfg["input"] = this.originalInput;
  6158. // Delete temorary 'output'.
  6159. delete this.cfg.cfg["output"];
  6160. }
  6161. }
  6162. <!-- Startup -->
  6163. window.pskovTool = new Tool();
  6164. window.pskovTool.run()
  6165. </script>
  6166. </body>
  6167. </html>