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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267
  1. (window["webpackJsonp"] = window["webpackJsonp"] || []).push([[3],{
  2. /***/ "./node_modules/css-loader/dist/runtime/api.js":
  3. /*!*****************************************************!*\
  4. !*** ./node_modules/css-loader/dist/runtime/api.js ***!
  5. \*****************************************************/
  6. /*! no static exports found */
  7. /***/ (function(module, exports, __webpack_require__) {
  8. "use strict";
  9. /*
  10. MIT License http://www.opensource.org/licenses/mit-license.php
  11. Author Tobias Koppers @sokra
  12. */
  13. // css base code, injected by the css-loader
  14. module.exports = function (useSourceMap) {
  15. var list = []; // return the list of modules as css string
  16. list.toString = function toString() {
  17. return this.map(function (item) {
  18. var content = cssWithMappingToString(item, useSourceMap);
  19. if (item[2]) {
  20. return '@media ' + item[2] + '{' + content + '}';
  21. } else {
  22. return content;
  23. }
  24. }).join('');
  25. }; // import a list of modules into the list
  26. list.i = function (modules, mediaQuery) {
  27. if (typeof modules === 'string') {
  28. modules = [[null, modules, '']];
  29. }
  30. var alreadyImportedModules = {};
  31. for (var i = 0; i < this.length; i++) {
  32. var id = this[i][0];
  33. if (id != null) {
  34. alreadyImportedModules[id] = true;
  35. }
  36. }
  37. for (i = 0; i < modules.length; i++) {
  38. var item = modules[i]; // skip already imported module
  39. // this implementation is not 100% perfect for weird media query combinations
  40. // when a module is imported multiple times with different media queries.
  41. // I hope this will never occur (Hey this way we have smaller bundles)
  42. if (item[0] == null || !alreadyImportedModules[item[0]]) {
  43. if (mediaQuery && !item[2]) {
  44. item[2] = mediaQuery;
  45. } else if (mediaQuery) {
  46. item[2] = '(' + item[2] + ') and (' + mediaQuery + ')';
  47. }
  48. list.push(item);
  49. }
  50. }
  51. };
  52. return list;
  53. };
  54. function cssWithMappingToString(item, useSourceMap) {
  55. var content = item[1] || '';
  56. var cssMapping = item[3];
  57. if (!cssMapping) {
  58. return content;
  59. }
  60. if (useSourceMap && typeof btoa === 'function') {
  61. var sourceMapping = toComment(cssMapping);
  62. var sourceURLs = cssMapping.sources.map(function (source) {
  63. return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */';
  64. });
  65. return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
  66. }
  67. return [content].join('\n');
  68. } // Adapted from convert-source-map (MIT)
  69. function toComment(sourceMap) {
  70. // eslint-disable-next-line no-undef
  71. var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
  72. var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
  73. return '/*# ' + data + ' */';
  74. }
  75. /***/ }),
  76. /***/ "./node_modules/dompurify/dist/purify.js":
  77. /*!***********************************************!*\
  78. !*** ./node_modules/dompurify/dist/purify.js ***!
  79. \***********************************************/
  80. /*! no static exports found */
  81. /***/ (function(module, exports, __webpack_require__) {
  82. (function (global, factory) {
  83. true ? module.exports = factory() :
  84. undefined;
  85. }(this, (function () { 'use strict';
  86. var freeze$1 = Object.freeze || function (x) {
  87. return x;
  88. };
  89. var html = freeze$1(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
  90. // SVG
  91. var svg = freeze$1(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'audio', 'canvas', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'video', 'view', 'vkern']);
  92. var svgFilters = freeze$1(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
  93. var mathMl = freeze$1(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']);
  94. var text = freeze$1(['#text']);
  95. var freeze$2 = Object.freeze || function (x) {
  96. return x;
  97. };
  98. var html$1 = freeze$2(['accept', 'action', 'align', 'alt', 'autocomplete', 'background', 'bgcolor', 'border', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'coords', 'crossorigin', 'datetime', 'default', 'dir', 'disabled', 'download', 'enctype', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'integrity', 'ismap', 'label', 'lang', 'list', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'multiple', 'name', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns']);
  99. var svg$1 = freeze$2(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'tabindex', 'targetx', 'targety', 'transform', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
  100. var mathMl$1 = freeze$2(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
  101. var xml = freeze$2(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
  102. var hasOwnProperty = Object.hasOwnProperty;
  103. var setPrototypeOf = Object.setPrototypeOf;
  104. var _ref$1 = typeof Reflect !== 'undefined' && Reflect;
  105. var apply$1 = _ref$1.apply;
  106. if (!apply$1) {
  107. apply$1 = function apply(fun, thisValue, args) {
  108. return fun.apply(thisValue, args);
  109. };
  110. }
  111. /* Add properties to a lookup table */
  112. function addToSet(set, array) {
  113. if (setPrototypeOf) {
  114. // Make 'in' and truthy checks like Boolean(set.constructor)
  115. // independent of any properties defined on Object.prototype.
  116. // Prevent prototype setters from intercepting set as a this value.
  117. setPrototypeOf(set, null);
  118. }
  119. var l = array.length;
  120. while (l--) {
  121. var element = array[l];
  122. if (typeof element === 'string') {
  123. var lcElement = element.toLowerCase();
  124. if (lcElement !== element) {
  125. // Config presets (e.g. tags.js, attrs.js) are immutable.
  126. if (!Object.isFrozen(array)) {
  127. array[l] = lcElement;
  128. }
  129. element = lcElement;
  130. }
  131. }
  132. set[element] = true;
  133. }
  134. return set;
  135. }
  136. /* Shallow clone an object */
  137. function clone(object) {
  138. var newObject = {};
  139. var property = void 0;
  140. for (property in object) {
  141. if (apply$1(hasOwnProperty, object, [property])) {
  142. newObject[property] = object[property];
  143. }
  144. }
  145. return newObject;
  146. }
  147. var seal = Object.seal || function (x) {
  148. return x;
  149. };
  150. var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
  151. var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm);
  152. var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
  153. var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
  154. var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
  155. );
  156. var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
  157. var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g // eslint-disable-line no-control-regex
  158. );
  159. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  160. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  161. var _ref = typeof Reflect !== 'undefined' && Reflect;
  162. var apply = _ref.apply;
  163. var arraySlice = Array.prototype.slice;
  164. var freeze = Object.freeze;
  165. var getGlobal = function getGlobal() {
  166. return typeof window === 'undefined' ? null : window;
  167. };
  168. if (!apply) {
  169. apply = function apply(fun, thisValue, args) {
  170. return fun.apply(thisValue, args);
  171. };
  172. }
  173. /**
  174. * Creates a no-op policy for internal use only.
  175. * Don't export this function outside this module!
  176. * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
  177. * @param {Document} document The document object (to determine policy name suffix)
  178. * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
  179. * are not supported).
  180. */
  181. var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) {
  182. if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
  183. return null;
  184. }
  185. // Allow the callers to control the unique policy name
  186. // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
  187. // Policy creation with duplicate names throws in Trusted Types.
  188. var suffix = null;
  189. var ATTR_NAME = 'data-tt-policy-suffix';
  190. if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) {
  191. suffix = document.currentScript.getAttribute(ATTR_NAME);
  192. }
  193. var policyName = 'dompurify' + (suffix ? '#' + suffix : '');
  194. try {
  195. return trustedTypes.createPolicy(policyName, {
  196. createHTML: function createHTML(html$$1) {
  197. return html$$1;
  198. }
  199. });
  200. } catch (error) {
  201. // Policy creation failed (most likely another DOMPurify script has
  202. // already run). Skip creating the policy, as this will only cause errors
  203. // if TT are enforced.
  204. console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
  205. return null;
  206. }
  207. };
  208. function createDOMPurify() {
  209. var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
  210. var DOMPurify = function DOMPurify(root) {
  211. return createDOMPurify(root);
  212. };
  213. /**
  214. * Version label, exposed for easier checks
  215. * if DOMPurify is up to date or not
  216. */
  217. DOMPurify.version = '1.0.10';
  218. /**
  219. * Array of elements that DOMPurify removed during sanitation.
  220. * Empty if nothing was removed.
  221. */
  222. DOMPurify.removed = [];
  223. if (!window || !window.document || window.document.nodeType !== 9) {
  224. // Not running in a browser, provide a factory function
  225. // so that you can pass your own Window
  226. DOMPurify.isSupported = false;
  227. return DOMPurify;
  228. }
  229. var originalDocument = window.document;
  230. var useDOMParser = false;
  231. var removeTitle = false;
  232. var document = window.document;
  233. var DocumentFragment = window.DocumentFragment,
  234. HTMLTemplateElement = window.HTMLTemplateElement,
  235. Node = window.Node,
  236. NodeFilter = window.NodeFilter,
  237. _window$NamedNodeMap = window.NamedNodeMap,
  238. NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap,
  239. Text = window.Text,
  240. Comment = window.Comment,
  241. DOMParser = window.DOMParser,
  242. TrustedTypes = window.TrustedTypes;
  243. // As per issue #47, the web-components registry is inherited by a
  244. // new document created via createHTMLDocument. As per the spec
  245. // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
  246. // a new empty registry is used when creating a template contents owner
  247. // document, so we use that as our parent document to ensure nothing
  248. // is inherited.
  249. if (typeof HTMLTemplateElement === 'function') {
  250. var template = document.createElement('template');
  251. if (template.content && template.content.ownerDocument) {
  252. document = template.content.ownerDocument;
  253. }
  254. }
  255. var trustedTypesPolicy = _createTrustedTypesPolicy(TrustedTypes, originalDocument);
  256. var emptyHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML('') : '';
  257. var _document = document,
  258. implementation = _document.implementation,
  259. createNodeIterator = _document.createNodeIterator,
  260. getElementsByTagName = _document.getElementsByTagName,
  261. createDocumentFragment = _document.createDocumentFragment;
  262. var importNode = originalDocument.importNode;
  263. var hooks = {};
  264. /**
  265. * Expose whether this browser supports running the full DOMPurify.
  266. */
  267. DOMPurify.isSupported = implementation && typeof implementation.createHTMLDocument !== 'undefined' && document.documentMode !== 9;
  268. var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR,
  269. ERB_EXPR$$1 = ERB_EXPR,
  270. DATA_ATTR$$1 = DATA_ATTR,
  271. ARIA_ATTR$$1 = ARIA_ATTR,
  272. IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA,
  273. ATTR_WHITESPACE$$1 = ATTR_WHITESPACE;
  274. var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI;
  275. /**
  276. * We consider the elements and attributes below to be safe. Ideally
  277. * don't add any new ones but feel free to remove unwanted ones.
  278. */
  279. /* allowed element names */
  280. var ALLOWED_TAGS = null;
  281. var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray(html), _toConsumableArray(svg), _toConsumableArray(svgFilters), _toConsumableArray(mathMl), _toConsumableArray(text)));
  282. /* Allowed attribute names */
  283. var ALLOWED_ATTR = null;
  284. var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray(html$1), _toConsumableArray(svg$1), _toConsumableArray(mathMl$1), _toConsumableArray(xml)));
  285. /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
  286. var FORBID_TAGS = null;
  287. /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
  288. var FORBID_ATTR = null;
  289. /* Decide if ARIA attributes are okay */
  290. var ALLOW_ARIA_ATTR = true;
  291. /* Decide if custom data attributes are okay */
  292. var ALLOW_DATA_ATTR = true;
  293. /* Decide if unknown protocols are okay */
  294. var ALLOW_UNKNOWN_PROTOCOLS = false;
  295. /* Output should be safe for jQuery's $() factory? */
  296. var SAFE_FOR_JQUERY = false;
  297. /* Output should be safe for common template engines.
  298. * This means, DOMPurify removes data attributes, mustaches and ERB
  299. */
  300. var SAFE_FOR_TEMPLATES = false;
  301. /* Decide if document with <html>... should be returned */
  302. var WHOLE_DOCUMENT = false;
  303. /* Track whether config is already set on this instance of DOMPurify. */
  304. var SET_CONFIG = false;
  305. /* Decide if all elements (e.g. style, script) must be children of
  306. * document.body. By default, browsers might move them to document.head */
  307. var FORCE_BODY = false;
  308. /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
  309. * string (or a TrustedHTML object if Trusted Types are supported).
  310. * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
  311. */
  312. var RETURN_DOM = false;
  313. /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
  314. * string (or a TrustedHTML object if Trusted Types are supported) */
  315. var RETURN_DOM_FRAGMENT = false;
  316. /* If `RETURN_DOM` or `RETURN_DOM_FRAGMENT` is enabled, decide if the returned DOM
  317. * `Node` is imported into the current `Document`. If this flag is not enabled the
  318. * `Node` will belong (its ownerDocument) to a fresh `HTMLDocument`, created by
  319. * DOMPurify. */
  320. var RETURN_DOM_IMPORT = false;
  321. /* Output should be free from DOM clobbering attacks? */
  322. var SANITIZE_DOM = true;
  323. /* Keep element content when removing element? */
  324. var KEEP_CONTENT = true;
  325. /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
  326. * of importing it into a new Document and returning a sanitized copy */
  327. var IN_PLACE = false;
  328. /* Allow usage of profiles like html, svg and mathMl */
  329. var USE_PROFILES = {};
  330. /* Tags to ignore content of when KEEP_CONTENT is true */
  331. var FORBID_CONTENTS = addToSet({}, ['audio', 'head', 'math', 'script', 'style', 'template', 'svg', 'video']);
  332. /* Tags that are safe for data: URIs */
  333. var DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image']);
  334. /* Attributes safe for values like "javascript:" */
  335. var URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'summary', 'title', 'value', 'style', 'xmlns']);
  336. /* Keep a reference to config to pass to hooks */
  337. var CONFIG = null;
  338. /* Ideally, do not touch anything below this line */
  339. /* ______________________________________________ */
  340. var formElement = document.createElement('form');
  341. /**
  342. * _parseConfig
  343. *
  344. * @param {Object} cfg optional config literal
  345. */
  346. // eslint-disable-next-line complexity
  347. var _parseConfig = function _parseConfig(cfg) {
  348. if (CONFIG && CONFIG === cfg) {
  349. return;
  350. }
  351. /* Shield configuration object from tampering */
  352. if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') {
  353. cfg = {};
  354. }
  355. /* Set configuration parameters */
  356. ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS;
  357. ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR;
  358. FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS) : {};
  359. FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR) : {};
  360. USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
  361. ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
  362. ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
  363. ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
  364. SAFE_FOR_JQUERY = cfg.SAFE_FOR_JQUERY || false; // Default false
  365. SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
  366. WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
  367. RETURN_DOM = cfg.RETURN_DOM || false; // Default false
  368. RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
  369. RETURN_DOM_IMPORT = cfg.RETURN_DOM_IMPORT || false; // Default false
  370. FORCE_BODY = cfg.FORCE_BODY || false; // Default false
  371. SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
  372. KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
  373. IN_PLACE = cfg.IN_PLACE || false; // Default false
  374. IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1;
  375. if (SAFE_FOR_TEMPLATES) {
  376. ALLOW_DATA_ATTR = false;
  377. }
  378. if (RETURN_DOM_FRAGMENT) {
  379. RETURN_DOM = true;
  380. }
  381. /* Parse profile info */
  382. if (USE_PROFILES) {
  383. ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray(text)));
  384. ALLOWED_ATTR = [];
  385. if (USE_PROFILES.html === true) {
  386. addToSet(ALLOWED_TAGS, html);
  387. addToSet(ALLOWED_ATTR, html$1);
  388. }
  389. if (USE_PROFILES.svg === true) {
  390. addToSet(ALLOWED_TAGS, svg);
  391. addToSet(ALLOWED_ATTR, svg$1);
  392. addToSet(ALLOWED_ATTR, xml);
  393. }
  394. if (USE_PROFILES.svgFilters === true) {
  395. addToSet(ALLOWED_TAGS, svgFilters);
  396. addToSet(ALLOWED_ATTR, svg$1);
  397. addToSet(ALLOWED_ATTR, xml);
  398. }
  399. if (USE_PROFILES.mathMl === true) {
  400. addToSet(ALLOWED_TAGS, mathMl);
  401. addToSet(ALLOWED_ATTR, mathMl$1);
  402. addToSet(ALLOWED_ATTR, xml);
  403. }
  404. }
  405. /* Merge configuration parameters */
  406. if (cfg.ADD_TAGS) {
  407. if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
  408. ALLOWED_TAGS = clone(ALLOWED_TAGS);
  409. }
  410. addToSet(ALLOWED_TAGS, cfg.ADD_TAGS);
  411. }
  412. if (cfg.ADD_ATTR) {
  413. if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
  414. ALLOWED_ATTR = clone(ALLOWED_ATTR);
  415. }
  416. addToSet(ALLOWED_ATTR, cfg.ADD_ATTR);
  417. }
  418. if (cfg.ADD_URI_SAFE_ATTR) {
  419. addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR);
  420. }
  421. /* Add #text in case KEEP_CONTENT is set to true */
  422. if (KEEP_CONTENT) {
  423. ALLOWED_TAGS['#text'] = true;
  424. }
  425. /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
  426. if (WHOLE_DOCUMENT) {
  427. addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
  428. }
  429. /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286 */
  430. if (ALLOWED_TAGS.table) {
  431. addToSet(ALLOWED_TAGS, ['tbody']);
  432. }
  433. // Prevent further manipulation of configuration.
  434. // Not available in IE8, Safari 5, etc.
  435. if (freeze) {
  436. freeze(cfg);
  437. }
  438. CONFIG = cfg;
  439. };
  440. /**
  441. * _forceRemove
  442. *
  443. * @param {Node} node a DOM node
  444. */
  445. var _forceRemove = function _forceRemove(node) {
  446. DOMPurify.removed.push({ element: node });
  447. try {
  448. node.parentNode.removeChild(node);
  449. } catch (error) {
  450. node.outerHTML = emptyHTML;
  451. }
  452. };
  453. /**
  454. * _removeAttribute
  455. *
  456. * @param {String} name an Attribute name
  457. * @param {Node} node a DOM node
  458. */
  459. var _removeAttribute = function _removeAttribute(name, node) {
  460. try {
  461. DOMPurify.removed.push({
  462. attribute: node.getAttributeNode(name),
  463. from: node
  464. });
  465. } catch (error) {
  466. DOMPurify.removed.push({
  467. attribute: null,
  468. from: node
  469. });
  470. }
  471. node.removeAttribute(name);
  472. };
  473. /**
  474. * _initDocument
  475. *
  476. * @param {String} dirty a string of dirty markup
  477. * @return {Document} a DOM, filled with the dirty markup
  478. */
  479. var _initDocument = function _initDocument(dirty) {
  480. /* Create a HTML document */
  481. var doc = void 0;
  482. var leadingWhitespace = void 0;
  483. if (FORCE_BODY) {
  484. dirty = '<remove></remove>' + dirty;
  485. } else {
  486. /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
  487. var matches = dirty.match(/^[\s]+/);
  488. leadingWhitespace = matches && matches[0];
  489. if (leadingWhitespace) {
  490. dirty = dirty.slice(leadingWhitespace.length);
  491. }
  492. }
  493. /* Use DOMParser to workaround Firefox bug (see comment below) */
  494. if (useDOMParser) {
  495. try {
  496. doc = new DOMParser().parseFromString(dirty, 'text/html');
  497. } catch (error) {}
  498. }
  499. /* Remove title to fix a mXSS bug in older MS Edge */
  500. if (removeTitle) {
  501. addToSet(FORBID_TAGS, ['title']);
  502. }
  503. /* Otherwise use createHTMLDocument, because DOMParser is unsafe in
  504. Safari (see comment below) */
  505. if (!doc || !doc.documentElement) {
  506. doc = implementation.createHTMLDocument('');
  507. var _doc = doc,
  508. body = _doc.body;
  509. body.parentNode.removeChild(body.parentNode.firstElementChild);
  510. body.outerHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
  511. }
  512. if (leadingWhitespace) {
  513. doc.body.insertBefore(document.createTextNode(leadingWhitespace), doc.body.childNodes[0] || null);
  514. }
  515. /* Work on whole document or just its body */
  516. return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
  517. };
  518. // Firefox uses a different parser for innerHTML rather than
  519. // DOMParser (see https://bugzilla.mozilla.org/show_bug.cgi?id=1205631)
  520. // which means that you *must* use DOMParser, otherwise the output may
  521. // not be safe if used in a document.write context later.
  522. //
  523. // So we feature detect the Firefox bug and use the DOMParser if necessary.
  524. //
  525. // MS Edge, in older versions, is affected by an mXSS behavior. The second
  526. // check tests for the behavior and fixes it if necessary.
  527. if (DOMPurify.isSupported) {
  528. (function () {
  529. try {
  530. var doc = _initDocument('<svg><p><style><img src="</style><img src=x onerror=1//">');
  531. if (doc.querySelector('svg img')) {
  532. useDOMParser = true;
  533. }
  534. } catch (error) {}
  535. })();
  536. (function () {
  537. try {
  538. var doc = _initDocument('<x/><title>&lt;/title&gt;&lt;img&gt;');
  539. if (doc.querySelector('title').innerHTML.match(/<\/title/)) {
  540. removeTitle = true;
  541. }
  542. } catch (error) {}
  543. })();
  544. }
  545. /**
  546. * _createIterator
  547. *
  548. * @param {Document} root document/fragment to create iterator for
  549. * @return {Iterator} iterator instance
  550. */
  551. var _createIterator = function _createIterator(root) {
  552. return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, function () {
  553. return NodeFilter.FILTER_ACCEPT;
  554. }, false);
  555. };
  556. /**
  557. * _isClobbered
  558. *
  559. * @param {Node} elm element to check for clobbering attacks
  560. * @return {Boolean} true if clobbered, false if safe
  561. */
  562. var _isClobbered = function _isClobbered(elm) {
  563. if (elm instanceof Text || elm instanceof Comment) {
  564. return false;
  565. }
  566. if (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function') {
  567. return true;
  568. }
  569. return false;
  570. };
  571. /**
  572. * _isNode
  573. *
  574. * @param {Node} obj object to check whether it's a DOM node
  575. * @return {Boolean} true is object is a DOM node
  576. */
  577. var _isNode = function _isNode(obj) {
  578. return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? obj instanceof Node : obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string';
  579. };
  580. /**
  581. * _executeHook
  582. * Execute user configurable hooks
  583. *
  584. * @param {String} entryPoint Name of the hook's entry point
  585. * @param {Node} currentNode node to work on with the hook
  586. * @param {Object} data additional hook parameters
  587. */
  588. var _executeHook = function _executeHook(entryPoint, currentNode, data) {
  589. if (!hooks[entryPoint]) {
  590. return;
  591. }
  592. hooks[entryPoint].forEach(function (hook) {
  593. hook.call(DOMPurify, currentNode, data, CONFIG);
  594. });
  595. };
  596. /**
  597. * _sanitizeElements
  598. *
  599. * @protect nodeName
  600. * @protect textContent
  601. * @protect removeChild
  602. *
  603. * @param {Node} currentNode to check for permission to exist
  604. * @return {Boolean} true if node was killed, false if left alive
  605. */
  606. // eslint-disable-next-line complexity
  607. var _sanitizeElements = function _sanitizeElements(currentNode) {
  608. var content = void 0;
  609. /* Execute a hook if present */
  610. _executeHook('beforeSanitizeElements', currentNode, null);
  611. /* Check if element is clobbered or can clobber */
  612. if (_isClobbered(currentNode)) {
  613. _forceRemove(currentNode);
  614. return true;
  615. }
  616. /* Now let's check the element's type and name */
  617. var tagName = currentNode.nodeName.toLowerCase();
  618. /* Execute a hook if present */
  619. _executeHook('uponSanitizeElement', currentNode, {
  620. tagName: tagName,
  621. allowedTags: ALLOWED_TAGS
  622. });
  623. /* Remove element if anything forbids its presence */
  624. if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
  625. /* Keep content except for black-listed elements */
  626. if (KEEP_CONTENT && !FORBID_CONTENTS[tagName] && typeof currentNode.insertAdjacentHTML === 'function') {
  627. try {
  628. var htmlToInsert = currentNode.innerHTML;
  629. currentNode.insertAdjacentHTML('AfterEnd', trustedTypesPolicy ? trustedTypesPolicy.createHTML(htmlToInsert) : htmlToInsert);
  630. } catch (error) {}
  631. }
  632. _forceRemove(currentNode);
  633. return true;
  634. }
  635. /* Remove in case a noscript/noembed XSS is suspected */
  636. if (tagName === 'noscript' && currentNode.innerHTML.match(/<\/noscript/i)) {
  637. _forceRemove(currentNode);
  638. return true;
  639. }
  640. if (tagName === 'noembed' && currentNode.innerHTML.match(/<\/noembed/i)) {
  641. _forceRemove(currentNode);
  642. return true;
  643. }
  644. /* Convert markup to cover jQuery behavior */
  645. if (SAFE_FOR_JQUERY && !currentNode.firstElementChild && (!currentNode.content || !currentNode.content.firstElementChild) && /</g.test(currentNode.textContent)) {
  646. DOMPurify.removed.push({ element: currentNode.cloneNode() });
  647. if (currentNode.innerHTML) {
  648. currentNode.innerHTML = currentNode.innerHTML.replace(/</g, '&lt;');
  649. } else {
  650. currentNode.innerHTML = currentNode.textContent.replace(/</g, '&lt;');
  651. }
  652. }
  653. /* Sanitize element content to be template-safe */
  654. if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
  655. /* Get the element's text content */
  656. content = currentNode.textContent;
  657. content = content.replace(MUSTACHE_EXPR$$1, ' ');
  658. content = content.replace(ERB_EXPR$$1, ' ');
  659. if (currentNode.textContent !== content) {
  660. DOMPurify.removed.push({ element: currentNode.cloneNode() });
  661. currentNode.textContent = content;
  662. }
  663. }
  664. /* Execute a hook if present */
  665. _executeHook('afterSanitizeElements', currentNode, null);
  666. return false;
  667. };
  668. /**
  669. * _isValidAttribute
  670. *
  671. * @param {string} lcTag Lowercase tag name of containing element.
  672. * @param {string} lcName Lowercase attribute name.
  673. * @param {string} value Attribute value.
  674. * @return {Boolean} Returns true if `value` is valid, otherwise false.
  675. */
  676. // eslint-disable-next-line complexity
  677. var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
  678. /* Make sure attribute cannot clobber */
  679. if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
  680. return false;
  681. }
  682. /* Allow valid data-* attributes: At least one character after "-"
  683. (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
  684. XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
  685. We don't need to check the value; it's always URI safe. */
  686. if (ALLOW_DATA_ATTR && DATA_ATTR$$1.test(lcName)) {
  687. // This attribute is safe
  688. } else if (ALLOW_ARIA_ATTR && ARIA_ATTR$$1.test(lcName)) {
  689. // This attribute is safe
  690. /* Otherwise, check the name is permitted */
  691. } else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
  692. return false;
  693. /* Check value is safe. First, is attr inert? If so, is safe */
  694. } else if (URI_SAFE_ATTRIBUTES[lcName]) {
  695. // This attribute is safe
  696. /* Check no script, data or unknown possibly unsafe URI
  697. unless we know URI values are safe for that attribute */
  698. } else if (IS_ALLOWED_URI$$1.test(value.replace(ATTR_WHITESPACE$$1, ''))) {
  699. // This attribute is safe
  700. /* Keep image data URIs alive if src/xlink:href is allowed */
  701. /* Further prevent gadget XSS for dynamically built script tags */
  702. } else if ((lcName === 'src' || lcName === 'xlink:href') && lcTag !== 'script' && value.indexOf('data:') === 0 && DATA_URI_TAGS[lcTag]) {
  703. // This attribute is safe
  704. /* Allow unknown protocols: This provides support for links that
  705. are handled by protocol handlers which may be unknown ahead of
  706. time, e.g. fb:, spotify: */
  707. } else if (ALLOW_UNKNOWN_PROTOCOLS && !IS_SCRIPT_OR_DATA$$1.test(value.replace(ATTR_WHITESPACE$$1, ''))) {
  708. // This attribute is safe
  709. /* Check for binary attributes */
  710. // eslint-disable-next-line no-negated-condition
  711. } else if (!value) {
  712. // Binary attributes are safe at this point
  713. /* Anything else, presume unsafe, do not add it back */
  714. } else {
  715. return false;
  716. }
  717. return true;
  718. };
  719. /**
  720. * _sanitizeAttributes
  721. *
  722. * @protect attributes
  723. * @protect nodeName
  724. * @protect removeAttribute
  725. * @protect setAttribute
  726. *
  727. * @param {Node} currentNode to sanitize
  728. */
  729. var _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
  730. var attr = void 0;
  731. var value = void 0;
  732. var lcName = void 0;
  733. var idAttr = void 0;
  734. var l = void 0;
  735. /* Execute a hook if present */
  736. _executeHook('beforeSanitizeAttributes', currentNode, null);
  737. var attributes = currentNode.attributes;
  738. /* Check if we have attributes; if not we might have a text node */
  739. if (!attributes) {
  740. return;
  741. }
  742. var hookEvent = {
  743. attrName: '',
  744. attrValue: '',
  745. keepAttr: true,
  746. allowedAttributes: ALLOWED_ATTR
  747. };
  748. l = attributes.length;
  749. /* Go backwards over all attributes; safely remove bad ones */
  750. while (l--) {
  751. attr = attributes[l];
  752. var _attr = attr,
  753. name = _attr.name,
  754. namespaceURI = _attr.namespaceURI;
  755. value = attr.value.trim();
  756. lcName = name.toLowerCase();
  757. /* Execute a hook if present */
  758. hookEvent.attrName = lcName;
  759. hookEvent.attrValue = value;
  760. hookEvent.keepAttr = true;
  761. _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
  762. value = hookEvent.attrValue;
  763. /* Remove attribute */
  764. // Safari (iOS + Mac), last tested v8.0.5, crashes if you try to
  765. // remove a "name" attribute from an <img> tag that has an "id"
  766. // attribute at the time.
  767. if (lcName === 'name' && currentNode.nodeName === 'IMG' && attributes.id) {
  768. idAttr = attributes.id;
  769. attributes = apply(arraySlice, attributes, []);
  770. _removeAttribute('id', currentNode);
  771. _removeAttribute(name, currentNode);
  772. if (attributes.indexOf(idAttr) > l) {
  773. currentNode.setAttribute('id', idAttr.value);
  774. }
  775. } else if (
  776. // This works around a bug in Safari, where input[type=file]
  777. // cannot be dynamically set after type has been removed
  778. currentNode.nodeName === 'INPUT' && lcName === 'type' && value === 'file' && (ALLOWED_ATTR[lcName] || !FORBID_ATTR[lcName])) {
  779. continue;
  780. } else {
  781. // This avoids a crash in Safari v9.0 with double-ids.
  782. // The trick is to first set the id to be empty and then to
  783. // remove the attribute
  784. if (name === 'id') {
  785. currentNode.setAttribute(name, '');
  786. }
  787. _removeAttribute(name, currentNode);
  788. }
  789. /* Did the hooks approve of the attribute? */
  790. if (!hookEvent.keepAttr) {
  791. continue;
  792. }
  793. /* Sanitize attribute content to be template-safe */
  794. if (SAFE_FOR_TEMPLATES) {
  795. value = value.replace(MUSTACHE_EXPR$$1, ' ');
  796. value = value.replace(ERB_EXPR$$1, ' ');
  797. }
  798. /* Is `value` valid for this attribute? */
  799. var lcTag = currentNode.nodeName.toLowerCase();
  800. if (!_isValidAttribute(lcTag, lcName, value)) {
  801. continue;
  802. }
  803. /* Handle invalid data-* attribute set by try-catching it */
  804. try {
  805. if (namespaceURI) {
  806. currentNode.setAttributeNS(namespaceURI, name, value);
  807. } else {
  808. /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
  809. currentNode.setAttribute(name, value);
  810. }
  811. DOMPurify.removed.pop();
  812. } catch (error) {}
  813. }
  814. /* Execute a hook if present */
  815. _executeHook('afterSanitizeAttributes', currentNode, null);
  816. };
  817. /**
  818. * _sanitizeShadowDOM
  819. *
  820. * @param {DocumentFragment} fragment to iterate over recursively
  821. */
  822. var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
  823. var shadowNode = void 0;
  824. var shadowIterator = _createIterator(fragment);
  825. /* Execute a hook if present */
  826. _executeHook('beforeSanitizeShadowDOM', fragment, null);
  827. while (shadowNode = shadowIterator.nextNode()) {
  828. /* Execute a hook if present */
  829. _executeHook('uponSanitizeShadowNode', shadowNode, null);
  830. /* Sanitize tags and elements */
  831. if (_sanitizeElements(shadowNode)) {
  832. continue;
  833. }
  834. /* Deep shadow DOM detected */
  835. if (shadowNode.content instanceof DocumentFragment) {
  836. _sanitizeShadowDOM(shadowNode.content);
  837. }
  838. /* Check attributes, sanitize if necessary */
  839. _sanitizeAttributes(shadowNode);
  840. }
  841. /* Execute a hook if present */
  842. _executeHook('afterSanitizeShadowDOM', fragment, null);
  843. };
  844. /**
  845. * Sanitize
  846. * Public method providing core sanitation functionality
  847. *
  848. * @param {String|Node} dirty string or DOM node
  849. * @param {Object} configuration object
  850. */
  851. // eslint-disable-next-line complexity
  852. DOMPurify.sanitize = function (dirty, cfg) {
  853. var body = void 0;
  854. var importedNode = void 0;
  855. var currentNode = void 0;
  856. var oldNode = void 0;
  857. var returnNode = void 0;
  858. /* Make sure we have a string to sanitize.
  859. DO NOT return early, as this will return the wrong type if
  860. the user has requested a DOM object rather than a string */
  861. if (!dirty) {
  862. dirty = '<!-->';
  863. }
  864. /* Stringify, in case dirty is an object */
  865. if (typeof dirty !== 'string' && !_isNode(dirty)) {
  866. // eslint-disable-next-line no-negated-condition
  867. if (typeof dirty.toString !== 'function') {
  868. throw new TypeError('toString is not a function');
  869. } else {
  870. dirty = dirty.toString();
  871. if (typeof dirty !== 'string') {
  872. throw new TypeError('dirty is not a string, aborting');
  873. }
  874. }
  875. }
  876. /* Check we can run. Otherwise fall back or ignore */
  877. if (!DOMPurify.isSupported) {
  878. if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') {
  879. if (typeof dirty === 'string') {
  880. return window.toStaticHTML(dirty);
  881. }
  882. if (_isNode(dirty)) {
  883. return window.toStaticHTML(dirty.outerHTML);
  884. }
  885. }
  886. return dirty;
  887. }
  888. /* Assign config vars */
  889. if (!SET_CONFIG) {
  890. _parseConfig(cfg);
  891. }
  892. /* Clean up removed elements */
  893. DOMPurify.removed = [];
  894. if (IN_PLACE) {
  895. /* No special handling necessary for in-place sanitization */
  896. } else if (dirty instanceof Node) {
  897. /* If dirty is a DOM element, append to an empty document to avoid
  898. elements being stripped by the parser */
  899. body = _initDocument('<!-->');
  900. importedNode = body.ownerDocument.importNode(dirty, true);
  901. if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
  902. /* Node is already a body, use as is */
  903. body = importedNode;
  904. } else {
  905. // eslint-disable-next-line unicorn/prefer-node-append
  906. body.appendChild(importedNode);
  907. }
  908. } else {
  909. /* Exit directly if we have nothing to do */
  910. if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf('<') === -1) {
  911. return trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
  912. }
  913. /* Initialize the document to work on */
  914. body = _initDocument(dirty);
  915. /* Check we have a DOM node from the data */
  916. if (!body) {
  917. return RETURN_DOM ? null : emptyHTML;
  918. }
  919. }
  920. /* Remove first element node (ours) if FORCE_BODY is set */
  921. if (body && FORCE_BODY) {
  922. _forceRemove(body.firstChild);
  923. }
  924. /* Get node iterator */
  925. var nodeIterator = _createIterator(IN_PLACE ? dirty : body);
  926. /* Now start iterating over the created document */
  927. while (currentNode = nodeIterator.nextNode()) {
  928. /* Fix IE's strange behavior with manipulated textNodes #89 */
  929. if (currentNode.nodeType === 3 && currentNode === oldNode) {
  930. continue;
  931. }
  932. /* Sanitize tags and elements */
  933. if (_sanitizeElements(currentNode)) {
  934. continue;
  935. }
  936. /* Shadow DOM detected, sanitize it */
  937. if (currentNode.content instanceof DocumentFragment) {
  938. _sanitizeShadowDOM(currentNode.content);
  939. }
  940. /* Check attributes, sanitize if necessary */
  941. _sanitizeAttributes(currentNode);
  942. oldNode = currentNode;
  943. }
  944. oldNode = null;
  945. /* If we sanitized `dirty` in-place, return it. */
  946. if (IN_PLACE) {
  947. return dirty;
  948. }
  949. /* Return sanitized string or DOM */
  950. if (RETURN_DOM) {
  951. if (RETURN_DOM_FRAGMENT) {
  952. returnNode = createDocumentFragment.call(body.ownerDocument);
  953. while (body.firstChild) {
  954. // eslint-disable-next-line unicorn/prefer-node-append
  955. returnNode.appendChild(body.firstChild);
  956. }
  957. } else {
  958. returnNode = body;
  959. }
  960. if (RETURN_DOM_IMPORT) {
  961. /* AdoptNode() is not used because internal state is not reset
  962. (e.g. the past names map of a HTMLFormElement), this is safe
  963. in theory but we would rather not risk another attack vector.
  964. The state that is cloned by importNode() is explicitly defined
  965. by the specs. */
  966. returnNode = importNode.call(originalDocument, returnNode, true);
  967. }
  968. return returnNode;
  969. }
  970. var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
  971. /* Sanitize final string template-safe */
  972. if (SAFE_FOR_TEMPLATES) {
  973. serializedHTML = serializedHTML.replace(MUSTACHE_EXPR$$1, ' ');
  974. serializedHTML = serializedHTML.replace(ERB_EXPR$$1, ' ');
  975. }
  976. return trustedTypesPolicy ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
  977. };
  978. /**
  979. * Public method to set the configuration once
  980. * setConfig
  981. *
  982. * @param {Object} cfg configuration object
  983. */
  984. DOMPurify.setConfig = function (cfg) {
  985. _parseConfig(cfg);
  986. SET_CONFIG = true;
  987. };
  988. /**
  989. * Public method to remove the configuration
  990. * clearConfig
  991. *
  992. */
  993. DOMPurify.clearConfig = function () {
  994. CONFIG = null;
  995. SET_CONFIG = false;
  996. };
  997. /**
  998. * Public method to check if an attribute value is valid.
  999. * Uses last set config, if any. Otherwise, uses config defaults.
  1000. * isValidAttribute
  1001. *
  1002. * @param {string} tag Tag name of containing element.
  1003. * @param {string} attr Attribute name.
  1004. * @param {string} value Attribute value.
  1005. * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
  1006. */
  1007. DOMPurify.isValidAttribute = function (tag, attr, value) {
  1008. /* Initialize shared config vars if necessary. */
  1009. if (!CONFIG) {
  1010. _parseConfig({});
  1011. }
  1012. var lcTag = tag.toLowerCase();
  1013. var lcName = attr.toLowerCase();
  1014. return _isValidAttribute(lcTag, lcName, value);
  1015. };
  1016. /**
  1017. * AddHook
  1018. * Public method to add DOMPurify hooks
  1019. *
  1020. * @param {String} entryPoint entry point for the hook to add
  1021. * @param {Function} hookFunction function to execute
  1022. */
  1023. DOMPurify.addHook = function (entryPoint, hookFunction) {
  1024. if (typeof hookFunction !== 'function') {
  1025. return;
  1026. }
  1027. hooks[entryPoint] = hooks[entryPoint] || [];
  1028. hooks[entryPoint].push(hookFunction);
  1029. };
  1030. /**
  1031. * RemoveHook
  1032. * Public method to remove a DOMPurify hook at a given entryPoint
  1033. * (pops it from the stack of hooks if more are present)
  1034. *
  1035. * @param {String} entryPoint entry point for the hook to remove
  1036. */
  1037. DOMPurify.removeHook = function (entryPoint) {
  1038. if (hooks[entryPoint]) {
  1039. hooks[entryPoint].pop();
  1040. }
  1041. };
  1042. /**
  1043. * RemoveHooks
  1044. * Public method to remove all DOMPurify hooks at a given entryPoint
  1045. *
  1046. * @param {String} entryPoint entry point for the hooks to remove
  1047. */
  1048. DOMPurify.removeHooks = function (entryPoint) {
  1049. if (hooks[entryPoint]) {
  1050. hooks[entryPoint] = [];
  1051. }
  1052. };
  1053. /**
  1054. * RemoveAllHooks
  1055. * Public method to remove all DOMPurify hooks
  1056. *
  1057. */
  1058. DOMPurify.removeAllHooks = function () {
  1059. hooks = {};
  1060. };
  1061. return DOMPurify;
  1062. }
  1063. var purify = createDOMPurify();
  1064. return purify;
  1065. })));
  1066. //# sourceMappingURL=purify.js.map
  1067. /***/ }),
  1068. /***/ "./node_modules/marked/lib/marked.js":
  1069. /*!*******************************************!*\
  1070. !*** ./node_modules/marked/lib/marked.js ***!
  1071. \*******************************************/
  1072. /*! no static exports found */
  1073. /***/ (function(module, exports, __webpack_require__) {
  1074. /* WEBPACK VAR INJECTION */(function(global) {/**
  1075. * marked - a markdown parser
  1076. * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT Licensed)
  1077. * https://github.com/markedjs/marked
  1078. */
  1079. ;(function(root) {
  1080. 'use strict';
  1081. /**
  1082. * Block-Level Grammar
  1083. */
  1084. var block = {
  1085. newline: /^\n+/,
  1086. code: /^( {4}[^\n]+\n*)+/,
  1087. fences: noop,
  1088. hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
  1089. heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
  1090. nptable: noop,
  1091. blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
  1092. list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
  1093. html: '^ {0,3}(?:' // optional indentation
  1094. + '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
  1095. + '|comment[^\\n]*(\\n+|$)' // (2)
  1096. + '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
  1097. + '|<![A-Z][\\s\\S]*?>\\n*' // (4)
  1098. + '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
  1099. + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
  1100. + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
  1101. + '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
  1102. + ')',
  1103. def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
  1104. table: noop,
  1105. lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
  1106. paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/,
  1107. text: /^[^\n]+/
  1108. };
  1109. block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
  1110. block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
  1111. block.def = edit(block.def)
  1112. .replace('label', block._label)
  1113. .replace('title', block._title)
  1114. .getRegex();
  1115. block.bullet = /(?:[*+-]|\d{1,9}\.)/;
  1116. block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
  1117. block.item = edit(block.item, 'gm')
  1118. .replace(/bull/g, block.bullet)
  1119. .getRegex();
  1120. block.list = edit(block.list)
  1121. .replace(/bull/g, block.bullet)
  1122. .replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
  1123. .replace('def', '\\n+(?=' + block.def.source + ')')
  1124. .getRegex();
  1125. block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
  1126. + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
  1127. + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
  1128. + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
  1129. + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
  1130. + '|track|ul';
  1131. block._comment = /<!--(?!-?>)[\s\S]*?-->/;
  1132. block.html = edit(block.html, 'i')
  1133. .replace('comment', block._comment)
  1134. .replace('tag', block._tag)
  1135. .replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
  1136. .getRegex();
  1137. block.paragraph = edit(block.paragraph)
  1138. .replace('hr', block.hr)
  1139. .replace('heading', block.heading)
  1140. .replace('lheading', block.lheading)
  1141. .replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
  1142. .getRegex();
  1143. block.blockquote = edit(block.blockquote)
  1144. .replace('paragraph', block.paragraph)
  1145. .getRegex();
  1146. /**
  1147. * Normal Block Grammar
  1148. */
  1149. block.normal = merge({}, block);
  1150. /**
  1151. * GFM Block Grammar
  1152. */
  1153. block.gfm = merge({}, block.normal, {
  1154. fences: /^ {0,3}(`{3,}|~{3,})([^`\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
  1155. paragraph: /^/,
  1156. heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
  1157. });
  1158. block.gfm.paragraph = edit(block.paragraph)
  1159. .replace('(?!', '(?!'
  1160. + block.gfm.fences.source.replace('\\1', '\\2') + '|'
  1161. + block.list.source.replace('\\1', '\\3') + '|')
  1162. .getRegex();
  1163. /**
  1164. * GFM + Tables Block Grammar
  1165. */
  1166. block.tables = merge({}, block.gfm, {
  1167. nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,
  1168. table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/
  1169. });
  1170. /**
  1171. * Pedantic grammar
  1172. */
  1173. block.pedantic = merge({}, block.normal, {
  1174. html: edit(
  1175. '^ *(?:comment *(?:\\n|\\s*$)'
  1176. + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
  1177. + '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
  1178. .replace('comment', block._comment)
  1179. .replace(/tag/g, '(?!(?:'
  1180. + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
  1181. + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
  1182. + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
  1183. .getRegex(),
  1184. def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/
  1185. });
  1186. /**
  1187. * Block Lexer
  1188. */
  1189. function Lexer(options) {
  1190. this.tokens = [];
  1191. this.tokens.links = Object.create(null);
  1192. this.options = options || marked.defaults;
  1193. this.rules = block.normal;
  1194. if (this.options.pedantic) {
  1195. this.rules = block.pedantic;
  1196. } else if (this.options.gfm) {
  1197. if (this.options.tables) {
  1198. this.rules = block.tables;
  1199. } else {
  1200. this.rules = block.gfm;
  1201. }
  1202. }
  1203. }
  1204. /**
  1205. * Expose Block Rules
  1206. */
  1207. Lexer.rules = block;
  1208. /**
  1209. * Static Lex Method
  1210. */
  1211. Lexer.lex = function(src, options) {
  1212. var lexer = new Lexer(options);
  1213. return lexer.lex(src);
  1214. };
  1215. /**
  1216. * Preprocessing
  1217. */
  1218. Lexer.prototype.lex = function(src) {
  1219. src = src
  1220. .replace(/\r\n|\r/g, '\n')
  1221. .replace(/\t/g, ' ')
  1222. .replace(/\u00a0/g, ' ')
  1223. .replace(/\u2424/g, '\n');
  1224. return this.token(src, true);
  1225. };
  1226. /**
  1227. * Lexing
  1228. */
  1229. Lexer.prototype.token = function(src, top) {
  1230. src = src.replace(/^ +$/gm, '');
  1231. var next,
  1232. loose,
  1233. cap,
  1234. bull,
  1235. b,
  1236. item,
  1237. listStart,
  1238. listItems,
  1239. t,
  1240. space,
  1241. i,
  1242. tag,
  1243. l,
  1244. isordered,
  1245. istask,
  1246. ischecked;
  1247. while (src) {
  1248. // newline
  1249. if (cap = this.rules.newline.exec(src)) {
  1250. src = src.substring(cap[0].length);
  1251. if (cap[0].length > 1) {
  1252. this.tokens.push({
  1253. type: 'space'
  1254. });
  1255. }
  1256. }
  1257. // code
  1258. if (cap = this.rules.code.exec(src)) {
  1259. src = src.substring(cap[0].length);
  1260. cap = cap[0].replace(/^ {4}/gm, '');
  1261. this.tokens.push({
  1262. type: 'code',
  1263. text: !this.options.pedantic
  1264. ? rtrim(cap, '\n')
  1265. : cap
  1266. });
  1267. continue;
  1268. }
  1269. // fences (gfm)
  1270. if (cap = this.rules.fences.exec(src)) {
  1271. src = src.substring(cap[0].length);
  1272. this.tokens.push({
  1273. type: 'code',
  1274. lang: cap[2] ? cap[2].trim() : cap[2],
  1275. text: cap[3] || ''
  1276. });
  1277. continue;
  1278. }
  1279. // heading
  1280. if (cap = this.rules.heading.exec(src)) {
  1281. src = src.substring(cap[0].length);
  1282. this.tokens.push({
  1283. type: 'heading',
  1284. depth: cap[1].length,
  1285. text: cap[2]
  1286. });
  1287. continue;
  1288. }
  1289. // table no leading pipe (gfm)
  1290. if (top && (cap = this.rules.nptable.exec(src))) {
  1291. item = {
  1292. type: 'table',
  1293. header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
  1294. align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
  1295. cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
  1296. };
  1297. if (item.header.length === item.align.length) {
  1298. src = src.substring(cap[0].length);
  1299. for (i = 0; i < item.align.length; i++) {
  1300. if (/^ *-+: *$/.test(item.align[i])) {
  1301. item.align[i] = 'right';
  1302. } else if (/^ *:-+: *$/.test(item.align[i])) {
  1303. item.align[i] = 'center';
  1304. } else if (/^ *:-+ *$/.test(item.align[i])) {
  1305. item.align[i] = 'left';
  1306. } else {
  1307. item.align[i] = null;
  1308. }
  1309. }
  1310. for (i = 0; i < item.cells.length; i++) {
  1311. item.cells[i] = splitCells(item.cells[i], item.header.length);
  1312. }
  1313. this.tokens.push(item);
  1314. continue;
  1315. }
  1316. }
  1317. // hr
  1318. if (cap = this.rules.hr.exec(src)) {
  1319. src = src.substring(cap[0].length);
  1320. this.tokens.push({
  1321. type: 'hr'
  1322. });
  1323. continue;
  1324. }
  1325. // blockquote
  1326. if (cap = this.rules.blockquote.exec(src)) {
  1327. src = src.substring(cap[0].length);
  1328. this.tokens.push({
  1329. type: 'blockquote_start'
  1330. });
  1331. cap = cap[0].replace(/^ *> ?/gm, '');
  1332. // Pass `top` to keep the current
  1333. // "toplevel" state. This is exactly
  1334. // how markdown.pl works.
  1335. this.token(cap, top);
  1336. this.tokens.push({
  1337. type: 'blockquote_end'
  1338. });
  1339. continue;
  1340. }
  1341. // list
  1342. if (cap = this.rules.list.exec(src)) {
  1343. src = src.substring(cap[0].length);
  1344. bull = cap[2];
  1345. isordered = bull.length > 1;
  1346. listStart = {
  1347. type: 'list_start',
  1348. ordered: isordered,
  1349. start: isordered ? +bull : '',
  1350. loose: false
  1351. };
  1352. this.tokens.push(listStart);
  1353. // Get each top-level item.
  1354. cap = cap[0].match(this.rules.item);
  1355. listItems = [];
  1356. next = false;
  1357. l = cap.length;
  1358. i = 0;
  1359. for (; i < l; i++) {
  1360. item = cap[i];
  1361. // Remove the list item's bullet
  1362. // so it is seen as the next token.
  1363. space = item.length;
  1364. item = item.replace(/^ *([*+-]|\d+\.) */, '');
  1365. // Outdent whatever the
  1366. // list item contains. Hacky.
  1367. if (~item.indexOf('\n ')) {
  1368. space -= item.length;
  1369. item = !this.options.pedantic
  1370. ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
  1371. : item.replace(/^ {1,4}/gm, '');
  1372. }
  1373. // Determine whether the next list item belongs here.
  1374. // Backpedal if it does not belong in this list.
  1375. if (i !== l - 1) {
  1376. b = block.bullet.exec(cap[i + 1])[0];
  1377. if (bull.length > 1 ? b.length === 1
  1378. : (b.length > 1 || (this.options.smartLists && b !== bull))) {
  1379. src = cap.slice(i + 1).join('\n') + src;
  1380. i = l - 1;
  1381. }
  1382. }
  1383. // Determine whether item is loose or not.
  1384. // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
  1385. // for discount behavior.
  1386. loose = next || /\n\n(?!\s*$)/.test(item);
  1387. if (i !== l - 1) {
  1388. next = item.charAt(item.length - 1) === '\n';
  1389. if (!loose) loose = next;
  1390. }
  1391. if (loose) {
  1392. listStart.loose = true;
  1393. }
  1394. // Check for task list items
  1395. istask = /^\[[ xX]\] /.test(item);
  1396. ischecked = undefined;
  1397. if (istask) {
  1398. ischecked = item[1] !== ' ';
  1399. item = item.replace(/^\[[ xX]\] +/, '');
  1400. }
  1401. t = {
  1402. type: 'list_item_start',
  1403. task: istask,
  1404. checked: ischecked,
  1405. loose: loose
  1406. };
  1407. listItems.push(t);
  1408. this.tokens.push(t);
  1409. // Recurse.
  1410. this.token(item, false);
  1411. this.tokens.push({
  1412. type: 'list_item_end'
  1413. });
  1414. }
  1415. if (listStart.loose) {
  1416. l = listItems.length;
  1417. i = 0;
  1418. for (; i < l; i++) {
  1419. listItems[i].loose = true;
  1420. }
  1421. }
  1422. this.tokens.push({
  1423. type: 'list_end'
  1424. });
  1425. continue;
  1426. }
  1427. // html
  1428. if (cap = this.rules.html.exec(src)) {
  1429. src = src.substring(cap[0].length);
  1430. this.tokens.push({
  1431. type: this.options.sanitize
  1432. ? 'paragraph'
  1433. : 'html',
  1434. pre: !this.options.sanitizer
  1435. && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
  1436. text: cap[0]
  1437. });
  1438. continue;
  1439. }
  1440. // def
  1441. if (top && (cap = this.rules.def.exec(src))) {
  1442. src = src.substring(cap[0].length);
  1443. if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
  1444. tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
  1445. if (!this.tokens.links[tag]) {
  1446. this.tokens.links[tag] = {
  1447. href: cap[2],
  1448. title: cap[3]
  1449. };
  1450. }
  1451. continue;
  1452. }
  1453. // table (gfm)
  1454. if (top && (cap = this.rules.table.exec(src))) {
  1455. item = {
  1456. type: 'table',
  1457. header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
  1458. align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
  1459. cells: cap[3] ? cap[3].replace(/(?: *\| *)?\n$/, '').split('\n') : []
  1460. };
  1461. if (item.header.length === item.align.length) {
  1462. src = src.substring(cap[0].length);
  1463. for (i = 0; i < item.align.length; i++) {
  1464. if (/^ *-+: *$/.test(item.align[i])) {
  1465. item.align[i] = 'right';
  1466. } else if (/^ *:-+: *$/.test(item.align[i])) {
  1467. item.align[i] = 'center';
  1468. } else if (/^ *:-+ *$/.test(item.align[i])) {
  1469. item.align[i] = 'left';
  1470. } else {
  1471. item.align[i] = null;
  1472. }
  1473. }
  1474. for (i = 0; i < item.cells.length; i++) {
  1475. item.cells[i] = splitCells(
  1476. item.cells[i].replace(/^ *\| *| *\| *$/g, ''),
  1477. item.header.length);
  1478. }
  1479. this.tokens.push(item);
  1480. continue;
  1481. }
  1482. }
  1483. // lheading
  1484. if (cap = this.rules.lheading.exec(src)) {
  1485. src = src.substring(cap[0].length);
  1486. this.tokens.push({
  1487. type: 'heading',
  1488. depth: cap[2] === '=' ? 1 : 2,
  1489. text: cap[1]
  1490. });
  1491. continue;
  1492. }
  1493. // top-level paragraph
  1494. if (top && (cap = this.rules.paragraph.exec(src))) {
  1495. src = src.substring(cap[0].length);
  1496. this.tokens.push({
  1497. type: 'paragraph',
  1498. text: cap[1].charAt(cap[1].length - 1) === '\n'
  1499. ? cap[1].slice(0, -1)
  1500. : cap[1]
  1501. });
  1502. continue;
  1503. }
  1504. // text
  1505. if (cap = this.rules.text.exec(src)) {
  1506. // Top-level should never reach here.
  1507. src = src.substring(cap[0].length);
  1508. this.tokens.push({
  1509. type: 'text',
  1510. text: cap[0]
  1511. });
  1512. continue;
  1513. }
  1514. if (src) {
  1515. throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
  1516. }
  1517. }
  1518. return this.tokens;
  1519. };
  1520. /**
  1521. * Inline-Level Grammar
  1522. */
  1523. var inline = {
  1524. escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
  1525. autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
  1526. url: noop,
  1527. tag: '^comment'
  1528. + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
  1529. + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
  1530. + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
  1531. + '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
  1532. + '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
  1533. link: /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/,
  1534. reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
  1535. nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
  1536. strong: /^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
  1537. em: /^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
  1538. code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
  1539. br: /^( {2,}|\\)\n(?!\s*$)/,
  1540. del: noop,
  1541. text: /^(`+|[^`])[\s\S]*?(?=[\\<!\[`*]|\b_| {2,}\n|$)/
  1542. };
  1543. // list of punctuation marks from common mark spec
  1544. // without ` and ] to workaround Rule 17 (inline code blocks/links)
  1545. inline._punctuation = '!"#$%&\'()*+,\\-./:;<=>?@\\[^_{|}~';
  1546. inline.em = edit(inline.em).replace(/punctuation/g, inline._punctuation).getRegex();
  1547. inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
  1548. inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
  1549. inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
  1550. inline.autolink = edit(inline.autolink)
  1551. .replace('scheme', inline._scheme)
  1552. .replace('email', inline._email)
  1553. .getRegex();
  1554. inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
  1555. inline.tag = edit(inline.tag)
  1556. .replace('comment', block._comment)
  1557. .replace('attribute', inline._attribute)
  1558. .getRegex();
  1559. inline._label = /(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|[^\[\]\\])*?/;
  1560. inline._href = /\s*(<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*)/;
  1561. inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
  1562. inline.link = edit(inline.link)
  1563. .replace('label', inline._label)
  1564. .replace('href', inline._href)
  1565. .replace('title', inline._title)
  1566. .getRegex();
  1567. inline.reflink = edit(inline.reflink)
  1568. .replace('label', inline._label)
  1569. .getRegex();
  1570. /**
  1571. * Normal Inline Grammar
  1572. */
  1573. inline.normal = merge({}, inline);
  1574. /**
  1575. * Pedantic Inline Grammar
  1576. */
  1577. inline.pedantic = merge({}, inline.normal, {
  1578. strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
  1579. em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
  1580. link: edit(/^!?\[(label)\]\((.*?)\)/)
  1581. .replace('label', inline._label)
  1582. .getRegex(),
  1583. reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
  1584. .replace('label', inline._label)
  1585. .getRegex()
  1586. });
  1587. /**
  1588. * GFM Inline Grammar
  1589. */
  1590. inline.gfm = merge({}, inline.normal, {
  1591. escape: edit(inline.escape).replace('])', '~|])').getRegex(),
  1592. _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
  1593. url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
  1594. _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
  1595. del: /^~+(?=\S)([\s\S]*?\S)~+/,
  1596. text: edit(inline.text)
  1597. .replace(']|', '~]|')
  1598. .replace('|$', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|$')
  1599. .getRegex()
  1600. });
  1601. inline.gfm.url = edit(inline.gfm.url, 'i')
  1602. .replace('email', inline.gfm._extended_email)
  1603. .getRegex();
  1604. /**
  1605. * GFM + Line Breaks Inline Grammar
  1606. */
  1607. inline.breaks = merge({}, inline.gfm, {
  1608. br: edit(inline.br).replace('{2,}', '*').getRegex(),
  1609. text: edit(inline.gfm.text).replace('{2,}', '*').getRegex()
  1610. });
  1611. /**
  1612. * Inline Lexer & Compiler
  1613. */
  1614. function InlineLexer(links, options) {
  1615. this.options = options || marked.defaults;
  1616. this.links = links;
  1617. this.rules = inline.normal;
  1618. this.renderer = this.options.renderer || new Renderer();
  1619. this.renderer.options = this.options;
  1620. if (!this.links) {
  1621. throw new Error('Tokens array requires a `links` property.');
  1622. }
  1623. if (this.options.pedantic) {
  1624. this.rules = inline.pedantic;
  1625. } else if (this.options.gfm) {
  1626. if (this.options.breaks) {
  1627. this.rules = inline.breaks;
  1628. } else {
  1629. this.rules = inline.gfm;
  1630. }
  1631. }
  1632. }
  1633. /**
  1634. * Expose Inline Rules
  1635. */
  1636. InlineLexer.rules = inline;
  1637. /**
  1638. * Static Lexing/Compiling Method
  1639. */
  1640. InlineLexer.output = function(src, links, options) {
  1641. var inline = new InlineLexer(links, options);
  1642. return inline.output(src);
  1643. };
  1644. /**
  1645. * Lexing/Compiling
  1646. */
  1647. InlineLexer.prototype.output = function(src) {
  1648. var out = '',
  1649. link,
  1650. text,
  1651. href,
  1652. title,
  1653. cap,
  1654. prevCapZero;
  1655. while (src) {
  1656. // escape
  1657. if (cap = this.rules.escape.exec(src)) {
  1658. src = src.substring(cap[0].length);
  1659. out += escape(cap[1]);
  1660. continue;
  1661. }
  1662. // tag
  1663. if (cap = this.rules.tag.exec(src)) {
  1664. if (!this.inLink && /^<a /i.test(cap[0])) {
  1665. this.inLink = true;
  1666. } else if (this.inLink && /^<\/a>/i.test(cap[0])) {
  1667. this.inLink = false;
  1668. }
  1669. if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
  1670. this.inRawBlock = true;
  1671. } else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
  1672. this.inRawBlock = false;
  1673. }
  1674. src = src.substring(cap[0].length);
  1675. out += this.options.sanitize
  1676. ? this.options.sanitizer
  1677. ? this.options.sanitizer(cap[0])
  1678. : escape(cap[0])
  1679. : cap[0];
  1680. continue;
  1681. }
  1682. // link
  1683. if (cap = this.rules.link.exec(src)) {
  1684. var lastParenIndex = findClosingBracket(cap[2], '()');
  1685. if (lastParenIndex > -1) {
  1686. var removeChars = cap[2].length - lastParenIndex;
  1687. cap[2] = cap[2].substring(0, lastParenIndex);
  1688. cap[0] = cap[0].substring(0, cap[0].length - removeChars);
  1689. }
  1690. src = src.substring(cap[0].length);
  1691. this.inLink = true;
  1692. href = cap[2];
  1693. if (this.options.pedantic) {
  1694. link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
  1695. if (link) {
  1696. href = link[1];
  1697. title = link[3];
  1698. } else {
  1699. title = '';
  1700. }
  1701. } else {
  1702. title = cap[3] ? cap[3].slice(1, -1) : '';
  1703. }
  1704. href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
  1705. out += this.outputLink(cap, {
  1706. href: InlineLexer.escapes(href),
  1707. title: InlineLexer.escapes(title)
  1708. });
  1709. this.inLink = false;
  1710. continue;
  1711. }
  1712. // reflink, nolink
  1713. if ((cap = this.rules.reflink.exec(src))
  1714. || (cap = this.rules.nolink.exec(src))) {
  1715. src = src.substring(cap[0].length);
  1716. link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
  1717. link = this.links[link.toLowerCase()];
  1718. if (!link || !link.href) {
  1719. out += cap[0].charAt(0);
  1720. src = cap[0].substring(1) + src;
  1721. continue;
  1722. }
  1723. this.inLink = true;
  1724. out += this.outputLink(cap, link);
  1725. this.inLink = false;
  1726. continue;
  1727. }
  1728. // strong
  1729. if (cap = this.rules.strong.exec(src)) {
  1730. src = src.substring(cap[0].length);
  1731. out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
  1732. continue;
  1733. }
  1734. // em
  1735. if (cap = this.rules.em.exec(src)) {
  1736. src = src.substring(cap[0].length);
  1737. out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]));
  1738. continue;
  1739. }
  1740. // code
  1741. if (cap = this.rules.code.exec(src)) {
  1742. src = src.substring(cap[0].length);
  1743. out += this.renderer.codespan(escape(cap[2].trim(), true));
  1744. continue;
  1745. }
  1746. // br
  1747. if (cap = this.rules.br.exec(src)) {
  1748. src = src.substring(cap[0].length);
  1749. out += this.renderer.br();
  1750. continue;
  1751. }
  1752. // del (gfm)
  1753. if (cap = this.rules.del.exec(src)) {
  1754. src = src.substring(cap[0].length);
  1755. out += this.renderer.del(this.output(cap[1]));
  1756. continue;
  1757. }
  1758. // autolink
  1759. if (cap = this.rules.autolink.exec(src)) {
  1760. src = src.substring(cap[0].length);
  1761. if (cap[2] === '@') {
  1762. text = escape(this.mangle(cap[1]));
  1763. href = 'mailto:' + text;
  1764. } else {
  1765. text = escape(cap[1]);
  1766. href = text;
  1767. }
  1768. out += this.renderer.link(href, null, text);
  1769. continue;
  1770. }
  1771. // url (gfm)
  1772. if (!this.inLink && (cap = this.rules.url.exec(src))) {
  1773. if (cap[2] === '@') {
  1774. text = escape(cap[0]);
  1775. href = 'mailto:' + text;
  1776. } else {
  1777. // do extended autolink path validation
  1778. do {
  1779. prevCapZero = cap[0];
  1780. cap[0] = this.rules._backpedal.exec(cap[0])[0];
  1781. } while (prevCapZero !== cap[0]);
  1782. text = escape(cap[0]);
  1783. if (cap[1] === 'www.') {
  1784. href = 'http://' + text;
  1785. } else {
  1786. href = text;
  1787. }
  1788. }
  1789. src = src.substring(cap[0].length);
  1790. out += this.renderer.link(href, null, text);
  1791. continue;
  1792. }
  1793. // text
  1794. if (cap = this.rules.text.exec(src)) {
  1795. src = src.substring(cap[0].length);
  1796. if (this.inRawBlock) {
  1797. out += this.renderer.text(cap[0]);
  1798. } else {
  1799. out += this.renderer.text(escape(this.smartypants(cap[0])));
  1800. }
  1801. continue;
  1802. }
  1803. if (src) {
  1804. throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
  1805. }
  1806. }
  1807. return out;
  1808. };
  1809. InlineLexer.escapes = function(text) {
  1810. return text ? text.replace(InlineLexer.rules._escapes, '$1') : text;
  1811. };
  1812. /**
  1813. * Compile Link
  1814. */
  1815. InlineLexer.prototype.outputLink = function(cap, link) {
  1816. var href = link.href,
  1817. title = link.title ? escape(link.title) : null;
  1818. return cap[0].charAt(0) !== '!'
  1819. ? this.renderer.link(href, title, this.output(cap[1]))
  1820. : this.renderer.image(href, title, escape(cap[1]));
  1821. };
  1822. /**
  1823. * Smartypants Transformations
  1824. */
  1825. InlineLexer.prototype.smartypants = function(text) {
  1826. if (!this.options.smartypants) return text;
  1827. return text
  1828. // em-dashes
  1829. .replace(/---/g, '\u2014')
  1830. // en-dashes
  1831. .replace(/--/g, '\u2013')
  1832. // opening singles
  1833. .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
  1834. // closing singles & apostrophes
  1835. .replace(/'/g, '\u2019')
  1836. // opening doubles
  1837. .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
  1838. // closing doubles
  1839. .replace(/"/g, '\u201d')
  1840. // ellipses
  1841. .replace(/\.{3}/g, '\u2026');
  1842. };
  1843. /**
  1844. * Mangle Links
  1845. */
  1846. InlineLexer.prototype.mangle = function(text) {
  1847. if (!this.options.mangle) return text;
  1848. var out = '',
  1849. l = text.length,
  1850. i = 0,
  1851. ch;
  1852. for (; i < l; i++) {
  1853. ch = text.charCodeAt(i);
  1854. if (Math.random() > 0.5) {
  1855. ch = 'x' + ch.toString(16);
  1856. }
  1857. out += '&#' + ch + ';';
  1858. }
  1859. return out;
  1860. };
  1861. /**
  1862. * Renderer
  1863. */
  1864. function Renderer(options) {
  1865. this.options = options || marked.defaults;
  1866. }
  1867. Renderer.prototype.code = function(code, infostring, escaped) {
  1868. var lang = (infostring || '').match(/\S*/)[0];
  1869. if (this.options.highlight) {
  1870. var out = this.options.highlight(code, lang);
  1871. if (out != null && out !== code) {
  1872. escaped = true;
  1873. code = out;
  1874. }
  1875. }
  1876. if (!lang) {
  1877. return '<pre><code>'
  1878. + (escaped ? code : escape(code, true))
  1879. + '</code></pre>';
  1880. }
  1881. return '<pre><code class="'
  1882. + this.options.langPrefix
  1883. + escape(lang, true)
  1884. + '">'
  1885. + (escaped ? code : escape(code, true))
  1886. + '</code></pre>\n';
  1887. };
  1888. Renderer.prototype.blockquote = function(quote) {
  1889. return '<blockquote>\n' + quote + '</blockquote>\n';
  1890. };
  1891. Renderer.prototype.html = function(html) {
  1892. return html;
  1893. };
  1894. Renderer.prototype.heading = function(text, level, raw, slugger) {
  1895. if (this.options.headerIds) {
  1896. return '<h'
  1897. + level
  1898. + ' id="'
  1899. + this.options.headerPrefix
  1900. + slugger.slug(raw)
  1901. + '">'
  1902. + text
  1903. + '</h'
  1904. + level
  1905. + '>\n';
  1906. }
  1907. // ignore IDs
  1908. return '<h' + level + '>' + text + '</h' + level + '>\n';
  1909. };
  1910. Renderer.prototype.hr = function() {
  1911. return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
  1912. };
  1913. Renderer.prototype.list = function(body, ordered, start) {
  1914. var type = ordered ? 'ol' : 'ul',
  1915. startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
  1916. return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
  1917. };
  1918. Renderer.prototype.listitem = function(text) {
  1919. return '<li>' + text + '</li>\n';
  1920. };
  1921. Renderer.prototype.checkbox = function(checked) {
  1922. return '<input '
  1923. + (checked ? 'checked="" ' : '')
  1924. + 'disabled="" type="checkbox"'
  1925. + (this.options.xhtml ? ' /' : '')
  1926. + '> ';
  1927. };
  1928. Renderer.prototype.paragraph = function(text) {
  1929. return '<p>' + text + '</p>\n';
  1930. };
  1931. Renderer.prototype.table = function(header, body) {
  1932. if (body) body = '<tbody>' + body + '</tbody>';
  1933. return '<table>\n'
  1934. + '<thead>\n'
  1935. + header
  1936. + '</thead>\n'
  1937. + body
  1938. + '</table>\n';
  1939. };
  1940. Renderer.prototype.tablerow = function(content) {
  1941. return '<tr>\n' + content + '</tr>\n';
  1942. };
  1943. Renderer.prototype.tablecell = function(content, flags) {
  1944. var type = flags.header ? 'th' : 'td';
  1945. var tag = flags.align
  1946. ? '<' + type + ' align="' + flags.align + '">'
  1947. : '<' + type + '>';
  1948. return tag + content + '</' + type + '>\n';
  1949. };
  1950. // span level renderer
  1951. Renderer.prototype.strong = function(text) {
  1952. return '<strong>' + text + '</strong>';
  1953. };
  1954. Renderer.prototype.em = function(text) {
  1955. return '<em>' + text + '</em>';
  1956. };
  1957. Renderer.prototype.codespan = function(text) {
  1958. return '<code>' + text + '</code>';
  1959. };
  1960. Renderer.prototype.br = function() {
  1961. return this.options.xhtml ? '<br/>' : '<br>';
  1962. };
  1963. Renderer.prototype.del = function(text) {
  1964. return '<del>' + text + '</del>';
  1965. };
  1966. Renderer.prototype.link = function(href, title, text) {
  1967. href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
  1968. if (href === null) {
  1969. return text;
  1970. }
  1971. var out = '<a href="' + escape(href) + '"';
  1972. if (title) {
  1973. out += ' title="' + title + '"';
  1974. }
  1975. out += '>' + text + '</a>';
  1976. return out;
  1977. };
  1978. Renderer.prototype.image = function(href, title, text) {
  1979. href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
  1980. if (href === null) {
  1981. return text;
  1982. }
  1983. var out = '<img src="' + href + '" alt="' + text + '"';
  1984. if (title) {
  1985. out += ' title="' + title + '"';
  1986. }
  1987. out += this.options.xhtml ? '/>' : '>';
  1988. return out;
  1989. };
  1990. Renderer.prototype.text = function(text) {
  1991. return text;
  1992. };
  1993. /**
  1994. * TextRenderer
  1995. * returns only the textual part of the token
  1996. */
  1997. function TextRenderer() {}
  1998. // no need for block level renderers
  1999. TextRenderer.prototype.strong =
  2000. TextRenderer.prototype.em =
  2001. TextRenderer.prototype.codespan =
  2002. TextRenderer.prototype.del =
  2003. TextRenderer.prototype.text = function (text) {
  2004. return text;
  2005. };
  2006. TextRenderer.prototype.link =
  2007. TextRenderer.prototype.image = function(href, title, text) {
  2008. return '' + text;
  2009. };
  2010. TextRenderer.prototype.br = function() {
  2011. return '';
  2012. };
  2013. /**
  2014. * Parsing & Compiling
  2015. */
  2016. function Parser(options) {
  2017. this.tokens = [];
  2018. this.token = null;
  2019. this.options = options || marked.defaults;
  2020. this.options.renderer = this.options.renderer || new Renderer();
  2021. this.renderer = this.options.renderer;
  2022. this.renderer.options = this.options;
  2023. this.slugger = new Slugger();
  2024. }
  2025. /**
  2026. * Static Parse Method
  2027. */
  2028. Parser.parse = function(src, options) {
  2029. var parser = new Parser(options);
  2030. return parser.parse(src);
  2031. };
  2032. /**
  2033. * Parse Loop
  2034. */
  2035. Parser.prototype.parse = function(src) {
  2036. this.inline = new InlineLexer(src.links, this.options);
  2037. // use an InlineLexer with a TextRenderer to extract pure text
  2038. this.inlineText = new InlineLexer(
  2039. src.links,
  2040. merge({}, this.options, {renderer: new TextRenderer()})
  2041. );
  2042. this.tokens = src.reverse();
  2043. var out = '';
  2044. while (this.next()) {
  2045. out += this.tok();
  2046. }
  2047. return out;
  2048. };
  2049. /**
  2050. * Next Token
  2051. */
  2052. Parser.prototype.next = function() {
  2053. return this.token = this.tokens.pop();
  2054. };
  2055. /**
  2056. * Preview Next Token
  2057. */
  2058. Parser.prototype.peek = function() {
  2059. return this.tokens[this.tokens.length - 1] || 0;
  2060. };
  2061. /**
  2062. * Parse Text Tokens
  2063. */
  2064. Parser.prototype.parseText = function() {
  2065. var body = this.token.text;
  2066. while (this.peek().type === 'text') {
  2067. body += '\n' + this.next().text;
  2068. }
  2069. return this.inline.output(body);
  2070. };
  2071. /**
  2072. * Parse Current Token
  2073. */
  2074. Parser.prototype.tok = function() {
  2075. switch (this.token.type) {
  2076. case 'space': {
  2077. return '';
  2078. }
  2079. case 'hr': {
  2080. return this.renderer.hr();
  2081. }
  2082. case 'heading': {
  2083. return this.renderer.heading(
  2084. this.inline.output(this.token.text),
  2085. this.token.depth,
  2086. unescape(this.inlineText.output(this.token.text)),
  2087. this.slugger);
  2088. }
  2089. case 'code': {
  2090. return this.renderer.code(this.token.text,
  2091. this.token.lang,
  2092. this.token.escaped);
  2093. }
  2094. case 'table': {
  2095. var header = '',
  2096. body = '',
  2097. i,
  2098. row,
  2099. cell,
  2100. j;
  2101. // header
  2102. cell = '';
  2103. for (i = 0; i < this.token.header.length; i++) {
  2104. cell += this.renderer.tablecell(
  2105. this.inline.output(this.token.header[i]),
  2106. { header: true, align: this.token.align[i] }
  2107. );
  2108. }
  2109. header += this.renderer.tablerow(cell);
  2110. for (i = 0; i < this.token.cells.length; i++) {
  2111. row = this.token.cells[i];
  2112. cell = '';
  2113. for (j = 0; j < row.length; j++) {
  2114. cell += this.renderer.tablecell(
  2115. this.inline.output(row[j]),
  2116. { header: false, align: this.token.align[j] }
  2117. );
  2118. }
  2119. body += this.renderer.tablerow(cell);
  2120. }
  2121. return this.renderer.table(header, body);
  2122. }
  2123. case 'blockquote_start': {
  2124. body = '';
  2125. while (this.next().type !== 'blockquote_end') {
  2126. body += this.tok();
  2127. }
  2128. return this.renderer.blockquote(body);
  2129. }
  2130. case 'list_start': {
  2131. body = '';
  2132. var ordered = this.token.ordered,
  2133. start = this.token.start;
  2134. while (this.next().type !== 'list_end') {
  2135. body += this.tok();
  2136. }
  2137. return this.renderer.list(body, ordered, start);
  2138. }
  2139. case 'list_item_start': {
  2140. body = '';
  2141. var loose = this.token.loose;
  2142. if (this.token.task) {
  2143. body += this.renderer.checkbox(this.token.checked);
  2144. }
  2145. while (this.next().type !== 'list_item_end') {
  2146. body += !loose && this.token.type === 'text'
  2147. ? this.parseText()
  2148. : this.tok();
  2149. }
  2150. return this.renderer.listitem(body);
  2151. }
  2152. case 'html': {
  2153. // TODO parse inline content if parameter markdown=1
  2154. return this.renderer.html(this.token.text);
  2155. }
  2156. case 'paragraph': {
  2157. return this.renderer.paragraph(this.inline.output(this.token.text));
  2158. }
  2159. case 'text': {
  2160. return this.renderer.paragraph(this.parseText());
  2161. }
  2162. default: {
  2163. var errMsg = 'Token with "' + this.token.type + '" type was not found.';
  2164. if (this.options.silent) {
  2165. console.log(errMsg);
  2166. } else {
  2167. throw new Error(errMsg);
  2168. }
  2169. }
  2170. }
  2171. };
  2172. /**
  2173. * Slugger generates header id
  2174. */
  2175. function Slugger () {
  2176. this.seen = {};
  2177. }
  2178. /**
  2179. * Convert string to unique id
  2180. */
  2181. Slugger.prototype.slug = function (value) {
  2182. var slug = value
  2183. .toLowerCase()
  2184. .trim()
  2185. .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
  2186. .replace(/\s/g, '-');
  2187. if (this.seen.hasOwnProperty(slug)) {
  2188. var originalSlug = slug;
  2189. do {
  2190. this.seen[originalSlug]++;
  2191. slug = originalSlug + '-' + this.seen[originalSlug];
  2192. } while (this.seen.hasOwnProperty(slug));
  2193. }
  2194. this.seen[slug] = 0;
  2195. return slug;
  2196. };
  2197. /**
  2198. * Helpers
  2199. */
  2200. function escape(html, encode) {
  2201. if (encode) {
  2202. if (escape.escapeTest.test(html)) {
  2203. return html.replace(escape.escapeReplace, function (ch) { return escape.replacements[ch]; });
  2204. }
  2205. } else {
  2206. if (escape.escapeTestNoEncode.test(html)) {
  2207. return html.replace(escape.escapeReplaceNoEncode, function (ch) { return escape.replacements[ch]; });
  2208. }
  2209. }
  2210. return html;
  2211. }
  2212. escape.escapeTest = /[&<>"']/;
  2213. escape.escapeReplace = /[&<>"']/g;
  2214. escape.replacements = {
  2215. '&': '&amp;',
  2216. '<': '&lt;',
  2217. '>': '&gt;',
  2218. '"': '&quot;',
  2219. "'": '&#39;'
  2220. };
  2221. escape.escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
  2222. escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
  2223. function unescape(html) {
  2224. // explicitly match decimal, hex, and named HTML entities
  2225. return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) {
  2226. n = n.toLowerCase();
  2227. if (n === 'colon') return ':';
  2228. if (n.charAt(0) === '#') {
  2229. return n.charAt(1) === 'x'
  2230. ? String.fromCharCode(parseInt(n.substring(2), 16))
  2231. : String.fromCharCode(+n.substring(1));
  2232. }
  2233. return '';
  2234. });
  2235. }
  2236. function edit(regex, opt) {
  2237. regex = regex.source || regex;
  2238. opt = opt || '';
  2239. return {
  2240. replace: function(name, val) {
  2241. val = val.source || val;
  2242. val = val.replace(/(^|[^\[])\^/g, '$1');
  2243. regex = regex.replace(name, val);
  2244. return this;
  2245. },
  2246. getRegex: function() {
  2247. return new RegExp(regex, opt);
  2248. }
  2249. };
  2250. }
  2251. function cleanUrl(sanitize, base, href) {
  2252. if (sanitize) {
  2253. try {
  2254. var prot = decodeURIComponent(unescape(href))
  2255. .replace(/[^\w:]/g, '')
  2256. .toLowerCase();
  2257. } catch (e) {
  2258. return null;
  2259. }
  2260. if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
  2261. return null;
  2262. }
  2263. }
  2264. if (base && !originIndependentUrl.test(href)) {
  2265. href = resolveUrl(base, href);
  2266. }
  2267. try {
  2268. href = encodeURI(href).replace(/%25/g, '%');
  2269. } catch (e) {
  2270. return null;
  2271. }
  2272. return href;
  2273. }
  2274. function resolveUrl(base, href) {
  2275. if (!baseUrls[' ' + base]) {
  2276. // we can ignore everything in base after the last slash of its path component,
  2277. // but we might need to add _that_
  2278. // https://tools.ietf.org/html/rfc3986#section-3
  2279. if (/^[^:]+:\/*[^/]*$/.test(base)) {
  2280. baseUrls[' ' + base] = base + '/';
  2281. } else {
  2282. baseUrls[' ' + base] = rtrim(base, '/', true);
  2283. }
  2284. }
  2285. base = baseUrls[' ' + base];
  2286. if (href.slice(0, 2) === '//') {
  2287. return base.replace(/:[\s\S]*/, ':') + href;
  2288. } else if (href.charAt(0) === '/') {
  2289. return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
  2290. } else {
  2291. return base + href;
  2292. }
  2293. }
  2294. var baseUrls = {};
  2295. var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
  2296. function noop() {}
  2297. noop.exec = noop;
  2298. function merge(obj) {
  2299. var i = 1,
  2300. target,
  2301. key;
  2302. for (; i < arguments.length; i++) {
  2303. target = arguments[i];
  2304. for (key in target) {
  2305. if (Object.prototype.hasOwnProperty.call(target, key)) {
  2306. obj[key] = target[key];
  2307. }
  2308. }
  2309. }
  2310. return obj;
  2311. }
  2312. function splitCells(tableRow, count) {
  2313. // ensure that every cell-delimiting pipe has a space
  2314. // before it to distinguish it from an escaped pipe
  2315. var row = tableRow.replace(/\|/g, function (match, offset, str) {
  2316. var escaped = false,
  2317. curr = offset;
  2318. while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
  2319. if (escaped) {
  2320. // odd number of slashes means | is escaped
  2321. // so we leave it alone
  2322. return '|';
  2323. } else {
  2324. // add space before unescaped |
  2325. return ' |';
  2326. }
  2327. }),
  2328. cells = row.split(/ \|/),
  2329. i = 0;
  2330. if (cells.length > count) {
  2331. cells.splice(count);
  2332. } else {
  2333. while (cells.length < count) cells.push('');
  2334. }
  2335. for (; i < cells.length; i++) {
  2336. // leading or trailing whitespace is ignored per the gfm spec
  2337. cells[i] = cells[i].trim().replace(/\\\|/g, '|');
  2338. }
  2339. return cells;
  2340. }
  2341. // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
  2342. // /c*$/ is vulnerable to REDOS.
  2343. // invert: Remove suffix of non-c chars instead. Default falsey.
  2344. function rtrim(str, c, invert) {
  2345. if (str.length === 0) {
  2346. return '';
  2347. }
  2348. // Length of suffix matching the invert condition.
  2349. var suffLen = 0;
  2350. // Step left until we fail to match the invert condition.
  2351. while (suffLen < str.length) {
  2352. var currChar = str.charAt(str.length - suffLen - 1);
  2353. if (currChar === c && !invert) {
  2354. suffLen++;
  2355. } else if (currChar !== c && invert) {
  2356. suffLen++;
  2357. } else {
  2358. break;
  2359. }
  2360. }
  2361. return str.substr(0, str.length - suffLen);
  2362. }
  2363. function findClosingBracket(str, b) {
  2364. if (str.indexOf(b[1]) === -1) {
  2365. return -1;
  2366. }
  2367. var level = 0;
  2368. for (var i = 0; i < str.length; i++) {
  2369. if (str[i] === '\\') {
  2370. i++;
  2371. } else if (str[i] === b[0]) {
  2372. level++;
  2373. } else if (str[i] === b[1]) {
  2374. level--;
  2375. if (level < 0) {
  2376. return i;
  2377. }
  2378. }
  2379. }
  2380. return -1;
  2381. }
  2382. /**
  2383. * Marked
  2384. */
  2385. function marked(src, opt, callback) {
  2386. // throw error in case of non string input
  2387. if (typeof src === 'undefined' || src === null) {
  2388. throw new Error('marked(): input parameter is undefined or null');
  2389. }
  2390. if (typeof src !== 'string') {
  2391. throw new Error('marked(): input parameter is of type '
  2392. + Object.prototype.toString.call(src) + ', string expected');
  2393. }
  2394. if (callback || typeof opt === 'function') {
  2395. if (!callback) {
  2396. callback = opt;
  2397. opt = null;
  2398. }
  2399. opt = merge({}, marked.defaults, opt || {});
  2400. var highlight = opt.highlight,
  2401. tokens,
  2402. pending,
  2403. i = 0;
  2404. try {
  2405. tokens = Lexer.lex(src, opt);
  2406. } catch (e) {
  2407. return callback(e);
  2408. }
  2409. pending = tokens.length;
  2410. var done = function(err) {
  2411. if (err) {
  2412. opt.highlight = highlight;
  2413. return callback(err);
  2414. }
  2415. var out;
  2416. try {
  2417. out = Parser.parse(tokens, opt);
  2418. } catch (e) {
  2419. err = e;
  2420. }
  2421. opt.highlight = highlight;
  2422. return err
  2423. ? callback(err)
  2424. : callback(null, out);
  2425. };
  2426. if (!highlight || highlight.length < 3) {
  2427. return done();
  2428. }
  2429. delete opt.highlight;
  2430. if (!pending) return done();
  2431. for (; i < tokens.length; i++) {
  2432. (function(token) {
  2433. if (token.type !== 'code') {
  2434. return --pending || done();
  2435. }
  2436. return highlight(token.text, token.lang, function(err, code) {
  2437. if (err) return done(err);
  2438. if (code == null || code === token.text) {
  2439. return --pending || done();
  2440. }
  2441. token.text = code;
  2442. token.escaped = true;
  2443. --pending || done();
  2444. });
  2445. })(tokens[i]);
  2446. }
  2447. return;
  2448. }
  2449. try {
  2450. if (opt) opt = merge({}, marked.defaults, opt);
  2451. return Parser.parse(Lexer.lex(src, opt), opt);
  2452. } catch (e) {
  2453. e.message += '\nPlease report this to https://github.com/markedjs/marked.';
  2454. if ((opt || marked.defaults).silent) {
  2455. return '<p>An error occurred:</p><pre>'
  2456. + escape(e.message + '', true)
  2457. + '</pre>';
  2458. }
  2459. throw e;
  2460. }
  2461. }
  2462. /**
  2463. * Options
  2464. */
  2465. marked.options =
  2466. marked.setOptions = function(opt) {
  2467. merge(marked.defaults, opt);
  2468. return marked;
  2469. };
  2470. marked.getDefaults = function () {
  2471. return {
  2472. baseUrl: null,
  2473. breaks: false,
  2474. gfm: true,
  2475. headerIds: true,
  2476. headerPrefix: '',
  2477. highlight: null,
  2478. langPrefix: 'language-',
  2479. mangle: true,
  2480. pedantic: false,
  2481. renderer: new Renderer(),
  2482. sanitize: false,
  2483. sanitizer: null,
  2484. silent: false,
  2485. smartLists: false,
  2486. smartypants: false,
  2487. tables: true,
  2488. xhtml: false
  2489. };
  2490. };
  2491. marked.defaults = marked.getDefaults();
  2492. /**
  2493. * Expose
  2494. */
  2495. marked.Parser = Parser;
  2496. marked.parser = Parser.parse;
  2497. marked.Renderer = Renderer;
  2498. marked.TextRenderer = TextRenderer;
  2499. marked.Lexer = Lexer;
  2500. marked.lexer = Lexer.lex;
  2501. marked.InlineLexer = InlineLexer;
  2502. marked.inlineLexer = InlineLexer.output;
  2503. marked.Slugger = Slugger;
  2504. marked.parse = marked;
  2505. if (true) {
  2506. module.exports = marked;
  2507. } else {}
  2508. })(this || (typeof window !== 'undefined' ? window : global));
  2509. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  2510. /***/ }),
  2511. /***/ "./node_modules/vue-style-loader/lib/addStylesClient.js":
  2512. /*!**************************************************************!*\
  2513. !*** ./node_modules/vue-style-loader/lib/addStylesClient.js ***!
  2514. \**************************************************************/
  2515. /*! exports provided: default */
  2516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2517. "use strict";
  2518. __webpack_require__.r(__webpack_exports__);
  2519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return addStylesClient; });
  2520. /* harmony import */ var _listToStyles__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./listToStyles */ "./node_modules/vue-style-loader/lib/listToStyles.js");
  2521. /*
  2522. MIT License http://www.opensource.org/licenses/mit-license.php
  2523. Author Tobias Koppers @sokra
  2524. Modified by Evan You @yyx990803
  2525. */
  2526. var hasDocument = typeof document !== 'undefined'
  2527. if (typeof DEBUG !== 'undefined' && DEBUG) {
  2528. if (!hasDocument) {
  2529. throw new Error(
  2530. 'vue-style-loader cannot be used in a non-browser environment. ' +
  2531. "Use { target: 'node' } in your Webpack config to indicate a server-rendering environment."
  2532. ) }
  2533. }
  2534. /*
  2535. type StyleObject = {
  2536. id: number;
  2537. parts: Array<StyleObjectPart>
  2538. }
  2539. type StyleObjectPart = {
  2540. css: string;
  2541. media: string;
  2542. sourceMap: ?string
  2543. }
  2544. */
  2545. var stylesInDom = {/*
  2546. [id: number]: {
  2547. id: number,
  2548. refs: number,
  2549. parts: Array<(obj?: StyleObjectPart) => void>
  2550. }
  2551. */}
  2552. var head = hasDocument && (document.head || document.getElementsByTagName('head')[0])
  2553. var singletonElement = null
  2554. var singletonCounter = 0
  2555. var isProduction = false
  2556. var noop = function () {}
  2557. var options = null
  2558. var ssrIdKey = 'data-vue-ssr-id'
  2559. // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
  2560. // tags it will allow on a page
  2561. var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\b/.test(navigator.userAgent.toLowerCase())
  2562. function addStylesClient (parentId, list, _isProduction, _options) {
  2563. isProduction = _isProduction
  2564. options = _options || {}
  2565. var styles = Object(_listToStyles__WEBPACK_IMPORTED_MODULE_0__["default"])(parentId, list)
  2566. addStylesToDom(styles)
  2567. return function update (newList) {
  2568. var mayRemove = []
  2569. for (var i = 0; i < styles.length; i++) {
  2570. var item = styles[i]
  2571. var domStyle = stylesInDom[item.id]
  2572. domStyle.refs--
  2573. mayRemove.push(domStyle)
  2574. }
  2575. if (newList) {
  2576. styles = Object(_listToStyles__WEBPACK_IMPORTED_MODULE_0__["default"])(parentId, newList)
  2577. addStylesToDom(styles)
  2578. } else {
  2579. styles = []
  2580. }
  2581. for (var i = 0; i < mayRemove.length; i++) {
  2582. var domStyle = mayRemove[i]
  2583. if (domStyle.refs === 0) {
  2584. for (var j = 0; j < domStyle.parts.length; j++) {
  2585. domStyle.parts[j]()
  2586. }
  2587. delete stylesInDom[domStyle.id]
  2588. }
  2589. }
  2590. }
  2591. }
  2592. function addStylesToDom (styles /* Array<StyleObject> */) {
  2593. for (var i = 0; i < styles.length; i++) {
  2594. var item = styles[i]
  2595. var domStyle = stylesInDom[item.id]
  2596. if (domStyle) {
  2597. domStyle.refs++
  2598. for (var j = 0; j < domStyle.parts.length; j++) {
  2599. domStyle.parts[j](item.parts[j])
  2600. }
  2601. for (; j < item.parts.length; j++) {
  2602. domStyle.parts.push(addStyle(item.parts[j]))
  2603. }
  2604. if (domStyle.parts.length > item.parts.length) {
  2605. domStyle.parts.length = item.parts.length
  2606. }
  2607. } else {
  2608. var parts = []
  2609. for (var j = 0; j < item.parts.length; j++) {
  2610. parts.push(addStyle(item.parts[j]))
  2611. }
  2612. stylesInDom[item.id] = { id: item.id, refs: 1, parts: parts }
  2613. }
  2614. }
  2615. }
  2616. function createStyleElement () {
  2617. var styleElement = document.createElement('style')
  2618. styleElement.type = 'text/css'
  2619. head.appendChild(styleElement)
  2620. return styleElement
  2621. }
  2622. function addStyle (obj /* StyleObjectPart */) {
  2623. var update, remove
  2624. var styleElement = document.querySelector('style[' + ssrIdKey + '~="' + obj.id + '"]')
  2625. if (styleElement) {
  2626. if (isProduction) {
  2627. // has SSR styles and in production mode.
  2628. // simply do nothing.
  2629. return noop
  2630. } else {
  2631. // has SSR styles but in dev mode.
  2632. // for some reason Chrome can't handle source map in server-rendered
  2633. // style tags - source maps in <style> only works if the style tag is
  2634. // created and inserted dynamically. So we remove the server rendered
  2635. // styles and inject new ones.
  2636. styleElement.parentNode.removeChild(styleElement)
  2637. }
  2638. }
  2639. if (isOldIE) {
  2640. // use singleton mode for IE9.
  2641. var styleIndex = singletonCounter++
  2642. styleElement = singletonElement || (singletonElement = createStyleElement())
  2643. update = applyToSingletonTag.bind(null, styleElement, styleIndex, false)
  2644. remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true)
  2645. } else {
  2646. // use multi-style-tag mode in all other cases
  2647. styleElement = createStyleElement()
  2648. update = applyToTag.bind(null, styleElement)
  2649. remove = function () {
  2650. styleElement.parentNode.removeChild(styleElement)
  2651. }
  2652. }
  2653. update(obj)
  2654. return function updateStyle (newObj /* StyleObjectPart */) {
  2655. if (newObj) {
  2656. if (newObj.css === obj.css &&
  2657. newObj.media === obj.media &&
  2658. newObj.sourceMap === obj.sourceMap) {
  2659. return
  2660. }
  2661. update(obj = newObj)
  2662. } else {
  2663. remove()
  2664. }
  2665. }
  2666. }
  2667. var replaceText = (function () {
  2668. var textStore = []
  2669. return function (index, replacement) {
  2670. textStore[index] = replacement
  2671. return textStore.filter(Boolean).join('\n')
  2672. }
  2673. })()
  2674. function applyToSingletonTag (styleElement, index, remove, obj) {
  2675. var css = remove ? '' : obj.css
  2676. if (styleElement.styleSheet) {
  2677. styleElement.styleSheet.cssText = replaceText(index, css)
  2678. } else {
  2679. var cssNode = document.createTextNode(css)
  2680. var childNodes = styleElement.childNodes
  2681. if (childNodes[index]) styleElement.removeChild(childNodes[index])
  2682. if (childNodes.length) {
  2683. styleElement.insertBefore(cssNode, childNodes[index])
  2684. } else {
  2685. styleElement.appendChild(cssNode)
  2686. }
  2687. }
  2688. }
  2689. function applyToTag (styleElement, obj) {
  2690. var css = obj.css
  2691. var media = obj.media
  2692. var sourceMap = obj.sourceMap
  2693. if (media) {
  2694. styleElement.setAttribute('media', media)
  2695. }
  2696. if (options.ssrId) {
  2697. styleElement.setAttribute(ssrIdKey, obj.id)
  2698. }
  2699. if (sourceMap) {
  2700. // https://developer.chrome.com/devtools/docs/javascript-debugging
  2701. // this makes source maps inside style tags work properly in Chrome
  2702. css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */'
  2703. // http://stackoverflow.com/a/26603875
  2704. css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */'
  2705. }
  2706. if (styleElement.styleSheet) {
  2707. styleElement.styleSheet.cssText = css
  2708. } else {
  2709. while (styleElement.firstChild) {
  2710. styleElement.removeChild(styleElement.firstChild)
  2711. }
  2712. styleElement.appendChild(document.createTextNode(css))
  2713. }
  2714. }
  2715. /***/ }),
  2716. /***/ "./node_modules/vue-style-loader/lib/listToStyles.js":
  2717. /*!***********************************************************!*\
  2718. !*** ./node_modules/vue-style-loader/lib/listToStyles.js ***!
  2719. \***********************************************************/
  2720. /*! exports provided: default */
  2721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2722. "use strict";
  2723. __webpack_require__.r(__webpack_exports__);
  2724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return listToStyles; });
  2725. /**
  2726. * Translates the list format produced by css-loader into something
  2727. * easier to manipulate.
  2728. */
  2729. function listToStyles (parentId, list) {
  2730. var styles = []
  2731. var newStyles = {}
  2732. for (var i = 0; i < list.length; i++) {
  2733. var item = list[i]
  2734. var id = item[0]
  2735. var css = item[1]
  2736. var media = item[2]
  2737. var sourceMap = item[3]
  2738. var part = {
  2739. id: parentId + ':' + i,
  2740. css: css,
  2741. media: media,
  2742. sourceMap: sourceMap
  2743. }
  2744. if (!newStyles[id]) {
  2745. styles.push(newStyles[id] = { id: id, parts: [part] })
  2746. } else {
  2747. newStyles[id].parts.push(part)
  2748. }
  2749. }
  2750. return styles
  2751. }
  2752. /***/ })
  2753. }]);
  2754. //# sourceMappingURL=vue-3.js.map