| 69 | `}tablerow({text:i}){return`<tr> |
| 70 | ${i}</tr> |
| 71 | `}tablecell(i){let e=this.parser.parseInline(i.tokens),A=i.header?"th":"td";return(i.align?`<${A} align="${i.align}">`:`<${A}>`)+e+`</${A}> |
| 72 | `}strong({tokens:i}){return`<strong>${this.parser.parseInline(i)}</strong>`}em({tokens:i}){return`<em>${this.parser.parseInline(i)}</em>`}codespan({text:i}){return`<code>${Hc(i,!0)}</code>`}br(i){return"<br>"}del({tokens:i}){return`<del>${this.parser.parseInline(i)}</del>`}link({href:i,title:e,tokens:A}){let t=this.parser.parseInline(A),n=lK(i);if(n===null)return t;i=n;let o='<a href="'+i+'"';return e&&(o+=' title="'+Hc(e)+'"'),o+=">"+t+"</a>",o}image({href:i,title:e,text:A,tokens:t}){t&&(A=this.parser.parseInline(t,this.parser.textRenderer));let n=lK(i);if(n===null)return Hc(A);i=n;let o=`<img src="${i}" alt="${Hc(A)}"`;return e&&(o+=` title="${Hc(e)}"`),o+=">",o}text(i){return"tokens"in i&&i.tokens?this.parser.parseInline(i.tokens):"escaped"in i&&i.escaped?i.text:Hc(i.text)}},mb=class{strong({text:i}){return i}em({text:i}){return i}codespan({text:i}){return i}del({text:i}){return i}html({text:i}){return i}text({text:i}){return i}link({text:i}){return""+i}image({text:i}){return""+i}br(){return""}checkbox({raw:i}){return i}},Og=class db{options;renderer;textRenderer;constructor(e){this.options=e||W1,this.options.renderer=this.options.renderer||new e2,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new mb}static parse(e,A){return new db(A).parse(e)}static parseInline(e,A){return new db(A).parseInline(e)}parse(e){let A="";for(let t=0;t<e.length;t++){let n=e[t];if(this.options.extensions?.renderers?.[n.type]){let a=n,r=this.options.extensions.renderers[a.type].call({parser:this},a);if(r!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){A+=r||"";continue}}let o=n;switch(o.type){case"space":{A+=this.renderer.space(o);break}case"hr":{A+=this.renderer.hr(o);break}case"heading":{A+=this.renderer.heading(o);break}case"code":{A+=this.renderer.code(o);break}case"table":{A+=this.renderer.table(o);break}case"blockquote":{A+=this.renderer.blockquote(o);break}case"list":{A+=this.renderer.list(o);break}case"checkbox":{A+=this.renderer.checkbox(o);break}case"html":{A+=this.renderer.html(o);break}case"def":{A+=this.renderer.def(o);break}case"paragraph":{A+=this.renderer.paragraph(o);break}case"text":{A+=this.renderer.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return A}parseInline(e,A=this.renderer){let t="";for(let n=0;n<e.length;n++){let o=e[n];if(this.options.extensions?.renderers?.[o.type]){let r=this.options.extensions.renderers[o.type].call({parser:this},o);if(r!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){t+=r||"";continue}}let a=o;switch(a.type){case"escape":{t+=A.text(a);break}case"html":{t+=A.html(a);break}case"link":{t+=A.link(a);break}case"image":{t+=A.image(a);break}case"checkbox":{t+=A.checkbox(a);break}case"strong":{t+=A.strong(a);break}case"em":{t+=A.em(a);break}case"codespan":{t+=A.codespan(a);break}case"br":{t+=A.br(a);break}case"del":{t+=A.del(a);break}case"text":{t+=A.text(a);break}default:{let r='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(r),"";throw new Error(r)}}}return t}},FQ=class{options;block;constructor(i){this.options=i||W1}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(i){return i}postprocess(i){return i}processAllTokens(i){return i}emStrongMask(i){return i}provideLexer(){return this.block?Tg.lex:Tg.lexInline}provideParser(){return this.block?Og.parse:Og.parseInline}},YiA=class{defaults=Ib();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Og;Renderer=e2;TextRenderer=mb;Lexer=Tg;Tokenizer=Ef;Hooks=FQ;constructor(...i){this.use(...i)}walkTokens(i,e){let A=[];for(let t of i)switch(A=A.concat(e.call(this,t)),t.type){case"table":{let n=t;for(let o of n.header)A=A.concat(this.walkTokens(o.tokens,e));for(let o of n.rows)for(let a of o)A=A.concat(this.walkTokens(a.tokens,e));break}case"list":{let n=t;A=A.concat(this.walkTokens(n.items,e));break}default:{let n=t;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(o=>{let a=n[o].flat(1/0);A=A.concat(this.walkTokens(a,e))}):n.tokens&&(A=A.concat(this.walkTokens(n.tokens,e)))}}return A}use(...i){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return i.forEach(A=>{let t=P({},A);if(t.async=this.defaults.async||t.async||!1,A.extensions&&(A.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let o=e.renderers[n.name];o?e.renderers[n.name]=function(...a){let r=n.renderer.apply(this,a);return r===!1&&(r=o.apply(this,a)),r}:e.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=e[n.level];o?o.unshift(n.tokenizer):e[n.level]=[n.tokenizer],n.start&&(n.level==="block"?e.startBlock?e.startBlock.push(n.start):e.startBlock=[n.start]:n.level==="inline"&&(e.startInline?e.startInline.push(n.start):e.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(e.childTokens[n.name]=n.childTokens)}),t.extensions=e),A.renderer){let n=this.defaults.renderer||new e2(this.defaults);for(let o in A.renderer){if(!(o in n))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,r=A.renderer[a],s=n[a];n[a]=(...l)=>{let g=r.apply(n,l);return g===!1&&(g=s.apply(n,l)),g||""}}t.renderer=n}if(A.tokenizer){let n=this.defaults.tokenizer||new Ef(this.defaults);for(let o in A.tokenizer){if(!(o in n))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,r=A.tokenizer[a],s=n[a];n[a]=(...l)=>{let g=r.apply(n,l);return g===!1&&(g=s.apply(n,l)),g}}t.tokenizer=n}if(A.hooks){let n=this.defaults.hooks||new FQ;for(let o in A.hooks){if(!(o in n))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,r=A.hooks[a],s=n[a];FQ.passThroughHooks.has(o)?n[a]=l=>{if(this.defaults.async&&FQ.passThroughHooksRespectAsync.has(o))return re(this,null,function*(){let C=yield r.call(n,l);return s.call(n,C)});let g=r.call(n,l);return s.call(n,g)}:n[a]=(...l)=>{if(this.defaults.async)return re(this,null,function*(){let C=yield r.apply(n,l);return C===!1&&(C=yield s.apply(n,l)),C});let g=r.apply(n,l);return g===!1&&(g=s.apply(n,l)),g}}t.hooks=n}if(A.walkTokens){let n=this.defaults.walkTokens,o=A.walkTokens;t.walkTokens=function(a){let r=[];return r.push(o.call(this,a)),n&&(r=r.concat(n.call(this,a))),r}}this.defaults=P(P({},this.defaults),t)}),this}setOptions(i){return this.defaults=P(P({},this.defaults),i),this}lexer(i,e){return Tg.lex(i,e??this.defaults)}parser(i,e){return Og.parse(i,e??this.defaults)}parseMarkdown(i){return(e,A)=>{let t=P({},A),n=P(P({},this.defaults),t),o=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&t.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=i),n.async)return re(this,null,function*(){let a=n.hooks?yield n.hooks.preprocess(e):e,r=yield(n.hooks?yield n.hooks.provideLexer():i?Tg.lex:Tg.lexInline)(a,n),s=n.hooks?yield n.hooks.processAllTokens(r):r;n.walkTokens&&(yield Promise.all(this.walkTokens(s,n.walkTokens)));let l=yield(n.hooks?yield n.hooks.provideParser():i?Og.parse:Og.parseInline)(s,n);return n.hooks?yield n.hooks.postprocess(l):l}).catch(o);try{n.hooks&&(e=n.hooks.preprocess(e));let a=(n.hooks?n.hooks.provideLexer():i?Tg.lex:Tg.lexInline)(e,n);n.hooks&&(a=n.hooks.processAllTokens(a)),n.walkTokens&&this.walkTokens(a,n.walkTokens);let r=(n.hooks?n.hooks.provideParser():i?Og.parse:Og.parseInline)(a,n);return n.hooks&&(r=n.hooks.postprocess(r)),r}catch(a){return o(a)}}}onError(i,e){return A=>{if(A.message+=` |
| 73 | Please report this to https://github.com/markedjs/marked.`,i){let t="<p>An error occurred:</p><pre>"+Hc(A.message+"",!0)+"</pre>";return e?Promise.resolve(t):t}if(e)return Promise.reject(A);throw A}}},q1=new YiA;function lo(i,e){return q1.parse(i,e)}lo.options=lo.setOptions=function(i){return q1.setOptions(i),lo.defaults=q1.defaults,CK(lo.defaults),lo};lo.getDefaults=Ib;lo.defaults=W1;lo.use=function(...i){return q1.use(...i),lo.defaults=q1.defaults,CK(lo.defaults),lo};lo.walkTokens=function(i,e){return q1.walkTokens(i,e)};lo.parseInline=q1.parseInline;lo.Parser=Og;lo.parser=Og.parse;lo.Renderer=e2;lo.TextRenderer=mb;lo.Lexer=Tg;lo.lexer=Tg.lex;lo.Tokenizer=Ef;lo.Hooks=FQ;lo.parse=lo;var QLA=lo.options,uLA=lo.setOptions,pLA=lo.use,fLA=lo.walkTokens,mLA=lo.parseInline;var wLA=Og.parse,yLA=Tg.lex;var HiA=["*"],ziA="Copy",PiA="Copied",jiA=(()=>{class i{constructor(){this._buttonClick$=new ne,this.copied=sr(this._buttonClick$.pipe(Mi(()=>Vi(oe(!0),$p(3e3).pipe(qE(!1)))),xg(),Js(1))),this.copiedText=ye(()=>this.copied()?PiA:ziA)}onCopyToClipboardClick(){this._buttonClick$.next()}static{this.\u0275fac=function(t){return new(t||i)}}static{this.\u0275cmp=vA({type:i,selectors:[["markdown-clipboard"]],decls:2,vars:3,consts:[[1,"markdown-clipboard-button",3,"click"]],template:function(t,n){t&1&&(Ln(0,"button",0),yI("click",function(){return n.onCopyToClipboardClick()}),D(1),Xn()),t&2&&(_A("copied",n.copied()),Q(),nA(n.copiedText()))},encapsulation:2,changeDetection:0})}}return i})(),ViA=new MA("CLIPBOARD_OPTIONS");var qiA=new MA("MARKED_EXTENSIONS"),WiA=new MA("MARKED_OPTIONS"),ZiA=new MA("MERMAID_OPTIONS"),XiA=new MA("SANITIZE");function $iA(i){return typeof i=="function"}var AnA="[ngx-markdown] When using the `emoji` attribute you *have to* include Emoji-Toolkit files to `angular.json` or use imports. See README for more information",enA="[ngx-markdown] When using the `katex` attribute you *have to* include KaTeX files to `angular.json` or use imports. See README for more information",tnA="[ngx-markdown] When using the `mermaid` attribute you *have to* include Mermaid files to `angular.json` or use imports. See README for more information",inA="[ngx-markdown] When using the `clipboard` attribute you *have to* include Clipboard files to `angular.json` or use imports. See README for more information",nnA="[ngx-markdown] When using the `clipboard` attribute you *have to* provide the `viewContainerRef` parameter to `MarkdownService.render()` function",onA="[ngx-markdown] When using the `src` attribute you *have to* pass the `HttpClient` as a parameter of the `forRoot` method. See README for more information";var yK=(()=>{class i{get options(){return this._options}set options(A){this._options=P(P({},this.DEFAULT_MARKED_OPTIONS),A)}get renderer(){return this.options.renderer}set renderer(A){this.options.renderer=A}constructor(){this.clipboardOptions=w(ViA,{optional:!0}),this.extensions=w(qiA,{optional:!0}),this.http=w(Mr,{optional:!0}),this.mermaidOptions=w(ZiA,{optional:!0}),this.platform=w(i3),this.sanitize=w(XiA,{optional:!0}),this.sanitizer=w(jC),this.DEFAULT_MARKED_OPTIONS={renderer:new e2},this.DEFAULT_KATEX_OPTIONS={delimiters:[{left:"$$",right:"$$",display:!0},{left:"$",right:"$",display:!1},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}]},this.DEFAULT_MERMAID_OPTIONS={startOnLoad:!1},this.DEFAULT_CLIPBOARD_OPTIONS={buttonComponent:void 0},this.DEFAULT_PARSE_OPTIONS={decodeHtml:!1,inline:!1,emoji:!1,mermaid:!1,markedOptions:void 0,disableSanitizer:!1},this.DEFAULT_RENDER_OPTIONS={clipboard:!1,clipboardOptions:void 0,katex:!1,katexOptions:void 0,mermaid:!1,mermaidOptions:void 0},this.DEFAULT_SECURITY_CONTEXT=Ng.HTML,this._options=null,this._reload$=new ne,this.reload$=this._reload$.asObservable(),this.options=w(WiA,{optional:!0})}parse(A,t=this.DEFAULT_PARSE_OPTIONS){let{decodeHtml:n,inline:o,emoji:a,mermaid:r,disableSanitizer:s}=t,l=P(P({},this.options),t.markedOptions),g=l.renderer||this.renderer||new e2;this.extensions&&(this.renderer=this.extendsRendererForExtensions(g)),r&&(this.renderer=this.extendsRendererForMermaid(g));let C=this.trimIndentation(A),d=n?this.decodeHtml(C):C,B=a?this.parseEmoji(d):d,u=this.parseMarked(B,l,o);return s?u:this.sanitizeHtml(u)}render(A,t=this.DEFAULT_RENDER_OPTIONS,n){let{clipboard:o,clipboardOptions:a,katex:r,katexOptions:s,mermaid:l,mermaidOptions:g}=t;r&&this.renderKatex(A,P(P({},this.DEFAULT_KATEX_OPTIONS),s)),l&&this.renderMermaid(A,P(P(P({},this.DEFAULT_MERMAID_OPTIONS),this.mermaidOptions),g)),o&&this.renderClipboard(A,n,P(P(P({},this.DEFAULT_CLIPBOARD_OPTIONS),this.clipboardOptions),a)),this.highlight(A)}reload(){this._reload$.next()}getSource(A){if(!this.http)throw new Error(onA);return this.http.get(A,{responseType:"text"}).pipe(Se(t=>this.handleExtension(A,t)))}highlight(A){if(!U0(this.platform)||typeof Prism>"u"||typeof Prism.highlightAllUnder>"u")return;A||(A=document);let t=A.querySelectorAll('pre code:not([class*="language-"])');Array.prototype.forEach.call(t,n=>n.classList.add("language-none")),Prism.highlightAllUnder(A)}decodeHtml(A){if(!U0(this.platform))return A;let t=document.createElement("textarea");return t.innerHTML=A,t.value}extendsRendererForExtensions(A){let t=A;return t.\u0275NgxMarkdownRendererExtendedForExtensions===!0||(this.extensions&&this.extensions.length>0&&lo.use(...this.extensions),t.\u0275NgxMarkdownRendererExtendedForExtensions=!0),A}extendsRendererForMermaid(A){let t=A;if(t.\u0275NgxMarkdownRendererExtendedForMermaid===!0)return A;let n=A.code;return A.code=o=>o.lang==="mermaid"?`<div class="mermaid">${o.text}</div>`:n(o),t.\u0275NgxMarkdownRendererExtendedForMermaid=!0,A}handleExtension(A,t){let n=A.lastIndexOf("://"),o=n>-1?A.substring(n+4):A,a=o.lastIndexOf("/"),r=a>-1?o.substring(a+1).split("?")[0]:"",s=r.lastIndexOf("."),l=s>-1?r.substring(s+1):"";return l&&l!=="md"?"```"+l+` |
| 74 | `+t+"\n```":t}parseMarked(A,t,n=!1){if(t.renderer){let o=P({},t.renderer);delete o.\u0275NgxMarkdownRendererExtendedForExtensions,delete o.\u0275NgxMarkdownRendererExtendedForMermaid,delete t.renderer,lo.use({renderer:o})}return n?lo.parseInline(A,t):lo.parse(A,t)}parseEmoji(A){if(!U0(this.platform))return A;if(typeof joypixels>"u"||typeof joypixels.shortnameToUnicode>"u")throw new Error(AnA);return joypixels.shortnameToUnicode(A)}renderKatex(A,t){if(U0(this.platform)){if(typeof katex>"u"||typeof renderMathInElement>"u")throw new Error(enA);renderMathInElement(A,t)}}renderClipboard(A,t,n){if(!U0(this.platform))return;if(typeof ClipboardJS>"u")throw new Error(inA);if(!t)throw new Error(nnA);let{buttonComponent:o,buttonTemplate:a}=n,r=A.querySelectorAll("pre");for(let s=0;s<r.length;s++){let l=r.item(s),g=document.createElement("div");g.style.position="relative",l.parentNode.insertBefore(g,l),g.appendChild(l);let C=document.createElement("div");C.classList.add("markdown-clipboard-toolbar"),C.style.position="absolute",C.style.top=".5em",C.style.right=".5em",C.style.zIndex="1",g.insertAdjacentElement("beforeend",C),g.onmouseenter=()=>C.classList.add("hover"),g.onmouseleave=()=>C.classList.remove("hover");let d;if(o){let u=t.createComponent(o);d=u.hostView,u.changeDetectorRef.markForCheck()}else if(a)d=t.createEmbeddedView(a);else{let u=t.createComponent(jiA);d=u.hostView,u.changeDetectorRef.markForCheck()}let B;d.rootNodes.forEach(u=>{C.appendChild(u),B=new ClipboardJS(u,{text:()=>l.innerText})}),d.onDestroy(()=>B.destroy())}}renderMermaid(A,t=this.DEFAULT_MERMAID_OPTIONS){if(!U0(this.platform))return;if(typeof mermaid>"u"||typeof mermaid.initialize>"u")throw new Error(tnA);let n=A.querySelectorAll(".mermaid");n.length!==0&&(mermaid.initialize(t),mermaid.run({nodes:n}))}trimIndentation(A){if(!A)return"";let t;return A.split(` |
| 75 | `).map(n=>{let o=t;return n.length>0&&(o=isNaN(o)?n.search(/\S|$/):Math.min(n.search(/\S|$/),o)),isNaN(t)&&(t=o),o?n.substring(o):n}).join(` |