crossnote 0.8.20 → 0.8.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/cjs/index.cjs CHANGED
@@ -574,7 +574,8 @@ sidebarTOCBtn.addEventListener('click', function(event) {
574
574
  `:(l=!l,r+=p+`
575
575
  `);o+=1;continue}p.match(/^\[toc\]/i)&&!l&&(p="[CROSSNOTETOC]"),r+=p+`
576
576
  `,o+=1}let c=this.notebook.config.pandocPath;return await new Promise((p,u)=>{var f;try{(f=(0,er.execFile)(c,n,{cwd:this.fileDirectoryPath,maxBuffer:1/0},(g,m,b)=>g?u(g):p(b?'<pre class="language-text"><code>'+(0,le.escape)(b)+"</code></pre>"+m:m)).stdin)==null||f.end(r,"utf-8")}catch(S){let g=S.toString();return g.indexOf("Error: write EPIPE")>=0&&(g=`"pandoc" is required to be installed.
577
- Check "http://pandoc.org/installing.html" website.`),u(g)}})}async parseMD(t,n){t||(t=await this.fs.readFile(this.filePath)),this.vscodePreviewPanel=n.vscodePreviewPanel,this.notebook.config.parserConfig.onWillParseMarkdown&&(t=await this.notebook.config.parserConfig.onWillParseMarkdown(t)),this.notebook.config.parserConfig.onWillTransformMarkdown&&(t=await this.notebook.config.parserConfig.onWillTransformMarkdown(t));let a,r,s,o,l,d;({outputString:a,slideConfigs:r,tocBracketEnabled:s,JSAndCssFiles:o,headings:l,frontMatterString:d}=await pe(t,{fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,projectDirectoryPath:this.projectDirectoryPath.fsPath,forPreview:n.isForPreview,embeddingFilesInMarkdownDirectly:this.notebook.config.usePandocParser,protocolsWhiteListRegExp:this.protocolsWhiteListRegExp,useRelativeFilePath:n.useRelativeFilePath,filesCache:this.filesCache,notebook:this.notebook})),this.notebook.config.parserConfig.onDidTransformMarkdown&&(a=await this.notebook.config.parserConfig.onDidTransformMarkdown(a));let c=this.processFrontMatter(d,n.hideFrontMatter),p=c.table,u=c.data||{};typeof u!="object"&&(u={}),a=c.content+a;let f;if(this.notebook.config.usePandocParser)try{let E=u.pandoc_args||[];E instanceof Array||(E=[]),E.find(w=>w.includes("pandoc-citeproc")||w.includes("--defaults"))===void 0&&(u.bibliography||u.references)&&E.push("--citeproc"),E=this.notebook.config.pandocArguments.concat(E),f=await this.pandocRender(a,E)}catch(E){f=`<pre class="language-text"><code>${(0,le.escape)(E.toString())}</code></pre>`}else n.isForPreview?f=this.notebook.md.render(a):f=this.notebook.initMarkdownIt({...this.notebook.md.options,sourceMap:!1}).render(a);let S=u.toc||{},g=S.depth_from||1,m=S.depth_to||6,b=S.ordered;this.tocHTML=ln(l,this.notebook.md.render.bind(this.notebook.md),{ordered:b,depthFrom:g,depthTo:m,tab:" "}),this.headings=l,s&&(f=f.replace(/^\s*<p[^>]+>\[CROSSNOTETOC\]<\/p>\s*/gm,E=>{let T=E.match(/data-source-line="(\d+)"/),w=T?T[1]:"";return w?`<div data-source-line="${w}">${this.tocHTML}</div>`:this.tocHTML}));let h=ce.load(f);return await Bt(h,this.notebook.config.mathRenderingOption,this.notebook.config.mathBlockDelimiters,this.notebook.config.katexConfig),await Ut({$:h,graphsCache:this.graphsCache,fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,imageDirectoryPath:ie(this.resolveFilePath(this.notebook.config.imageFolderPath,!1)),plantumlServer:this.notebook.config.plantumlServer,plantumlJarPath:this.notebook.config.plantumlJarPath,kirokiServer:this.notebook.config.krokiServer}),await Mt(h,this.codeChunksData,n,this.generateRunOptions()),await xt(h),await $t(h,n,this.resolveFilePath.bind(this)),this.notebook.config.enableExtendedTableSyntax&&await Dt(h),f=p+h("head").html()+h("body").html(),r.length&&(f=this.parseSlides(f,r,n.useRelativeFilePath),u&&(u.isPresentationMode=!0)),this.notebook.config.parserConfig.onDidParseMarkdown&&(f=await this.notebook.config.parserConfig.onDidParseMarkdown(f)),n.runAllCodeChunks?(await Ft(this.codeChunksData,this.generateRunOptions()),n.runAllCodeChunks=!1,this.parseMD(t,n)):(n.isForPreview&&(this.isPreviewInPresentationMode=!!r.length),n.triggeredBySave&&u.export_on_save&&this.exportOnSave(u.export_on_save),this.notebook.config.enableScriptExecution||(o=[]),{html:f,markdown:t,tocHTML:this.tocHTML,yamlConfig:u,JSAndCssFiles:o})}runCodeChunks(){return Ft(this.codeChunksData,this.generateRunOptions())}runCodeChunk(t){return lt(t,this.codeChunksData,this.generateRunOptions())}async modifySource(t,n,a){let r=()=>(t.running=!1,n),s=await this.notebook.fs.readFile(a);if(!s)return r();let o=async(u,f)=>{let S=f.length,g=0;for(let m=u+1;m<u+6&&m<S;m++)if(f[m].startsWith("<!-- code_chunk_output -->")){g=m;break}if(g){let m=g+1;for(;m<S&&!f[m].startsWith("<!-- /code_chunk_output -->");)m+=1;let b="";for(let E=g+2;E<m-1;E++)b+=f[E]+`
577
+ Check "http://pandoc.org/installing.html" website.`),u(g)}})}async parseMD(t,n){t||(t=await this.fs.readFile(this.filePath)),this.vscodePreviewPanel=n.vscodePreviewPanel,this.notebook.config.parserConfig.onWillParseMarkdown&&(t=await this.notebook.config.parserConfig.onWillParseMarkdown(t)),this.notebook.config.parserConfig.onWillTransformMarkdown&&(t=await this.notebook.config.parserConfig.onWillTransformMarkdown(t));let a,r,s,o,l,d;({outputString:a,slideConfigs:r,tocBracketEnabled:s,JSAndCssFiles:o,headings:l,frontMatterString:d}=await pe(t,{fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,projectDirectoryPath:this.projectDirectoryPath.fsPath,forPreview:n.isForPreview,embeddingFilesInMarkdownDirectly:this.notebook.config.usePandocParser,protocolsWhiteListRegExp:this.protocolsWhiteListRegExp,useRelativeFilePath:n.useRelativeFilePath,filesCache:this.filesCache,notebook:this.notebook})),this.notebook.config.parserConfig.onDidTransformMarkdown&&(a=await this.notebook.config.parserConfig.onDidTransformMarkdown(a));let c=this.processFrontMatter(d,n.hideFrontMatter),p=c.table,u=c.data||{};typeof u!="object"&&(u={}),a=c.content+a;let f;if(this.notebook.config.usePandocParser)try{let E=u.pandoc_args||[];E instanceof Array||(E=[]),E.find(w=>w.includes("pandoc-citeproc")||w.includes("--defaults"))===void 0&&(u.bibliography||u.references)&&E.push("--citeproc"),E=this.notebook.config.pandocArguments.concat(E),f=await this.pandocRender(a,E)}catch(E){f=`<pre class="language-text"><code>${(0,le.escape)(E.toString())}</code></pre>`}else n.isForPreview?f=this.notebook.md.render(a):f=this.notebook.initMarkdownIt({...this.notebook.md.options,sourceMap:!1}).render(a);let S=u.toc||{},g=S.depth_from||1,m=S.depth_to||6,b=S.ordered;this.tocHTML=ln(l,this.notebook.md.render.bind(this.notebook.md),{ordered:b,depthFrom:g,depthTo:m,tab:" "}),this.headings=l,s&&(f=f.replace(/^\s*<p[^>]+>\[CROSSNOTETOC\]<\/p>\s*/gm,E=>{let T=E.match(/data-source-line="(\d+)"/),w=T?T[1]:"";return w?`<div data-source-line="${w}">${this.tocHTML}</div>`:this.tocHTML}));let h=ce.load(f);return await Bt(h,this.notebook.config.mathRenderingOption,this.notebook.config.mathBlockDelimiters,this.notebook.config.katexConfig),await Ut({$:h,graphsCache:this.graphsCache,fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,imageDirectoryPath:ie(this.resolveFilePath(this.notebook.config.imageFolderPath,!1)),plantumlServer:this.notebook.config.plantumlServer,plantumlJarPath:this.notebook.config.plantumlJarPath,kirokiServer:this.notebook.config.krokiServer}),await Mt(h,this.codeChunksData,n,this.generateRunOptions()),await xt(h),await $t(h,n,this.resolveFilePath.bind(this)),this.notebook.config.enableExtendedTableSyntax&&await Dt(h),f=p+`
578
+ `+h("head").html()+h("body").html(),r.length&&(f=this.parseSlides(f,r,n.useRelativeFilePath),u&&(u.isPresentationMode=!0)),this.notebook.config.parserConfig.onDidParseMarkdown&&(f=await this.notebook.config.parserConfig.onDidParseMarkdown(f)),n.runAllCodeChunks?(await Ft(this.codeChunksData,this.generateRunOptions()),n.runAllCodeChunks=!1,this.parseMD(t,n)):(n.isForPreview&&(this.isPreviewInPresentationMode=!!r.length),n.triggeredBySave&&u.export_on_save&&this.exportOnSave(u.export_on_save),this.notebook.config.enableScriptExecution||(o=[]),{html:f,markdown:t,tocHTML:this.tocHTML,yamlConfig:u,JSAndCssFiles:o})}runCodeChunks(){return Ft(this.codeChunksData,this.generateRunOptions())}runCodeChunk(t){return lt(t,this.codeChunksData,this.generateRunOptions())}async modifySource(t,n,a){let r=()=>(t.running=!1,n),s=await this.notebook.fs.readFile(a);if(!s)return r();let o=async(u,f)=>{let S=f.length,g=0;for(let m=u+1;m<u+6&&m<S;m++)if(f[m].startsWith("<!-- code_chunk_output -->")){g=m;break}if(g){let m=g+1;for(;m<S&&!f[m].startsWith("<!-- /code_chunk_output -->");)m+=1;let b="";for(let E=g+2;E<m-1;E++)b+=f[E]+`
578
579
  `;if(b===n+`
579
580
  `)return"";let h=[...f.slice(0,g+2),n,...f.slice(m-1)];return await this.notebook.fs.writeFile(a,h.join(`
580
581
  `)),""}else{let m=[...f.slice(0,u+1),`
package/out/esm/index.mjs CHANGED
@@ -574,7 +574,8 @@ sidebarTOCBtn.addEventListener('click', function(event) {
574
574
  `:(l=!l,r+=p+`
575
575
  `);o+=1;continue}p.match(/^\[toc\]/i)&&!l&&(p="[CROSSNOTETOC]"),r+=p+`
576
576
  `,o+=1}let c=this.notebook.config.pandocPath;return await new Promise((p,g)=>{try{ri(c,n,{cwd:this.fileDirectoryPath,maxBuffer:1/0},(S,m,u)=>S?g(S):p(u?'<pre class="language-text"><code>'+le(u)+"</code></pre>"+m:m)).stdin?.end(r,"utf-8")}catch(f){let S=f.toString();return S.indexOf("Error: write EPIPE")>=0&&(S=`"pandoc" is required to be installed.
577
- Check "http://pandoc.org/installing.html" website.`),g(S)}})}async parseMD(t,n){t||(t=await this.fs.readFile(this.filePath)),this.vscodePreviewPanel=n.vscodePreviewPanel,this.notebook.config.parserConfig.onWillParseMarkdown&&(t=await this.notebook.config.parserConfig.onWillParseMarkdown(t)),this.notebook.config.parserConfig.onWillTransformMarkdown&&(t=await this.notebook.config.parserConfig.onWillTransformMarkdown(t));let a,r,s,o,l,d;({outputString:a,slideConfigs:r,tocBracketEnabled:s,JSAndCssFiles:o,headings:l,frontMatterString:d}=await ge(t,{fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,projectDirectoryPath:this.projectDirectoryPath.fsPath,forPreview:n.isForPreview,embeddingFilesInMarkdownDirectly:this.notebook.config.usePandocParser,protocolsWhiteListRegExp:this.protocolsWhiteListRegExp,useRelativeFilePath:n.useRelativeFilePath,filesCache:this.filesCache,notebook:this.notebook})),this.notebook.config.parserConfig.onDidTransformMarkdown&&(a=await this.notebook.config.parserConfig.onDidTransformMarkdown(a));let c=this.processFrontMatter(d,n.hideFrontMatter),p=c.table,g=c.data||{};typeof g!="object"&&(g={}),a=c.content+a;let f;if(this.notebook.config.usePandocParser)try{let h=g.pandoc_args||[];h instanceof Array||(h=[]),h.find(w=>w.includes("pandoc-citeproc")||w.includes("--defaults"))===void 0&&(g.bibliography||g.references)&&h.push("--citeproc"),h=this.notebook.config.pandocArguments.concat(h),f=await this.pandocRender(a,h)}catch(h){f=`<pre class="language-text"><code>${le(h.toString())}</code></pre>`}else n.isForPreview?f=this.notebook.md.render(a):f=this.notebook.initMarkdownIt({...this.notebook.md.options,sourceMap:!1}).render(a);let S=g.toc||{},m=S.depth_from||1,u=S.depth_to||6,b=S.ordered;this.tocHTML=Ht(l,this.notebook.md.render.bind(this.notebook.md),{ordered:b,depthFrom:m,depthTo:u,tab:" "}),this.headings=l,s&&(f=f.replace(/^\s*<p[^>]+>\[CROSSNOTETOC\]<\/p>\s*/gm,h=>{let A=h.match(/data-source-line="(\d+)"/),w=A?A[1]:"";return w?`<div data-source-line="${w}">${this.tocHTML}</div>`:this.tocHTML}));let E=de.load(f);return await Rt(E,this.notebook.config.mathRenderingOption,this.notebook.config.mathBlockDelimiters,this.notebook.config.katexConfig),await It({$:E,graphsCache:this.graphsCache,fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,imageDirectoryPath:re(this.resolveFilePath(this.notebook.config.imageFolderPath,!1)),plantumlServer:this.notebook.config.plantumlServer,plantumlJarPath:this.notebook.config.plantumlJarPath,kirokiServer:this.notebook.config.krokiServer}),await Tt(E,this.codeChunksData,n,this.generateRunOptions()),await yt(E),await vt(E,n,this.resolveFilePath.bind(this)),this.notebook.config.enableExtendedTableSyntax&&await wt(E),f=p+E("head").html()+E("body").html(),r.length&&(f=this.parseSlides(f,r,n.useRelativeFilePath),g&&(g.isPresentationMode=!0)),this.notebook.config.parserConfig.onDidParseMarkdown&&(f=await this.notebook.config.parserConfig.onDidParseMarkdown(f)),n.runAllCodeChunks?(await At(this.codeChunksData,this.generateRunOptions()),n.runAllCodeChunks=!1,this.parseMD(t,n)):(n.isForPreview&&(this.isPreviewInPresentationMode=!!r.length),n.triggeredBySave&&g.export_on_save&&this.exportOnSave(g.export_on_save),this.notebook.config.enableScriptExecution||(o=[]),{html:f,markdown:t,tocHTML:this.tocHTML,yamlConfig:g,JSAndCssFiles:o})}runCodeChunks(){return At(this.codeChunksData,this.generateRunOptions())}runCodeChunk(t){return Xe(t,this.codeChunksData,this.generateRunOptions())}async modifySource(t,n,a){let r=()=>(t.running=!1,n),s=await this.notebook.fs.readFile(a);if(!s)return r();let o=async(g,f)=>{let S=f.length,m=0;for(let u=g+1;u<g+6&&u<S;u++)if(f[u].startsWith("<!-- code_chunk_output -->")){m=u;break}if(m){let u=m+1;for(;u<S&&!f[u].startsWith("<!-- /code_chunk_output -->");)u+=1;let b="";for(let h=m+2;h<u-1;h++)b+=f[h]+`
577
+ Check "http://pandoc.org/installing.html" website.`),g(S)}})}async parseMD(t,n){t||(t=await this.fs.readFile(this.filePath)),this.vscodePreviewPanel=n.vscodePreviewPanel,this.notebook.config.parserConfig.onWillParseMarkdown&&(t=await this.notebook.config.parserConfig.onWillParseMarkdown(t)),this.notebook.config.parserConfig.onWillTransformMarkdown&&(t=await this.notebook.config.parserConfig.onWillTransformMarkdown(t));let a,r,s,o,l,d;({outputString:a,slideConfigs:r,tocBracketEnabled:s,JSAndCssFiles:o,headings:l,frontMatterString:d}=await ge(t,{fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,projectDirectoryPath:this.projectDirectoryPath.fsPath,forPreview:n.isForPreview,embeddingFilesInMarkdownDirectly:this.notebook.config.usePandocParser,protocolsWhiteListRegExp:this.protocolsWhiteListRegExp,useRelativeFilePath:n.useRelativeFilePath,filesCache:this.filesCache,notebook:this.notebook})),this.notebook.config.parserConfig.onDidTransformMarkdown&&(a=await this.notebook.config.parserConfig.onDidTransformMarkdown(a));let c=this.processFrontMatter(d,n.hideFrontMatter),p=c.table,g=c.data||{};typeof g!="object"&&(g={}),a=c.content+a;let f;if(this.notebook.config.usePandocParser)try{let h=g.pandoc_args||[];h instanceof Array||(h=[]),h.find(w=>w.includes("pandoc-citeproc")||w.includes("--defaults"))===void 0&&(g.bibliography||g.references)&&h.push("--citeproc"),h=this.notebook.config.pandocArguments.concat(h),f=await this.pandocRender(a,h)}catch(h){f=`<pre class="language-text"><code>${le(h.toString())}</code></pre>`}else n.isForPreview?f=this.notebook.md.render(a):f=this.notebook.initMarkdownIt({...this.notebook.md.options,sourceMap:!1}).render(a);let S=g.toc||{},m=S.depth_from||1,u=S.depth_to||6,b=S.ordered;this.tocHTML=Ht(l,this.notebook.md.render.bind(this.notebook.md),{ordered:b,depthFrom:m,depthTo:u,tab:" "}),this.headings=l,s&&(f=f.replace(/^\s*<p[^>]+>\[CROSSNOTETOC\]<\/p>\s*/gm,h=>{let A=h.match(/data-source-line="(\d+)"/),w=A?A[1]:"";return w?`<div data-source-line="${w}">${this.tocHTML}</div>`:this.tocHTML}));let E=de.load(f);return await Rt(E,this.notebook.config.mathRenderingOption,this.notebook.config.mathBlockDelimiters,this.notebook.config.katexConfig),await It({$:E,graphsCache:this.graphsCache,fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,imageDirectoryPath:re(this.resolveFilePath(this.notebook.config.imageFolderPath,!1)),plantumlServer:this.notebook.config.plantumlServer,plantumlJarPath:this.notebook.config.plantumlJarPath,kirokiServer:this.notebook.config.krokiServer}),await Tt(E,this.codeChunksData,n,this.generateRunOptions()),await yt(E),await vt(E,n,this.resolveFilePath.bind(this)),this.notebook.config.enableExtendedTableSyntax&&await wt(E),f=p+`
578
+ `+E("head").html()+E("body").html(),r.length&&(f=this.parseSlides(f,r,n.useRelativeFilePath),g&&(g.isPresentationMode=!0)),this.notebook.config.parserConfig.onDidParseMarkdown&&(f=await this.notebook.config.parserConfig.onDidParseMarkdown(f)),n.runAllCodeChunks?(await At(this.codeChunksData,this.generateRunOptions()),n.runAllCodeChunks=!1,this.parseMD(t,n)):(n.isForPreview&&(this.isPreviewInPresentationMode=!!r.length),n.triggeredBySave&&g.export_on_save&&this.exportOnSave(g.export_on_save),this.notebook.config.enableScriptExecution||(o=[]),{html:f,markdown:t,tocHTML:this.tocHTML,yamlConfig:g,JSAndCssFiles:o})}runCodeChunks(){return At(this.codeChunksData,this.generateRunOptions())}runCodeChunk(t){return Xe(t,this.codeChunksData,this.generateRunOptions())}async modifySource(t,n,a){let r=()=>(t.running=!1,n),s=await this.notebook.fs.readFile(a);if(!s)return r();let o=async(g,f)=>{let S=f.length,m=0;for(let u=g+1;u<g+6&&u<S;u++)if(f[u].startsWith("<!-- code_chunk_output -->")){m=u;break}if(m){let u=m+1;for(;u<S&&!f[u].startsWith("<!-- /code_chunk_output -->");)u+=1;let b="";for(let h=m+2;h<u-1;h++)b+=f[h]+`
578
579
  `;if(b===n+`
579
580
  `)return"";let E=[...f.slice(0,m+2),n,...f.slice(u-1)];return await this.notebook.fs.writeFile(a,E.join(`
580
581
  `)),""}else{let u=[...f.slice(0,g+1),`