`}tablecell(r){let e=this.parser.parseInline(r.tokens),n=r.header?"th":"td";return(r.align?`<${n} align="${r.align}">`:`<${n}>`)+e+`${n}>
`}strong({tokens:r}){return`${this.parser.parseInline(r)}`}em({tokens:r}){return`${this.parser.parseInline(r)}`}codespan({text:r}){return`${y(r,!0)}`}br(r){return" "}del({tokens:r}){return`${this.parser.parseInline(r)}`}link({href:r,title:e,tokens:n}){let s=this.parser.parseInline(n),t=pe(r);if(t===null)return s;r=t;let l='"+s+"",l}image({href:r,title:e,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let t=pe(r);if(t===null)return y(n);r=t;let l=`",l}text(r){return"tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:y(r.text)}},ee=class{strong({text:r}){return r}em({text:r}){return r}codespan({text:r}){return r}del({text:r}){return r}html({text:r}){return r}text({text:r}){return r}link({text:r}){return""+r}image({text:r}){return""+r}br(){return""}checkbox({raw:r}){return r}},w=class N{options;renderer;textRenderer;constructor(e){this.options=e||T,this.options.renderer=this.options.renderer||new M,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ee}static parse(e,n){return new N(n).parse(e)}static parseInline(e,n){return new N(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let s=0;s{let i=t[l].flat(1/0);n=n.concat(this.walkTokens(i,e))}):t.tokens&&(n=n.concat(this.walkTokens(t.tokens,e)))}}return n}use(...r){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(t=>{if(!t.name)throw new Error("extension name required");if("renderer"in t){let l=e.renderers[t.name];l?e.renderers[t.name]=function(...i){let o=t.renderer.apply(this,i);return o===!1&&(o=l.apply(this,i)),o}:e.renderers[t.name]=t.renderer}if("tokenizer"in t){if(!t.level||t.level!=="block"&&t.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let l=e[t.level];l?l.unshift(t.tokenizer):e[t.level]=[t.tokenizer],t.start&&(t.level==="block"?e.startBlock?e.startBlock.push(t.start):e.startBlock=[t.start]:t.level==="inline"&&(e.startInline?e.startInline.push(t.start):e.startInline=[t.start]))}"childTokens"in t&&t.childTokens&&(e.childTokens[t.name]=t.childTokens)}),s.extensions=e),n.renderer){let t=this.defaults.renderer||new M(this.defaults);for(let l in n.renderer){if(!(l in t))throw new Error(`renderer '${l}' does not exist`);if(["options","parser"].includes(l))continue;let i=l,o=n.renderer[i],a=t[i];t[i]=(...h)=>{let c=o.apply(t,h);return c===!1&&(c=a.apply(t,h)),c||""}}s.renderer=t}if(n.tokenizer){let t=this.defaults.tokenizer||new C(this.defaults);for(let l in n.tokenizer){if(!(l in t))throw new Error(`tokenizer '${l}' does not exist`);if(["options","rules","lexer"].includes(l))continue;let i=l,o=n.tokenizer[i],a=t[i];t[i]=(...h)=>{let c=o.apply(t,h);return c===!1&&(c=a.apply(t,h)),c}}s.tokenizer=t}if(n.hooks){let t=this.defaults.hooks||new _;for(let l in n.hooks){if(!(l in t))throw new Error(`hook '${l}' does not exist`);if(["options","block"].includes(l))continue;let i=l,o=n.hooks[i],a=t[i];_.passThroughHooks.has(l)?t[i]=h=>{if(this.defaults.async&&_.passThroughHooksRespectAsync.has(l))return(async()=>{let g=await o.call(t,h);return a.call(t,g)})();let c=o.call(t,h);return a.call(t,c)}:t[i]=(...h)=>{if(this.defaults.async)return(async()=>{let g=await o.apply(t,h);return g===!1&&(g=await a.apply(t,h)),g})();let c=o.apply(t,h);return c===!1&&(c=a.apply(t,h)),c}}s.hooks=t}if(n.walkTokens){let t=this.defaults.walkTokens,l=n.walkTokens;s.walkTokens=function(i){let o=[];return o.push(l.call(this,i)),t&&(o=o.concat(t.call(this,i))),o}}this.defaults={...this.defaults,...s}}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,e){return m.lex(r,e??this.defaults)}parser(r,e){return w.parse(r,e??this.defaults)}parseMarkdown(r){return(e,n)=>{let s={...n},t={...this.defaults,...s},l=this.onError(!!t.silent,!!t.async);if(this.defaults.async===!0&&s.async===!1)return l(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 l(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(t.hooks&&(t.hooks.options=t,t.hooks.block=r),t.async)return(async()=>{let i=t.hooks?await t.hooks.preprocess(e):e,o=await(t.hooks?await t.hooks.provideLexer(r):r?m.lex:m.lexInline)(i,t),a=t.hooks?await t.hooks.processAllTokens(o):o;t.walkTokens&&await Promise.all(this.walkTokens(a,t.walkTokens));let h=await(t.hooks?await t.hooks.provideParser(r):r?w.parse:w.parseInline)(a,t);return t.hooks?await t.hooks.postprocess(h):h})().catch(l);try{t.hooks&&(e=t.hooks.preprocess(e));let i=(t.hooks?t.hooks.provideLexer(r):r?m.lex:m.lexInline)(e,t);t.hooks&&(i=t.hooks.processAllTokens(i)),t.walkTokens&&this.walkTokens(i,t.walkTokens);let o=(t.hooks?t.hooks.provideParser(r):r?w.parse:w.parseInline)(i,t);return t.hooks&&(o=t.hooks.postprocess(o)),o}catch(i){return l(i)}}}onError(r,e){return n=>{if(n.message+=`
Please report this to https://github.com/markedjs/marked.`,r){let s="
An error occurred:
"+y(n.message+"",!0)+"
";return e?Promise.resolve(s):s}if(e)return Promise.reject(n);throw n}}},R=new te;function d(r,e){return R.parse(r,e)}d.options=d.setOptions=function(r){return R.setOptions(r),d.defaults=R.defaults,de(d.defaults),d};d.getDefaults=W;d.defaults=T;d.use=function(...r){return R.use(...r),d.defaults=R.defaults,de(d.defaults),d};d.walkTokens=function(r,e){return R.walkTokens(r,e)};d.parseInline=R.parseInline;d.Parser=w;d.parser=w.parse;d.Renderer=M;d.TextRenderer=ee;d.Lexer=m;d.lexer=m.lex;d.Tokenizer=C;d.Hooks=_;d.parse=d;var It=d.options,Lt=d.setOptions,Et=d.use,Bt=d.walkTokens,qt=d.parseInline;var Ct=w.parse,Mt=m.lex;var re="/x/sites/gh-proxy/src/sanitizer.js",$t=["Google Chrome","Microsoft Edge","Firefox","Safari"];function Rt(){let r=process.env.BROWSER;if(r)return r;for(let e of $t)if(se(`/Applications/${e}.app`))return e;return"Safari"}function Tt(r){return String(r).replace(/[&<>"']/g,e=>{switch(e){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case"'":return"'";default:return e}})}function zt(r,e){return`
${Tt(r)}
${e}
`}function At(r){let e={preprocess(n){return n.replace(/^\uFEFF/,"")}};return r&&(e.postprocess=function(n){return r.process(n)}),new te({gfm:!0,breaks:!1,pedantic:!1,silent:!1,async:!1,hooks:e})}var Ae=se(re);function F(r){let e=Ae?` -x, --xss Enable XSS filtering (matches gh-proxy sanitization)
`:"";(r===0?process.stdout:process.stderr).write(`Usage: render-md ${Ae?"[-x|--xss] ":""}[-o FILE|-] [file]
`+e+` -o FILE Write HTML to FILE instead of opening in browser
-o - Write HTML to stdout
file Markdown file to render (default: stdin)
`),process.exit(r)}var _e=!1,L=null,b=null,H=process.argv.slice(2);for(let r=0;r=H.length&&F(1),L=H[r]):e==="-h"||e==="--help"?F(0):e.startsWith("-")?(process.stderr.write(`render-md: unknown option: ${e}
`),F(1)):b=e}var Ie=null;if(_e)try{let{createHtmlSanitizer:r}=await import(re);Ie=r()}catch{process.stderr.write(`render-md: -x/--xss requires gh-proxy XSS config at ${re}
Install: ensure /x/sites/gh-proxy exists with npm dependencies installed
`),process.exit(1)}!b&&process.stdin.isTTY&&F(0);var ne;b?(se(b)||(process.stderr.write(`render-md: ${b}: No such file
`),process.exit(1)),ne=Re(b,"utf-8")):ne=Re(0,"utf-8");var vt=At(Ie),Pt=b?yt(b).replace(/\.md$/i,""):"Untitled",_t=vt.parse(ne),E=zt(Pt,_t);if(b){let r=ve(Pe(b));E=E.replace("",`
`)}if(L==="-")process.stdout.write(E);else if(L)Te(L,E,"utf-8"),process.stderr.write(`Wrote ${L}
`);else{let r;if(b){let n=Pe(process.env.PWD||process.cwd(),b);r=ze("/tmp","md",n+".html")}else r=ze("/tmp","md",`render-md-${Date.now()}.html`);wt(ve(r),{recursive:!0}),Te(r,E,"utf-8");let e=Rt();try{St("open",["-a",e,r],{stdio:"ignore"})}catch{process.stderr.write(`render-md: failed to open browser "${e}"
`),process.stderr.write(`Output written to ${r}
`),process.exit(1)}}