crossnote 0.8.9 → 0.8.11
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 +6 -6
- package/out/esm/index.mjs +6 -6
- package/out/styles/preview.css +1 -1
- package/out/styles/style-template.css +1 -1
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/out/webview/backlinks.css +1 -1
- package/out/webview/backlinks.js +5 -5
- package/out/webview/preview.css +1 -1
- package/out/webview/preview.js +6 -6
- package/package.json +3 -3
package/out/cjs/index.cjs
CHANGED
|
@@ -320,9 +320,9 @@ ${f.plainResult}\`\`\`
|
|
|
320
320
|
---`))>0){let a=e.slice(3,t);try{n=nt.parse(a)}catch{n={}}e=e.slice(t+4).replace(/^[ \t]*\n/,"")}return{data:n,content:e}}function Sa(e,t){t=t||{};let n=nt.stringify(t).trim();return n==="{}"||!n?e:`---
|
|
321
321
|
${n}
|
|
322
322
|
---
|
|
323
|
-
${e}`}var Ie=class{constructor(){this.map={}}addReference(t,n,a){if(t===n&&!a){t in this.map||(this.map[t]={[n]:[]});return}if(a)if(t in this.map){let r=this.map[t];n in r?r[n].push(a):r[n]=[a]}else this.map[t]={[n]:[a]}}deleteReferences(t,n){if(t===n){delete this.map[t];return}t in this.map&&n in this.map[t]&&(delete this.map[t][n],Object.keys(this.map[t]).length===0&&delete this.map[t])}hasRelation(t,n){return t in this.map&&n in this.map[t]||n in this.map&&t in this.map[n]||t===n}getReferences(t,n){return t in this.map&&n in this.map[t]?this.map[t][n]:[]}noteHasReferences(t){return t in this.map}getReferredByNotesCount(t){if(t in this.map){let n=Object.keys(this.map[t]).length;return t in this.map[t]&&(n-=1),n}else return 0}};var ya=N(require("minisearch"));function Dr(e,t="-"){return e.replace(/[.\s!@#$%^&*()\-=_+~`[\]{}\\<>?/|()【】::,。]+/g,t)}var he=class{constructor(){this.miniSearch=new ya.default({fields:["title","aliases","filePath"],storeFields:["title","aliases","filePath"],extractField:(t,n)=>n==="aliases"?t.aliases.join("|"):t[n],tokenize:t=>Dr(t," ").match(/([^\x00-\x7F]|\w+)/g)??[]}),this._cache={}}add(t,n,a=[]){if(!(t in this._cache)){let r={id:t+"#"+n,filePath:t,title:n,aliases:a};this.miniSearch.add(r),this._cache[t]=r}}remove(t){if(t in this._cache){let n=this._cache[t];n&&this.miniSearch.remove(n),delete this._cache[t]}}search(t,n){return this.miniSearch.search(t,n)}addAlias(t,n){let a=this._cache[t];a&&(this.remove(t),this.add(t,a.title,a.aliases.concat(n)))}deleteAlias(t,n){let a=this._cache[t];a&&(this.remove(t),this.add(t,a.title,a.aliases.filter(r=>r!==n)))}};var Pr={html:!0,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkify:!0,typographer:!0},vt=class e{constructor(){this.notes={};this.hasLoadedNotes=!1;this.referenceMap=new Ie;this.refreshNotesIfNotLoadedMutex=new ka.Mutex;this.search=new he;this.markdownEngines={}}async init({notebookPath:t,config:n={},fs:a}){let r=at.URI.parse(t);if(!W.isAbsolute(r.
|
|
323
|
+
${e}`}var Ie=class{constructor(){this.map={}}addReference(t,n,a){if(t===n&&!a){t in this.map||(this.map[t]={[n]:[]});return}if(a)if(t in this.map){let r=this.map[t];n in r?r[n].push(a):r[n]=[a]}else this.map[t]={[n]:[a]}}deleteReferences(t,n){if(t===n){delete this.map[t];return}t in this.map&&n in this.map[t]&&(delete this.map[t][n],Object.keys(this.map[t]).length===0&&delete this.map[t])}hasRelation(t,n){return t in this.map&&n in this.map[t]||n in this.map&&t in this.map[n]||t===n}getReferences(t,n){return t in this.map&&n in this.map[t]?this.map[t][n]:[]}noteHasReferences(t){return t in this.map}getReferredByNotesCount(t){if(t in this.map){let n=Object.keys(this.map[t]).length;return t in this.map[t]&&(n-=1),n}else return 0}};var ya=N(require("minisearch"));function Dr(e,t="-"){return e.replace(/[.\s!@#$%^&*()\-=_+~`[\]{}\\<>?/|()【】::,。]+/g,t)}var he=class{constructor(){this.miniSearch=new ya.default({fields:["title","aliases","filePath"],storeFields:["title","aliases","filePath"],extractField:(t,n)=>n==="aliases"?t.aliases.join("|"):t[n],tokenize:t=>Dr(t," ").match(/([^\x00-\x7F]|\w+)/g)??[]}),this._cache={}}add(t,n,a=[]){if(!(t in this._cache)){let r={id:t+"#"+n,filePath:t,title:n,aliases:a};this.miniSearch.add(r),this._cache[t]=r}}remove(t){if(t in this._cache){let n=this._cache[t];n&&this.miniSearch.remove(n),delete this._cache[t]}}search(t,n){return this.miniSearch.search(t,n)}addAlias(t,n){let a=this._cache[t];a&&(this.remove(t),this.add(t,a.title,a.aliases.concat(n)))}deleteAlias(t,n){let a=this._cache[t];a&&(this.remove(t),this.add(t,a.title,a.aliases.filter(r=>r!==n)))}};var Pr={html:!0,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkify:!0,typographer:!0},vt=class e{constructor(){this.notes={};this.hasLoadedNotes=!1;this.referenceMap=new Ie;this.refreshNotesIfNotLoadedMutex=new ka.Mutex;this.search=new he;this.markdownEngines={}}async init({notebookPath:t,config:n={},fs:a}){let r=at.URI.parse(t);if(!W.isAbsolute(r.fsPath)||r.path.startsWith("/./"))throw new Error(`\`notebookPath\`: "${t}" must be an absolute path`);this.notebookPath=r,this.initFs(a),await this.initConfig(n),this.initMarkdownIt(),this.updateConfig({})}static async init(t){let n=new e;return await n.init(t),n}async initConfig(t){let n=await et(W.join(this.notebookPath.fsPath,"./.crossnote"),this.fs);this.config={...ce(),...n,...t}}initMarkdownIt(){this.md=new Ta.default(Pr),this.md.use(_a.default),this.md.use(Ia.default),this.md.use(va.default),this.md.use(Aa.default),this.md.use(wa.default),this.md.use(Ra.default),ia(this.md),oa(this.md,this),ca(this.md,this),ua(this.md,this),fa(this.md,this),ba(this.md,this),ra(this.md)}initFs(t){if(t)this.fs=t;else if(It)this.fs=tt();else throw new Error("`fs` is required")}updateConfig(t){this.config={...this.config,...t},this.interpolateConfig(),this.md.set({typographer:!!this.config.enableTypographer,breaks:!!this.config.breakOnSingleNewLine,linkify:!!this.config.enableLinkify})}interpolateConfig(){var a,r,s,o;let t=/\${\s*(\w+?)\s*}/g,n={projectDir:this.notebookPath,workspaceFolder:this.notebookPath};this.config.imageFolderPath=(a=this.config.imageFolderPath)==null?void 0:a.replace(t,(l,d)=>n[d]||l),this.config.imageMagickPath=(r=this.config.imageMagickPath)==null?void 0:r.replace(t,(l,d)=>n[d]||l),this.config.chromePath=(s=this.config.chromePath)==null?void 0:s.replace(t,(l,d)=>n[d]||l),this.config.plantumlJarPath=(o=this.config.plantumlJarPath)==null?void 0:o.replace(t,(l,d)=>n[d]||l)}async getBacklinkedNotes(t){if(t=this.resolveNoteRelativePath(t),t in this.referenceMap.map){let n=this.referenceMap.map[t],a={};for(let r in n){if(r===t)continue;let s=await this.getNote(r);s&&(a[r]=s)}return a}else return{}}async getNoteBacklinks(t){let n=await this.getBacklinkedNotes(t),a=[],r=Object.keys(n);for(let s of r){let o=n[s],l=await this.getReferences(t,s);a.push({note:{notebookPath:o.notebookPath,filePath:o.filePath,title:o.title,config:o.config},references:l,referenceHtmls:l.map(d=>{let c=[d.parentToken??d.token];return this.md.renderer.render(c,this.md.options,{})})})}return a}async getReferences(t,n){return this.referenceMap.getReferences(this.resolveNoteRelativePath(t),this.resolveNoteRelativePath(n))}async processNoteMentionsAndMentionedBy(t){let n=await this.getNote(t);if(!n)return;let a=this.md.parse(n.markdown,{}),r=p=>(p.endsWith(".md")||(p=p+".md"),p.startsWith("/")?W.relative(this.notebookPath.fsPath,W.join(this.notebookPath.fsPath,"."+p)):W.relative(this.notebookPath.fsPath,W.join(W.dirname(W.join(this.notebookPath.fsPath,n.filePath)),p))),s=p=>at.Utils.joinPath(this.notebookPath,p).toString(),o=(p,u,b,S)=>{var g;for(let m=0;m<p.length;m++){let f=p[m];if(f.type==="wikilink"){let h=f.content.split("|"),E,A;if(this.config.useGitHubStylePipedLink?(E=h[0].trim(),A=(h.length>1?h[1]:h[0]).trim()):(E=(h.length>1?h[1]:h[0]).trim(),A=h[0].trim()),A.match(/https?:\/\//))continue;A=r(A),this.config.useGitHubStylePipedLink?f.content=`${E} | ${s(A)}`:f.content=`${s(A)} | ${E}`,b.push({elementId:f.attrGet("id")||"",text:E,link:A,parentToken:u,token:f})}else if(f.type==="tag"){let h=f.content.trim(),E=f.content.trim();b.push({elementId:f.attrGet("id")||"",text:h,link:r(E),parentToken:u,token:f})}else if(f.type==="link_open"&&p[m+1]&&p[m+1].type==="text"){if((g=f.attrs)!=null&&g.length&&f.attrs[0][0]==="href"){let h=decodeURI(f.attrs[0][1]),E=p[m+1].content.trim();if(h.match(/https?:\/\//)||!E.length||!h.endsWith(".md"))continue;h=r(h),f.attrs[0][1]=s(h),b.push({elementId:f.attrGet("id")||"",text:E,link:h,parentToken:u,token:f})}}else f.children&&f.children.length&&o(f.children,f,b,S+1)}return b},l=o(a,null,[],0),d=new Set,c=n.mentions;for(let p in c)this.referenceMap.deleteReferences(p,n.filePath);for(let p=0;p<l.length;p++){let{link:u}=l[p];d[u]=!0,this.referenceMap.addReference(u,n.filePath,l[p])}this.referenceMap.addReference(n.filePath,n.filePath,void 0),n.mentions=d}async getNote(t,n=!1){if(t=this.resolveNoteRelativePath(t),!n&&t in this.notes)return this.notes[t];let a=this.resolveNoteAbsolutePath(t),r;try{r=await this.fs.stat(a)}catch{return null}if(r.isFile()&&this.config.markdownFileExtensions.includes(W.extname(t))){let s=await this.fs.readFile(a),o={createdAt:new Date(r.ctimeMs),modifiedAt:new Date(r.mtimeMs),aliases:[]};try{let p=Ea(s),u=Object.assign({},p.data);if(p.data.created&&(o.createdAt=new Date(p.data.created),delete u.created),p.data.modified&&(o.modifiedAt=new Date(p.data.modified),delete u.modified),p.data.pinned&&(o.pinned=p.data.pinned,delete u.pinned),p.data.favorited&&(o.favorited=p.data.favorited,delete u.favorited),p.data.icon&&(o.icon=p.data.icon,delete u.icon),p.data.aliases){let b=p.data.aliases||[];typeof b=="string"?o.aliases=b.split(",").map(S=>S.trim()):o.aliases=b,delete u.aliases}s=Sa(p.content,u)}catch{s=`Please fix front-matter. (\u{1F448} Don't forget to delete this line)
|
|
324
324
|
|
|
325
|
-
`+s}let l=new Set,d=this.notes[t];d&&(l=d.mentions);let c={notebookPath:this.notebookPath,filePath:W.relative(this.notebookPath.
|
|
325
|
+
`+s}let l=new Set,d=this.notes[t];d&&(l=d.mentions);let c={notebookPath:this.notebookPath,filePath:W.relative(this.notebookPath.fsPath,a),title:W.basename(a).replace(/\.md$/,""),markdown:s,config:o,mentions:l};return n&&(this.notes[c.filePath]=c,this.search.add(c.filePath,c.title,c.config.aliases),await this.processNoteMentionsAndMentionedBy(c.filePath)),c}else return null}async refreshNotesIfNotLoaded({dir:t="./",includeSubdirectories:n=!1}){return await this.refreshNotesIfNotLoadedMutex.runExclusive(async()=>{this.hasLoadedNotes||(await this.refreshNotes({dir:t,includeSubdirectories:n,refreshRelations:!0}),this.hasLoadedNotes=!0)}),this.notes}async refreshNotes({dir:t="./",includeSubdirectories:n=!1,refreshRelations:a=!0}){a&&(this.notes={},this.referenceMap=new Ie,this.search=new he);let r=[];try{r=await this.fs.readdir(W.resolve(this.notebookPath.fsPath,t))}catch(o){console.error(o),r=[]}let s=[];for(let o=0;o<r.length;o++){let l=r[o];if(l.match(/^(node_modules|\.git)$/))continue;let d=W.resolve(this.notebookPath.fsPath,t,l),c=await this.getNote(W.relative(this.notebookPath.fsPath,d));c&&(this.notes[c.filePath]=c,this.search.add(c.filePath,c.title,c.config.aliases));let p;try{p=await this.fs.stat(d)}catch(u){console.error(u)}p&&p.isDirectory()&&n&&s.push(this.refreshNotes({dir:W.relative(this.notebookPath.fsPath,d),includeSubdirectories:n,refreshRelations:!1}))}if(await Promise.all(s),a)for(let o in this.notes)await this.processNoteMentionsAndMentionedBy(o);return this.notes}async removeNoteRelations(t){let n=await this.getNote(t);if(!n)return;let a=n.mentions;for(let r in a)this.referenceMap.deleteReferences(r,n.filePath);delete this.notes[n.filePath]}async deleteNote(t,n=!1){let a=this.resolveNoteAbsolutePath(t);(n||await this.fs.exists(a))&&(await this.fs.unlink(a),await this.removeNoteRelations(t),this.search.remove(t))}resolveNoteAbsolutePath(t){return W.isAbsolute(t)?t:W.resolve(this.notebookPath.fsPath,t)}resolveNoteRelativePath(t){return W.isAbsolute(t)?W.relative(this.notebookPath.fsPath,t):t}getNoteMarkdownEngine(t){return t=this.resolveNoteRelativePath(t),t in this.markdownEngines||(this.markdownEngines[t]=new ve({notebook:this,filePath:this.resolveNoteAbsolutePath(t)})),this.markdownEngines[t]}getNoteMarkdownEngines(){return this.markdownEngines}clearAllNoteMarkdownEngineCaches(){for(let t in this.markdownEngines)this.markdownEngines[t].clearCaches()}};var La=require("html-escaper");var Mr={sh:"bash",bash:"bash",c:"c","c++":"cpp",cpp:"cpp",coffee:"coffeescript",coffeescript:"coffeescript","coffee-script":"coffeescript",cs:"csharp",csharp:"csharp",css:"css",scss:"scss",sass:"sass",elm:"elm",elmlang:"elm","elm-lang":"elm",erlang:"erlang",go:"go",html:"html",java:"java",js:"javascript",javascript:"javascript",json:"json",less:"less",objc:"objectivec",objectivec:"objectivec","objective-c":"objectivec",php:"php",py:"python",python:"python",rb:"ruby",ruby:"ruby",text:"text",tex:"latex",xml:"xml",yaml:"yaml",yml:"yaml",yaml_table:"yaml",mermaid:"mermaid",plantuml:"plantuml",puml:"plantuml",wavedrom:"wavedrom",graphviz:"dot",viz:"dot",dot:"dot",erd:"erd",node:"javascript",md:"gfm",diff:"diff"};function Na(e){return e=e.toLowerCase(),Mr[e]||e}function Ca(e){e.languages.iele={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],variable:{pattern:/(@|%)([A-Za-z0-9\\_\\.\\-\\$])[a-zA-Z\\.\\_\\$][0-9a-zA-Z\\.\\_\\-\\$]*/,greedy:!0},string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},keyword:/\b(?:load|store|sload|sstore|iszero|not|add|mul|sub|div|exp|mod|addmod|mulmod|expmod|byte|sext|twos|and|or|xor|shift|lt|le|gt|ge|eq|ne|cmp|sha3|br|call|staticcall|at|send|gaslimit|ret|void|revert|log|create|copycreate|selfdestruct|contract|external|define|public|log2|bswap|calladdress)\b/,label:/(?!\d)(?:[-$.\w]|\\[a-f\d]{2})+:/i,boolean:/\b(?:true|false)\b/,number:/\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/}}function Oa(e){e.languages.k={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":/\b(?:strict|avoid|prefer|bracket|non-assoc|seqstrict|left|right|macro-rec|macro|token|notInRules|autoReject|structural|latex|binder|klabel|symbol|format)\b/,keyword:{pattern:/\b(?:syntax\s+(?:priority|priorities|left|right|non-assoc|lexical)|syntax|rule|Id|Int|Bool|String|Token|Lexer|Float|configuration|import|imports|require|requires|Kresult|context\s+alias|context|module|endmodule|claim)\b/,greedy:!0},boolean:/\b(?:true|false)\b/,number:/\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,operator:{pattern:/[<>]=|=>|~>|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/},punctuation:/[{}[\];(),.:]/,tag:{pattern:/<\/?(?!\d)[^\s>/=$<%]+(?:\s(?:\s*[^\s>/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>/:]+:/}},"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>/]+/,inside:{namespace:/^[^\s>/:]+:/}}}}}}var Ee=N(xa());Ee.default.hooks.add("wrap",e=>{e.type==="keyword"&&e.classes.push(`keyword-${e.content}`)});Oa(Ee.default);Ca(Ee.default);async function Nt(e){e("pre>code").each((t,n)=>{let a=e(n),r=a.text(),s=a.parent();a.replaceWith((0,La.escape)(r)),s.addClass("language-text")}),e('[data-role="codeBlock"]').each((t,n)=>{let a=e(n);if(a.data("hiddenByEnhancer")||a.data("normalizedInfo").attributes.hide===!0){a.remove();return}let s=a.text(),o=a.data("normalizedInfo"),l=Ur(Na(o.language),s);try{let d=Ee.default.highlight(s,Ee.default.languages[l],l);a.html(d)}catch{a.empty().append(e("<code></code>").text(s))}a.addClass(`language-${l}`),o.attributes.class&&(a.addClass(o.attributes.class),Br(a,s)),o.attributes.highlight&&$r(a,s,o.attributes.highlight),a.removeAttr("data-parsed-info"),a.removeAttr("data-normalized-info")})}function Ur(e,t){return e==="vega"||e==="vega-lite"?(t.match(/^\s*(.)/)??[])[1]==="{"?"json":"yaml":e}function Br(e,t){if(e.hasClass("numberLines")&&(e.addClass("line-numbers"),e.removeClass("numberLines")),e.hasClass("line-numbers")){if(!t.trim().length)return;let n=t.match(/\n(?!$)/g),a=n?n.length+1:1,r="";for(let s=0;s<a;s++)r+="<span></span>";e.append(`<span aria-hidden="true" class="line-numbers-rows">${r}</span>`)}}function $r(e,t,n){if(!t.trim().length)return;typeof n=="number"?n=[n.toString()]:typeof n=="string"&&(n=n.split(","));let a=t.match(/\n(?!$)/g),r=a?a.length+1:1,s=[];n.forEach(o=>{if(o=o.toString(),o.indexOf("-")>0){let[l,d]=o.split("-").map(u=>parseInt(u,10));if(isNaN(l)||isNaN(d)||l<0||d<0||(l>d&&([l,d]=[d,l]),d>r))return;let c="";for(let u=l;u<=d;u++)c+=`
|
|
326
326
|
`;let p="";for(let u=0;u<l-1;u++)p+=`
|
|
327
327
|
`;s.push(`<div class="line-highlight-wrapper">${p}<div aria-hidden="true" class="line-highlight" data-range="${l}-${d}" data-start="${l}" data-end="${d}">${c}</div></div>`)}else{let l="",d=parseInt(o,10);if(isNaN(d)||d<0||d>r)return;for(let c=0;c<d-1;c++)l+=`
|
|
328
328
|
`;s.push(`<div class="line-highlight-wrapper">${l}<div aria-hidden="true" class="line-highlight" data-range="${o}" data-start="${o}">
|
|
@@ -384,7 +384,7 @@ if (typeof(window['Reveal']) !== 'undefined') {
|
|
|
384
384
|
window["initRevealPresentation"] = async function() {
|
|
385
385
|
${s}
|
|
386
386
|
}
|
|
387
|
-
</script>`,r+s}getPrismTheme(t=!1,n={}){if(this.notebook.config.codeBlockTheme==="auto.css")if(t){let a=n.presentation&&typeof n.presentation=="object"&&n.presentation.theme?n.presentation.theme:this.notebook.config.revealjsTheme;return pe.AutoPrismThemeMapForPresentation[a]||"default.css"}else return pe.AutoPrismThemeMap[this.notebook.config.previewTheme]||"default.css";else return this.notebook.config.codeBlockTheme}generateStylesForPreview(t=!1,n={},a=null){let r="";return this.notebook.config.mathRenderingOption==="KaTeX"&&!this.notebook.config.usePandocParser&&(r+=`<link rel="stylesheet" href="${V(R.resolve(B(),"./dependencies/katex/katex.min.css"),a)}">`),r+=`<link rel="stylesheet" href="${V(R.resolve(B(),"./dependencies/font-awesome/css/font-awesome.min.css"),a)}">`,t?(r+=`<link rel="stylesheet" href="${V(R.resolve(B(),"./dependencies/reveal/css/reveal.css"),a)}" >`,r+=`<link rel="stylesheet" href="${V(R.resolve(B(),`./dependencies/reveal/css/theme/${n.presentation&&typeof n.presentation=="object"&&n.presentation.theme?n.presentation.theme:this.notebook.config.revealjsTheme}`),a)}" >`):r+=`<link rel="stylesheet" href="${V(R.resolve(B(),`./styles/preview_theme/${this.notebook.config.previewTheme}`),a)}">`,r+=`<link rel="stylesheet" href="${V(R.resolve(B(),`./styles/prism_theme/${this.getPrismTheme(t,n)}`),a)}">`,r+=`<link rel="stylesheet" media="screen" href="${V(R.resolve(B(),"./styles/style-template.css"),a)}">`,r+=`<link rel="stylesheet" media="screen" href="${V(R.resolve(B(),"./styles/markdown-it-admonition.css"),a)}">`,r+=`<style>${this.notebook.config.globalCss}</style>`,r}generateJSAndCssFilesForPreview(t=[],n=null){let a="";return t.forEach(r=>{let s=r;r[0]==="/"?s=V(R.resolve(this.projectDirectoryPath.
|
|
387
|
+
</script>`,r+s}getPrismTheme(t=!1,n={}){if(this.notebook.config.codeBlockTheme==="auto.css")if(t){let a=n.presentation&&typeof n.presentation=="object"&&n.presentation.theme?n.presentation.theme:this.notebook.config.revealjsTheme;return pe.AutoPrismThemeMapForPresentation[a]||"default.css"}else return pe.AutoPrismThemeMap[this.notebook.config.previewTheme]||"default.css";else return this.notebook.config.codeBlockTheme}generateStylesForPreview(t=!1,n={},a=null){let r="";return this.notebook.config.mathRenderingOption==="KaTeX"&&!this.notebook.config.usePandocParser&&(r+=`<link rel="stylesheet" href="${V(R.resolve(B(),"./dependencies/katex/katex.min.css"),a)}">`),r+=`<link rel="stylesheet" href="${V(R.resolve(B(),"./dependencies/font-awesome/css/font-awesome.min.css"),a)}">`,t?(r+=`<link rel="stylesheet" href="${V(R.resolve(B(),"./dependencies/reveal/css/reveal.css"),a)}" >`,r+=`<link rel="stylesheet" href="${V(R.resolve(B(),`./dependencies/reveal/css/theme/${n.presentation&&typeof n.presentation=="object"&&n.presentation.theme?n.presentation.theme:this.notebook.config.revealjsTheme}`),a)}" >`):r+=`<link rel="stylesheet" href="${V(R.resolve(B(),`./styles/preview_theme/${this.notebook.config.previewTheme}`),a)}">`,r+=`<link rel="stylesheet" href="${V(R.resolve(B(),`./styles/prism_theme/${this.getPrismTheme(t,n)}`),a)}">`,r+=`<link rel="stylesheet" media="screen" href="${V(R.resolve(B(),"./styles/style-template.css"),a)}">`,r+=`<link rel="stylesheet" media="screen" href="${V(R.resolve(B(),"./styles/markdown-it-admonition.css"),a)}">`,r+=`<style>${this.notebook.config.globalCss}</style>`,r}generateJSAndCssFilesForPreview(t=[],n=null){let a="";return t.forEach(r=>{let s=r;r[0]==="/"?s=V(R.resolve(this.projectDirectoryPath.fsPath,"."+r),n):r.match(/^file:\/\//)||r.match(/^https?:\/\//)||(s=V(R.resolve(this.fileDirectoryPath,r),n)),s.endsWith(".js")?a+=`<script type="text/javascript" src="${s}"></script>`:a+=`<link rel="stylesheet" href="${s}">`}),a}async generateHTMLTemplateForPreview({inputString:t="",body:n="",webviewScript:a="",scripts:r="",styles:s="",head:o=`<base href="${this.filePath}">`,config:l,vscodePreviewPanel:d=null,contentSecurityPolicy:c="",isVSCodeWebExtension:p}){t||(t=await this.fs.readFile(this.filePath));let u="";a||(a=V(R.resolve(B(),"./webview/preview.js"),d),u=V(R.resolve(B(),"./webview/preview.css"),d)),n||(n="");let{yamlConfig:b,JSAndCssFiles:S,html:g}=await this.parseMD(t,{isForPreview:!0,useRelativeFilePath:!1,hideFrontMatter:!1,vscodePreviewPanel:d}),m=b.isPresentationMode;return`<!DOCTYPE html>
|
|
388
388
|
<html>
|
|
389
389
|
<head>
|
|
390
390
|
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
|
|
@@ -548,10 +548,10 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
548
548
|
</body>
|
|
549
549
|
</html>
|
|
550
550
|
`,R.extname(l)===".html")return await this.fs.writeFile(l,s),l;function y(){E.forEach(w=>{K.unlink(w,()=>{})})}try{let w=await Q({prefix:"crossnote",suffix:".html"});return K.writeFileSync(w.fd,s),await Qt(w.path,l,c),y(),l}catch(w){throw y(),w}}async pandocExport({runAllCodeChunks:t=!1,openFileAfterGeneration:n=!1}){let a=await this.fs.readFile(this.filePath);this.notebook.config.parserConfig.onWillParseMarkdown&&(a=await this.notebook.config.parserConfig.onWillParseMarkdown(a)),t&&await this.parseMD(a,{useRelativeFilePath:!0,isForPreview:!1,hideFrontMatter:!1,runAllCodeChunks:t});let r={};if(a.startsWith("---")){let o=a.indexOf(`
|
|
551
|
-
---`);if(o>0){let l=a.slice(0,o+4);r=this.processFrontMatter(l,!1).data}}let s=await ta(a,{fileDirectoryPath:this.fileDirectoryPath,projectDirectoryPath:this.projectDirectoryPath.
|
|
551
|
+
---`);if(o>0){let l=a.slice(0,o+4);r=this.processFrontMatter(l,!1).data}}let s=await ta(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&&le(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(`
|
|
552
552
|
---`);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(R.extname(this.filePath)),"_"+R.extname(this.filePath)),r.path=R.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=`---
|
|
553
553
|
`+Ha.stringify(a)+`---
|
|
554
|
-
`+n),await Zn(n,{projectDirectoryPath:this.projectDirectoryPath.
|
|
554
|
+
`+n),await Zn(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=gt();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?R.relative(a||this.fileDirectoryPath,R.resolve(this.projectDirectoryPath.fsPath,"."+t)):V(R.resolve(this.projectDirectoryPath.fsPath,"."+t),this.vscodePreviewPanel):n?t:V(R.resolve(a||this.fileDirectoryPath,t),this.vscodePreviewPanel)}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>${r}</th>`,a+=`<td>${this.frontMatterToTable(t[r])}</td>`);return n+="</tr></thead>",a+="</tr></tbody>",`<table>${n}${a}</table>`}else return t}processFrontMatter(t,n=!1){if(t){let a=xe(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>Failed to parse YAML.</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("<p>[CROSSNOTESLIDE]</p>"),s=r[0];r=r.slice(1);let o="",l=0,d=-1,c=0;for(;l<r.length;){let u=r[l],b=n[l];"data-background-image"in b&&(b["data-background-image"]=this.resolveFilePath(b["data-background-image"],a)),"data-background-video"in b&&(b["data-background-video"]=this.resolveFilePath(b["data-background-video"],a)),"data-background-iframe"in b&&(b["data-background-iframe"]=this.resolveFilePath(b["data-background-iframe"],a));let S=Y(b,!1),g=b.class||"",m=b.id?`id="${b.id}"`:"";b.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-line="${b.lineNo}" data-h="${d}" data-v="${c}">${u}</section>`,l+=1}l>0&&n[l-1].vertical&&(o+="</section>");let p=oe.load(o);return p("li").each((u,b)=>{let S=p(b),m=(S.html()??"").trim().split(`
|
|
555
555
|
`)[0].match(/<!--(.+?)-->/);if(m){let f=m[1].replace(/\.element:/,"").trim(),h=ne(f);for(let E in h)h.hasOwnProperty(E)&&S.attr(E,h[E])}}),`
|
|
556
556
|
<div style="display:none;">${s}</div>
|
|
557
557
|
<div class="reveal">
|
|
@@ -565,7 +565,7 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
565
565
|
`:(l=!l,r+=p+`
|
|
566
566
|
`);o+=1;continue}p.match(/^\[toc\]/i)&&!l&&(p="[CROSSNOTETOC]"),r+=p+`
|
|
567
567
|
`,o+=1}let c=this.notebook.config.pandocPath;return await new Promise((p,u)=>{var b;try{(b=(0,Ga.execFile)(c,n,{cwd:this.fileDirectoryPath,maxBuffer:1/0},(g,m,f)=>g?u(g):p(f?"<pre>"+f+"</pre>"+m:m)).stdin)==null||b.end(r,"utf-8")}catch(S){let g=S.toString();return g.indexOf("Error: write EPIPE")>=0&&(g=`"pandoc" is required to be installed.
|
|
568
|
-
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 de(t,{fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,projectDirectoryPath:this.projectDirectoryPath.
|
|
568
|
+
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 de(t,{fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,projectDirectoryPath:this.projectDirectoryPath.fsPath,forPreview:n.isForPreview,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 b;if(this.notebook.config.usePandocParser)try{let E=u.pandoc_args||[];E instanceof Array||(E=[]),E.find(_=>_.includes("pandoc-citeproc")||_.includes("--defaults"))===void 0&&(u.bibliography||u.references)&&E.push("--citeproc"),E=this.notebook.config.pandocArguments.concat(E),b=await this.pandocRender(a,E)}catch(E){b=`<pre>${E}</pre>`}else b=this.notebook.md.render(a);let S=u.toc||{},g=S.depth_from||1,m=S.depth_to||6,f=S.ordered;this.tocHTML=an(l,this.notebook.md.render.bind(this.notebook.md),{ordered:f,depthFrom:g,depthTo:m,tab:" "}),this.headings=l,s&&(b=b.replace(/^\s*<p>\[CROSSNOTETOC\]<\/p>\s*/gm,this.tocHTML));let h=oe.load(b);return await Pt(h,this.notebook.config.mathRenderingOption,this.notebook.config.mathBlockDelimiters,this.notebook.config.katexConfig),await Dt({$:h,graphsCache:this.graphsCache,fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,imageDirectoryPath:ee(this.resolveFilePath(this.notebook.config.imageFolderPath,!1)),plantumlServer:this.notebook.config.plantumlServer,plantumlJarPath:this.notebook.config.plantumlJarPath,kirokiServer:this.notebook.config.krokiServer}),await xt(h,this.codeChunksData,n,this.generateRunOptions()),await Nt(h),await Mt(h,n,this.resolveFilePath.bind(this),this.notebook.config.usePandocParser),this.notebook.config.enableExtendedTableSyntax&&await Ot(h),b=p+h("head").html()+h("body").html(),r.length&&(b=this.parseSlides(b,r,n.useRelativeFilePath),u&&(u.isPresentationMode=!0)),this.notebook.config.parserConfig.onDidParseMarkdown&&(b=await this.notebook.config.parserConfig.onDidParseMarkdown(b)),n.runAllCodeChunks?(await Lt(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:b,markdown:t,tocHTML:this.tocHTML,yamlConfig:u,JSAndCssFiles:o})}runCodeChunks(){return Lt(this.codeChunksData,this.generateRunOptions())}runCodeChunk(t){return ot(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,b)=>{let S=b.length,g=0;for(let m=u+1;m<u+6&&m<S;m++)if(b[m].startsWith("<!-- code_chunk_output -->")){g=m;break}if(g){let m=g+1;for(;m<S&&!b[m].startsWith("<!-- /code_chunk_output -->");)m+=1;let f="";for(let E=g+2;E<m-1;E++)f+=b[E]+`
|
|
569
569
|
`;if(f===n+`
|
|
570
570
|
`)return"";let h=[...b.slice(0,g+2),n,...b.slice(m-1)];return await this.notebook.fs.writeFile(a,h.join(`
|
|
571
571
|
`)),""}else{let m=[...b.slice(0,u+1),`
|
package/out/esm/index.mjs
CHANGED
|
@@ -320,9 +320,9 @@ ${f.plainResult}\`\`\`
|
|
|
320
320
|
---`))>0){let a=e.slice(3,t);try{n=We.parse(a)}catch{n={}}e=e.slice(t+4).replace(/^[ \t]*\n/,"")}return{data:n,content:e}}function $n(e,t){t=t||{};let n=We.stringify(t).trim();return n==="{}"||!n?e:`---
|
|
321
321
|
${n}
|
|
322
322
|
---
|
|
323
|
-
${e}`}var we=class{constructor(){this.map={}}addReference(t,n,a){if(t===n&&!a){t in this.map||(this.map[t]={[n]:[]});return}if(a)if(t in this.map){let r=this.map[t];n in r?r[n].push(a):r[n]=[a]}else this.map[t]={[n]:[a]}}deleteReferences(t,n){if(t===n){delete this.map[t];return}t in this.map&&n in this.map[t]&&(delete this.map[t][n],Object.keys(this.map[t]).length===0&&delete this.map[t])}hasRelation(t,n){return t in this.map&&n in this.map[t]||n in this.map&&t in this.map[n]||t===n}getReferences(t,n){return t in this.map&&n in this.map[t]?this.map[t][n]:[]}noteHasReferences(t){return t in this.map}getReferredByNotesCount(t){if(t in this.map){let n=Object.keys(this.map[t]).length;return t in this.map[t]&&(n-=1),n}else return 0}};import gr from"minisearch";function mr(e,t="-"){return e.replace(/[.\s!@#$%^&*()\-=_+~`[\]{}\\<>?/|()【】::,。]+/g,t)}var fe=class{constructor(){this.miniSearch=new gr({fields:["title","aliases","filePath"],storeFields:["title","aliases","filePath"],extractField:(t,n)=>n==="aliases"?t.aliases.join("|"):t[n],tokenize:t=>mr(t," ").match(/([^\x00-\x7F]|\w+)/g)??[]}),this._cache={}}add(t,n,a=[]){if(!(t in this._cache)){let r={id:t+"#"+n,filePath:t,title:n,aliases:a};this.miniSearch.add(r),this._cache[t]=r}}remove(t){if(t in this._cache){let n=this._cache[t];n&&this.miniSearch.remove(n),delete this._cache[t]}}search(t,n){return this.miniSearch.search(t,n)}addAlias(t,n){let a=this._cache[t];a&&(this.remove(t),this.add(t,a.title,a.aliases.concat(n)))}deleteAlias(t,n){let a=this._cache[t];a&&(this.remove(t),this.add(t,a.title,a.aliases.filter(r=>r!==n)))}};var _r={html:!0,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkify:!0,typographer:!0},Gn=class e{constructor(){this.notes={};this.hasLoadedNotes=!1;this.referenceMap=new we;this.refreshNotesIfNotLoadedMutex=new fr;this.search=new fe;this.markdownEngines={}}async init({notebookPath:t,config:n={},fs:a}){let r=wr.parse(t);if(!j.isAbsolute(r.
|
|
323
|
+
${e}`}var we=class{constructor(){this.map={}}addReference(t,n,a){if(t===n&&!a){t in this.map||(this.map[t]={[n]:[]});return}if(a)if(t in this.map){let r=this.map[t];n in r?r[n].push(a):r[n]=[a]}else this.map[t]={[n]:[a]}}deleteReferences(t,n){if(t===n){delete this.map[t];return}t in this.map&&n in this.map[t]&&(delete this.map[t][n],Object.keys(this.map[t]).length===0&&delete this.map[t])}hasRelation(t,n){return t in this.map&&n in this.map[t]||n in this.map&&t in this.map[n]||t===n}getReferences(t,n){return t in this.map&&n in this.map[t]?this.map[t][n]:[]}noteHasReferences(t){return t in this.map}getReferredByNotesCount(t){if(t in this.map){let n=Object.keys(this.map[t]).length;return t in this.map[t]&&(n-=1),n}else return 0}};import gr from"minisearch";function mr(e,t="-"){return e.replace(/[.\s!@#$%^&*()\-=_+~`[\]{}\\<>?/|()【】::,。]+/g,t)}var fe=class{constructor(){this.miniSearch=new gr({fields:["title","aliases","filePath"],storeFields:["title","aliases","filePath"],extractField:(t,n)=>n==="aliases"?t.aliases.join("|"):t[n],tokenize:t=>mr(t," ").match(/([^\x00-\x7F]|\w+)/g)??[]}),this._cache={}}add(t,n,a=[]){if(!(t in this._cache)){let r={id:t+"#"+n,filePath:t,title:n,aliases:a};this.miniSearch.add(r),this._cache[t]=r}}remove(t){if(t in this._cache){let n=this._cache[t];n&&this.miniSearch.remove(n),delete this._cache[t]}}search(t,n){return this.miniSearch.search(t,n)}addAlias(t,n){let a=this._cache[t];a&&(this.remove(t),this.add(t,a.title,a.aliases.concat(n)))}deleteAlias(t,n){let a=this._cache[t];a&&(this.remove(t),this.add(t,a.title,a.aliases.filter(r=>r!==n)))}};var _r={html:!0,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkify:!0,typographer:!0},Gn=class e{constructor(){this.notes={};this.hasLoadedNotes=!1;this.referenceMap=new we;this.refreshNotesIfNotLoadedMutex=new fr;this.search=new fe;this.markdownEngines={}}async init({notebookPath:t,config:n={},fs:a}){let r=wr.parse(t);if(!j.isAbsolute(r.fsPath)||r.path.startsWith("/./"))throw new Error(`\`notebookPath\`: "${t}" must be an absolute path`);this.notebookPath=r,this.initFs(a),await this.initConfig(n),this.initMarkdownIt(),this.updateConfig({})}static async init(t){let n=new e;return await n.init(t),n}async initConfig(t){let n=await Et(j.join(this.notebookPath.fsPath,"./.crossnote"),this.fs);this.config={...ge(),...n,...t}}initMarkdownIt(){this.md=new br(_r),this.md.use(Sr),this.md.use(kr),this.md.use(Tr),this.md.use(Er),this.md.use(hr),this.md.use(yr),Cn(this.md),On(this.md,this),Ln(this.md,this),Dn(this.md,this),Pn(this.md,this),Mn(this.md,this),Nn(this.md)}initFs(t){if(t)this.fs=t;else if(Fn)this.fs=St();else throw new Error("`fs` is required")}updateConfig(t){this.config={...this.config,...t},this.interpolateConfig(),this.md.set({typographer:!!this.config.enableTypographer,breaks:!!this.config.breakOnSingleNewLine,linkify:!!this.config.enableLinkify})}interpolateConfig(){let t=/\${\s*(\w+?)\s*}/g,n={projectDir:this.notebookPath,workspaceFolder:this.notebookPath};this.config.imageFolderPath=this.config.imageFolderPath?.replace(t,(a,r)=>n[r]||a),this.config.imageMagickPath=this.config.imageMagickPath?.replace(t,(a,r)=>n[r]||a),this.config.chromePath=this.config.chromePath?.replace(t,(a,r)=>n[r]||a),this.config.plantumlJarPath=this.config.plantumlJarPath?.replace(t,(a,r)=>n[r]||a)}async getBacklinkedNotes(t){if(t=this.resolveNoteRelativePath(t),t in this.referenceMap.map){let n=this.referenceMap.map[t],a={};for(let r in n){if(r===t)continue;let s=await this.getNote(r);s&&(a[r]=s)}return a}else return{}}async getNoteBacklinks(t){let n=await this.getBacklinkedNotes(t),a=[],r=Object.keys(n);for(let s of r){let o=n[s],l=await this.getReferences(t,s);a.push({note:{notebookPath:o.notebookPath,filePath:o.filePath,title:o.title,config:o.config},references:l,referenceHtmls:l.map(d=>{let p=[d.parentToken??d.token];return this.md.renderer.render(p,this.md.options,{})})})}return a}async getReferences(t,n){return this.referenceMap.getReferences(this.resolveNoteRelativePath(t),this.resolveNoteRelativePath(n))}async processNoteMentionsAndMentionedBy(t){let n=await this.getNote(t);if(!n)return;let a=this.md.parse(n.markdown,{}),r=c=>(c.endsWith(".md")||(c=c+".md"),c.startsWith("/")?j.relative(this.notebookPath.fsPath,j.join(this.notebookPath.fsPath,"."+c)):j.relative(this.notebookPath.fsPath,j.join(j.dirname(j.join(this.notebookPath.fsPath,n.filePath)),c))),s=c=>Ar.joinPath(this.notebookPath,c).toString(),o=(c,g,b,S)=>{for(let m=0;m<c.length;m++){let u=c[m];if(u.type==="wikilink"){let f=u.content.split("|"),h,E;if(this.config.useGitHubStylePipedLink?(h=f[0].trim(),E=(f.length>1?f[1]:f[0]).trim()):(h=(f.length>1?f[1]:f[0]).trim(),E=f[0].trim()),E.match(/https?:\/\//))continue;E=r(E),this.config.useGitHubStylePipedLink?u.content=`${h} | ${s(E)}`:u.content=`${s(E)} | ${h}`,b.push({elementId:u.attrGet("id")||"",text:h,link:E,parentToken:g,token:u})}else if(u.type==="tag"){let f=u.content.trim(),h=u.content.trim();b.push({elementId:u.attrGet("id")||"",text:f,link:r(h),parentToken:g,token:u})}else if(u.type==="link_open"&&c[m+1]&&c[m+1].type==="text"){if(u.attrs?.length&&u.attrs[0][0]==="href"){let f=decodeURI(u.attrs[0][1]),h=c[m+1].content.trim();if(f.match(/https?:\/\//)||!h.length||!f.endsWith(".md"))continue;f=r(f),u.attrs[0][1]=s(f),b.push({elementId:u.attrGet("id")||"",text:h,link:f,parentToken:g,token:u})}}else u.children&&u.children.length&&o(u.children,u,b,S+1)}return b},l=o(a,null,[],0),d=new Set,p=n.mentions;for(let c in p)this.referenceMap.deleteReferences(c,n.filePath);for(let c=0;c<l.length;c++){let{link:g}=l[c];d[g]=!0,this.referenceMap.addReference(g,n.filePath,l[c])}this.referenceMap.addReference(n.filePath,n.filePath,void 0),n.mentions=d}async getNote(t,n=!1){if(t=this.resolveNoteRelativePath(t),!n&&t in this.notes)return this.notes[t];let a=this.resolveNoteAbsolutePath(t),r;try{r=await this.fs.stat(a)}catch{return null}if(r.isFile()&&this.config.markdownFileExtensions.includes(j.extname(t))){let s=await this.fs.readFile(a),o={createdAt:new Date(r.ctimeMs),modifiedAt:new Date(r.mtimeMs),aliases:[]};try{let c=Bn(s),g=Object.assign({},c.data);if(c.data.created&&(o.createdAt=new Date(c.data.created),delete g.created),c.data.modified&&(o.modifiedAt=new Date(c.data.modified),delete g.modified),c.data.pinned&&(o.pinned=c.data.pinned,delete g.pinned),c.data.favorited&&(o.favorited=c.data.favorited,delete g.favorited),c.data.icon&&(o.icon=c.data.icon,delete g.icon),c.data.aliases){let b=c.data.aliases||[];typeof b=="string"?o.aliases=b.split(",").map(S=>S.trim()):o.aliases=b,delete g.aliases}s=$n(c.content,g)}catch{s=`Please fix front-matter. (\u{1F448} Don't forget to delete this line)
|
|
324
324
|
|
|
325
|
-
`+s}let l=new Set,d=this.notes[t];d&&(l=d.mentions);let p={notebookPath:this.notebookPath,filePath:j.relative(this.notebookPath.
|
|
325
|
+
`+s}let l=new Set,d=this.notes[t];d&&(l=d.mentions);let p={notebookPath:this.notebookPath,filePath:j.relative(this.notebookPath.fsPath,a),title:j.basename(a).replace(/\.md$/,""),markdown:s,config:o,mentions:l};return n&&(this.notes[p.filePath]=p,this.search.add(p.filePath,p.title,p.config.aliases),await this.processNoteMentionsAndMentionedBy(p.filePath)),p}else return null}async refreshNotesIfNotLoaded({dir:t="./",includeSubdirectories:n=!1}){return await this.refreshNotesIfNotLoadedMutex.runExclusive(async()=>{this.hasLoadedNotes||(await this.refreshNotes({dir:t,includeSubdirectories:n,refreshRelations:!0}),this.hasLoadedNotes=!0)}),this.notes}async refreshNotes({dir:t="./",includeSubdirectories:n=!1,refreshRelations:a=!0}){a&&(this.notes={},this.referenceMap=new we,this.search=new fe);let r=[];try{r=await this.fs.readdir(j.resolve(this.notebookPath.fsPath,t))}catch(o){console.error(o),r=[]}let s=[];for(let o=0;o<r.length;o++){let l=r[o];if(l.match(/^(node_modules|\.git)$/))continue;let d=j.resolve(this.notebookPath.fsPath,t,l),p=await this.getNote(j.relative(this.notebookPath.fsPath,d));p&&(this.notes[p.filePath]=p,this.search.add(p.filePath,p.title,p.config.aliases));let c;try{c=await this.fs.stat(d)}catch(g){console.error(g)}c&&c.isDirectory()&&n&&s.push(this.refreshNotes({dir:j.relative(this.notebookPath.fsPath,d),includeSubdirectories:n,refreshRelations:!1}))}if(await Promise.all(s),a)for(let o in this.notes)await this.processNoteMentionsAndMentionedBy(o);return this.notes}async removeNoteRelations(t){let n=await this.getNote(t);if(!n)return;let a=n.mentions;for(let r in a)this.referenceMap.deleteReferences(r,n.filePath);delete this.notes[n.filePath]}async deleteNote(t,n=!1){let a=this.resolveNoteAbsolutePath(t);(n||await this.fs.exists(a))&&(await this.fs.unlink(a),await this.removeNoteRelations(t),this.search.remove(t))}resolveNoteAbsolutePath(t){return j.isAbsolute(t)?t:j.resolve(this.notebookPath.fsPath,t)}resolveNoteRelativePath(t){return j.isAbsolute(t)?j.relative(this.notebookPath.fsPath,t):t}getNoteMarkdownEngine(t){return t=this.resolveNoteRelativePath(t),t in this.markdownEngines||(this.markdownEngines[t]=new Ve({notebook:this,filePath:this.resolveNoteAbsolutePath(t)})),this.markdownEngines[t]}getNoteMarkdownEngines(){return this.markdownEngines}clearAllNoteMarkdownEngineCaches(){for(let t in this.markdownEngines)this.markdownEngines[t].clearCaches()}};import{escape as vr}from"html-escaper";var Rr={sh:"bash",bash:"bash",c:"c","c++":"cpp",cpp:"cpp",coffee:"coffeescript",coffeescript:"coffeescript","coffee-script":"coffeescript",cs:"csharp",csharp:"csharp",css:"css",scss:"scss",sass:"sass",elm:"elm",elmlang:"elm","elm-lang":"elm",erlang:"erlang",go:"go",html:"html",java:"java",js:"javascript",javascript:"javascript",json:"json",less:"less",objc:"objectivec",objectivec:"objectivec","objective-c":"objectivec",php:"php",py:"python",python:"python",rb:"ruby",ruby:"ruby",text:"text",tex:"latex",xml:"xml",yaml:"yaml",yml:"yaml",yaml_table:"yaml",mermaid:"mermaid",plantuml:"plantuml",puml:"plantuml",wavedrom:"wavedrom",graphviz:"dot",viz:"dot",dot:"dot",erd:"erd",node:"javascript",md:"gfm",diff:"diff"};function zn(e){return e=e.toLowerCase(),Rr[e]||e}function Hn(e){e.languages.iele={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],variable:{pattern:/(@|%)([A-Za-z0-9\\_\\.\\-\\$])[a-zA-Z\\.\\_\\$][0-9a-zA-Z\\.\\_\\-\\$]*/,greedy:!0},string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},keyword:/\b(?:load|store|sload|sstore|iszero|not|add|mul|sub|div|exp|mod|addmod|mulmod|expmod|byte|sext|twos|and|or|xor|shift|lt|le|gt|ge|eq|ne|cmp|sha3|br|call|staticcall|at|send|gaslimit|ret|void|revert|log|create|copycreate|selfdestruct|contract|external|define|public|log2|bswap|calladdress)\b/,label:/(?!\d)(?:[-$.\w]|\\[a-f\d]{2})+:/i,boolean:/\b(?:true|false)\b/,number:/\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/}}function jn(e){e.languages.k={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":/\b(?:strict|avoid|prefer|bracket|non-assoc|seqstrict|left|right|macro-rec|macro|token|notInRules|autoReject|structural|latex|binder|klabel|symbol|format)\b/,keyword:{pattern:/\b(?:syntax\s+(?:priority|priorities|left|right|non-assoc|lexical)|syntax|rule|Id|Int|Bool|String|Token|Lexer|Float|configuration|import|imports|require|requires|Kresult|context\s+alias|context|module|endmodule|claim)\b/,greedy:!0},boolean:/\b(?:true|false)\b/,number:/\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,operator:{pattern:/[<>]=|=>|~>|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/},punctuation:/[{}[\];(),.:]/,tag:{pattern:/<\/?(?!\d)[^\s>/=$<%]+(?:\s(?:\s*[^\s>/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>/:]+:/}},"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>/]+/,inside:{namespace:/^[^\s>/:]+:/}}}}}}var be=ra(Wn());be.default.hooks.add("wrap",e=>{e.type==="keyword"&&e.classes.push(`keyword-${e.content}`)});jn(be.default);Hn(be.default);async function yt(e){e("pre>code").each((t,n)=>{let a=e(n),r=a.text(),s=a.parent();a.replaceWith(vr(r)),s.addClass("language-text")}),e('[data-role="codeBlock"]').each((t,n)=>{let a=e(n);if(a.data("hiddenByEnhancer")||a.data("normalizedInfo").attributes.hide===!0){a.remove();return}let s=a.text(),o=a.data("normalizedInfo"),l=Nr(zn(o.language),s);try{let d=be.default.highlight(s,be.default.languages[l],l);a.html(d)}catch{a.empty().append(e("<code></code>").text(s))}a.addClass(`language-${l}`),o.attributes.class&&(a.addClass(o.attributes.class),Cr(a,s)),o.attributes.highlight&&Or(a,s,o.attributes.highlight),a.removeAttr("data-parsed-info"),a.removeAttr("data-normalized-info")})}function Nr(e,t){return e==="vega"||e==="vega-lite"?(t.match(/^\s*(.)/)??[])[1]==="{"?"json":"yaml":e}function Cr(e,t){if(e.hasClass("numberLines")&&(e.addClass("line-numbers"),e.removeClass("numberLines")),e.hasClass("line-numbers")){if(!t.trim().length)return;let n=t.match(/\n(?!$)/g),a=n?n.length+1:1,r="";for(let s=0;s<a;s++)r+="<span></span>";e.append(`<span aria-hidden="true" class="line-numbers-rows">${r}</span>`)}}function Or(e,t,n){if(!t.trim().length)return;typeof n=="number"?n=[n.toString()]:typeof n=="string"&&(n=n.split(","));let a=t.match(/\n(?!$)/g),r=a?a.length+1:1,s=[];n.forEach(o=>{if(o=o.toString(),o.indexOf("-")>0){let[l,d]=o.split("-").map(g=>parseInt(g,10));if(isNaN(l)||isNaN(d)||l<0||d<0||(l>d&&([l,d]=[d,l]),d>r))return;let p="";for(let g=l;g<=d;g++)p+=`
|
|
326
326
|
`;let c="";for(let g=0;g<l-1;g++)c+=`
|
|
327
327
|
`;s.push(`<div class="line-highlight-wrapper">${c}<div aria-hidden="true" class="line-highlight" data-range="${l}-${d}" data-start="${l}" data-end="${d}">${p}</div></div>`)}else{let l="",d=parseInt(o,10);if(isNaN(d)||d<0||d>r)return;for(let p=0;p<d-1;p++)l+=`
|
|
328
328
|
`;s.push(`<div class="line-highlight-wrapper">${l}<div aria-hidden="true" class="line-highlight" data-range="${o}" data-start="${o}">
|
|
@@ -384,7 +384,7 @@ if (typeof(window['Reveal']) !== 'undefined') {
|
|
|
384
384
|
window["initRevealPresentation"] = async function() {
|
|
385
385
|
${s}
|
|
386
386
|
}
|
|
387
|
-
</script>`,r+s}static{this.AutoPrismThemeMap={"atom-dark.css":"atom-dark.css","atom-light.css":"atom-light.css","atom-material.css":"atom-material.css","github-dark.css":"github-dark.css","github-light.css":"github.css","gothic.css":"github.css","medium.css":"github.css","monokai.css":"monokai.css","newsprint.css":"pen-paper-coffee.css","night.css":"darcula.css","one-dark.css":"one-dark.css","one-light.css":"one-light.css","solarized-light.css":"solarized-light.css","solarized-dark.css":"solarized-dark.css","vue.css":"vue.css"}}static{this.AutoPrismThemeMapForPresentation={"beige.css":"pen-paper-coffee.css","black.css":"one-dark.css","blood.css":"monokai.css","league.css":"okaidia.css","moon.css":"funky.css","night.css":"atom-dark.css","serif.css":"github.css","simple.css":"github.css","sky.css":"default.css","solarized.css":"solarized-light.css","white.css":"default.css"}}getPrismTheme(t=!1,n={}){if(this.notebook.config.codeBlockTheme==="auto.css")if(t){let a=n.presentation&&typeof n.presentation=="object"&&n.presentation.theme?n.presentation.theme:this.notebook.config.revealjsTheme;return e.AutoPrismThemeMapForPresentation[a]||"default.css"}else return e.AutoPrismThemeMap[this.notebook.config.previewTheme]||"default.css";else return this.notebook.config.codeBlockTheme}generateStylesForPreview(t=!1,n={},a=null){let r="";return this.notebook.config.mathRenderingOption==="KaTeX"&&!this.notebook.config.usePandocParser&&(r+=`<link rel="stylesheet" href="${W(R.resolve(U(),"./dependencies/katex/katex.min.css"),a)}">`),r+=`<link rel="stylesheet" href="${W(R.resolve(U(),"./dependencies/font-awesome/css/font-awesome.min.css"),a)}">`,t?(r+=`<link rel="stylesheet" href="${W(R.resolve(U(),"./dependencies/reveal/css/reveal.css"),a)}" >`,r+=`<link rel="stylesheet" href="${W(R.resolve(U(),`./dependencies/reveal/css/theme/${n.presentation&&typeof n.presentation=="object"&&n.presentation.theme?n.presentation.theme:this.notebook.config.revealjsTheme}`),a)}" >`):r+=`<link rel="stylesheet" href="${W(R.resolve(U(),`./styles/preview_theme/${this.notebook.config.previewTheme}`),a)}">`,r+=`<link rel="stylesheet" href="${W(R.resolve(U(),`./styles/prism_theme/${this.getPrismTheme(t,n)}`),a)}">`,r+=`<link rel="stylesheet" media="screen" href="${W(R.resolve(U(),"./styles/style-template.css"),a)}">`,r+=`<link rel="stylesheet" media="screen" href="${W(R.resolve(U(),"./styles/markdown-it-admonition.css"),a)}">`,r+=`<style>${this.notebook.config.globalCss}</style>`,r}generateJSAndCssFilesForPreview(t=[],n=null){let a="";return t.forEach(r=>{let s=r;r[0]==="/"?s=W(R.resolve(this.projectDirectoryPath.
|
|
387
|
+
</script>`,r+s}static{this.AutoPrismThemeMap={"atom-dark.css":"atom-dark.css","atom-light.css":"atom-light.css","atom-material.css":"atom-material.css","github-dark.css":"github-dark.css","github-light.css":"github.css","gothic.css":"github.css","medium.css":"github.css","monokai.css":"monokai.css","newsprint.css":"pen-paper-coffee.css","night.css":"darcula.css","one-dark.css":"one-dark.css","one-light.css":"one-light.css","solarized-light.css":"solarized-light.css","solarized-dark.css":"solarized-dark.css","vue.css":"vue.css"}}static{this.AutoPrismThemeMapForPresentation={"beige.css":"pen-paper-coffee.css","black.css":"one-dark.css","blood.css":"monokai.css","league.css":"okaidia.css","moon.css":"funky.css","night.css":"atom-dark.css","serif.css":"github.css","simple.css":"github.css","sky.css":"default.css","solarized.css":"solarized-light.css","white.css":"default.css"}}getPrismTheme(t=!1,n={}){if(this.notebook.config.codeBlockTheme==="auto.css")if(t){let a=n.presentation&&typeof n.presentation=="object"&&n.presentation.theme?n.presentation.theme:this.notebook.config.revealjsTheme;return e.AutoPrismThemeMapForPresentation[a]||"default.css"}else return e.AutoPrismThemeMap[this.notebook.config.previewTheme]||"default.css";else return this.notebook.config.codeBlockTheme}generateStylesForPreview(t=!1,n={},a=null){let r="";return this.notebook.config.mathRenderingOption==="KaTeX"&&!this.notebook.config.usePandocParser&&(r+=`<link rel="stylesheet" href="${W(R.resolve(U(),"./dependencies/katex/katex.min.css"),a)}">`),r+=`<link rel="stylesheet" href="${W(R.resolve(U(),"./dependencies/font-awesome/css/font-awesome.min.css"),a)}">`,t?(r+=`<link rel="stylesheet" href="${W(R.resolve(U(),"./dependencies/reveal/css/reveal.css"),a)}" >`,r+=`<link rel="stylesheet" href="${W(R.resolve(U(),`./dependencies/reveal/css/theme/${n.presentation&&typeof n.presentation=="object"&&n.presentation.theme?n.presentation.theme:this.notebook.config.revealjsTheme}`),a)}" >`):r+=`<link rel="stylesheet" href="${W(R.resolve(U(),`./styles/preview_theme/${this.notebook.config.previewTheme}`),a)}">`,r+=`<link rel="stylesheet" href="${W(R.resolve(U(),`./styles/prism_theme/${this.getPrismTheme(t,n)}`),a)}">`,r+=`<link rel="stylesheet" media="screen" href="${W(R.resolve(U(),"./styles/style-template.css"),a)}">`,r+=`<link rel="stylesheet" media="screen" href="${W(R.resolve(U(),"./styles/markdown-it-admonition.css"),a)}">`,r+=`<style>${this.notebook.config.globalCss}</style>`,r}generateJSAndCssFilesForPreview(t=[],n=null){let a="";return t.forEach(r=>{let s=r;r[0]==="/"?s=W(R.resolve(this.projectDirectoryPath.fsPath,"."+r),n):r.match(/^file:\/\//)||r.match(/^https?:\/\//)||(s=W(R.resolve(this.fileDirectoryPath,r),n)),s.endsWith(".js")?a+=`<script type="text/javascript" src="${s}"></script>`:a+=`<link rel="stylesheet" href="${s}">`}),a}async generateHTMLTemplateForPreview({inputString:t="",body:n="",webviewScript:a="",scripts:r="",styles:s="",head:o=`<base href="${this.filePath}">`,config:l,vscodePreviewPanel:d=null,contentSecurityPolicy:p="",isVSCodeWebExtension:c}){t||(t=await this.fs.readFile(this.filePath));let g="";a||(a=W(R.resolve(U(),"./webview/preview.js"),d),g=W(R.resolve(U(),"./webview/preview.css"),d)),n||(n="");let{yamlConfig:b,JSAndCssFiles:S,html:m}=await this.parseMD(t,{isForPreview:!0,useRelativeFilePath:!1,hideFrontMatter:!1,vscodePreviewPanel:d}),u=b.isPresentationMode;return`<!DOCTYPE html>
|
|
388
388
|
<html>
|
|
389
389
|
<head>
|
|
390
390
|
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
|
|
@@ -548,10 +548,10 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
548
548
|
</body>
|
|
549
549
|
</html>
|
|
550
550
|
`,R.extname(l)===".html")return await this.fs.writeFile(l,s),l;function y(){E.forEach(w=>{Y.unlink(w,()=>{})})}try{let w=await J({prefix:"crossnote",suffix:".html"});return Y.writeFileSync(w.fd,s),await Bt(w.path,l,p),y(),l}catch(w){throw y(),w}}async pandocExport({runAllCodeChunks:t=!1,openFileAfterGeneration:n=!1}){let a=await this.fs.readFile(this.filePath);this.notebook.config.parserConfig.onWillParseMarkdown&&(a=await this.notebook.config.parserConfig.onWillParseMarkdown(a)),t&&await this.parseMD(a,{useRelativeFilePath:!0,isForPreview:!1,hideFrontMatter:!1,runAllCodeChunks:t});let r={};if(a.startsWith("---")){let o=a.indexOf(`
|
|
551
|
-
---`);if(o>0){let l=a.slice(0,o+4);r=this.processFrontMatter(l,!1).data}}let s=await In(a,{fileDirectoryPath:this.fileDirectoryPath,projectDirectoryPath:this.projectDirectoryPath.
|
|
551
|
+
---`);if(o>0){let l=a.slice(0,o+4);r=this.processFrontMatter(l,!1).data}}let s=await In(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&&se(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(`
|
|
552
552
|
---`);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(R.extname(this.filePath)),"_"+R.extname(this.filePath)),r.path=R.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=`---
|
|
553
553
|
`+Zn.stringify(a)+`---
|
|
554
|
-
`+n),await wn(n,{projectDirectoryPath:this.projectDirectoryPath.
|
|
554
|
+
`+n),await wn(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=nt();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?R.relative(a||this.fileDirectoryPath,R.resolve(this.projectDirectoryPath.fsPath,"."+t)):W(R.resolve(this.projectDirectoryPath.fsPath,"."+t),this.vscodePreviewPanel):n?t:W(R.resolve(a||this.fileDirectoryPath,t),this.vscodePreviewPanel)}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>${r}</th>`,a+=`<td>${this.frontMatterToTable(t[r])}</td>`);return n+="</tr></thead>",a+="</tr></tbody>",`<table>${n}${a}</table>`}else return t}processFrontMatter(t,n=!1){if(t){let a=Ie(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>Failed to parse YAML.</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("<p>[CROSSNOTESLIDE]</p>"),s=r[0];r=r.slice(1);let o="",l=0,d=-1,p=0;for(;l<r.length;){let g=r[l],b=n[l];"data-background-image"in b&&(b["data-background-image"]=this.resolveFilePath(b["data-background-image"],a)),"data-background-video"in b&&(b["data-background-video"]=this.resolveFilePath(b["data-background-video"],a)),"data-background-iframe"in b&&(b["data-background-iframe"]=this.resolveFilePath(b["data-background-iframe"],a));let S=q(b,!1),m=b.class||"",u=b.id?`id="${b.id}"`:"";b.vertical?p+=1:(d+=1,l>0&&n[l-1].vertical&&(o+="</section>",p=0),l<r.length-1&&n[l+1].vertical&&(o+="<section>")),o+=`<section ${S} ${u} class="slide ${m}" data-line="${b.lineNo}" data-h="${d}" data-v="${p}">${g}</section>`,l+=1}l>0&&n[l-1].vertical&&(o+="</section>");let c=ie.load(o);return c("li").each((g,b)=>{let S=c(b),u=(S.html()??"").trim().split(`
|
|
555
555
|
`)[0].match(/<!--(.+?)-->/);if(u){let f=u[1].replace(/\.element:/,"").trim(),h=te(f);for(let E in h)h.hasOwnProperty(E)&&S.attr(E,h[E])}}),`
|
|
556
556
|
<div style="display:none;">${s}</div>
|
|
557
557
|
<div class="reveal">
|
|
@@ -565,7 +565,7 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
565
565
|
`:(l=!l,r+=c+`
|
|
566
566
|
`);o+=1;continue}c.match(/^\[toc\]/i)&&!l&&(c="[CROSSNOTETOC]"),r+=c+`
|
|
567
567
|
`,o+=1}let p=this.notebook.config.pandocPath;return await new Promise((c,g)=>{try{Hr(p,n,{cwd:this.fileDirectoryPath,maxBuffer:1/0},(S,m,u)=>S?g(S):c(u?"<pre>"+u+"</pre>"+m:m)).stdin?.end(r,"utf-8")}catch(b){let S=b.toString();return S.indexOf("Error: write EPIPE")>=0&&(S=`"pandoc" is required to be installed.
|
|
568
|
-
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 le(t,{fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,projectDirectoryPath:this.projectDirectoryPath.
|
|
568
|
+
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 le(t,{fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,projectDirectoryPath:this.projectDirectoryPath.fsPath,forPreview:n.isForPreview,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 p=this.processFrontMatter(d,n.hideFrontMatter),c=p.table,g=p.data||{};typeof g!="object"&&(g={}),a=p.content+a;let b;if(this.notebook.config.usePandocParser)try{let E=g.pandoc_args||[];E instanceof Array||(E=[]),E.find(A=>A.includes("pandoc-citeproc")||A.includes("--defaults"))===void 0&&(g.bibliography||g.references)&&E.push("--citeproc"),E=this.notebook.config.pandocArguments.concat(E),b=await this.pandocRender(a,E)}catch(E){b=`<pre>${E}</pre>`}else b=this.notebook.md.render(a);let S=g.toc||{},m=S.depth_from||1,u=S.depth_to||6,f=S.ordered;this.tocHTML=Gt(l,this.notebook.md.render.bind(this.notebook.md),{ordered:f,depthFrom:m,depthTo:u,tab:" "}),this.headings=l,s&&(b=b.replace(/^\s*<p>\[CROSSNOTETOC\]<\/p>\s*/gm,this.tocHTML));let h=ie.load(b);return await Rt(h,this.notebook.config.mathRenderingOption,this.notebook.config.mathBlockDelimiters,this.notebook.config.katexConfig),await _t({$:h,graphsCache:this.graphsCache,fileDirectoryPath:n.fileDirectoryPath||this.fileDirectoryPath,imageDirectoryPath:Q(this.resolveFilePath(this.notebook.config.imageFolderPath,!1)),plantumlServer:this.notebook.config.plantumlServer,plantumlJarPath:this.notebook.config.plantumlJarPath,kirokiServer:this.notebook.config.krokiServer}),await wt(h,this.codeChunksData,n,this.generateRunOptions()),await yt(h),await It(h,n,this.resolveFilePath.bind(this),this.notebook.config.usePandocParser),this.notebook.config.enableExtendedTableSyntax&&await Tt(h),b=c+h("head").html()+h("body").html(),r.length&&(b=this.parseSlides(b,r,n.useRelativeFilePath),g&&(g.isPresentationMode=!0)),this.notebook.config.parserConfig.onDidParseMarkdown&&(b=await this.notebook.config.parserConfig.onDidParseMarkdown(b)),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:b,markdown:t,tocHTML:this.tocHTML,yamlConfig:g,JSAndCssFiles:o})}runCodeChunks(){return At(this.codeChunksData,this.generateRunOptions())}runCodeChunk(t){return Ke(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,b)=>{let S=b.length,m=0;for(let u=g+1;u<g+6&&u<S;u++)if(b[u].startsWith("<!-- code_chunk_output -->")){m=u;break}if(m){let u=m+1;for(;u<S&&!b[u].startsWith("<!-- /code_chunk_output -->");)u+=1;let f="";for(let E=m+2;E<u-1;E++)f+=b[E]+`
|
|
569
569
|
`;if(f===n+`
|
|
570
570
|
`)return"";let h=[...b.slice(0,m+2),n,...b.slice(u-1)];return await this.notebook.fs.writeFile(a,h.join(`
|
|
571
571
|
`)),""}else{let u=[...b.slice(0,g+1),`
|
package/out/styles/preview.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
body,html{width:100%}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,.66);border:4px solid rgba(150,150,150,.66);background-clip:content-box}.crossnote::-webkit-scrollbar{width:8px}.crossnote::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.crossnote::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,.66);border:4px solid rgba(150,150,150,.66);background-clip:content-box}.preview-container{width:100%;margin:0;padding:0;box-sizing:border-box}.preview-container .btn{display:inline-block;color:#99aeb8;text-shadow:none;border:1px solid #171e22;background-color:#32424a;background-image:linear-gradient(#364850,#32424a);height:auto;padding:0 .8em;font-size:1em;line-height:2em;margin-bottom:0;font-weight:400;text-align:center;vertical-align:middle;border:none;border-radius:3px;white-space:nowrap;cursor:pointer;z-index:0;user-select:none;box-sizing:border-box}.preview-container
|
|
1
|
+
body,html{width:100%}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,.66);border:4px solid rgba(150,150,150,.66);background-clip:content-box}.crossnote::-webkit-scrollbar{width:8px}.crossnote::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.crossnote::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,.66);border:4px solid rgba(150,150,150,.66);background-clip:content-box}.preview-container{width:100%;margin:0;padding:0;box-sizing:border-box}.preview-container ul{list-style:disc}.preview-container ol{list-style:decimal}.preview-container .btn{display:inline-block;color:#99aeb8;text-shadow:none;border:1px solid #171e22;background-color:#32424a;background-image:linear-gradient(#364850,#32424a);height:auto;padding:0 .8em;font-size:1em;line-height:2em;margin-bottom:0;font-weight:400;text-align:center;vertical-align:middle;border:none;border-radius:3px;white-space:nowrap;cursor:pointer;z-index:0;user-select:none;box-sizing:border-box}.preview-container.show-sidebar-toc .md-sidebar-toc{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;position:fixed;top:0;right:0;width:268px;height:100%;padding:32px 0 12px 0;overflow:auto;background-color:#fff;font-size:14px;box-shadow:-4px 0 12px rgba(150,150,150,.33);box-sizing:border-box}.preview-container.show-sidebar-toc .md-sidebar-toc a{text-decoration:none}.preview-container.show-sidebar-toc .md-sidebar-toc .md-toc{padding:0 16px}.preview-container.show-sidebar-toc .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link{display:inline;padding:.25rem 0}.preview-container.show-sidebar-toc .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link div,.preview-container.show-sidebar-toc .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link p{display:inline}.preview-container.show-sidebar-toc .md-sidebar-toc .md-toc .md-toc-link-wrapper.highlighted .md-toc-link{font-weight:800}.preview-container.show-sidebar-toc .crossnote{width:calc(100% - 268px)}.preview-container .crossnote[data-for=preview]{left:0;top:0;margin:0;padding:2em;overflow:auto;display:block;box-sizing:border-box}.preview-container .crossnote[data-for=preview] .code-chunk{position:relative}.preview-container .crossnote[data-for=preview] .code-chunk pre{cursor:text}.preview-container .crossnote[data-for=preview] .code-chunk .btn-group{position:absolute;right:0;top:0;display:none}.preview-container .crossnote[data-for=preview] .code-chunk .btn-group .run-all-btn,.preview-container .crossnote[data-for=preview] .code-chunk .btn-group .run-btn{float:right;margin-left:4px;border-radius:3px;font-size:.8em;color:#eee;background-color:#528bff;background-image:none;border:none}.preview-container .crossnote[data-for=preview] .code-chunk .btn-group .run-all-btn:hover,.preview-container .crossnote[data-for=preview] .code-chunk .btn-group .run-btn:hover{background-color:#4b7fe8;cursor:pointer}.preview-container .crossnote[data-for=preview] .code-chunk:hover .btn-group{display:block}.preview-container .crossnote[data-for=preview] .code-chunk .status{position:absolute;right:0;top:0;font-size:.85em;color:inherit;padding:2px 6px;background-color:rgba(0,0,0,.04);display:none}.preview-container .crossnote[data-for=preview] .code-chunk.running .btn-group{display:none}.preview-container .crossnote[data-for=preview] .code-chunk.running .status{display:block}body[data-presentation-mode] .crossnote[data-for=preview]{padding:0!important;width:100%;height:100%}body:not([data-presentation-mode]) .crossnote[data-for=preview]{height:auto}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .newpage,.markdown-preview .pagebreak{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center!important}.markdown-preview:not([data-for=preview]) .code-chunk .btn-group{display:none}.markdown-preview:not([data-for=preview]) .code-chunk .status{display:none}.markdown-preview:not([data-for=preview]) .code-chunk .output-div{margin-bottom:16px}.markdown-preview .md-toc{padding:0}.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link{display:inline;padding:.25rem 0}.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link div,.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link p{display:inline}.markdown-preview .md-toc .md-toc-link-wrapper.highlighted .md-toc-link{font-weight:800}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,.66);border:4px solid rgba(150,150,150,.66);background-clip:content-box}html body[for=html-export]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{font-size:14px!important;padding:1em}}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,.66);border:4px solid rgba(150,150,150,.66);background-clip:content-box}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc{padding:0 16px}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link{display:inline;padding:.25rem 0}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link div,html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link p{display:inline}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper.highlighted .md-toc-link{font-weight:800}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% - 300px);padding:2em calc(50% - 457px - 300px/2);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for=html-export]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for=html-export]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
|
|
1
|
+
.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .newpage,.markdown-preview .pagebreak{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center!important}.markdown-preview:not([data-for=preview]) .code-chunk .btn-group{display:none}.markdown-preview:not([data-for=preview]) .code-chunk .status{display:none}.markdown-preview:not([data-for=preview]) .code-chunk .output-div{margin-bottom:16px}.markdown-preview .md-toc{padding:0}.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link{display:inline;padding:.25rem 0}.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link div,.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link p{display:inline}.markdown-preview .md-toc .md-toc-link-wrapper.highlighted .md-toc-link{font-weight:800}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,.66);border:4px solid rgba(150,150,150,.66);background-clip:content-box}html body[for=html-export]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{font-size:14px!important;padding:1em}}@media print{html body[for=html-export]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for=html-export]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,.66);border:4px solid rgba(150,150,150,.66);background-clip:content-box}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc{padding:0 16px}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link{display:inline;padding:.25rem 0}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link div,html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link p{display:inline}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper.highlighted .md-toc-link{font-weight:800}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% - 300px);padding:2em calc(50% - 457px - 300px/2);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for=html-export]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for=html-export]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
|