crossnote 0.9.41 → 0.9.43
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/README.md +8 -8
- package/out/cjs/index.cjs +342 -332
- package/out/cli/index.cjs +532 -261
- package/out/dependencies/README.md +6 -3
- package/out/dependencies/katex/katex-swap.min.css +1 -1
- package/out/dependencies/katex/katex.min.css +1 -1
- package/out/dependencies/mermaid/mermaid.min.js +1268 -1315
- package/out/esm/index.mjs +320 -310
- package/out/server-app/server-app.css +1 -1
- package/out/types/src/custom-markdown-it-features/math.d.ts +1 -0
- package/out/types/src/markdown-engine/index.d.ts +1 -0
- package/out/types/src/markdown-engine/mermaid-export.d.ts +2 -0
- package/out/types/src/markdown-engine/mermaid-polyfill.d.ts +1 -0
- package/out/types/src/markdown-engine/transformer.d.ts +2 -0
- package/out/types/src/notebook/index.d.ts +1 -1
- package/out/types/src/notebook/types.d.ts +2 -1
- package/out/types/src/render-enhancers/resolved-image-paths.d.ts +1 -0
- package/out/types/src/renderers/csv.d.ts +1 -0
- package/out/types/src/utility.d.ts +6 -0
- package/out/types/src/webview/lib/picture-color-scheme.d.ts +1 -0
- package/out/types/src/webview/lib/source-text-map.d.ts +25 -0
- package/out/types/test/browser/mermaid-export.spec.d.ts +1 -0
- package/out/types/test/chrome-export.test.d.ts +1 -0
- package/out/types/test/csv.test.d.ts +1 -0
- package/out/types/test/extended-table-syntax.test.d.ts +1 -0
- package/out/types/test/fence-resync.test.d.ts +1 -0
- package/out/types/test/file-url-suffix.test.d.ts +1 -0
- package/out/types/test/import-absolute-paths.test.d.ts +1 -0
- package/out/types/test/import-extensionless.test.d.ts +1 -0
- package/out/types/test/katex-vendor.test.d.ts +1 -0
- package/out/types/test/mermaid-theme.test.d.ts +1 -0
- package/out/types/test/pandoc-math-method.test.d.ts +1 -0
- package/out/types/test/picture-color-scheme.test.d.ts +1 -0
- package/out/types/test/resolved-image-srcset.test.d.ts +1 -0
- package/out/types/test/source-text-map.test.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/out/webview/backlinks.css +1 -1
- package/out/webview/backlinks.js +4 -4
- package/out/webview/graph-view.css +1 -1
- package/out/webview/preview.css +1 -1
- package/out/webview/preview.js +205 -202
- package/package.json +6 -7
package/out/cli/index.cjs
CHANGED
|
@@ -23370,7 +23370,7 @@ var path27 = __toESM(require("path"));
|
|
|
23370
23370
|
var fs21 = __toESM(require("fs"));
|
|
23371
23371
|
var http = __toESM(require("http"));
|
|
23372
23372
|
var path26 = __toESM(require("path"));
|
|
23373
|
-
var
|
|
23373
|
+
var import_url3 = require("url");
|
|
23374
23374
|
var import_crypto_js2 = require("crypto-js");
|
|
23375
23375
|
|
|
23376
23376
|
// src/markdown-engine/heading-id-generator.ts
|
|
@@ -23845,6 +23845,31 @@ function addFileProtocol(filePath, vscodePreviewPanel) {
|
|
|
23845
23845
|
}
|
|
23846
23846
|
return filePath;
|
|
23847
23847
|
}
|
|
23848
|
+
function splitUrlReference(url) {
|
|
23849
|
+
const index = url.search(/[?#]/);
|
|
23850
|
+
const rawPath = index === -1 ? url : url.slice(0, index);
|
|
23851
|
+
const suffix = index === -1 ? "" : url.slice(index);
|
|
23852
|
+
try {
|
|
23853
|
+
return { path: decodeURIComponent(rawPath), suffix };
|
|
23854
|
+
} catch {
|
|
23855
|
+
return { path: rawPath, suffix };
|
|
23856
|
+
}
|
|
23857
|
+
}
|
|
23858
|
+
function appendUrlSuffix(url, suffix) {
|
|
23859
|
+
if (!suffix || url.startsWith("data:")) {
|
|
23860
|
+
return url;
|
|
23861
|
+
}
|
|
23862
|
+
if (suffix[0] === "?" && url.includes("?")) {
|
|
23863
|
+
return `${url}&${suffix.slice(1)}`;
|
|
23864
|
+
}
|
|
23865
|
+
return url + suffix;
|
|
23866
|
+
}
|
|
23867
|
+
function escapeUrlPath(filePath) {
|
|
23868
|
+
return filePath.replace(/\\/g, "/").replace(
|
|
23869
|
+
/[%#? ()]/g,
|
|
23870
|
+
(c) => "%" + c.charCodeAt(0).toString(16).toUpperCase()
|
|
23871
|
+
);
|
|
23872
|
+
}
|
|
23848
23873
|
function removeFileProtocol(filePath) {
|
|
23849
23874
|
const regex = /^(?:(?:file|(vscode)-(?:webview-)?resource|vscode--resource):\/+)(.*)/m;
|
|
23850
23875
|
return filePath.replace(regex, (m, isVSCode, rest) => {
|
|
@@ -23937,7 +23962,7 @@ var import_child_process11 = require("child_process");
|
|
|
23937
23962
|
var import_copy_anything = require("copy-anything");
|
|
23938
23963
|
var import_crypto_js = __toESM(require("crypto-js"));
|
|
23939
23964
|
var fs14 = __toESM(require("fs"));
|
|
23940
|
-
var
|
|
23965
|
+
var import_html_escaper14 = require("html-escaper");
|
|
23941
23966
|
var path19 = __toESM(require("path"));
|
|
23942
23967
|
var YAML7 = __toESM(require("yaml"));
|
|
23943
23968
|
|
|
@@ -24102,7 +24127,7 @@ function ebookConvert(src, dest, config = {}) {
|
|
|
24102
24127
|
args.push(arg);
|
|
24103
24128
|
});
|
|
24104
24129
|
(0, import_mkdirp.mkdirp)(path3.dirname(dest)).then(() => {
|
|
24105
|
-
(0, import_child_process.execFile)("ebook-convert", args, (error2) => {
|
|
24130
|
+
(0, import_child_process.execFile)("ebook-convert", args, { windowsHide: true }, (error2) => {
|
|
24106
24131
|
if (error2) {
|
|
24107
24132
|
return reject(error2.toString());
|
|
24108
24133
|
} else {
|
|
@@ -24300,6 +24325,7 @@ var import_html_escaper2 = require("html-escaper");
|
|
|
24300
24325
|
var less = __toESM(require("less"));
|
|
24301
24326
|
var Papa = __toESM(require("papaparse"));
|
|
24302
24327
|
var path5 = __toESM(require("path"));
|
|
24328
|
+
var import_url2 = require("url");
|
|
24303
24329
|
|
|
24304
24330
|
// src/lib/block-attributes/normalizeBlockAttributes.ts
|
|
24305
24331
|
var import_case_anything = require("case-anything");
|
|
@@ -24575,14 +24601,18 @@ function toSVGMarkdown(pdfFilePath, {
|
|
|
24575
24601
|
svgDirectoryPath = SVG_DIRECTORY_PATH;
|
|
24576
24602
|
}
|
|
24577
24603
|
const svgFilePrefix = compute_checksum_default(pdfFilePath) + "_";
|
|
24578
|
-
const task = (0, import_child_process2.spawn)(
|
|
24579
|
-
|
|
24580
|
-
|
|
24581
|
-
|
|
24582
|
-
|
|
24583
|
-
|
|
24584
|
-
|
|
24585
|
-
|
|
24604
|
+
const task = (0, import_child_process2.spawn)(
|
|
24605
|
+
"pdf2svg",
|
|
24606
|
+
[
|
|
24607
|
+
pdfFilePath,
|
|
24608
|
+
path4.resolve(
|
|
24609
|
+
svgDirectoryPath ?? `/tmp/crossnote_pdf`,
|
|
24610
|
+
svgFilePrefix + "%d.svg"
|
|
24611
|
+
),
|
|
24612
|
+
"all"
|
|
24613
|
+
],
|
|
24614
|
+
{ windowsHide: true }
|
|
24615
|
+
);
|
|
24586
24616
|
const chunks = [];
|
|
24587
24617
|
task.stdout.on("data", (chunk) => {
|
|
24588
24618
|
chunks.push(chunk);
|
|
@@ -24939,6 +24969,13 @@ async function downloadFileIfNecessary(filePath) {
|
|
|
24939
24969
|
await fs3.writeFile(localFilePath, Buffer.from(buffer));
|
|
24940
24970
|
return localFilePath;
|
|
24941
24971
|
}
|
|
24972
|
+
async function isFile(notebook, filePath) {
|
|
24973
|
+
try {
|
|
24974
|
+
return (await notebook.fs.stat(filePath)).isFile();
|
|
24975
|
+
} catch {
|
|
24976
|
+
return false;
|
|
24977
|
+
}
|
|
24978
|
+
}
|
|
24942
24979
|
async function loadFile(filePath, {
|
|
24943
24980
|
fileDirectoryPath,
|
|
24944
24981
|
imageDirectoryPath,
|
|
@@ -24984,6 +25021,19 @@ async function loadFile(filePath, {
|
|
|
24984
25021
|
}
|
|
24985
25022
|
}
|
|
24986
25023
|
var BLOCK_ID_RE = /(?<!\s)\s+\^([a-zA-Z0-9_-]+)$/;
|
|
25024
|
+
function absoluteImportPath(target, pathImpl = path5) {
|
|
25025
|
+
if (/^file:\/\//i.test(target)) {
|
|
25026
|
+
try {
|
|
25027
|
+
return (0, import_url2.fileURLToPath)(target);
|
|
25028
|
+
} catch {
|
|
25029
|
+
return null;
|
|
25030
|
+
}
|
|
25031
|
+
}
|
|
25032
|
+
if (!target.startsWith("/") && pathImpl.isAbsolute(target)) {
|
|
25033
|
+
return target;
|
|
25034
|
+
}
|
|
25035
|
+
return null;
|
|
25036
|
+
}
|
|
24987
25037
|
async function transformMarkdown(inputString, {
|
|
24988
25038
|
fileDirectoryPath = "",
|
|
24989
25039
|
projectDirectoryPath = "",
|
|
@@ -25122,7 +25172,15 @@ async function transformMarkdown(inputString, {
|
|
|
25122
25172
|
}
|
|
25123
25173
|
if (!inCodeBlock) {
|
|
25124
25174
|
lastOpeningCodeBlockFence = currentCodeBlockFence;
|
|
25125
|
-
} else if (lastOpeningCodeBlockFence !== null &&
|
|
25175
|
+
} else if (lastOpeningCodeBlockFence !== null && // A closing fence carries no info string (CommonMark). Treating
|
|
25176
|
+
// "```bash" as a closer desyncs this tracker from markdown-it
|
|
25177
|
+
// whenever markdown-it auto-closes a fence at a container
|
|
25178
|
+
// boundary (e.g. a list item ends while its fence is open):
|
|
25179
|
+
// every later bare "```" is then misread as an opener, gets
|
|
25180
|
+
// {data-source-line=…} appended — which makes it invalid as a
|
|
25181
|
+
// closer — and everything below collapses into one code block
|
|
25182
|
+
// (vscode-mpe#2337).
|
|
25183
|
+
rest.trim() === "" && currentCodeBlockFence.trim().length === lastOpeningCodeBlockFence.trim().length) {
|
|
25126
25184
|
lastOpeningCodeBlockFence = null;
|
|
25127
25185
|
}
|
|
25128
25186
|
i = end + 1;
|
|
@@ -25342,9 +25400,10 @@ async function transformMarkdown(inputString, {
|
|
|
25342
25400
|
continue;
|
|
25343
25401
|
}
|
|
25344
25402
|
const importMatch = line.match(/^(\s*)@import(\s+)"([^"]+)";?/);
|
|
25345
|
-
const
|
|
25403
|
+
const lineImageMatch = line.match(
|
|
25346
25404
|
/^(\s*)!\[([^\]]*)\]\(([^)]+)\)(?:{([^}]*)})?(\s*)$/
|
|
25347
25405
|
);
|
|
25406
|
+
const imageImportMatch = lineImageMatch && !/^\s*data:/i.test(lineImageMatch[3]) ? lineImageMatch : null;
|
|
25348
25407
|
const wikilinkImportMatch = line.match(
|
|
25349
25408
|
/^(\s*)!\[\[(.+?)\]\](?:{([^}]*)})?\s*$/
|
|
25350
25409
|
);
|
|
@@ -25400,10 +25459,15 @@ async function transformMarkdown(inputString, {
|
|
|
25400
25459
|
config["data-source-line"] = lineNo + 1;
|
|
25401
25460
|
}
|
|
25402
25461
|
let absoluteFilePath;
|
|
25403
|
-
|
|
25462
|
+
const absoluteImport = absoluteImportPath(filePath);
|
|
25463
|
+
if (absoluteImport) {
|
|
25464
|
+
absoluteFilePath = absoluteImport;
|
|
25465
|
+
} else if (protocolsWhiteListRegExp && filePath.match(protocolsWhiteListRegExp)) {
|
|
25404
25466
|
absoluteFilePath = filePath;
|
|
25405
25467
|
} else if (filePath.startsWith("/")) {
|
|
25406
25468
|
absoluteFilePath = path5.resolve(projectDirectoryPath, "." + filePath);
|
|
25469
|
+
} else if (!wikilinkImportMatch && !path5.extname(filePath) && await isFile(notebook, path5.resolve(fileDirectoryPath, filePath))) {
|
|
25470
|
+
absoluteFilePath = path5.resolve(fileDirectoryPath, filePath);
|
|
25407
25471
|
} else {
|
|
25408
25472
|
const currentRelativeDir = path5.relative(
|
|
25409
25473
|
projectDirectoryPath,
|
|
@@ -25435,24 +25499,25 @@ async function transformMarkdown(inputString, {
|
|
|
25435
25499
|
lineNo = lineNo + 1;
|
|
25436
25500
|
outputString = outputString + output2;
|
|
25437
25501
|
continue;
|
|
25438
|
-
} else if (extname14.match(/^\.(apng|avif|gif|jpeg|jpg|png|svg|bmp|webp|emf)/) ||
|
|
25502
|
+
} else if (extname14.match(/^\.(apng|avif|gif|jpeg|jpg|png|svg|bmp|webp|emf)/) || // NOTE: For example, for github image like: 
|
|
25503
|
+
// A local file without an extension is an image only when written
|
|
25504
|
+
// as ``; `@import "Caddyfile"` is shown as a code block below.
|
|
25505
|
+
extname14 === "" && (absoluteFilePath === filePath || !!imageImportMatch)) {
|
|
25439
25506
|
if (importMatch || wikilinkImportMatch) {
|
|
25440
25507
|
let imageSrc = filesCache[filePath];
|
|
25441
25508
|
if (!imageSrc) {
|
|
25442
25509
|
if (protocolsWhiteListRegExp && filePath.match(protocolsWhiteListRegExp)) {
|
|
25443
25510
|
imageSrc = filePath;
|
|
25444
|
-
} else if (useRelativeFilePath) {
|
|
25445
|
-
imageSrc = path5.relative(fileDirectoryPath, absoluteFilePath);
|
|
25446
|
-
if (!forMarkdownExport) {
|
|
25447
|
-
imageSrc += "?" + (timestamp ?? Math.random());
|
|
25448
|
-
}
|
|
25449
25511
|
} else {
|
|
25450
|
-
imageSrc =
|
|
25512
|
+
imageSrc = useRelativeFilePath ? escapeUrlPath(
|
|
25513
|
+
path5.relative(fileDirectoryPath, absoluteFilePath)
|
|
25514
|
+
) : "/" + escapeUrlPath(
|
|
25515
|
+
path5.relative(projectDirectoryPath, absoluteFilePath)
|
|
25516
|
+
);
|
|
25451
25517
|
if (!forMarkdownExport) {
|
|
25452
25518
|
imageSrc += "?" + (timestamp ?? Math.random());
|
|
25453
25519
|
}
|
|
25454
25520
|
}
|
|
25455
|
-
imageSrc = imageSrc.replace(/ /g, "%20").replace(/\\/g, "/");
|
|
25456
25521
|
filesCache[filePath] = imageSrc;
|
|
25457
25522
|
}
|
|
25458
25523
|
output = "![";
|
|
@@ -25887,7 +25952,8 @@ function toSVGMarkdown2(texFilePath, {
|
|
|
25887
25952
|
}) {
|
|
25888
25953
|
return new Promise((resolve21, reject) => {
|
|
25889
25954
|
const task = (0, import_child_process3.spawn)(latexEngine, [texFilePath], {
|
|
25890
|
-
cwd: path6.dirname(texFilePath)
|
|
25955
|
+
cwd: path6.dirname(texFilePath),
|
|
25956
|
+
windowsHide: true
|
|
25891
25957
|
});
|
|
25892
25958
|
const chunks = [];
|
|
25893
25959
|
task.stdout.on("data", (chunk) => {
|
|
@@ -26025,7 +26091,10 @@ except Exception:
|
|
|
26025
26091
|
args.push(savePath);
|
|
26026
26092
|
}
|
|
26027
26093
|
return await new Promise((resolve21) => {
|
|
26028
|
-
const task = (0, import_child_process4.spawn)(cmd, args, {
|
|
26094
|
+
const task = (0, import_child_process4.spawn)(cmd, args, {
|
|
26095
|
+
cwd: fileDirectoryPath,
|
|
26096
|
+
windowsHide: true
|
|
26097
|
+
});
|
|
26029
26098
|
if (normalizedAttributes["stdin"]) {
|
|
26030
26099
|
task.stdin.write(content);
|
|
26031
26100
|
}
|
|
@@ -26120,23 +26189,27 @@ var PlantUMLTask = class {
|
|
|
26120
26189
|
});
|
|
26121
26190
|
}
|
|
26122
26191
|
startTask() {
|
|
26123
|
-
this.task = (0, import_child_process5.spawn)(
|
|
26124
|
-
"
|
|
26125
|
-
|
|
26126
|
-
|
|
26127
|
-
|
|
26128
|
-
|
|
26129
|
-
|
|
26130
|
-
|
|
26131
|
-
|
|
26132
|
-
|
|
26133
|
-
|
|
26134
|
-
|
|
26135
|
-
|
|
26136
|
-
|
|
26137
|
-
|
|
26138
|
-
|
|
26139
|
-
|
|
26192
|
+
this.task = (0, import_child_process5.spawn)(
|
|
26193
|
+
"java",
|
|
26194
|
+
[
|
|
26195
|
+
"-Djava.awt.headless=true",
|
|
26196
|
+
"-Dfile.encoding=UTF-8",
|
|
26197
|
+
"-Dplantuml.include.path=" + [
|
|
26198
|
+
this.fileDirectoryPath
|
|
26199
|
+
/*getExtensionConfigPath()*/
|
|
26200
|
+
].join(
|
|
26201
|
+
path8.delimiter
|
|
26202
|
+
),
|
|
26203
|
+
"-jar",
|
|
26204
|
+
this.plantumlJarPath,
|
|
26205
|
+
// '-graphvizdot', 'exe'
|
|
26206
|
+
"-pipe",
|
|
26207
|
+
"-tsvg",
|
|
26208
|
+
"-charset",
|
|
26209
|
+
"UTF-8"
|
|
26210
|
+
],
|
|
26211
|
+
{ windowsHide: true }
|
|
26212
|
+
);
|
|
26140
26213
|
this.task.stdout.on("data", (chunk) => {
|
|
26141
26214
|
let data = chunk.toString();
|
|
26142
26215
|
this.chunks += data;
|
|
@@ -26291,7 +26364,7 @@ async function svgElementToPNGFile(svgElement, pngFilePath, imageMagickPath = ""
|
|
|
26291
26364
|
const args = [info.path, pngFilePath];
|
|
26292
26365
|
try {
|
|
26293
26366
|
if (imageMagickPath && imageMagickPath.length) {
|
|
26294
|
-
await (0, import_child_process6.execFileSync)(imageMagickPath, args);
|
|
26367
|
+
await (0, import_child_process6.execFileSync)(imageMagickPath, args, { windowsHide: true });
|
|
26295
26368
|
} else {
|
|
26296
26369
|
await import_imagemagick_cli.default.exec(`convert ${args.join(" ")}`);
|
|
26297
26370
|
}
|
|
@@ -26332,6 +26405,9 @@ async function mermaidToPNG(mermaidCode, pngFilePath, projectDirectoryPath, them
|
|
|
26332
26405
|
],
|
|
26333
26406
|
{
|
|
26334
26407
|
cwd: projectDirectoryPath,
|
|
26408
|
+
// Without this, the `cmd.exe` wrapper cross-spawn uses on Windows
|
|
26409
|
+
// flashes a console window per diagram (CREATE_NO_WINDOW).
|
|
26410
|
+
windowsHide: true,
|
|
26335
26411
|
// Match the old `execFileSync` behavior: the CLI's errors stream to
|
|
26336
26412
|
// our stderr; neither stream is read here.
|
|
26337
26413
|
stdio: ["ignore", "ignore", "inherit"]
|
|
@@ -26388,6 +26464,8 @@ async function render3(wavedromCode, projectDirectoryPath) {
|
|
|
26388
26464
|
try {
|
|
26389
26465
|
const result = import_cross_spawn2.default.sync("npx", ["wavedrom-cli", "-i", info.path], {
|
|
26390
26466
|
cwd: projectDirectoryPath,
|
|
26467
|
+
// Hide the `cmd.exe` wrapper window cross-spawn uses on Windows.
|
|
26468
|
+
windowsHide: true,
|
|
26391
26469
|
// stdout carries the SVG; stderr streams to our console like the old
|
|
26392
26470
|
// `execFileSync` call did.
|
|
26393
26471
|
stdio: ["ignore", "pipe", "inherit"]
|
|
@@ -26661,7 +26739,9 @@ ${error}
|
|
|
26661
26739
|
content,
|
|
26662
26740
|
pngFilePath,
|
|
26663
26741
|
projectDirectoryPath,
|
|
26664
|
-
|
|
26742
|
+
// An explicit mermaidConfig.theme (config script) wins, same as
|
|
26743
|
+
// in the preview init script.
|
|
26744
|
+
notebook.config.mermaidConfig?.theme || notebook.config.mermaidTheme
|
|
26665
26745
|
);
|
|
26666
26746
|
let displayPNGFilePath;
|
|
26667
26747
|
if (useRelativeFilePath) {
|
|
@@ -27291,6 +27371,10 @@ async function pandocConvert(text, {
|
|
|
27291
27371
|
codeChunksData,
|
|
27292
27372
|
graphsCache,
|
|
27293
27373
|
addOptionsStr: true,
|
|
27374
|
+
// The cache-busting `?0.5319…` query suffix is a webview device; pandoc
|
|
27375
|
+
// resolves image paths literally, so `assets/x.png?0.53…` is a missing
|
|
27376
|
+
// file and the image is dropped from the output (vscode-mpe#2350).
|
|
27377
|
+
cacheBust: false,
|
|
27294
27378
|
notebook
|
|
27295
27379
|
});
|
|
27296
27380
|
await mkdirp3.sync(path11.dirname(outputFilePath));
|
|
@@ -27298,7 +27382,7 @@ async function pandocConvert(text, {
|
|
|
27298
27382
|
const program = (0, import_child_process7.execFile)(
|
|
27299
27383
|
notebook.config.pandocPath,
|
|
27300
27384
|
args,
|
|
27301
|
-
{ cwd: fileDirectoryPath },
|
|
27385
|
+
{ cwd: fileDirectoryPath, windowsHide: true },
|
|
27302
27386
|
(error) => {
|
|
27303
27387
|
if (error) {
|
|
27304
27388
|
return reject(error.toString());
|
|
@@ -27318,6 +27402,7 @@ function princeConvert(src, dest) {
|
|
|
27318
27402
|
(0, import_child_process8.execFile)(
|
|
27319
27403
|
"prince",
|
|
27320
27404
|
[src, "--javascript", "-o", dest],
|
|
27405
|
+
{ windowsHide: true },
|
|
27321
27406
|
(error) => {
|
|
27322
27407
|
if (error) {
|
|
27323
27408
|
let errorMessage = error.toString();
|
|
@@ -30803,6 +30888,24 @@ var html5_embed_default = (md, notebook) => {
|
|
|
30803
30888
|
};
|
|
30804
30889
|
|
|
30805
30890
|
// src/custom-markdown-it-features/math.ts
|
|
30891
|
+
var ENDS_WITH_WORD_CHAR = /[\p{L}\p{M}\p{N}]$/u;
|
|
30892
|
+
var TEX_START = /^[\^_\\{]/;
|
|
30893
|
+
var AMOUNT = /^(?:\d|\s\d)/;
|
|
30894
|
+
var TEX_CHARS = /[\\^_{}=+\-*/<>]/;
|
|
30895
|
+
var SPACE = /\s/;
|
|
30896
|
+
function isDollarMathSpan(src, open2, close) {
|
|
30897
|
+
if (ENDS_WITH_WORD_CHAR.test(src.slice(Math.max(0, open2 - 2), open2)) && !TEX_START.test(src.slice(open2 + 1, open2 + 2))) {
|
|
30898
|
+
return false;
|
|
30899
|
+
}
|
|
30900
|
+
const content = src.slice(open2 + 1, close);
|
|
30901
|
+
if (AMOUNT.test(content) && SPACE.test(content) && !TEX_CHARS.test(content)) {
|
|
30902
|
+
return false;
|
|
30903
|
+
}
|
|
30904
|
+
if (SPACE.test(src.charAt(close - 1))) {
|
|
30905
|
+
return false;
|
|
30906
|
+
}
|
|
30907
|
+
return !AMOUNT.test(src.slice(close + 1, close + 3));
|
|
30908
|
+
}
|
|
30806
30909
|
var math_default = (md, notebook) => {
|
|
30807
30910
|
md.block.ruler.before(
|
|
30808
30911
|
"lheading",
|
|
@@ -30916,6 +31019,9 @@ var math_default = (md, notebook) => {
|
|
|
30916
31019
|
} else {
|
|
30917
31020
|
return false;
|
|
30918
31021
|
}
|
|
31022
|
+
if (openTag === "$" && closeTag === "$" && !isDollarMathSpan(state.src, state.pos, end)) {
|
|
31023
|
+
return false;
|
|
31024
|
+
}
|
|
30919
31025
|
if (content && !silent) {
|
|
30920
31026
|
const token = state.push("math", "", 0);
|
|
30921
31027
|
token.content = content.trim();
|
|
@@ -31036,6 +31142,11 @@ function replaceDelimited(html, openTag, closeTag, displayMode, notebook) {
|
|
|
31036
31142
|
i += openTag.length;
|
|
31037
31143
|
continue;
|
|
31038
31144
|
}
|
|
31145
|
+
if (openTag === "$" && closeTag === "$" && !isDollarMathSpan(html, i, end)) {
|
|
31146
|
+
out += html[i];
|
|
31147
|
+
i += 1;
|
|
31148
|
+
continue;
|
|
31149
|
+
}
|
|
31039
31150
|
const content = html.slice(i + openTag.length, end).trim();
|
|
31040
31151
|
out += parse_math_default({
|
|
31041
31152
|
content,
|
|
@@ -31071,6 +31182,9 @@ var tag_default = (md, notebook) => {
|
|
|
31071
31182
|
if (!notebook.config.enableTagSyntax || state.src.charCodeAt(state.pos) !== 35) {
|
|
31072
31183
|
return false;
|
|
31073
31184
|
}
|
|
31185
|
+
if (state.linkLevel > 0) {
|
|
31186
|
+
return false;
|
|
31187
|
+
}
|
|
31074
31188
|
if (state.pos > 0) {
|
|
31075
31189
|
const prev = state.src.charCodeAt(state.pos - 1);
|
|
31076
31190
|
if (prev === 47 || prev === 38 || prev === 63 || prev === 92 || prev >= 48 && prev <= 57 || prev >= 65 && prev <= 90 || prev >= 97 && prev <= 122 || prev === 95 || prev === 45) {
|
|
@@ -32023,6 +32137,12 @@ function isSamePath(a, b) {
|
|
|
32023
32137
|
}
|
|
32024
32138
|
return a === b;
|
|
32025
32139
|
}
|
|
32140
|
+
function normalizeNotebookConfig(config) {
|
|
32141
|
+
if (config.markdownParser === "markdown_yo") {
|
|
32142
|
+
return { ...config, markdownParser: "markdown-yo" };
|
|
32143
|
+
}
|
|
32144
|
+
return config;
|
|
32145
|
+
}
|
|
32026
32146
|
var Notebook = class _Notebook {
|
|
32027
32147
|
constructor() {
|
|
32028
32148
|
/**
|
|
@@ -32106,12 +32226,12 @@ var Notebook = class _Notebook {
|
|
|
32106
32226
|
this.processedMtimes = /* @__PURE__ */ new Map();
|
|
32107
32227
|
this.search = new Search();
|
|
32108
32228
|
/**
|
|
32109
|
-
* Optional
|
|
32110
|
-
* Used for HTML rendering when `markdownParser === '
|
|
32229
|
+
* Optional markdown-yo WASM renderer.
|
|
32230
|
+
* Used for HTML rendering when `markdownParser === 'markdown-yo'`.
|
|
32111
32231
|
*/
|
|
32112
32232
|
this.markdownYoRenderer = null;
|
|
32113
32233
|
/**
|
|
32114
|
-
* Tracks in-flight
|
|
32234
|
+
* Tracks in-flight markdown-yo initialization to avoid duplicate loads.
|
|
32115
32235
|
*/
|
|
32116
32236
|
this.markdownYoRendererPromise = null;
|
|
32117
32237
|
/**
|
|
@@ -32144,7 +32264,7 @@ var Notebook = class _Notebook {
|
|
|
32144
32264
|
this.initFs(fs23);
|
|
32145
32265
|
await this.initConfig(config);
|
|
32146
32266
|
this.md = this.initMarkdownIt();
|
|
32147
|
-
if (this.config.markdownParser === "
|
|
32267
|
+
if (this.config.markdownParser === "markdown-yo") {
|
|
32148
32268
|
await this.initMarkdownYo();
|
|
32149
32269
|
}
|
|
32150
32270
|
this.updateConfig({});
|
|
@@ -32159,14 +32279,16 @@ var Notebook = class _Notebook {
|
|
|
32159
32279
|
path15.join(this.notebookPath.fsPath, "./.crossnote"),
|
|
32160
32280
|
this.fs
|
|
32161
32281
|
);
|
|
32162
|
-
this.config = {
|
|
32282
|
+
this.config = normalizeNotebookConfig({
|
|
32163
32283
|
...getDefaultNotebookConfig(),
|
|
32164
32284
|
...extraConfig,
|
|
32165
32285
|
...config
|
|
32166
|
-
};
|
|
32286
|
+
});
|
|
32167
32287
|
}
|
|
32168
32288
|
initMarkdownIt(options) {
|
|
32169
32289
|
const md = new import_markdown_it.default(options ?? defaultMarkdownItConfig);
|
|
32290
|
+
const validateLink = md.validateLink.bind(md);
|
|
32291
|
+
md.validateLink = (url) => validateLink(url) || /^data:image\/svg\+xml[;,]/i.test(url.trim());
|
|
32170
32292
|
md.use(import_markdown_it_footnote.default);
|
|
32171
32293
|
md.use(import_markdown_it_sub.default);
|
|
32172
32294
|
md.use(import_markdown_it_sup.default);
|
|
@@ -32221,7 +32343,7 @@ var Notebook = class _Notebook {
|
|
|
32221
32343
|
}
|
|
32222
32344
|
}
|
|
32223
32345
|
/**
|
|
32224
|
-
* Initialize the
|
|
32346
|
+
* Initialize the markdown-yo WASM renderer.
|
|
32225
32347
|
*/
|
|
32226
32348
|
async initMarkdownYo() {
|
|
32227
32349
|
if (this.markdownYoRendererPromise) {
|
|
@@ -32233,15 +32355,15 @@ var Notebook = class _Notebook {
|
|
|
32233
32355
|
}
|
|
32234
32356
|
this.markdownYoRendererPromise = (async () => {
|
|
32235
32357
|
try {
|
|
32236
|
-
const { createRenderer } = await import("
|
|
32358
|
+
const { createRenderer } = await import("@shd101wyy/markdown-yo");
|
|
32237
32359
|
const renderer = await createRenderer();
|
|
32238
|
-
if (this.config.markdownParser === "
|
|
32360
|
+
if (this.config.markdownParser === "markdown-yo") {
|
|
32239
32361
|
this.markdownYoRenderer = renderer;
|
|
32240
32362
|
} else {
|
|
32241
32363
|
renderer.destroy();
|
|
32242
32364
|
}
|
|
32243
32365
|
} catch (error) {
|
|
32244
|
-
console.warn("Failed to load
|
|
32366
|
+
console.warn("Failed to load markdown-yo WASM renderer:", error);
|
|
32245
32367
|
this.markdownYoRenderer = null;
|
|
32246
32368
|
} finally {
|
|
32247
32369
|
this.markdownYoRendererPromise = null;
|
|
@@ -32254,7 +32376,7 @@ var Notebook = class _Notebook {
|
|
|
32254
32376
|
this.markdownYoRenderer = null;
|
|
32255
32377
|
}
|
|
32256
32378
|
/**
|
|
32257
|
-
* Build
|
|
32379
|
+
* Build markdown-yo render options from the current notebook config.
|
|
32258
32380
|
*/
|
|
32259
32381
|
buildMarkdownYoOptions(isForPreview) {
|
|
32260
32382
|
const c = this.config;
|
|
@@ -32280,7 +32402,7 @@ var Notebook = class _Notebook {
|
|
|
32280
32402
|
};
|
|
32281
32403
|
}
|
|
32282
32404
|
/**
|
|
32283
|
-
* Convert
|
|
32405
|
+
* Convert markdown-yo RenderOptions to CLI flags for the native binary.
|
|
32284
32406
|
*/
|
|
32285
32407
|
buildMarkdownYoBinaryArgs(opts) {
|
|
32286
32408
|
const flags = [];
|
|
@@ -32304,11 +32426,11 @@ var Notebook = class _Notebook {
|
|
|
32304
32426
|
return flags;
|
|
32305
32427
|
}
|
|
32306
32428
|
/**
|
|
32307
|
-
* Render markdown to HTML using
|
|
32429
|
+
* Render markdown to HTML using markdown-yo (WASM) if available,
|
|
32308
32430
|
* otherwise falls back to markdown-it.
|
|
32309
32431
|
*/
|
|
32310
32432
|
renderMarkdown(markdown, options) {
|
|
32311
|
-
if (this.config.markdownParser === "
|
|
32433
|
+
if (this.config.markdownParser === "markdown-yo") {
|
|
32312
32434
|
const renderOpts = this.buildMarkdownYoOptions(!!options?.isForPreview);
|
|
32313
32435
|
const binaryPath = this.config.markdownYoBinaryPath;
|
|
32314
32436
|
let html;
|
|
@@ -32317,7 +32439,8 @@ var Notebook = class _Notebook {
|
|
|
32317
32439
|
html = (0, import_child_process9.execFileSync)(binaryPath, args, {
|
|
32318
32440
|
input: markdown,
|
|
32319
32441
|
encoding: "utf8",
|
|
32320
|
-
maxBuffer: 256 * 1024 * 1024
|
|
32442
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
32443
|
+
windowsHide: true
|
|
32321
32444
|
});
|
|
32322
32445
|
} else if (this.markdownYoRenderer) {
|
|
32323
32446
|
html = this.markdownYoRenderer.render(markdown, renderOpts);
|
|
@@ -32339,7 +32462,7 @@ var Notebook = class _Notebook {
|
|
|
32339
32462
|
return md.render(markdown);
|
|
32340
32463
|
}
|
|
32341
32464
|
/**
|
|
32342
|
-
* Post-process
|
|
32465
|
+
* Post-process markdown-yo HTML output:
|
|
32343
32466
|
* - Render math expressions with KaTeX (when mathRenderingOption is 'KaTeX')
|
|
32344
32467
|
* - Append file extension to wikilink hrefs
|
|
32345
32468
|
*/
|
|
@@ -32381,17 +32504,17 @@ var Notebook = class _Notebook {
|
|
|
32381
32504
|
return html;
|
|
32382
32505
|
}
|
|
32383
32506
|
updateConfig(config) {
|
|
32384
|
-
this.config = {
|
|
32507
|
+
this.config = normalizeNotebookConfig({
|
|
32385
32508
|
...this.config,
|
|
32386
32509
|
...config
|
|
32387
|
-
};
|
|
32510
|
+
});
|
|
32388
32511
|
this.interpolateConfig();
|
|
32389
32512
|
this.md.set({
|
|
32390
32513
|
typographer: !!this.config.enableTypographer,
|
|
32391
32514
|
breaks: !!this.config.breakOnSingleNewLine,
|
|
32392
32515
|
linkify: !!this.config.enableLinkify
|
|
32393
32516
|
});
|
|
32394
|
-
if (this.config.markdownParser === "
|
|
32517
|
+
if (this.config.markdownParser === "markdown-yo") {
|
|
32395
32518
|
void this.initMarkdownYo();
|
|
32396
32519
|
} else {
|
|
32397
32520
|
this.destroyMarkdownYo();
|
|
@@ -32682,12 +32805,12 @@ var Notebook = class _Notebook {
|
|
|
32682
32805
|
* front-matter-normalised `markdown` body. No caching — the caller
|
|
32683
32806
|
* decides whether to stash the note into `this.notes`.
|
|
32684
32807
|
*/
|
|
32685
|
-
async loadNoteFromDisk(filePath) {
|
|
32808
|
+
async loadNoteFromDisk(filePath, knownStats) {
|
|
32686
32809
|
filePath = this.resolveNoteRelativePath(filePath);
|
|
32687
32810
|
const absFilePath = this.resolveNoteAbsolutePath(filePath);
|
|
32688
32811
|
let stats;
|
|
32689
32812
|
try {
|
|
32690
|
-
stats = await this.fs.stat(absFilePath);
|
|
32813
|
+
stats = knownStats ?? await this.fs.stat(absFilePath);
|
|
32691
32814
|
} catch {
|
|
32692
32815
|
return null;
|
|
32693
32816
|
}
|
|
@@ -32953,70 +33076,70 @@ var Notebook = class _Notebook {
|
|
|
32953
33076
|
} catch {
|
|
32954
33077
|
return;
|
|
32955
33078
|
}
|
|
33079
|
+
const sizeLimit = this.config.maxNoteFileSize ?? 0;
|
|
33080
|
+
const isIndexableMarkdown = (stats, name) => stats.isFile() && this.config.markdownFileExtensions.includes(path15.extname(name)) && (sizeLimit <= 0 || stats.size <= sizeLimit);
|
|
32956
33081
|
const subdirPromises = [];
|
|
32957
|
-
|
|
32958
|
-
|
|
32959
|
-
|
|
32960
|
-
|
|
32961
|
-
|
|
32962
|
-
|
|
32963
|
-
|
|
32964
|
-
|
|
32965
|
-
|
|
32966
|
-
|
|
32967
|
-
|
|
32968
|
-
|
|
32969
|
-
|
|
32970
|
-
|
|
32971
|
-
|
|
32972
|
-
|
|
32973
|
-
|
|
32974
|
-
this.oversizedWalkWarned
|
|
32975
|
-
|
|
32976
|
-
|
|
32977
|
-
|
|
32978
|
-
|
|
32979
|
-
|
|
32980
|
-
|
|
32981
|
-
|
|
32982
|
-
|
|
32983
|
-
|
|
32984
|
-
|
|
32985
|
-
|
|
32986
|
-
|
|
32987
|
-
|
|
32988
|
-
|
|
32989
|
-
|
|
32990
|
-
|
|
32991
|
-
|
|
32992
|
-
|
|
32993
|
-
|
|
32994
|
-
|
|
32995
|
-
|
|
32996
|
-
|
|
32997
|
-
|
|
32998
|
-
|
|
33082
|
+
await Promise.all(
|
|
33083
|
+
files.map(async (file) => {
|
|
33084
|
+
if (file.match(/^(node_modules|\.git)$/)) {
|
|
33085
|
+
return;
|
|
33086
|
+
}
|
|
33087
|
+
const absFilePath = path15.resolve(dirAbsPath, file);
|
|
33088
|
+
const relFromNotebook = path15.relative(this.notebookPath.fsPath, absFilePath).replace(/\\/g, "/");
|
|
33089
|
+
if (currentStack.length > 0 && isIgnoredByGitignore(relFromNotebook)) {
|
|
33090
|
+
return;
|
|
33091
|
+
}
|
|
33092
|
+
let stats;
|
|
33093
|
+
try {
|
|
33094
|
+
stats = await this.fs.stat(absFilePath);
|
|
33095
|
+
} catch {
|
|
33096
|
+
return;
|
|
33097
|
+
}
|
|
33098
|
+
this.walkedEntriesThisRefresh += 1;
|
|
33099
|
+
if (!this.oversizedWalkWarned && this.walkedEntriesThisRefresh > OVERSIZED_WALK_WARN_THRESHOLD) {
|
|
33100
|
+
this.oversizedWalkWarned = true;
|
|
33101
|
+
console.warn(
|
|
33102
|
+
`Crossnote: the note index walk under "${this.notebookPath.fsPath}" has passed ${OVERSIZED_WALK_WARN_THRESHOLD} filesystem entries \u2014 this notebook root is unusually broad, so wikilink/backlink/graph indexing may be slow. If this is unexpected, open a smaller folder as the notebook root.`
|
|
33103
|
+
);
|
|
33104
|
+
}
|
|
33105
|
+
if (stats.isSymbolicLink()) {
|
|
33106
|
+
return;
|
|
33107
|
+
}
|
|
33108
|
+
if (isIndexableMarkdown(stats, relFromNotebook)) {
|
|
33109
|
+
await onFile({
|
|
33110
|
+
absPath: absFilePath,
|
|
33111
|
+
relPath: relFromNotebook,
|
|
33112
|
+
stats
|
|
33113
|
+
});
|
|
33114
|
+
} else if (stats.isDirectory() && includeSubdirectories) {
|
|
33115
|
+
subdirPromises.push(
|
|
33116
|
+
this._walkNotebookDir(
|
|
33117
|
+
relFromNotebook,
|
|
33118
|
+
includeSubdirectories,
|
|
33119
|
+
currentStack,
|
|
33120
|
+
onFile
|
|
33121
|
+
)
|
|
33122
|
+
);
|
|
33123
|
+
}
|
|
33124
|
+
})
|
|
33125
|
+
);
|
|
32999
33126
|
await Promise.all(subdirPromises);
|
|
33000
33127
|
}
|
|
33001
33128
|
/**
|
|
33002
33129
|
* Recursively stat all files under `dir` and write each markdown
|
|
33003
|
-
* file's notebook-relative path → mtimeMs into `out`.
|
|
33004
|
-
* large (`maxNoteFileSize`) or
|
|
33005
|
-
*
|
|
33006
|
-
* incremental refresh never tries to process
|
|
33007
|
-
* loader would reject.
|
|
33130
|
+
* file's notebook-relative path → mtimeMs into `out`. The walk
|
|
33131
|
+
* already excludes files that are too large (`maxNoteFileSize`) or
|
|
33132
|
+
* have a non-markdown extension — the same gates `loadNoteFromDisk`
|
|
33133
|
+
* applies — so the incremental refresh never tries to process
|
|
33134
|
+
* something that the loader would reject.
|
|
33008
33135
|
*/
|
|
33009
33136
|
async _collectOnDiskMtimes(dir, includeSubdirectories, gitignoreStack, out) {
|
|
33010
|
-
const sizeLimit = this.config.maxNoteFileSize ?? 0;
|
|
33011
33137
|
await this._walkNotebookDir(
|
|
33012
33138
|
dir,
|
|
33013
33139
|
includeSubdirectories,
|
|
33014
33140
|
gitignoreStack,
|
|
33015
33141
|
async ({ relPath, stats }) => {
|
|
33016
|
-
|
|
33017
|
-
if (this.config.markdownFileExtensions.includes(ext) && (sizeLimit <= 0 || stats.size <= sizeLimit)) {
|
|
33018
|
-
out.set(relPath, Math.floor(stats.mtimeMs));
|
|
33019
|
-
}
|
|
33142
|
+
out.set(relPath, Math.floor(stats.mtimeMs));
|
|
33020
33143
|
}
|
|
33021
33144
|
);
|
|
33022
33145
|
}
|
|
@@ -33032,7 +33155,7 @@ var Notebook = class _Notebook {
|
|
|
33032
33155
|
includeSubdirectories,
|
|
33033
33156
|
gitignoreStack,
|
|
33034
33157
|
async ({ relPath, stats }) => {
|
|
33035
|
-
const result = await this.loadNoteFromDisk(relPath);
|
|
33158
|
+
const result = await this.loadNoteFromDisk(relPath, stats);
|
|
33036
33159
|
if (!result) return;
|
|
33037
33160
|
const { note, markdown } = result;
|
|
33038
33161
|
this.notes[note.filePath] = note;
|
|
@@ -33894,17 +34017,19 @@ async function enhance5($) {
|
|
|
33894
34017
|
const $col = $(col);
|
|
33895
34018
|
const text = $col.text();
|
|
33896
34019
|
const html = $col.html();
|
|
34020
|
+
const $children = $col.children();
|
|
34021
|
+
const isBareText = !$children.length || $children.length === 1 && $children.is("p") && !$children.children().length;
|
|
33897
34022
|
if (!text.length && !html?.length) {
|
|
33898
34023
|
const $prev = $col.prev();
|
|
33899
34024
|
if ($prev.length) {
|
|
33900
34025
|
colspans2.push([$prev, $col]);
|
|
33901
34026
|
}
|
|
33902
|
-
} else if (text.trim() === "^" && $prevRow) {
|
|
34027
|
+
} else if (isBareText && text.trim() === "^" && $prevRow) {
|
|
33903
34028
|
const $prev = $($prevRow.children()[j]);
|
|
33904
34029
|
if ($prev.length) {
|
|
33905
34030
|
rowspans.push([$prev, $col]);
|
|
33906
34031
|
}
|
|
33907
|
-
} else if (text.trim() === ">") {
|
|
34032
|
+
} else if (isBareText && text.trim() === ">") {
|
|
33908
34033
|
const $next = $col.next();
|
|
33909
34034
|
if ($next.length) {
|
|
33910
34035
|
colspans.push([$col, $next]);
|
|
@@ -34140,7 +34265,7 @@ async function runCodeChunks(codeChunksData, runOptions) {
|
|
|
34140
34265
|
|
|
34141
34266
|
// src/render-enhancers/fenced-diagrams.ts
|
|
34142
34267
|
var import_cross_fetch2 = __toESM(require("cross-fetch"));
|
|
34143
|
-
var
|
|
34268
|
+
var import_html_escaper12 = require("html-escaper");
|
|
34144
34269
|
var YAML6 = __toESM(require("yaml"));
|
|
34145
34270
|
|
|
34146
34271
|
// src/renderers/bitfield.ts
|
|
@@ -34161,10 +34286,26 @@ async function renderBitfield(code, options) {
|
|
|
34161
34286
|
}
|
|
34162
34287
|
}
|
|
34163
34288
|
|
|
34289
|
+
// src/renderers/csv.ts
|
|
34290
|
+
var import_html_escaper9 = require("html-escaper");
|
|
34291
|
+
var Papa2 = __toESM(require("papaparse"));
|
|
34292
|
+
function renderCsv(code) {
|
|
34293
|
+
const { data, errors } = Papa2.parse(code.trim(), {
|
|
34294
|
+
skipEmptyLines: true
|
|
34295
|
+
});
|
|
34296
|
+
const error = errors.find((e) => e.type !== "Delimiter");
|
|
34297
|
+
if (error) {
|
|
34298
|
+
throw new Error(`CSV parse error: ${error.message}`);
|
|
34299
|
+
}
|
|
34300
|
+
const [header = [], ...rows] = data;
|
|
34301
|
+
const tr = (cells, tag) => `<tr>${cells.map((c) => `<${tag}>${(0, import_html_escaper9.escape)(c)}</${tag}>`).join("")}</tr>`;
|
|
34302
|
+
return `<table><thead>${tr(header, "th")}</thead><tbody>${rows.map((r) => tr(r, "td")).join("")}</tbody></table>`;
|
|
34303
|
+
}
|
|
34304
|
+
|
|
34164
34305
|
// src/renderers/d2.ts
|
|
34165
34306
|
var import_child_process10 = require("child_process");
|
|
34166
34307
|
var crypto = __toESM(require("crypto"));
|
|
34167
|
-
var
|
|
34308
|
+
var import_html_escaper10 = require("html-escaper");
|
|
34168
34309
|
var fs12 = __toESM(require("fs"));
|
|
34169
34310
|
var os2 = __toESM(require("os"));
|
|
34170
34311
|
var path17 = __toESM(require("path"));
|
|
@@ -34202,7 +34343,7 @@ async function renderD2(code, opts, fileDirectoryPath) {
|
|
|
34202
34343
|
(0, import_child_process10.execFile)(
|
|
34203
34344
|
opts.d2Path,
|
|
34204
34345
|
args,
|
|
34205
|
-
{ timeout: 3e4 },
|
|
34346
|
+
{ timeout: 3e4, windowsHide: true },
|
|
34206
34347
|
(err, _stdout, stderr) => {
|
|
34207
34348
|
if (err) {
|
|
34208
34349
|
const wrapped = new Error(stderr || err.message);
|
|
@@ -34220,7 +34361,7 @@ async function renderD2(code, opts, fileDirectoryPath) {
|
|
|
34220
34361
|
const code2 = err.code;
|
|
34221
34362
|
const isNotFound = code2 === "ENOENT" || /not recognized as an internal or external command/i.test(msg);
|
|
34222
34363
|
if (isNotFound) return D2_NOT_FOUND;
|
|
34223
|
-
return `<pre class="language-text"><code>D2 error: ${(0,
|
|
34364
|
+
return `<pre class="language-text"><code>D2 error: ${(0, import_html_escaper10.escape)(msg)}</code></pre>`;
|
|
34224
34365
|
} finally {
|
|
34225
34366
|
if (tmpIn) {
|
|
34226
34367
|
fs12.promises.unlink(tmpIn).catch(() => void 0);
|
|
@@ -34230,7 +34371,7 @@ async function renderD2(code, opts, fileDirectoryPath) {
|
|
|
34230
34371
|
}
|
|
34231
34372
|
|
|
34232
34373
|
// src/renderers/tikz.ts
|
|
34233
|
-
var
|
|
34374
|
+
var import_html_escaper11 = require("html-escaper");
|
|
34234
34375
|
var import_async_mutex2 = require("async-mutex");
|
|
34235
34376
|
var TIKZ_NOT_AVAILABLE = /* @__PURE__ */ Symbol("TIKZ_NOT_AVAILABLE");
|
|
34236
34377
|
var mutex = new import_async_mutex2.Mutex();
|
|
@@ -34304,7 +34445,7 @@ ${input}
|
|
|
34304
34445
|
return svg;
|
|
34305
34446
|
} catch (err) {
|
|
34306
34447
|
const msg = err instanceof Error ? err.message : String(err);
|
|
34307
|
-
return `<pre class="language-text"><code>TikZ error: ${(0,
|
|
34448
|
+
return `<pre class="language-text"><code>TikZ error: ${(0, import_html_escaper11.escape)(msg)}</code></pre>`;
|
|
34308
34449
|
}
|
|
34309
34450
|
});
|
|
34310
34451
|
}
|
|
@@ -34468,7 +34609,8 @@ var supportedLanguages = [
|
|
|
34468
34609
|
"vega-lite",
|
|
34469
34610
|
"wsd",
|
|
34470
34611
|
"d2",
|
|
34471
|
-
"tikz"
|
|
34612
|
+
"tikz",
|
|
34613
|
+
"csv"
|
|
34472
34614
|
];
|
|
34473
34615
|
async function enhance7({
|
|
34474
34616
|
$,
|
|
@@ -34572,7 +34714,7 @@ async function renderDiagram({
|
|
|
34572
34714
|
)}>${diagram}</div>`;
|
|
34573
34715
|
graphsCache[checksum] = $output;
|
|
34574
34716
|
} catch (error) {
|
|
34575
|
-
$output = `<pre class="language-text"><code>${(0,
|
|
34717
|
+
$output = `<pre class="language-text"><code>${(0, import_html_escaper12.escape)(
|
|
34576
34718
|
String(error)
|
|
34577
34719
|
)}</code></pre>`;
|
|
34578
34720
|
}
|
|
@@ -34586,7 +34728,7 @@ async function renderDiagram({
|
|
|
34586
34728
|
normalizedInfo.attributes,
|
|
34587
34729
|
normalizedInfo.language
|
|
34588
34730
|
)
|
|
34589
|
-
)}>${(0,
|
|
34731
|
+
)}>${(0, import_html_escaper12.escape)(code)}</div>`;
|
|
34590
34732
|
break;
|
|
34591
34733
|
}
|
|
34592
34734
|
case "wavedrom": {
|
|
@@ -34652,7 +34794,7 @@ async function renderDiagram({
|
|
|
34652
34794
|
spec = JSON.parse(rawSpec);
|
|
34653
34795
|
}
|
|
34654
34796
|
$output = hiddenCode(
|
|
34655
|
-
(0,
|
|
34797
|
+
(0, import_html_escaper12.escape)(JSON.stringify(spec)),
|
|
34656
34798
|
normalizedInfo.attributes,
|
|
34657
34799
|
normalizedInfo.language
|
|
34658
34800
|
);
|
|
@@ -34676,7 +34818,7 @@ async function renderDiagram({
|
|
|
34676
34818
|
const imgUrl = buildWsdImageUrl(code, server, style, apiKey);
|
|
34677
34819
|
$output = `<div ${stringifyBlockAttributes(
|
|
34678
34820
|
ensureClassInAttributes(normalizedInfo.attributes, "wsd")
|
|
34679
|
-
)}><img src="${(0,
|
|
34821
|
+
)}><img src="${(0, import_html_escaper12.escape)(imgUrl)}" alt="Sequence Diagram"></div>`;
|
|
34680
34822
|
break;
|
|
34681
34823
|
}
|
|
34682
34824
|
case "d2": {
|
|
@@ -34737,10 +34879,19 @@ async function renderDiagram({
|
|
|
34737
34879
|
)}>${svg}</div>`;
|
|
34738
34880
|
break;
|
|
34739
34881
|
}
|
|
34882
|
+
case "csv": {
|
|
34883
|
+
$output = `<div ${stringifyBlockAttributes(
|
|
34884
|
+
ensureClassInAttributes(
|
|
34885
|
+
normalizedInfo.attributes,
|
|
34886
|
+
normalizedInfo.language
|
|
34887
|
+
)
|
|
34888
|
+
)}>${renderCsv(code)}</div>`;
|
|
34889
|
+
break;
|
|
34890
|
+
}
|
|
34740
34891
|
}
|
|
34741
34892
|
} catch (error) {
|
|
34742
34893
|
$output = $(
|
|
34743
|
-
`<pre class="language-text"><code>${(0,
|
|
34894
|
+
`<pre class="language-text"><code>${(0, import_html_escaper12.escape)(
|
|
34744
34895
|
String(error)
|
|
34745
34896
|
)}</code></pre>`
|
|
34746
34897
|
);
|
|
@@ -34762,7 +34913,7 @@ var hiddenCode = (code, attributes, language) => `<p ${stringifyBlockAttributes(
|
|
|
34762
34913
|
)}><span style="display: none">${code}</span></p>`;
|
|
34763
34914
|
|
|
34764
34915
|
// src/render-enhancers/fenced-math.ts
|
|
34765
|
-
var
|
|
34916
|
+
var import_html_escaper13 = require("html-escaper");
|
|
34766
34917
|
var supportedLanguages2 = ["math"];
|
|
34767
34918
|
async function enhance8($, renderingOption, mathBlockDelimiters, katexConfig) {
|
|
34768
34919
|
$('[data-role="codeBlock"]').each((i, container) => {
|
|
@@ -34813,7 +34964,7 @@ var renderMath = (code, normalizedInfo, renderingOption, mathBlockDelimiters, ka
|
|
|
34813
34964
|
normalizedInfo.attributes
|
|
34814
34965
|
)}>${mathHtml}</p>`;
|
|
34815
34966
|
} catch (error) {
|
|
34816
|
-
$output = `<pre class="language-text"><code>${(0,
|
|
34967
|
+
$output = `<pre class="language-text"><code>${(0, import_html_escaper13.escape)(
|
|
34817
34968
|
String(error)
|
|
34818
34969
|
)}</code></pre>`;
|
|
34819
34970
|
}
|
|
@@ -34821,7 +34972,42 @@ var renderMath = (code, normalizedInfo, renderingOption, mathBlockDelimiters, ka
|
|
|
34821
34972
|
};
|
|
34822
34973
|
|
|
34823
34974
|
// src/render-enhancers/resolved-image-paths.ts
|
|
34975
|
+
function mapSrcsetUrls(srcset, mapUrl) {
|
|
34976
|
+
const candidates = [];
|
|
34977
|
+
let i = 0;
|
|
34978
|
+
while (i < srcset.length) {
|
|
34979
|
+
while (i < srcset.length && /[\s,]/.test(srcset[i])) {
|
|
34980
|
+
i++;
|
|
34981
|
+
}
|
|
34982
|
+
if (i >= srcset.length) {
|
|
34983
|
+
break;
|
|
34984
|
+
}
|
|
34985
|
+
let j = i;
|
|
34986
|
+
while (j < srcset.length && !/\s/.test(srcset[j])) {
|
|
34987
|
+
j++;
|
|
34988
|
+
}
|
|
34989
|
+
let url = srcset.slice(i, j);
|
|
34990
|
+
let descriptor = "";
|
|
34991
|
+
if (/,$/.test(url)) {
|
|
34992
|
+
url = url.replace(/,+$/, "");
|
|
34993
|
+
} else {
|
|
34994
|
+
const comma = srcset.indexOf(",", j);
|
|
34995
|
+
const end = comma === -1 ? srcset.length : comma;
|
|
34996
|
+
descriptor = srcset.slice(j, end).trim();
|
|
34997
|
+
j = end;
|
|
34998
|
+
}
|
|
34999
|
+
i = j;
|
|
35000
|
+
const mapped = mapUrl(url);
|
|
35001
|
+
candidates.push(descriptor ? `${mapped} ${descriptor}` : mapped);
|
|
35002
|
+
}
|
|
35003
|
+
return candidates.join(", ");
|
|
35004
|
+
}
|
|
34824
35005
|
async function enhance9($, options, resolveFilePath) {
|
|
35006
|
+
const resolve21 = (src) => resolveFilePath(
|
|
35007
|
+
src,
|
|
35008
|
+
options.useRelativeFilePath,
|
|
35009
|
+
options.fileDirectoryPath
|
|
35010
|
+
);
|
|
34825
35011
|
$("img, a").each((i, imgElement) => {
|
|
34826
35012
|
let srcTag = "src";
|
|
34827
35013
|
if (imgElement.name === "a") {
|
|
@@ -34832,14 +35018,15 @@ async function enhance9($, options, resolveFilePath) {
|
|
|
34832
35018
|
if (!src) {
|
|
34833
35019
|
return;
|
|
34834
35020
|
}
|
|
34835
|
-
img.attr(
|
|
34836
|
-
|
|
34837
|
-
|
|
34838
|
-
|
|
34839
|
-
|
|
34840
|
-
|
|
34841
|
-
|
|
34842
|
-
|
|
35021
|
+
img.attr(srcTag, resolve21(src));
|
|
35022
|
+
});
|
|
35023
|
+
$("img[srcset], source[srcset]").each((i, element) => {
|
|
35024
|
+
const $element = $(element);
|
|
35025
|
+
const srcset = $element.attr("srcset");
|
|
35026
|
+
if (!srcset) {
|
|
35027
|
+
return;
|
|
35028
|
+
}
|
|
35029
|
+
$element.attr("srcset", mapSrcsetUrls(srcset, resolve21));
|
|
34843
35030
|
});
|
|
34844
35031
|
}
|
|
34845
35032
|
|
|
@@ -34947,6 +35134,61 @@ function buildMathJaxConfigScript(mathJaxConfig) {
|
|
|
34947
35134
|
})();`;
|
|
34948
35135
|
}
|
|
34949
35136
|
|
|
35137
|
+
// src/markdown-engine/mermaid-export.ts
|
|
35138
|
+
function buildMermaidExportScript(config, hasZenUML) {
|
|
35139
|
+
return `
|
|
35140
|
+
// Page load and data-processed do not imply that Mermaid's layout is complete.
|
|
35141
|
+
window.__crossnoteMermaidExport = { status: 'pending' }
|
|
35142
|
+
try {
|
|
35143
|
+
// Disable the load listener before an external module can yield control.
|
|
35144
|
+
mermaid.startOnLoad = false
|
|
35145
|
+
// TODO: If ZenUML gets integrated into mermaid in the future,
|
|
35146
|
+
// we can remove the following lines.
|
|
35147
|
+
${hasZenUML ? `const { default: zenuml } = await import('https://${config.jsdelivrCdnHost}/npm/@mermaid-js/mermaid-zenuml@0.1.0/dist/mermaid-zenuml.esm.min.mjs');
|
|
35148
|
+
await mermaid.registerExternalDiagrams([zenuml])` : ``}
|
|
35149
|
+
|
|
35150
|
+
var MERMAID_CONFIG = (${JSON.stringify(config.mermaidConfig)});
|
|
35151
|
+
if (typeof MERMAID_CONFIG !== 'undefined') {
|
|
35152
|
+
MERMAID_CONFIG.startOnLoad = false
|
|
35153
|
+
MERMAID_CONFIG.cloneCssStyles = false
|
|
35154
|
+
MERMAID_CONFIG.theme = MERMAID_CONFIG.theme || "${config.mermaidTheme}"
|
|
35155
|
+
}
|
|
35156
|
+
|
|
35157
|
+
mermaid.initialize(MERMAID_CONFIG || {})
|
|
35158
|
+
// Complete the initial pass before Reveal can start separate renders.
|
|
35159
|
+
await mermaid.run({
|
|
35160
|
+
nodes: document.querySelectorAll('div.mermaid')
|
|
35161
|
+
})
|
|
35162
|
+
if (typeof(window['Reveal']) !== 'undefined') {
|
|
35163
|
+
function mermaidRevealHelper(event) {
|
|
35164
|
+
var currentSlide = event.currentSlide
|
|
35165
|
+
var diagrams = currentSlide.querySelectorAll('div.mermaid')
|
|
35166
|
+
for (var i = 0; i < diagrams.length; i++) {
|
|
35167
|
+
var diagram = diagrams[i]
|
|
35168
|
+
if (!diagram.hasAttribute('data-processed')) {
|
|
35169
|
+
mermaid.init(null, diagram, ()=> {
|
|
35170
|
+
Reveal.slide(event.indexh, event.indexv)
|
|
35171
|
+
})
|
|
35172
|
+
}
|
|
35173
|
+
}
|
|
35174
|
+
}
|
|
35175
|
+
Reveal.addEventListener('slidetransitionend', mermaidRevealHelper)
|
|
35176
|
+
Reveal.addEventListener('ready', mermaidRevealHelper)
|
|
35177
|
+
}
|
|
35178
|
+
window.__crossnoteMermaidExport = { status: 'complete' }
|
|
35179
|
+
} catch (error) {
|
|
35180
|
+
window.__crossnoteMermaidExport = {
|
|
35181
|
+
status: 'error',
|
|
35182
|
+
message: String(error && error.message || error)
|
|
35183
|
+
}
|
|
35184
|
+
console.error(error)
|
|
35185
|
+
}
|
|
35186
|
+
`;
|
|
35187
|
+
}
|
|
35188
|
+
|
|
35189
|
+
// src/markdown-engine/mermaid-polyfill.ts
|
|
35190
|
+
var MERMAID_LEGACY_WEBVIEW_POLYFILL = `<script>if(!Object.groupBy){Object.groupBy=function(e,t){var r=Object.create(null);for(var i=0;i<e.length;i++){var k=t(e[i],i);if(typeof k!=="symbol"){k=String(k)}if(!(k in r)){r[k]=[]}r[k].push(e[i])}return r}}</script>`;
|
|
35191
|
+
|
|
34950
35192
|
// src/renderers/wavedrom-source.ts
|
|
34951
35193
|
var import_json52 = __toESM(require("json5"));
|
|
34952
35194
|
|
|
@@ -35129,7 +35371,7 @@ function normalizeMarkdownYoCodeBlocks($) {
|
|
|
35129
35371
|
const code = $code.text();
|
|
35130
35372
|
const parsedInfo = parseBlockInfo(language);
|
|
35131
35373
|
const normalizedInfo = normalizeBlockInfo(parsedInfo);
|
|
35132
|
-
$pre.attr("data-role", "codeBlock").attr("data-info", language).attr("data-parsed-info", JSON.stringify(parsedInfo)).attr("data-normalized-info", JSON.stringify(normalizedInfo)).html((0,
|
|
35374
|
+
$pre.attr("data-role", "codeBlock").attr("data-info", language).attr("data-parsed-info", JSON.stringify(parsedInfo)).attr("data-normalized-info", JSON.stringify(normalizedInfo)).html((0, import_html_escaper14.escape)(code));
|
|
35133
35375
|
});
|
|
35134
35376
|
}
|
|
35135
35377
|
function normalizeMarkdownYoHeadings($) {
|
|
@@ -35156,6 +35398,32 @@ function normalizeMarkdownYoHeadings($) {
|
|
|
35156
35398
|
}
|
|
35157
35399
|
});
|
|
35158
35400
|
}
|
|
35401
|
+
function pandocVersionSupportsMathMethod(versionOutput) {
|
|
35402
|
+
const match = versionOutput.match(/pandoc(?:\.exe)?\s+(\d+)\.(\d+)/i);
|
|
35403
|
+
if (!match) {
|
|
35404
|
+
return false;
|
|
35405
|
+
}
|
|
35406
|
+
const [major, minor] = [Number(match[1]), Number(match[2])];
|
|
35407
|
+
return major > 3 || major === 3 && minor >= 11;
|
|
35408
|
+
}
|
|
35409
|
+
var PANDOC_MATH_METHOD_SUPPORT = /* @__PURE__ */ new Map();
|
|
35410
|
+
function pandocSupportsMathMethod(pandocPath) {
|
|
35411
|
+
let support = PANDOC_MATH_METHOD_SUPPORT.get(pandocPath);
|
|
35412
|
+
if (!support) {
|
|
35413
|
+
support = new Promise((resolve21) => {
|
|
35414
|
+
(0, import_child_process11.execFile)(
|
|
35415
|
+
pandocPath,
|
|
35416
|
+
["--version"],
|
|
35417
|
+
{ timeout: 1e4, windowsHide: true },
|
|
35418
|
+
(error, stdout) => {
|
|
35419
|
+
resolve21(!error && pandocVersionSupportsMathMethod(String(stdout)));
|
|
35420
|
+
}
|
|
35421
|
+
);
|
|
35422
|
+
});
|
|
35423
|
+
PANDOC_MATH_METHOD_SUPPORT.set(pandocPath, support);
|
|
35424
|
+
}
|
|
35425
|
+
return support;
|
|
35426
|
+
}
|
|
35159
35427
|
function isPathInsideDirectory(parentDirectoryPath, filePath) {
|
|
35160
35428
|
const realpath = (p) => {
|
|
35161
35429
|
try {
|
|
@@ -35225,6 +35493,7 @@ var MarkdownEngine = class _MarkdownEngine {
|
|
|
35225
35493
|
generateScriptsForPreview(isForPresentation = false, yamlConfig = {}, vscodePreviewPanel = null) {
|
|
35226
35494
|
let scripts = "";
|
|
35227
35495
|
scripts += `<script>var exports = undefined</script>`;
|
|
35496
|
+
scripts += MERMAID_LEGACY_WEBVIEW_POLYFILL;
|
|
35228
35497
|
scripts += `<script type="text/javascript" src="${addFileProtocol(
|
|
35229
35498
|
path19.resolve(
|
|
35230
35499
|
getCrossnoteBuildDirectory(),
|
|
@@ -35318,7 +35587,7 @@ var MERMAID_CONFIG = (${JSON.stringify(this.notebook.config.mermaidConfig)});
|
|
|
35318
35587
|
if (typeof MERMAID_CONFIG !== 'undefined') {
|
|
35319
35588
|
MERMAID_CONFIG.startOnLoad = false
|
|
35320
35589
|
MERMAID_CONFIG.cloneCssStyles = false
|
|
35321
|
-
MERMAID_CONFIG.theme = "${this.notebook.config.mermaidTheme}"
|
|
35590
|
+
MERMAID_CONFIG.theme = MERMAID_CONFIG.theme || "${this.notebook.config.mermaidTheme}"
|
|
35322
35591
|
}
|
|
35323
35592
|
mermaid.initialize(MERMAID_CONFIG || {})
|
|
35324
35593
|
if (typeof(window['Reveal']) !== 'undefined') {
|
|
@@ -35700,7 +35969,7 @@ window["initRevealPresentation"] = async function() {
|
|
|
35700
35969
|
<html>
|
|
35701
35970
|
<head>
|
|
35702
35971
|
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
|
|
35703
|
-
<meta id="crossnote-data" data-config="${(0,
|
|
35972
|
+
<meta id="crossnote-data" data-config="${(0, import_html_escaper14.escape)(
|
|
35704
35973
|
JSON.stringify({ ...this.notebook.config, ...config })
|
|
35705
35974
|
)}" data-time="${Date.now()}">
|
|
35706
35975
|
<meta charset="UTF-8">
|
|
@@ -35749,7 +36018,7 @@ window["initRevealPresentation"] = async function() {
|
|
|
35749
36018
|
)}
|
|
35750
36019
|
${head}
|
|
35751
36020
|
</head>
|
|
35752
|
-
<body class="preview-container ${isVSCodeWebExtension2 ? "vscode-web-extension" : ""} ${config.isWiki ? "wiki-readonly" : ""}" data-html="${(0,
|
|
36021
|
+
<body class="preview-container ${isVSCodeWebExtension2 ? "vscode-web-extension" : ""} ${config.isWiki ? "wiki-readonly" : ""}" data-html="${(0, import_html_escaper14.escape)(html)}" ${isPresentationMode ? "data-presentation-mode" : ""}>
|
|
35753
36022
|
${body}
|
|
35754
36023
|
</body>
|
|
35755
36024
|
${this.generateScriptsForPreview(
|
|
@@ -35867,7 +36136,7 @@ window["initRevealPresentation"] = async function() {
|
|
|
35867
36136
|
if (options.offline) {
|
|
35868
36137
|
mathStyle = await offlineStyle("./dependencies/katex/katex.min.css");
|
|
35869
36138
|
} else {
|
|
35870
|
-
mathStyle = `<link rel="stylesheet" href="https://${this.notebook.config.jsdelivrCdnHost}/npm/katex@0.
|
|
36139
|
+
mathStyle = `<link rel="stylesheet" href="https://${this.notebook.config.jsdelivrCdnHost}/npm/katex@0.19.1/dist/katex.min.css">`;
|
|
35871
36140
|
}
|
|
35872
36141
|
} else {
|
|
35873
36142
|
mathStyle = "";
|
|
@@ -35885,51 +36154,18 @@ window["initRevealPresentation"] = async function() {
|
|
|
35885
36154
|
let mermaidScript = "";
|
|
35886
36155
|
let mermaidInitScript = "";
|
|
35887
36156
|
if (html.indexOf(' class="mermaid') >= 0) {
|
|
36157
|
+
mermaidScript = MERMAID_LEGACY_WEBVIEW_POLYFILL;
|
|
35888
36158
|
if (options.offline) {
|
|
35889
|
-
mermaidScript
|
|
36159
|
+
mermaidScript += await offlineScript(
|
|
35890
36160
|
"./dependencies/mermaid/mermaid.min.js"
|
|
35891
36161
|
);
|
|
35892
36162
|
} else {
|
|
35893
|
-
mermaidScript
|
|
35894
|
-
}
|
|
35895
|
-
mermaidInitScript += `<script type="module">
|
|
35896
|
-
// TODO: If ZenUML gets integrated into mermaid in the future,
|
|
35897
|
-
// we can remove the following lines.
|
|
35898
|
-
${html.match(/zenuml/i) ? `import zenuml from 'https://${this.notebook.config.jsdelivrCdnHost}/npm/@mermaid-js/mermaid-zenuml@0.1.0/dist/mermaid-zenuml.esm.min.mjs';
|
|
35899
|
-
await mermaid.registerExternalDiagrams([zenuml])` : ``}
|
|
35900
|
-
|
|
35901
|
-
var MERMAID_CONFIG = (${JSON.stringify(this.notebook.config.mermaidConfig)});
|
|
35902
|
-
if (typeof MERMAID_CONFIG !== 'undefined') {
|
|
35903
|
-
MERMAID_CONFIG.startOnLoad = false
|
|
35904
|
-
MERMAID_CONFIG.cloneCssStyles = false
|
|
35905
|
-
MERMAID_CONFIG.theme = "${this.notebook.config.mermaidTheme}"
|
|
35906
|
-
}
|
|
35907
|
-
|
|
35908
|
-
mermaid.initialize(MERMAID_CONFIG || {})
|
|
35909
|
-
if (typeof(window['Reveal']) !== 'undefined') {
|
|
35910
|
-
function mermaidRevealHelper(event) {
|
|
35911
|
-
var currentSlide = event.currentSlide
|
|
35912
|
-
var diagrams = currentSlide.querySelectorAll('div.mermaid')
|
|
35913
|
-
for (var i = 0; i < diagrams.length; i++) {
|
|
35914
|
-
var diagram = diagrams[i]
|
|
35915
|
-
if (!diagram.hasAttribute('data-processed')) {
|
|
35916
|
-
mermaid.init(null, diagram, ()=> {
|
|
35917
|
-
Reveal.slide(event.indexh, event.indexv)
|
|
35918
|
-
})
|
|
36163
|
+
mermaidScript += `<script src="https://${this.notebook.config.jsdelivrCdnHost}/npm/mermaid@12.3.0/dist/mermaid.min.js"></script>`;
|
|
35919
36164
|
}
|
|
35920
|
-
|
|
35921
|
-
|
|
35922
|
-
|
|
35923
|
-
|
|
35924
|
-
await mermaid.run({
|
|
35925
|
-
nodes: document.querySelectorAll('div.mermaid')
|
|
35926
|
-
})
|
|
35927
|
-
} else {
|
|
35928
|
-
await mermaid.run({
|
|
35929
|
-
nodes: document.querySelectorAll('div.mermaid')
|
|
35930
|
-
})
|
|
35931
|
-
}
|
|
35932
|
-
</script>`;
|
|
36165
|
+
mermaidInitScript = `<script type="module">${buildMermaidExportScript(
|
|
36166
|
+
this.notebook.config,
|
|
36167
|
+
/zenuml/i.test(html)
|
|
36168
|
+
)}</script>`;
|
|
35933
36169
|
}
|
|
35934
36170
|
let wavedromScript = ``;
|
|
35935
36171
|
let wavedromInitScript = ``;
|
|
@@ -36302,7 +36538,13 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
36302
36538
|
isForPrint: false,
|
|
36303
36539
|
isForPrince: false,
|
|
36304
36540
|
offline: true,
|
|
36305
|
-
|
|
36541
|
+
// Embed assets and images: the temp document lives outside the
|
|
36542
|
+
// crossnote build directory, and Safari/Firefox block cross-tree
|
|
36543
|
+
// `file://` subresources (vscode-mpe#2452 — KaTeX rendered twice
|
|
36544
|
+
// because its CSS never loaded). Chrome loads them either way.
|
|
36545
|
+
embedOfflineAssets: true,
|
|
36546
|
+
embedLocalImages: true,
|
|
36547
|
+
embedSVG: true,
|
|
36306
36548
|
isForBrowser: true
|
|
36307
36549
|
});
|
|
36308
36550
|
const info = await tempOpen({
|
|
@@ -36436,47 +36678,66 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
36436
36678
|
executablePath,
|
|
36437
36679
|
headless: true
|
|
36438
36680
|
});
|
|
36439
|
-
|
|
36440
|
-
|
|
36441
|
-
|
|
36442
|
-
|
|
36443
|
-
|
|
36444
|
-
|
|
36445
|
-
|
|
36446
|
-
|
|
36447
|
-
|
|
36448
|
-
|
|
36449
|
-
|
|
36450
|
-
|
|
36451
|
-
|
|
36452
|
-
|
|
36453
|
-
|
|
36454
|
-
};
|
|
36455
|
-
let timeout = 0;
|
|
36456
|
-
if (chromeConfig && chromeConfig["timeout"]) {
|
|
36457
|
-
timeout = chromeConfig["timeout"];
|
|
36458
|
-
} else if (puppeteerConfig2 && puppeteerConfig2["timeout"]) {
|
|
36459
|
-
timeout = puppeteerConfig2["timeout"];
|
|
36460
|
-
}
|
|
36461
|
-
if (timeout && typeof timeout === "number") {
|
|
36462
|
-
await new Promise((resolve21) => setTimeout(resolve21, timeout));
|
|
36463
|
-
} else if (this.notebook.config.puppeteerWaitForTimeout && this.notebook.config.puppeteerWaitForTimeout > 0) {
|
|
36464
|
-
await new Promise(
|
|
36465
|
-
(resolve21) => setTimeout(resolve21, this.notebook.config.puppeteerWaitForTimeout)
|
|
36681
|
+
try {
|
|
36682
|
+
const info = await tempOpen({
|
|
36683
|
+
prefix: "crossnote",
|
|
36684
|
+
suffix: ".html"
|
|
36685
|
+
});
|
|
36686
|
+
fs14.writeFileSync(info.fd, html);
|
|
36687
|
+
const page = await browser.newPage();
|
|
36688
|
+
const loadPath = toFileURL(info.path) + (yamlConfig["isPresentationMode"] ? "?print-pdf" : "");
|
|
36689
|
+
await page.goto(loadPath);
|
|
36690
|
+
await page.waitForFunction(
|
|
36691
|
+
() => {
|
|
36692
|
+
const state = window.__crossnoteMermaidExport;
|
|
36693
|
+
return !document.querySelector("div.mermaid") || state?.status === "complete" || state?.status === "error";
|
|
36694
|
+
},
|
|
36695
|
+
{ timeout: 3e4 }
|
|
36466
36696
|
);
|
|
36697
|
+
const mermaidError = await page.evaluate(() => {
|
|
36698
|
+
const state = window.__crossnoteMermaidExport;
|
|
36699
|
+
return state?.status === "error" ? state.message : void 0;
|
|
36700
|
+
});
|
|
36701
|
+
if (mermaidError !== void 0) {
|
|
36702
|
+
throw new Error("Mermaid rendering failed: " + mermaidError);
|
|
36703
|
+
}
|
|
36704
|
+
const chromeConfig = yamlConfig["chrome"] && typeof yamlConfig["chrome"] === "object" && !Array.isArray(yamlConfig["chrome"]) ? yamlConfig["chrome"] : void 0;
|
|
36705
|
+
const puppeteerConfig2 = yamlConfig["puppeteer"] && typeof yamlConfig["puppeteer"] === "object" && !Array.isArray(yamlConfig["puppeteer"]) ? yamlConfig["puppeteer"] : void 0;
|
|
36706
|
+
const puppeteerConfig = {
|
|
36707
|
+
path: dest,
|
|
36708
|
+
...yamlConfig["isPresentationMode"] ? {} : {
|
|
36709
|
+
margin: { top: "1cm", bottom: "1cm", left: "1cm", right: "1cm" }
|
|
36710
|
+
},
|
|
36711
|
+
printBackground: this.notebook.config.printBackground,
|
|
36712
|
+
...chromeConfig || puppeteerConfig2 || {}
|
|
36713
|
+
};
|
|
36714
|
+
let timeout = 0;
|
|
36715
|
+
if (chromeConfig && chromeConfig["timeout"]) {
|
|
36716
|
+
timeout = chromeConfig["timeout"];
|
|
36717
|
+
} else if (puppeteerConfig2 && puppeteerConfig2["timeout"]) {
|
|
36718
|
+
timeout = puppeteerConfig2["timeout"];
|
|
36719
|
+
}
|
|
36720
|
+
if (timeout && typeof timeout === "number") {
|
|
36721
|
+
await new Promise((resolve21) => setTimeout(resolve21, timeout));
|
|
36722
|
+
} else if (this.notebook.config.puppeteerWaitForTimeout && this.notebook.config.puppeteerWaitForTimeout > 0) {
|
|
36723
|
+
await new Promise(
|
|
36724
|
+
(resolve21) => setTimeout(resolve21, this.notebook.config.puppeteerWaitForTimeout)
|
|
36725
|
+
);
|
|
36726
|
+
}
|
|
36727
|
+
if (fileType === "pdf") {
|
|
36728
|
+
await page.pdf(puppeteerConfig);
|
|
36729
|
+
} else {
|
|
36730
|
+
puppeteerConfig["fullPage"] = true;
|
|
36731
|
+
await page.screenshot(puppeteerConfig);
|
|
36732
|
+
}
|
|
36733
|
+
if (openFileAfterGeneration) {
|
|
36734
|
+
openFile(dest);
|
|
36735
|
+
}
|
|
36736
|
+
return dest;
|
|
36737
|
+
} finally {
|
|
36738
|
+
browser.close().catch(() => {
|
|
36739
|
+
});
|
|
36467
36740
|
}
|
|
36468
|
-
if (fileType === "pdf") {
|
|
36469
|
-
await page.pdf(puppeteerConfig);
|
|
36470
|
-
} else {
|
|
36471
|
-
puppeteerConfig["fullPage"] = true;
|
|
36472
|
-
await page.screenshot(puppeteerConfig);
|
|
36473
|
-
}
|
|
36474
|
-
browser.close().catch(() => {
|
|
36475
|
-
});
|
|
36476
|
-
if (openFileAfterGeneration) {
|
|
36477
|
-
openFile(dest);
|
|
36478
|
-
}
|
|
36479
|
-
return dest;
|
|
36480
36741
|
}
|
|
36481
36742
|
/**
|
|
36482
36743
|
* prince pdf file export
|
|
@@ -36708,7 +36969,7 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
36708
36969
|
let mathStyle = "";
|
|
36709
36970
|
if (outputHTML.indexOf('class="katex"') > 0) {
|
|
36710
36971
|
if (path19.extname(dest) === ".html" && ebookConfig["html"] && ebookConfig["html"]["cdn"]) {
|
|
36711
|
-
mathStyle = `<link rel="stylesheet" href="https://${this.notebook.config.jsdelivrCdnHost}/npm/katex@0.
|
|
36972
|
+
mathStyle = `<link rel="stylesheet" href="https://${this.notebook.config.jsdelivrCdnHost}/npm/katex@0.19.1/dist/katex.min.css">`;
|
|
36712
36973
|
} else {
|
|
36713
36974
|
mathStyle = `<link rel="stylesheet" href="${toFileURL(
|
|
36714
36975
|
path19.resolve(
|
|
@@ -36998,6 +37259,13 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
36998
37259
|
}
|
|
36999
37260
|
}
|
|
37000
37261
|
/**
|
|
37262
|
+
* Resolve a link from the rendered HTML (`src`, `href`, …) to a URL.
|
|
37263
|
+
*
|
|
37264
|
+
* The link is a URL, not a filesystem path: markdown-it has already
|
|
37265
|
+
* percent-encoded it (`图.png` → `%E5%9B%BE.png`), and it may carry a
|
|
37266
|
+
* `?cache-buster` or `#fragment`. The path part is decoded before it is
|
|
37267
|
+
* resolved and the suffix is re-attached afterwards, so the host builds its
|
|
37268
|
+
* URL from a real file path (issues vscode-mpe#2441, vscode-mpe#2328).
|
|
37001
37269
|
*
|
|
37002
37270
|
* @param filePath
|
|
37003
37271
|
* @param relative: whether to use the path relative to filePath or not.
|
|
@@ -37005,28 +37273,24 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37005
37273
|
resolveFilePath(filePath = "", relative11, fileDirectoryPath = "") {
|
|
37006
37274
|
if (filePath.match(this.protocolsWhiteListRegExp) || filePath.startsWith("data:image/") || filePath.startsWith("tag://") || filePath[0] === "#") {
|
|
37007
37275
|
return filePath;
|
|
37008
|
-
}
|
|
37009
|
-
|
|
37010
|
-
|
|
37276
|
+
}
|
|
37277
|
+
if (relative11 && filePath[0] !== "/") {
|
|
37278
|
+
return filePath;
|
|
37279
|
+
}
|
|
37280
|
+
const { path: linkPath, suffix } = splitUrlReference(filePath);
|
|
37281
|
+
const absolutePath = linkPath[0] === "/" ? path19.resolve(this.projectDirectoryPath.fsPath, "." + linkPath) : path19.resolve(fileDirectoryPath || this.fileDirectoryPath, linkPath);
|
|
37282
|
+
if (relative11) {
|
|
37283
|
+
return escapeUrlPath(
|
|
37284
|
+
path19.relative(
|
|
37011
37285
|
fileDirectoryPath || this.fileDirectoryPath,
|
|
37012
|
-
|
|
37013
|
-
)
|
|
37014
|
-
|
|
37015
|
-
return addFileProtocol(
|
|
37016
|
-
path19.resolve(this.projectDirectoryPath.fsPath, "." + filePath),
|
|
37017
|
-
this.vscodePreviewPanel
|
|
37018
|
-
);
|
|
37019
|
-
}
|
|
37020
|
-
} else {
|
|
37021
|
-
if (relative11) {
|
|
37022
|
-
return filePath;
|
|
37023
|
-
} else {
|
|
37024
|
-
return addFileProtocol(
|
|
37025
|
-
path19.resolve(fileDirectoryPath || this.fileDirectoryPath, filePath),
|
|
37026
|
-
this.vscodePreviewPanel
|
|
37027
|
-
);
|
|
37028
|
-
}
|
|
37286
|
+
absolutePath
|
|
37287
|
+
)
|
|
37288
|
+
) + suffix;
|
|
37029
37289
|
}
|
|
37290
|
+
return appendUrlSuffix(
|
|
37291
|
+
addFileProtocol(absolutePath, this.vscodePreviewPanel),
|
|
37292
|
+
suffix
|
|
37293
|
+
);
|
|
37030
37294
|
}
|
|
37031
37295
|
/**
|
|
37032
37296
|
* Turn the absolute filesystem paths that `resolveRelativeCssUrls` left in
|
|
@@ -37123,7 +37387,7 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37123
37387
|
let tbody2 = "<tbody>";
|
|
37124
37388
|
for (const key in arg) {
|
|
37125
37389
|
if (arg.hasOwnProperty(key)) {
|
|
37126
|
-
tbody2 += `<tr><th>${(0,
|
|
37390
|
+
tbody2 += `<tr><th>${(0, import_html_escaper14.escape)(key)}</th><td>${this.frontMatterToTable(
|
|
37127
37391
|
arg[key],
|
|
37128
37392
|
vertical
|
|
37129
37393
|
)}</td></tr>`;
|
|
@@ -37136,7 +37400,7 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37136
37400
|
let tbody = "<tbody><tr>";
|
|
37137
37401
|
for (const key in arg) {
|
|
37138
37402
|
if (arg.hasOwnProperty(key)) {
|
|
37139
|
-
thead += `<th>${(0,
|
|
37403
|
+
thead += `<th>${(0, import_html_escaper14.escape)(key)}</th>`;
|
|
37140
37404
|
tbody += `<td>${this.frontMatterToTable(arg[key], vertical)}</td>`;
|
|
37141
37405
|
}
|
|
37142
37406
|
}
|
|
@@ -37144,7 +37408,7 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37144
37408
|
tbody += "</tr></tbody>";
|
|
37145
37409
|
return `<table>${thead}${tbody}</table>`;
|
|
37146
37410
|
} else {
|
|
37147
|
-
return (0,
|
|
37411
|
+
return (0, import_html_escaper14.escape)(arg);
|
|
37148
37412
|
}
|
|
37149
37413
|
}
|
|
37150
37414
|
/**
|
|
@@ -37267,13 +37531,16 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37267
37531
|
`;
|
|
37268
37532
|
}
|
|
37269
37533
|
async pandocRender(text = "", args) {
|
|
37534
|
+
const mathMethod = await pandocSupportsMathMethod(
|
|
37535
|
+
this.notebook.config.pandocPath
|
|
37536
|
+
);
|
|
37270
37537
|
let mathRenderer;
|
|
37271
37538
|
switch (this.notebook.config.mathRenderingOption) {
|
|
37272
37539
|
case "MathJax":
|
|
37273
|
-
mathRenderer = "--mathjax";
|
|
37540
|
+
mathRenderer = mathMethod ? "--math-method=mathjax" : "--mathjax";
|
|
37274
37541
|
break;
|
|
37275
37542
|
case "KaTeX":
|
|
37276
|
-
mathRenderer = "--katex";
|
|
37543
|
+
mathRenderer = mathMethod ? "--math-method=katex" : "--katex";
|
|
37277
37544
|
break;
|
|
37278
37545
|
default:
|
|
37279
37546
|
mathRenderer = "";
|
|
@@ -37303,11 +37570,11 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37303
37570
|
const parsedInfo = parseBlockInfo(info);
|
|
37304
37571
|
const normalizedInfo = normalizeBlockInfo(parsedInfo);
|
|
37305
37572
|
codeBlockSpacesAhead = match[1].length;
|
|
37306
|
-
outputString += `${match[1]}\`\`\`{.text data-role="codeBlock" data-info="${(0,
|
|
37573
|
+
outputString += `${match[1]}\`\`\`{.text data-role="codeBlock" data-info="${(0, import_html_escaper14.escape)(
|
|
37307
37574
|
info
|
|
37308
|
-
)}" data-parsed-info="${(0,
|
|
37575
|
+
)}" data-parsed-info="${(0, import_html_escaper14.escape)(
|
|
37309
37576
|
JSON.stringify(parsedInfo)
|
|
37310
|
-
)}" data-normalized-info="${(0,
|
|
37577
|
+
)}" data-normalized-info="${(0, import_html_escaper14.escape)(
|
|
37311
37578
|
JSON.stringify(normalizedInfo)
|
|
37312
37579
|
)}"}
|
|
37313
37580
|
`;
|
|
@@ -37330,13 +37597,17 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37330
37597
|
const program = (0, import_child_process11.execFile)(
|
|
37331
37598
|
pandocPath,
|
|
37332
37599
|
args,
|
|
37333
|
-
{
|
|
37600
|
+
{
|
|
37601
|
+
cwd: this.fileDirectoryPath,
|
|
37602
|
+
maxBuffer: Infinity,
|
|
37603
|
+
windowsHide: true
|
|
37604
|
+
},
|
|
37334
37605
|
(error, stdout, stderr) => {
|
|
37335
37606
|
if (error) {
|
|
37336
37607
|
return reject(error);
|
|
37337
37608
|
} else if (stderr) {
|
|
37338
37609
|
return resolve21(
|
|
37339
|
-
'<pre class="language-text"><code>' + (0,
|
|
37610
|
+
'<pre class="language-text"><code>' + (0, import_html_escaper14.escape)(stderr) + "</code></pre>" + stdout
|
|
37340
37611
|
);
|
|
37341
37612
|
} else {
|
|
37342
37613
|
return resolve21(stdout);
|
|
@@ -37411,7 +37682,7 @@ Check "http://pandoc.org/installing.html" website.`;
|
|
|
37411
37682
|
args = this.notebook.config.pandocArguments.concat(args);
|
|
37412
37683
|
html = await this.pandocRender(outputString, args);
|
|
37413
37684
|
} catch (error) {
|
|
37414
|
-
html = `<pre class="language-text"><code>${(0,
|
|
37685
|
+
html = `<pre class="language-text"><code>${(0, import_html_escaper14.escape)(
|
|
37415
37686
|
String(error)
|
|
37416
37687
|
)}</code></pre>`;
|
|
37417
37688
|
}
|
|
@@ -37457,7 +37728,7 @@ Check "http://pandoc.org/installing.html" website.`;
|
|
|
37457
37728
|
);
|
|
37458
37729
|
}
|
|
37459
37730
|
const $ = cheerio3.load(html);
|
|
37460
|
-
if (this.notebook.config.markdownParser === "
|
|
37731
|
+
if (this.notebook.config.markdownParser === "markdown-yo") {
|
|
37461
37732
|
normalizeMarkdownYoCodeBlocks($);
|
|
37462
37733
|
normalizeMarkdownYoHeadings($);
|
|
37463
37734
|
}
|
|
@@ -38979,7 +39250,7 @@ async function startServeServer(options) {
|
|
|
38979
39250
|
if (/^\/(?:files|assets)\//.test(filePath)) {
|
|
38980
39251
|
return filePath;
|
|
38981
39252
|
}
|
|
38982
|
-
return (0,
|
|
39253
|
+
return (0, import_url3.pathToFileURL)(filePath).href;
|
|
38983
39254
|
});
|
|
38984
39255
|
function rootIndexOf(absolutePath) {
|
|
38985
39256
|
const resolved = path26.resolve(absolutePath);
|