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

pskov_1.0.0.html 289KB

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