crossnote 0.8.22 → 0.8.23

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
@@ -560,7 +560,7 @@ sidebarTOCBtn.addEventListener('click', function(event) {
560
560
  ---`);if(o>0){let l=a.slice(0,o+4);r=this.processFrontMatter(l,!1).data}}let s=await ia(a,{fileDirectoryPath:this.fileDirectoryPath,projectDirectoryPath:this.projectDirectoryPath.fsPath,sourceFilePath:this.filePath,protocolsWhiteListRegExp:this.protocolsWhiteListRegExp,filesCache:this.filesCache,codeChunksData:this.codeChunksData,graphsCache:this.graphsCache,notebook:this.notebook},r);return n&&me(s),s}async markdownExport({runAllCodeChunks:t=!1}){let n=await this.fs.readFile(this.filePath);t&&await this.parseMD(n,{useRelativeFilePath:!0,isForPreview:!1,hideFrontMatter:!1,runAllCodeChunks:t});let a={};if(n.startsWith("---")){let s=n.indexOf(`
561
561
  ---`);if(s>0){let o=n.slice(0,s+4);n=n.replace(o,""),a=this.processFrontMatter(o,!1).data}}let r={};return a.markdown&&(r={...a.markdown}),r.image_dir||(r.image_dir=this.notebook.config.imageFolderPath),r.path||(this.filePath.match(/\.src\./)?r.path=this.filePath.replace(/\.src\./,"."):r.path=this.filePath.replace(new RegExp(v.extname(this.filePath)),"_"+v.extname(this.filePath)),r.path=v.basename(r.path)),(r.ignore_from_front_matter||!("ignore_from_front_matter"in r))&&delete a.markdown,a.export_on_save&&delete a.export_on_save,Object.keys(a).length&&(n=`---
562
562
  `+nr.stringify(a)+`---
563
- `+n),await ea(n,{projectDirectoryPath:this.projectDirectoryPath.fsPath,fileDirectoryPath:this.fileDirectoryPath,protocolsWhiteListRegExp:this.protocolsWhiteListRegExp,filesCache:this.filesCache,codeChunksData:this.codeChunksData,graphsCache:this.graphsCache,notebook:this.notebook},r)}exportOnSave(t){let n=ft();for(let a in t)if(a==="html")this.htmlExport({});else if(!n&&a==="prince")this.princeExport({openFileAfterGeneration:!1});else if(!n&&a==="puppeteer"||a==="chrome"){let r=t[a],s=this.chromeExport;s=s.bind(this),r===!0?s({fileType:"pdf",openFileAfterGeneration:!1}):typeof r=="string"?s({fileType:r,openFileAfterGeneration:!1}):r instanceof Array&&r.forEach(o=>{s({fileType:o,openFileAfterGeneration:!1})})}else if(!n&&a==="pandoc")this.pandocExport({openFileAfterGeneration:!1});else if(!n&&a==="ebook"){let r=t[a];r===!0?this.eBookExport({fileType:"epub"}):typeof r=="string"?this.eBookExport({fileType:r}):r instanceof Array&&r.forEach(s=>{this.eBookExport({fileType:s})})}}resolveFilePath(t="",n,a=""){return t.match(this.protocolsWhiteListRegExp)||t.startsWith("data:image/")||t[0]==="#"?t:t[0]==="/"?n?v.relative(a||this.fileDirectoryPath,v.resolve(this.projectDirectoryPath.fsPath,"."+t)):Y(v.resolve(this.projectDirectoryPath.fsPath,"."+t),this.vscodePreviewPanel):n?t:Y(v.resolve(a||this.fileDirectoryPath,t),this.vscodePreviewPanel)}async resolvePathsInHeader(t){let n=ce.load(t),a=n("script");for(let r=0;r<a.length;r++){let s=n(a[r]),o=s.attr("src");if(o&&!o.match(/^https?:\/\//)&&o.startsWith("/")){let l=v.join(this.notebook.notebookPath.fsPath,"."+o);try{let d=await this.fs.readFile(l);s.html(d),s.removeAttr("src")}catch(d){console.error(d)}}}return n.html()}clearCaches(){this.filesCache={},this.codeChunksData={},this.graphsCache={}}frontMatterToTable(t){if(t instanceof Array){let n="<tbody><tr>";return t.forEach(a=>n+=`<td>${this.frontMatterToTable(a)}</td>`),n+="</tr></tbody>",`<table>${n}</table>`}else if(typeof t=="object"){let n="<thead><tr>",a="<tbody><tr>";for(let r in t)t.hasOwnProperty(r)&&(n+=`<th>${(0,le.escape)(r)}</th>`,a+=`<td>${this.frontMatterToTable(t[r])}</td>`);return n+="</tr></thead>",a+="</tr></tbody>",`<table>${n}${a}</table>`}else return(0,le.escape)(t)}processFrontMatter(t,n=!1){if(t){let a=De(t);if(this.notebook.config.usePandocParser)return{content:t,table:"",data:a||{}};if(n||(this.notebook.config.frontMatterRenderingOption??"")[0]==="n")return{content:"",table:"",data:a};if((this.notebook.config.frontMatterRenderingOption??"")[0]==="t"){let r;return typeof a=="object"?r=this.frontMatterToTable(a):r='<pre class="language-text"><code>Failed to parse YAML.</code></pre>',{content:"",table:r,data:a}}else return{content:t.replace(/^---/,"```yaml").replace(/\n---$/,"\n```\n"),table:"",data:a}}else return{content:t,table:"",data:{}}}parseSlides(t,n,a){let r=t.split(/^\s*<p[^>]+><span>\[CROSSNOTESLIDE\]<\/span><\/p>\s*/gm),s=r[0];r=r.slice(1);let o="",l=0,d=-1,c=0;for(;l<r.length;){let u=r[l],f=n[l];"data-background-image"in f&&(f["data-background-image"]=this.resolveFilePath(f["data-background-image"],a)),"data-background-video"in f&&(f["data-background-video"]=this.resolveFilePath(f["data-background-video"],a)),"data-background-iframe"in f&&(f["data-background-iframe"]=this.resolveFilePath(f["data-background-iframe"],a));let S=K(f,!1),g=f.class||"",m=f.id?`id="${f.id}"`:"";f.vertical?c+=1:(d+=1,l>0&&n[l-1].vertical&&(o+="</section>",c=0),l<r.length-1&&n[l+1].vertical&&(o+="<section>")),o+=`<section ${S} ${m} class="slide ${g}" data-source-line="${f.lineNo}" data-h="${d}" data-v="${c}">${u}</section>`,l+=1}l>0&&n[l-1].vertical&&(o+="</section>");let p=ce.load(o);return p("li").each((u,f)=>{let S=p(f),m=(S.html()??"").trim().split(`
563
+ `+n),await ea(n,{projectDirectoryPath:this.projectDirectoryPath.fsPath,fileDirectoryPath:this.fileDirectoryPath,protocolsWhiteListRegExp:this.protocolsWhiteListRegExp,filesCache:this.filesCache,codeChunksData:this.codeChunksData,graphsCache:this.graphsCache,notebook:this.notebook},r)}exportOnSave(t){let n=ft();for(let a in t)if(a==="html")this.htmlExport({});else if(!n&&a==="prince")this.princeExport({openFileAfterGeneration:!1});else if(!n&&a==="puppeteer"||a==="chrome"){let r=t[a],s=this.chromeExport;s=s.bind(this),r===!0?s({fileType:"pdf",openFileAfterGeneration:!1}):typeof r=="string"?s({fileType:r,openFileAfterGeneration:!1}):r instanceof Array&&r.forEach(o=>{s({fileType:o,openFileAfterGeneration:!1})})}else if(!n&&a==="pandoc")this.pandocExport({openFileAfterGeneration:!1});else if(!n&&a==="ebook"){let r=t[a];r===!0?this.eBookExport({fileType:"epub"}):typeof r=="string"?this.eBookExport({fileType:r}):r instanceof Array&&r.forEach(s=>{this.eBookExport({fileType:s})})}}resolveFilePath(t="",n,a=""){return t.match(this.protocolsWhiteListRegExp)||t.startsWith("data:image/")||t[0]==="#"?t:t[0]==="/"?n?v.relative(a||this.fileDirectoryPath,v.resolve(this.projectDirectoryPath.fsPath,"."+t)):Y(v.resolve(this.projectDirectoryPath.fsPath,"."+t),this.vscodePreviewPanel):n?t:Y(v.resolve(a||this.fileDirectoryPath,t),this.vscodePreviewPanel)}async resolvePathsInHeader(t){let n=ce.load(t),a=n("script");for(let r=0;r<a.length;r++){let s=n(a[r]),o=s.attr("src");if(o&&!o.match(/^https?:\/\//)&&o.startsWith("/")){let l=v.join(this.notebook.notebookPath.fsPath,"."+o);try{let d=await this.fs.readFile(l);s.html(d),s.removeAttr("src")}catch(d){console.error(d)}}}return n.html()}clearCaches(){this.filesCache={},this.codeChunksData={},this.graphsCache={}}frontMatterToTable(t){if(t instanceof Array){let n="<tbody><tr>";return t.forEach(a=>n+=`<td>${this.frontMatterToTable(a)}</td>`),n+="</tr></tbody>",`<table>${n}</table>`}else if(typeof t=="object"){let n="<thead><tr>",a="<tbody><tr>";for(let r in t)t.hasOwnProperty(r)&&(n+=`<th>${(0,le.escape)(r)}</th>`,a+=`<td>${this.frontMatterToTable(t[r])}</td>`);return n+="</tr></thead>",a+="</tr></tbody>",`<table>${n}${a}</table>`}else return(0,le.escape)(t)}processFrontMatter(t,n=!1){if(t){let a=De(t);if(this.notebook.config.usePandocParser)return{content:t,table:"",data:a||{}};if(n||(this.notebook.config.frontMatterRenderingOption??"")[0]==="n")return{content:"",table:"",data:a};if((this.notebook.config.frontMatterRenderingOption??"")[0]==="t"){let r;return typeof a=="object"?r=this.frontMatterToTable(a):r='<pre class="language-text"><code>Failed to parse YAML.</code></pre>',{content:"",table:r,data:a}}else return{content:t.replace(/^---/,"```yaml").replace(/\n---$/,"\n```\n"),table:"",data:a}}else return{content:t,table:"",data:{}}}parseSlides(t,n,a){let r=t.split(/^\s*<p[^>]*><span>\[CROSSNOTESLIDE\]<\/span><\/p>\s*/gm),s=r[0];r=r.slice(1);let o="",l=0,d=-1,c=0;for(;l<r.length;){let u=r[l],f=n[l];"data-background-image"in f&&(f["data-background-image"]=this.resolveFilePath(f["data-background-image"],a)),"data-background-video"in f&&(f["data-background-video"]=this.resolveFilePath(f["data-background-video"],a)),"data-background-iframe"in f&&(f["data-background-iframe"]=this.resolveFilePath(f["data-background-iframe"],a));let S=K(f,!1),g=f.class||"",m=f.id?`id="${f.id}"`:"";f.vertical?c+=1:(d+=1,l>0&&n[l-1].vertical&&(o+="</section>",c=0),l<r.length-1&&n[l+1].vertical&&(o+="<section>")),o+=`<section ${S} ${m} class="slide ${g}" data-source-line="${f.lineNo}" data-h="${d}" data-v="${c}">${u}</section>`,l+=1}l>0&&n[l-1].vertical&&(o+="</section>");let p=ce.load(o);return p("li").each((u,f)=>{let S=p(f),m=(S.html()??"").trim().split(`
564
564
  `)[0].match(/<!--(.+?)-->/);if(m){let b=m[1].replace(/\.element:/,"").trim(),h=ne(b);for(let E in h)h.hasOwnProperty(E)&&S.attr(E,h[E])}}),`
565
565
  <div style="display:none;">${s}</div>
566
566
  <div class="reveal">
package/out/esm/index.mjs CHANGED
@@ -560,7 +560,7 @@ sidebarTOCBtn.addEventListener('click', function(event) {
560
560
  ---`);if(o>0){let l=a.slice(0,o+4);r=this.processFrontMatter(l,!1).data}}let s=await Nn(a,{fileDirectoryPath:this.fileDirectoryPath,projectDirectoryPath:this.projectDirectoryPath.fsPath,sourceFilePath:this.filePath,protocolsWhiteListRegExp:this.protocolsWhiteListRegExp,filesCache:this.filesCache,codeChunksData:this.codeChunksData,graphsCache:this.graphsCache,notebook:this.notebook},r);return n&&ue(s),s}async markdownExport({runAllCodeChunks:t=!1}){let n=await this.fs.readFile(this.filePath);t&&await this.parseMD(n,{useRelativeFilePath:!0,isForPreview:!1,hideFrontMatter:!1,runAllCodeChunks:t});let a={};if(n.startsWith("---")){let s=n.indexOf(`
561
561
  ---`);if(s>0){let o=n.slice(0,s+4);n=n.replace(o,""),a=this.processFrontMatter(o,!1).data}}let r={};return a.markdown&&(r={...a.markdown}),r.image_dir||(r.image_dir=this.notebook.config.imageFolderPath),r.path||(this.filePath.match(/\.src\./)?r.path=this.filePath.replace(/\.src\./,"."):r.path=this.filePath.replace(new RegExp(v.extname(this.filePath)),"_"+v.extname(this.filePath)),r.path=v.basename(r.path)),(r.ignore_from_front_matter||!("ignore_from_front_matter"in r))&&delete a.markdown,a.export_on_save&&delete a.export_on_save,Object.keys(a).length&&(n=`---
562
562
  `+ia.stringify(a)+`---
563
- `+n),await _n(n,{projectDirectoryPath:this.projectDirectoryPath.fsPath,fileDirectoryPath:this.fileDirectoryPath,protocolsWhiteListRegExp:this.protocolsWhiteListRegExp,filesCache:this.filesCache,codeChunksData:this.codeChunksData,graphsCache:this.graphsCache,notebook:this.notebook},r)}exportOnSave(t){let n=at();for(let a in t)if(a==="html")this.htmlExport({});else if(!n&&a==="prince")this.princeExport({openFileAfterGeneration:!1});else if(!n&&a==="puppeteer"||a==="chrome"){let r=t[a],s=this.chromeExport;s=s.bind(this),r===!0?s({fileType:"pdf",openFileAfterGeneration:!1}):typeof r=="string"?s({fileType:r,openFileAfterGeneration:!1}):r instanceof Array&&r.forEach(o=>{s({fileType:o,openFileAfterGeneration:!1})})}else if(!n&&a==="pandoc")this.pandocExport({openFileAfterGeneration:!1});else if(!n&&a==="ebook"){let r=t[a];r===!0?this.eBookExport({fileType:"epub"}):typeof r=="string"?this.eBookExport({fileType:r}):r instanceof Array&&r.forEach(s=>{this.eBookExport({fileType:s})})}}resolveFilePath(t="",n,a=""){return t.match(this.protocolsWhiteListRegExp)||t.startsWith("data:image/")||t[0]==="#"?t:t[0]==="/"?n?v.relative(a||this.fileDirectoryPath,v.resolve(this.projectDirectoryPath.fsPath,"."+t)):q(v.resolve(this.projectDirectoryPath.fsPath,"."+t),this.vscodePreviewPanel):n?t:q(v.resolve(a||this.fileDirectoryPath,t),this.vscodePreviewPanel)}async resolvePathsInHeader(t){let n=de.load(t),a=n("script");for(let r=0;r<a.length;r++){let s=n(a[r]),o=s.attr("src");if(o&&!o.match(/^https?:\/\//)&&o.startsWith("/")){let l=v.join(this.notebook.notebookPath.fsPath,"."+o);try{let d=await this.fs.readFile(l);s.html(d),s.removeAttr("src")}catch(d){console.error(d)}}}return n.html()}clearCaches(){this.filesCache={},this.codeChunksData={},this.graphsCache={}}frontMatterToTable(t){if(t instanceof Array){let n="<tbody><tr>";return t.forEach(a=>n+=`<td>${this.frontMatterToTable(a)}</td>`),n+="</tr></tbody>",`<table>${n}</table>`}else if(typeof t=="object"){let n="<thead><tr>",a="<tbody><tr>";for(let r in t)t.hasOwnProperty(r)&&(n+=`<th>${le(r)}</th>`,a+=`<td>${this.frontMatterToTable(t[r])}</td>`);return n+="</tr></thead>",a+="</tr></tbody>",`<table>${n}${a}</table>`}else return le(t)}processFrontMatter(t,n=!1){if(t){let a=Ne(t);if(this.notebook.config.usePandocParser)return{content:t,table:"",data:a||{}};if(n||(this.notebook.config.frontMatterRenderingOption??"")[0]==="n")return{content:"",table:"",data:a};if((this.notebook.config.frontMatterRenderingOption??"")[0]==="t"){let r;return typeof a=="object"?r=this.frontMatterToTable(a):r='<pre class="language-text"><code>Failed to parse YAML.</code></pre>',{content:"",table:r,data:a}}else return{content:t.replace(/^---/,"```yaml").replace(/\n---$/,"\n```\n"),table:"",data:a}}else return{content:t,table:"",data:{}}}parseSlides(t,n,a){let r=t.split(/^\s*<p[^>]+><span>\[CROSSNOTESLIDE\]<\/span><\/p>\s*/gm),s=r[0];r=r.slice(1);let o="",l=0,d=-1,c=0;for(;l<r.length;){let g=r[l],f=n[l];"data-background-image"in f&&(f["data-background-image"]=this.resolveFilePath(f["data-background-image"],a)),"data-background-video"in f&&(f["data-background-video"]=this.resolveFilePath(f["data-background-video"],a)),"data-background-iframe"in f&&(f["data-background-iframe"]=this.resolveFilePath(f["data-background-iframe"],a));let S=Y(f,!1),m=f.class||"",u=f.id?`id="${f.id}"`:"";f.vertical?c+=1:(d+=1,l>0&&n[l-1].vertical&&(o+="</section>",c=0),l<r.length-1&&n[l+1].vertical&&(o+="<section>")),o+=`<section ${S} ${u} class="slide ${m}" data-source-line="${f.lineNo}" data-h="${d}" data-v="${c}">${g}</section>`,l+=1}l>0&&n[l-1].vertical&&(o+="</section>");let p=de.load(o);return p("li").each((g,f)=>{let S=p(f),u=(S.html()??"").trim().split(`
563
+ `+n),await _n(n,{projectDirectoryPath:this.projectDirectoryPath.fsPath,fileDirectoryPath:this.fileDirectoryPath,protocolsWhiteListRegExp:this.protocolsWhiteListRegExp,filesCache:this.filesCache,codeChunksData:this.codeChunksData,graphsCache:this.graphsCache,notebook:this.notebook},r)}exportOnSave(t){let n=at();for(let a in t)if(a==="html")this.htmlExport({});else if(!n&&a==="prince")this.princeExport({openFileAfterGeneration:!1});else if(!n&&a==="puppeteer"||a==="chrome"){let r=t[a],s=this.chromeExport;s=s.bind(this),r===!0?s({fileType:"pdf",openFileAfterGeneration:!1}):typeof r=="string"?s({fileType:r,openFileAfterGeneration:!1}):r instanceof Array&&r.forEach(o=>{s({fileType:o,openFileAfterGeneration:!1})})}else if(!n&&a==="pandoc")this.pandocExport({openFileAfterGeneration:!1});else if(!n&&a==="ebook"){let r=t[a];r===!0?this.eBookExport({fileType:"epub"}):typeof r=="string"?this.eBookExport({fileType:r}):r instanceof Array&&r.forEach(s=>{this.eBookExport({fileType:s})})}}resolveFilePath(t="",n,a=""){return t.match(this.protocolsWhiteListRegExp)||t.startsWith("data:image/")||t[0]==="#"?t:t[0]==="/"?n?v.relative(a||this.fileDirectoryPath,v.resolve(this.projectDirectoryPath.fsPath,"."+t)):q(v.resolve(this.projectDirectoryPath.fsPath,"."+t),this.vscodePreviewPanel):n?t:q(v.resolve(a||this.fileDirectoryPath,t),this.vscodePreviewPanel)}async resolvePathsInHeader(t){let n=de.load(t),a=n("script");for(let r=0;r<a.length;r++){let s=n(a[r]),o=s.attr("src");if(o&&!o.match(/^https?:\/\//)&&o.startsWith("/")){let l=v.join(this.notebook.notebookPath.fsPath,"."+o);try{let d=await this.fs.readFile(l);s.html(d),s.removeAttr("src")}catch(d){console.error(d)}}}return n.html()}clearCaches(){this.filesCache={},this.codeChunksData={},this.graphsCache={}}frontMatterToTable(t){if(t instanceof Array){let n="<tbody><tr>";return t.forEach(a=>n+=`<td>${this.frontMatterToTable(a)}</td>`),n+="</tr></tbody>",`<table>${n}</table>`}else if(typeof t=="object"){let n="<thead><tr>",a="<tbody><tr>";for(let r in t)t.hasOwnProperty(r)&&(n+=`<th>${le(r)}</th>`,a+=`<td>${this.frontMatterToTable(t[r])}</td>`);return n+="</tr></thead>",a+="</tr></tbody>",`<table>${n}${a}</table>`}else return le(t)}processFrontMatter(t,n=!1){if(t){let a=Ne(t);if(this.notebook.config.usePandocParser)return{content:t,table:"",data:a||{}};if(n||(this.notebook.config.frontMatterRenderingOption??"")[0]==="n")return{content:"",table:"",data:a};if((this.notebook.config.frontMatterRenderingOption??"")[0]==="t"){let r;return typeof a=="object"?r=this.frontMatterToTable(a):r='<pre class="language-text"><code>Failed to parse YAML.</code></pre>',{content:"",table:r,data:a}}else return{content:t.replace(/^---/,"```yaml").replace(/\n---$/,"\n```\n"),table:"",data:a}}else return{content:t,table:"",data:{}}}parseSlides(t,n,a){let r=t.split(/^\s*<p[^>]*><span>\[CROSSNOTESLIDE\]<\/span><\/p>\s*/gm),s=r[0];r=r.slice(1);let o="",l=0,d=-1,c=0;for(;l<r.length;){let g=r[l],f=n[l];"data-background-image"in f&&(f["data-background-image"]=this.resolveFilePath(f["data-background-image"],a)),"data-background-video"in f&&(f["data-background-video"]=this.resolveFilePath(f["data-background-video"],a)),"data-background-iframe"in f&&(f["data-background-iframe"]=this.resolveFilePath(f["data-background-iframe"],a));let S=Y(f,!1),m=f.class||"",u=f.id?`id="${f.id}"`:"";f.vertical?c+=1:(d+=1,l>0&&n[l-1].vertical&&(o+="</section>",c=0),l<r.length-1&&n[l+1].vertical&&(o+="<section>")),o+=`<section ${S} ${u} class="slide ${m}" data-source-line="${f.lineNo}" data-h="${d}" data-v="${c}">${g}</section>`,l+=1}l>0&&n[l-1].vertical&&(o+="</section>");let p=de.load(o);return p("li").each((g,f)=>{let S=p(f),u=(S.html()??"").trim().split(`
564
564
  `)[0].match(/<!--(.+?)-->/);if(u){let b=u[1].replace(/\.element:/,"").trim(),E=te(b);for(let h in E)E.hasOwnProperty(h)&&S.attr(h,E[h])}}),`
565
565
  <div style="display:none;">${s}</div>
566
566
  <div class="reveal">