crossnote 0.9.42 → 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 +294 -284
- package/out/cli/index.cjs +262 -140
- 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 +264 -254
- 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/mermaid-export.d.ts +2 -0
- package/out/types/src/markdown-engine/mermaid-polyfill.d.ts +1 -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/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/extended-table-syntax.test.d.ts +1 -0
- package/out/types/test/fence-resync.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/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
|
@@ -24127,7 +24127,7 @@ function ebookConvert(src, dest, config = {}) {
|
|
|
24127
24127
|
args.push(arg);
|
|
24128
24128
|
});
|
|
24129
24129
|
(0, import_mkdirp.mkdirp)(path3.dirname(dest)).then(() => {
|
|
24130
|
-
(0, import_child_process.execFile)("ebook-convert", args, (error2) => {
|
|
24130
|
+
(0, import_child_process.execFile)("ebook-convert", args, { windowsHide: true }, (error2) => {
|
|
24131
24131
|
if (error2) {
|
|
24132
24132
|
return reject(error2.toString());
|
|
24133
24133
|
} else {
|
|
@@ -24601,14 +24601,18 @@ function toSVGMarkdown(pdfFilePath, {
|
|
|
24601
24601
|
svgDirectoryPath = SVG_DIRECTORY_PATH;
|
|
24602
24602
|
}
|
|
24603
24603
|
const svgFilePrefix = compute_checksum_default(pdfFilePath) + "_";
|
|
24604
|
-
const task = (0, import_child_process2.spawn)(
|
|
24605
|
-
|
|
24606
|
-
|
|
24607
|
-
|
|
24608
|
-
|
|
24609
|
-
|
|
24610
|
-
|
|
24611
|
-
|
|
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
|
+
);
|
|
24612
24616
|
const chunks = [];
|
|
24613
24617
|
task.stdout.on("data", (chunk) => {
|
|
24614
24618
|
chunks.push(chunk);
|
|
@@ -25168,7 +25172,15 @@ async function transformMarkdown(inputString, {
|
|
|
25168
25172
|
}
|
|
25169
25173
|
if (!inCodeBlock) {
|
|
25170
25174
|
lastOpeningCodeBlockFence = currentCodeBlockFence;
|
|
25171
|
-
} 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) {
|
|
25172
25184
|
lastOpeningCodeBlockFence = null;
|
|
25173
25185
|
}
|
|
25174
25186
|
i = end + 1;
|
|
@@ -25940,7 +25952,8 @@ function toSVGMarkdown2(texFilePath, {
|
|
|
25940
25952
|
}) {
|
|
25941
25953
|
return new Promise((resolve21, reject) => {
|
|
25942
25954
|
const task = (0, import_child_process3.spawn)(latexEngine, [texFilePath], {
|
|
25943
|
-
cwd: path6.dirname(texFilePath)
|
|
25955
|
+
cwd: path6.dirname(texFilePath),
|
|
25956
|
+
windowsHide: true
|
|
25944
25957
|
});
|
|
25945
25958
|
const chunks = [];
|
|
25946
25959
|
task.stdout.on("data", (chunk) => {
|
|
@@ -26078,7 +26091,10 @@ except Exception:
|
|
|
26078
26091
|
args.push(savePath);
|
|
26079
26092
|
}
|
|
26080
26093
|
return await new Promise((resolve21) => {
|
|
26081
|
-
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
|
+
});
|
|
26082
26098
|
if (normalizedAttributes["stdin"]) {
|
|
26083
26099
|
task.stdin.write(content);
|
|
26084
26100
|
}
|
|
@@ -26173,23 +26189,27 @@ var PlantUMLTask = class {
|
|
|
26173
26189
|
});
|
|
26174
26190
|
}
|
|
26175
26191
|
startTask() {
|
|
26176
|
-
this.task = (0, import_child_process5.spawn)(
|
|
26177
|
-
"
|
|
26178
|
-
|
|
26179
|
-
|
|
26180
|
-
|
|
26181
|
-
|
|
26182
|
-
|
|
26183
|
-
|
|
26184
|
-
|
|
26185
|
-
|
|
26186
|
-
|
|
26187
|
-
|
|
26188
|
-
|
|
26189
|
-
|
|
26190
|
-
|
|
26191
|
-
|
|
26192
|
-
|
|
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
|
+
);
|
|
26193
26213
|
this.task.stdout.on("data", (chunk) => {
|
|
26194
26214
|
let data = chunk.toString();
|
|
26195
26215
|
this.chunks += data;
|
|
@@ -26344,7 +26364,7 @@ async function svgElementToPNGFile(svgElement, pngFilePath, imageMagickPath = ""
|
|
|
26344
26364
|
const args = [info.path, pngFilePath];
|
|
26345
26365
|
try {
|
|
26346
26366
|
if (imageMagickPath && imageMagickPath.length) {
|
|
26347
|
-
await (0, import_child_process6.execFileSync)(imageMagickPath, args);
|
|
26367
|
+
await (0, import_child_process6.execFileSync)(imageMagickPath, args, { windowsHide: true });
|
|
26348
26368
|
} else {
|
|
26349
26369
|
await import_imagemagick_cli.default.exec(`convert ${args.join(" ")}`);
|
|
26350
26370
|
}
|
|
@@ -26385,6 +26405,9 @@ async function mermaidToPNG(mermaidCode, pngFilePath, projectDirectoryPath, them
|
|
|
26385
26405
|
],
|
|
26386
26406
|
{
|
|
26387
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,
|
|
26388
26411
|
// Match the old `execFileSync` behavior: the CLI's errors stream to
|
|
26389
26412
|
// our stderr; neither stream is read here.
|
|
26390
26413
|
stdio: ["ignore", "ignore", "inherit"]
|
|
@@ -26441,6 +26464,8 @@ async function render3(wavedromCode, projectDirectoryPath) {
|
|
|
26441
26464
|
try {
|
|
26442
26465
|
const result = import_cross_spawn2.default.sync("npx", ["wavedrom-cli", "-i", info.path], {
|
|
26443
26466
|
cwd: projectDirectoryPath,
|
|
26467
|
+
// Hide the `cmd.exe` wrapper window cross-spawn uses on Windows.
|
|
26468
|
+
windowsHide: true,
|
|
26444
26469
|
// stdout carries the SVG; stderr streams to our console like the old
|
|
26445
26470
|
// `execFileSync` call did.
|
|
26446
26471
|
stdio: ["ignore", "pipe", "inherit"]
|
|
@@ -26714,7 +26739,9 @@ ${error}
|
|
|
26714
26739
|
content,
|
|
26715
26740
|
pngFilePath,
|
|
26716
26741
|
projectDirectoryPath,
|
|
26717
|
-
|
|
26742
|
+
// An explicit mermaidConfig.theme (config script) wins, same as
|
|
26743
|
+
// in the preview init script.
|
|
26744
|
+
notebook.config.mermaidConfig?.theme || notebook.config.mermaidTheme
|
|
26718
26745
|
);
|
|
26719
26746
|
let displayPNGFilePath;
|
|
26720
26747
|
if (useRelativeFilePath) {
|
|
@@ -27344,6 +27371,10 @@ async function pandocConvert(text, {
|
|
|
27344
27371
|
codeChunksData,
|
|
27345
27372
|
graphsCache,
|
|
27346
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,
|
|
27347
27378
|
notebook
|
|
27348
27379
|
});
|
|
27349
27380
|
await mkdirp3.sync(path11.dirname(outputFilePath));
|
|
@@ -27351,7 +27382,7 @@ async function pandocConvert(text, {
|
|
|
27351
27382
|
const program = (0, import_child_process7.execFile)(
|
|
27352
27383
|
notebook.config.pandocPath,
|
|
27353
27384
|
args,
|
|
27354
|
-
{ cwd: fileDirectoryPath },
|
|
27385
|
+
{ cwd: fileDirectoryPath, windowsHide: true },
|
|
27355
27386
|
(error) => {
|
|
27356
27387
|
if (error) {
|
|
27357
27388
|
return reject(error.toString());
|
|
@@ -27371,6 +27402,7 @@ function princeConvert(src, dest) {
|
|
|
27371
27402
|
(0, import_child_process8.execFile)(
|
|
27372
27403
|
"prince",
|
|
27373
27404
|
[src, "--javascript", "-o", dest],
|
|
27405
|
+
{ windowsHide: true },
|
|
27374
27406
|
(error) => {
|
|
27375
27407
|
if (error) {
|
|
27376
27408
|
let errorMessage = error.toString();
|
|
@@ -30856,6 +30888,24 @@ var html5_embed_default = (md, notebook) => {
|
|
|
30856
30888
|
};
|
|
30857
30889
|
|
|
30858
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
|
+
}
|
|
30859
30909
|
var math_default = (md, notebook) => {
|
|
30860
30910
|
md.block.ruler.before(
|
|
30861
30911
|
"lheading",
|
|
@@ -30969,6 +31019,9 @@ var math_default = (md, notebook) => {
|
|
|
30969
31019
|
} else {
|
|
30970
31020
|
return false;
|
|
30971
31021
|
}
|
|
31022
|
+
if (openTag === "$" && closeTag === "$" && !isDollarMathSpan(state.src, state.pos, end)) {
|
|
31023
|
+
return false;
|
|
31024
|
+
}
|
|
30972
31025
|
if (content && !silent) {
|
|
30973
31026
|
const token = state.push("math", "", 0);
|
|
30974
31027
|
token.content = content.trim();
|
|
@@ -31089,6 +31142,11 @@ function replaceDelimited(html, openTag, closeTag, displayMode, notebook) {
|
|
|
31089
31142
|
i += openTag.length;
|
|
31090
31143
|
continue;
|
|
31091
31144
|
}
|
|
31145
|
+
if (openTag === "$" && closeTag === "$" && !isDollarMathSpan(html, i, end)) {
|
|
31146
|
+
out += html[i];
|
|
31147
|
+
i += 1;
|
|
31148
|
+
continue;
|
|
31149
|
+
}
|
|
31092
31150
|
const content = html.slice(i + openTag.length, end).trim();
|
|
31093
31151
|
out += parse_math_default({
|
|
31094
31152
|
content,
|
|
@@ -31124,6 +31182,9 @@ var tag_default = (md, notebook) => {
|
|
|
31124
31182
|
if (!notebook.config.enableTagSyntax || state.src.charCodeAt(state.pos) !== 35) {
|
|
31125
31183
|
return false;
|
|
31126
31184
|
}
|
|
31185
|
+
if (state.linkLevel > 0) {
|
|
31186
|
+
return false;
|
|
31187
|
+
}
|
|
31127
31188
|
if (state.pos > 0) {
|
|
31128
31189
|
const prev = state.src.charCodeAt(state.pos - 1);
|
|
31129
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) {
|
|
@@ -32076,6 +32137,12 @@ function isSamePath(a, b) {
|
|
|
32076
32137
|
}
|
|
32077
32138
|
return a === b;
|
|
32078
32139
|
}
|
|
32140
|
+
function normalizeNotebookConfig(config) {
|
|
32141
|
+
if (config.markdownParser === "markdown_yo") {
|
|
32142
|
+
return { ...config, markdownParser: "markdown-yo" };
|
|
32143
|
+
}
|
|
32144
|
+
return config;
|
|
32145
|
+
}
|
|
32079
32146
|
var Notebook = class _Notebook {
|
|
32080
32147
|
constructor() {
|
|
32081
32148
|
/**
|
|
@@ -32159,12 +32226,12 @@ var Notebook = class _Notebook {
|
|
|
32159
32226
|
this.processedMtimes = /* @__PURE__ */ new Map();
|
|
32160
32227
|
this.search = new Search();
|
|
32161
32228
|
/**
|
|
32162
|
-
* Optional
|
|
32163
|
-
* Used for HTML rendering when `markdownParser === '
|
|
32229
|
+
* Optional markdown-yo WASM renderer.
|
|
32230
|
+
* Used for HTML rendering when `markdownParser === 'markdown-yo'`.
|
|
32164
32231
|
*/
|
|
32165
32232
|
this.markdownYoRenderer = null;
|
|
32166
32233
|
/**
|
|
32167
|
-
* Tracks in-flight
|
|
32234
|
+
* Tracks in-flight markdown-yo initialization to avoid duplicate loads.
|
|
32168
32235
|
*/
|
|
32169
32236
|
this.markdownYoRendererPromise = null;
|
|
32170
32237
|
/**
|
|
@@ -32197,7 +32264,7 @@ var Notebook = class _Notebook {
|
|
|
32197
32264
|
this.initFs(fs23);
|
|
32198
32265
|
await this.initConfig(config);
|
|
32199
32266
|
this.md = this.initMarkdownIt();
|
|
32200
|
-
if (this.config.markdownParser === "
|
|
32267
|
+
if (this.config.markdownParser === "markdown-yo") {
|
|
32201
32268
|
await this.initMarkdownYo();
|
|
32202
32269
|
}
|
|
32203
32270
|
this.updateConfig({});
|
|
@@ -32212,11 +32279,11 @@ var Notebook = class _Notebook {
|
|
|
32212
32279
|
path15.join(this.notebookPath.fsPath, "./.crossnote"),
|
|
32213
32280
|
this.fs
|
|
32214
32281
|
);
|
|
32215
|
-
this.config = {
|
|
32282
|
+
this.config = normalizeNotebookConfig({
|
|
32216
32283
|
...getDefaultNotebookConfig(),
|
|
32217
32284
|
...extraConfig,
|
|
32218
32285
|
...config
|
|
32219
|
-
};
|
|
32286
|
+
});
|
|
32220
32287
|
}
|
|
32221
32288
|
initMarkdownIt(options) {
|
|
32222
32289
|
const md = new import_markdown_it.default(options ?? defaultMarkdownItConfig);
|
|
@@ -32276,7 +32343,7 @@ var Notebook = class _Notebook {
|
|
|
32276
32343
|
}
|
|
32277
32344
|
}
|
|
32278
32345
|
/**
|
|
32279
|
-
* Initialize the
|
|
32346
|
+
* Initialize the markdown-yo WASM renderer.
|
|
32280
32347
|
*/
|
|
32281
32348
|
async initMarkdownYo() {
|
|
32282
32349
|
if (this.markdownYoRendererPromise) {
|
|
@@ -32288,15 +32355,15 @@ var Notebook = class _Notebook {
|
|
|
32288
32355
|
}
|
|
32289
32356
|
this.markdownYoRendererPromise = (async () => {
|
|
32290
32357
|
try {
|
|
32291
|
-
const { createRenderer } = await import("
|
|
32358
|
+
const { createRenderer } = await import("@shd101wyy/markdown-yo");
|
|
32292
32359
|
const renderer = await createRenderer();
|
|
32293
|
-
if (this.config.markdownParser === "
|
|
32360
|
+
if (this.config.markdownParser === "markdown-yo") {
|
|
32294
32361
|
this.markdownYoRenderer = renderer;
|
|
32295
32362
|
} else {
|
|
32296
32363
|
renderer.destroy();
|
|
32297
32364
|
}
|
|
32298
32365
|
} catch (error) {
|
|
32299
|
-
console.warn("Failed to load
|
|
32366
|
+
console.warn("Failed to load markdown-yo WASM renderer:", error);
|
|
32300
32367
|
this.markdownYoRenderer = null;
|
|
32301
32368
|
} finally {
|
|
32302
32369
|
this.markdownYoRendererPromise = null;
|
|
@@ -32309,7 +32376,7 @@ var Notebook = class _Notebook {
|
|
|
32309
32376
|
this.markdownYoRenderer = null;
|
|
32310
32377
|
}
|
|
32311
32378
|
/**
|
|
32312
|
-
* Build
|
|
32379
|
+
* Build markdown-yo render options from the current notebook config.
|
|
32313
32380
|
*/
|
|
32314
32381
|
buildMarkdownYoOptions(isForPreview) {
|
|
32315
32382
|
const c = this.config;
|
|
@@ -32335,7 +32402,7 @@ var Notebook = class _Notebook {
|
|
|
32335
32402
|
};
|
|
32336
32403
|
}
|
|
32337
32404
|
/**
|
|
32338
|
-
* Convert
|
|
32405
|
+
* Convert markdown-yo RenderOptions to CLI flags for the native binary.
|
|
32339
32406
|
*/
|
|
32340
32407
|
buildMarkdownYoBinaryArgs(opts) {
|
|
32341
32408
|
const flags = [];
|
|
@@ -32359,11 +32426,11 @@ var Notebook = class _Notebook {
|
|
|
32359
32426
|
return flags;
|
|
32360
32427
|
}
|
|
32361
32428
|
/**
|
|
32362
|
-
* Render markdown to HTML using
|
|
32429
|
+
* Render markdown to HTML using markdown-yo (WASM) if available,
|
|
32363
32430
|
* otherwise falls back to markdown-it.
|
|
32364
32431
|
*/
|
|
32365
32432
|
renderMarkdown(markdown, options) {
|
|
32366
|
-
if (this.config.markdownParser === "
|
|
32433
|
+
if (this.config.markdownParser === "markdown-yo") {
|
|
32367
32434
|
const renderOpts = this.buildMarkdownYoOptions(!!options?.isForPreview);
|
|
32368
32435
|
const binaryPath = this.config.markdownYoBinaryPath;
|
|
32369
32436
|
let html;
|
|
@@ -32372,7 +32439,8 @@ var Notebook = class _Notebook {
|
|
|
32372
32439
|
html = (0, import_child_process9.execFileSync)(binaryPath, args, {
|
|
32373
32440
|
input: markdown,
|
|
32374
32441
|
encoding: "utf8",
|
|
32375
|
-
maxBuffer: 256 * 1024 * 1024
|
|
32442
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
32443
|
+
windowsHide: true
|
|
32376
32444
|
});
|
|
32377
32445
|
} else if (this.markdownYoRenderer) {
|
|
32378
32446
|
html = this.markdownYoRenderer.render(markdown, renderOpts);
|
|
@@ -32394,7 +32462,7 @@ var Notebook = class _Notebook {
|
|
|
32394
32462
|
return md.render(markdown);
|
|
32395
32463
|
}
|
|
32396
32464
|
/**
|
|
32397
|
-
* Post-process
|
|
32465
|
+
* Post-process markdown-yo HTML output:
|
|
32398
32466
|
* - Render math expressions with KaTeX (when mathRenderingOption is 'KaTeX')
|
|
32399
32467
|
* - Append file extension to wikilink hrefs
|
|
32400
32468
|
*/
|
|
@@ -32436,17 +32504,17 @@ var Notebook = class _Notebook {
|
|
|
32436
32504
|
return html;
|
|
32437
32505
|
}
|
|
32438
32506
|
updateConfig(config) {
|
|
32439
|
-
this.config = {
|
|
32507
|
+
this.config = normalizeNotebookConfig({
|
|
32440
32508
|
...this.config,
|
|
32441
32509
|
...config
|
|
32442
|
-
};
|
|
32510
|
+
});
|
|
32443
32511
|
this.interpolateConfig();
|
|
32444
32512
|
this.md.set({
|
|
32445
32513
|
typographer: !!this.config.enableTypographer,
|
|
32446
32514
|
breaks: !!this.config.breakOnSingleNewLine,
|
|
32447
32515
|
linkify: !!this.config.enableLinkify
|
|
32448
32516
|
});
|
|
32449
|
-
if (this.config.markdownParser === "
|
|
32517
|
+
if (this.config.markdownParser === "markdown-yo") {
|
|
32450
32518
|
void this.initMarkdownYo();
|
|
32451
32519
|
} else {
|
|
32452
32520
|
this.destroyMarkdownYo();
|
|
@@ -33949,17 +34017,19 @@ async function enhance5($) {
|
|
|
33949
34017
|
const $col = $(col);
|
|
33950
34018
|
const text = $col.text();
|
|
33951
34019
|
const html = $col.html();
|
|
34020
|
+
const $children = $col.children();
|
|
34021
|
+
const isBareText = !$children.length || $children.length === 1 && $children.is("p") && !$children.children().length;
|
|
33952
34022
|
if (!text.length && !html?.length) {
|
|
33953
34023
|
const $prev = $col.prev();
|
|
33954
34024
|
if ($prev.length) {
|
|
33955
34025
|
colspans2.push([$prev, $col]);
|
|
33956
34026
|
}
|
|
33957
|
-
} else if (text.trim() === "^" && $prevRow) {
|
|
34027
|
+
} else if (isBareText && text.trim() === "^" && $prevRow) {
|
|
33958
34028
|
const $prev = $($prevRow.children()[j]);
|
|
33959
34029
|
if ($prev.length) {
|
|
33960
34030
|
rowspans.push([$prev, $col]);
|
|
33961
34031
|
}
|
|
33962
|
-
} else if (text.trim() === ">") {
|
|
34032
|
+
} else if (isBareText && text.trim() === ">") {
|
|
33963
34033
|
const $next = $col.next();
|
|
33964
34034
|
if ($next.length) {
|
|
33965
34035
|
colspans.push([$col, $next]);
|
|
@@ -34273,7 +34343,7 @@ async function renderD2(code, opts, fileDirectoryPath) {
|
|
|
34273
34343
|
(0, import_child_process10.execFile)(
|
|
34274
34344
|
opts.d2Path,
|
|
34275
34345
|
args,
|
|
34276
|
-
{ timeout: 3e4 },
|
|
34346
|
+
{ timeout: 3e4, windowsHide: true },
|
|
34277
34347
|
(err, _stdout, stderr) => {
|
|
34278
34348
|
if (err) {
|
|
34279
34349
|
const wrapped = new Error(stderr || err.message);
|
|
@@ -35064,6 +35134,61 @@ function buildMathJaxConfigScript(mathJaxConfig) {
|
|
|
35064
35134
|
})();`;
|
|
35065
35135
|
}
|
|
35066
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
|
+
|
|
35067
35192
|
// src/renderers/wavedrom-source.ts
|
|
35068
35193
|
var import_json52 = __toESM(require("json5"));
|
|
35069
35194
|
|
|
@@ -35289,7 +35414,7 @@ function pandocSupportsMathMethod(pandocPath) {
|
|
|
35289
35414
|
(0, import_child_process11.execFile)(
|
|
35290
35415
|
pandocPath,
|
|
35291
35416
|
["--version"],
|
|
35292
|
-
{ timeout: 1e4 },
|
|
35417
|
+
{ timeout: 1e4, windowsHide: true },
|
|
35293
35418
|
(error, stdout) => {
|
|
35294
35419
|
resolve21(!error && pandocVersionSupportsMathMethod(String(stdout)));
|
|
35295
35420
|
}
|
|
@@ -35368,6 +35493,7 @@ var MarkdownEngine = class _MarkdownEngine {
|
|
|
35368
35493
|
generateScriptsForPreview(isForPresentation = false, yamlConfig = {}, vscodePreviewPanel = null) {
|
|
35369
35494
|
let scripts = "";
|
|
35370
35495
|
scripts += `<script>var exports = undefined</script>`;
|
|
35496
|
+
scripts += MERMAID_LEGACY_WEBVIEW_POLYFILL;
|
|
35371
35497
|
scripts += `<script type="text/javascript" src="${addFileProtocol(
|
|
35372
35498
|
path19.resolve(
|
|
35373
35499
|
getCrossnoteBuildDirectory(),
|
|
@@ -35461,7 +35587,7 @@ var MERMAID_CONFIG = (${JSON.stringify(this.notebook.config.mermaidConfig)});
|
|
|
35461
35587
|
if (typeof MERMAID_CONFIG !== 'undefined') {
|
|
35462
35588
|
MERMAID_CONFIG.startOnLoad = false
|
|
35463
35589
|
MERMAID_CONFIG.cloneCssStyles = false
|
|
35464
|
-
MERMAID_CONFIG.theme = "${this.notebook.config.mermaidTheme}"
|
|
35590
|
+
MERMAID_CONFIG.theme = MERMAID_CONFIG.theme || "${this.notebook.config.mermaidTheme}"
|
|
35465
35591
|
}
|
|
35466
35592
|
mermaid.initialize(MERMAID_CONFIG || {})
|
|
35467
35593
|
if (typeof(window['Reveal']) !== 'undefined') {
|
|
@@ -36010,7 +36136,7 @@ window["initRevealPresentation"] = async function() {
|
|
|
36010
36136
|
if (options.offline) {
|
|
36011
36137
|
mathStyle = await offlineStyle("./dependencies/katex/katex.min.css");
|
|
36012
36138
|
} else {
|
|
36013
|
-
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">`;
|
|
36014
36140
|
}
|
|
36015
36141
|
} else {
|
|
36016
36142
|
mathStyle = "";
|
|
@@ -36028,51 +36154,18 @@ window["initRevealPresentation"] = async function() {
|
|
|
36028
36154
|
let mermaidScript = "";
|
|
36029
36155
|
let mermaidInitScript = "";
|
|
36030
36156
|
if (html.indexOf(' class="mermaid') >= 0) {
|
|
36157
|
+
mermaidScript = MERMAID_LEGACY_WEBVIEW_POLYFILL;
|
|
36031
36158
|
if (options.offline) {
|
|
36032
|
-
mermaidScript
|
|
36159
|
+
mermaidScript += await offlineScript(
|
|
36033
36160
|
"./dependencies/mermaid/mermaid.min.js"
|
|
36034
36161
|
);
|
|
36035
36162
|
} else {
|
|
36036
|
-
mermaidScript
|
|
36163
|
+
mermaidScript += `<script src="https://${this.notebook.config.jsdelivrCdnHost}/npm/mermaid@12.3.0/dist/mermaid.min.js"></script>`;
|
|
36037
36164
|
}
|
|
36038
|
-
mermaidInitScript
|
|
36039
|
-
|
|
36040
|
-
|
|
36041
|
-
|
|
36042
|
-
await mermaid.registerExternalDiagrams([zenuml])` : ``}
|
|
36043
|
-
|
|
36044
|
-
var MERMAID_CONFIG = (${JSON.stringify(this.notebook.config.mermaidConfig)});
|
|
36045
|
-
if (typeof MERMAID_CONFIG !== 'undefined') {
|
|
36046
|
-
MERMAID_CONFIG.startOnLoad = false
|
|
36047
|
-
MERMAID_CONFIG.cloneCssStyles = false
|
|
36048
|
-
MERMAID_CONFIG.theme = "${this.notebook.config.mermaidTheme}"
|
|
36049
|
-
}
|
|
36050
|
-
|
|
36051
|
-
mermaid.initialize(MERMAID_CONFIG || {})
|
|
36052
|
-
if (typeof(window['Reveal']) !== 'undefined') {
|
|
36053
|
-
function mermaidRevealHelper(event) {
|
|
36054
|
-
var currentSlide = event.currentSlide
|
|
36055
|
-
var diagrams = currentSlide.querySelectorAll('div.mermaid')
|
|
36056
|
-
for (var i = 0; i < diagrams.length; i++) {
|
|
36057
|
-
var diagram = diagrams[i]
|
|
36058
|
-
if (!diagram.hasAttribute('data-processed')) {
|
|
36059
|
-
mermaid.init(null, diagram, ()=> {
|
|
36060
|
-
Reveal.slide(event.indexh, event.indexv)
|
|
36061
|
-
})
|
|
36062
|
-
}
|
|
36063
|
-
}
|
|
36064
|
-
}
|
|
36065
|
-
Reveal.addEventListener('slidetransitionend', mermaidRevealHelper)
|
|
36066
|
-
Reveal.addEventListener('ready', mermaidRevealHelper)
|
|
36067
|
-
await mermaid.run({
|
|
36068
|
-
nodes: document.querySelectorAll('div.mermaid')
|
|
36069
|
-
})
|
|
36070
|
-
} else {
|
|
36071
|
-
await mermaid.run({
|
|
36072
|
-
nodes: document.querySelectorAll('div.mermaid')
|
|
36073
|
-
})
|
|
36074
|
-
}
|
|
36075
|
-
</script>`;
|
|
36165
|
+
mermaidInitScript = `<script type="module">${buildMermaidExportScript(
|
|
36166
|
+
this.notebook.config,
|
|
36167
|
+
/zenuml/i.test(html)
|
|
36168
|
+
)}</script>`;
|
|
36076
36169
|
}
|
|
36077
36170
|
let wavedromScript = ``;
|
|
36078
36171
|
let wavedromInitScript = ``;
|
|
@@ -36445,7 +36538,13 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
36445
36538
|
isForPrint: false,
|
|
36446
36539
|
isForPrince: false,
|
|
36447
36540
|
offline: true,
|
|
36448
|
-
|
|
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,
|
|
36449
36548
|
isForBrowser: true
|
|
36450
36549
|
});
|
|
36451
36550
|
const info = await tempOpen({
|
|
@@ -36579,47 +36678,66 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
36579
36678
|
executablePath,
|
|
36580
36679
|
headless: true
|
|
36581
36680
|
});
|
|
36582
|
-
|
|
36583
|
-
|
|
36584
|
-
|
|
36585
|
-
|
|
36586
|
-
|
|
36587
|
-
|
|
36588
|
-
|
|
36589
|
-
|
|
36590
|
-
|
|
36591
|
-
|
|
36592
|
-
|
|
36593
|
-
|
|
36594
|
-
|
|
36595
|
-
|
|
36596
|
-
|
|
36597
|
-
};
|
|
36598
|
-
let timeout = 0;
|
|
36599
|
-
if (chromeConfig && chromeConfig["timeout"]) {
|
|
36600
|
-
timeout = chromeConfig["timeout"];
|
|
36601
|
-
} else if (puppeteerConfig2 && puppeteerConfig2["timeout"]) {
|
|
36602
|
-
timeout = puppeteerConfig2["timeout"];
|
|
36603
|
-
}
|
|
36604
|
-
if (timeout && typeof timeout === "number") {
|
|
36605
|
-
await new Promise((resolve21) => setTimeout(resolve21, timeout));
|
|
36606
|
-
} else if (this.notebook.config.puppeteerWaitForTimeout && this.notebook.config.puppeteerWaitForTimeout > 0) {
|
|
36607
|
-
await new Promise(
|
|
36608
|
-
(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 }
|
|
36609
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
|
+
});
|
|
36610
36740
|
}
|
|
36611
|
-
if (fileType === "pdf") {
|
|
36612
|
-
await page.pdf(puppeteerConfig);
|
|
36613
|
-
} else {
|
|
36614
|
-
puppeteerConfig["fullPage"] = true;
|
|
36615
|
-
await page.screenshot(puppeteerConfig);
|
|
36616
|
-
}
|
|
36617
|
-
browser.close().catch(() => {
|
|
36618
|
-
});
|
|
36619
|
-
if (openFileAfterGeneration) {
|
|
36620
|
-
openFile(dest);
|
|
36621
|
-
}
|
|
36622
|
-
return dest;
|
|
36623
36741
|
}
|
|
36624
36742
|
/**
|
|
36625
36743
|
* prince pdf file export
|
|
@@ -36851,7 +36969,7 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
36851
36969
|
let mathStyle = "";
|
|
36852
36970
|
if (outputHTML.indexOf('class="katex"') > 0) {
|
|
36853
36971
|
if (path19.extname(dest) === ".html" && ebookConfig["html"] && ebookConfig["html"]["cdn"]) {
|
|
36854
|
-
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">`;
|
|
36855
36973
|
} else {
|
|
36856
36974
|
mathStyle = `<link rel="stylesheet" href="${toFileURL(
|
|
36857
36975
|
path19.resolve(
|
|
@@ -37479,7 +37597,11 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37479
37597
|
const program = (0, import_child_process11.execFile)(
|
|
37480
37598
|
pandocPath,
|
|
37481
37599
|
args,
|
|
37482
|
-
{
|
|
37600
|
+
{
|
|
37601
|
+
cwd: this.fileDirectoryPath,
|
|
37602
|
+
maxBuffer: Infinity,
|
|
37603
|
+
windowsHide: true
|
|
37604
|
+
},
|
|
37483
37605
|
(error, stdout, stderr) => {
|
|
37484
37606
|
if (error) {
|
|
37485
37607
|
return reject(error);
|
|
@@ -37606,7 +37728,7 @@ Check "http://pandoc.org/installing.html" website.`;
|
|
|
37606
37728
|
);
|
|
37607
37729
|
}
|
|
37608
37730
|
const $ = cheerio3.load(html);
|
|
37609
|
-
if (this.notebook.config.markdownParser === "
|
|
37731
|
+
if (this.notebook.config.markdownParser === "markdown-yo") {
|
|
37610
37732
|
normalizeMarkdownYoCodeBlocks($);
|
|
37611
37733
|
normalizeMarkdownYoHeadings($);
|
|
37612
37734
|
}
|