crossnote 0.9.40 → 0.9.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/cjs/index.cjs +270 -270
- package/out/cli/index.cjs +368 -125
- package/out/esm/index.mjs +233 -233
- package/out/types/src/lib/dangerous-urls.d.ts +3 -0
- package/out/types/src/markdown-engine/index.d.ts +1 -0
- package/out/types/src/markdown-engine/transformer.d.ts +2 -0
- 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/test/csv.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/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/tsconfig.tsbuildinfo +1 -1
- package/out/webview/preview.js +161 -161
- package/package.json +1 -1
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
|
|
|
@@ -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");
|
|
@@ -24939,6 +24965,13 @@ async function downloadFileIfNecessary(filePath) {
|
|
|
24939
24965
|
await fs3.writeFile(localFilePath, Buffer.from(buffer));
|
|
24940
24966
|
return localFilePath;
|
|
24941
24967
|
}
|
|
24968
|
+
async function isFile(notebook, filePath) {
|
|
24969
|
+
try {
|
|
24970
|
+
return (await notebook.fs.stat(filePath)).isFile();
|
|
24971
|
+
} catch {
|
|
24972
|
+
return false;
|
|
24973
|
+
}
|
|
24974
|
+
}
|
|
24942
24975
|
async function loadFile(filePath, {
|
|
24943
24976
|
fileDirectoryPath,
|
|
24944
24977
|
imageDirectoryPath,
|
|
@@ -24984,6 +25017,19 @@ async function loadFile(filePath, {
|
|
|
24984
25017
|
}
|
|
24985
25018
|
}
|
|
24986
25019
|
var BLOCK_ID_RE = /(?<!\s)\s+\^([a-zA-Z0-9_-]+)$/;
|
|
25020
|
+
function absoluteImportPath(target, pathImpl = path5) {
|
|
25021
|
+
if (/^file:\/\//i.test(target)) {
|
|
25022
|
+
try {
|
|
25023
|
+
return (0, import_url2.fileURLToPath)(target);
|
|
25024
|
+
} catch {
|
|
25025
|
+
return null;
|
|
25026
|
+
}
|
|
25027
|
+
}
|
|
25028
|
+
if (!target.startsWith("/") && pathImpl.isAbsolute(target)) {
|
|
25029
|
+
return target;
|
|
25030
|
+
}
|
|
25031
|
+
return null;
|
|
25032
|
+
}
|
|
24987
25033
|
async function transformMarkdown(inputString, {
|
|
24988
25034
|
fileDirectoryPath = "",
|
|
24989
25035
|
projectDirectoryPath = "",
|
|
@@ -25342,9 +25388,10 @@ async function transformMarkdown(inputString, {
|
|
|
25342
25388
|
continue;
|
|
25343
25389
|
}
|
|
25344
25390
|
const importMatch = line.match(/^(\s*)@import(\s+)"([^"]+)";?/);
|
|
25345
|
-
const
|
|
25391
|
+
const lineImageMatch = line.match(
|
|
25346
25392
|
/^(\s*)!\[([^\]]*)\]\(([^)]+)\)(?:{([^}]*)})?(\s*)$/
|
|
25347
25393
|
);
|
|
25394
|
+
const imageImportMatch = lineImageMatch && !/^\s*data:/i.test(lineImageMatch[3]) ? lineImageMatch : null;
|
|
25348
25395
|
const wikilinkImportMatch = line.match(
|
|
25349
25396
|
/^(\s*)!\[\[(.+?)\]\](?:{([^}]*)})?\s*$/
|
|
25350
25397
|
);
|
|
@@ -25400,10 +25447,15 @@ async function transformMarkdown(inputString, {
|
|
|
25400
25447
|
config["data-source-line"] = lineNo + 1;
|
|
25401
25448
|
}
|
|
25402
25449
|
let absoluteFilePath;
|
|
25403
|
-
|
|
25450
|
+
const absoluteImport = absoluteImportPath(filePath);
|
|
25451
|
+
if (absoluteImport) {
|
|
25452
|
+
absoluteFilePath = absoluteImport;
|
|
25453
|
+
} else if (protocolsWhiteListRegExp && filePath.match(protocolsWhiteListRegExp)) {
|
|
25404
25454
|
absoluteFilePath = filePath;
|
|
25405
25455
|
} else if (filePath.startsWith("/")) {
|
|
25406
25456
|
absoluteFilePath = path5.resolve(projectDirectoryPath, "." + filePath);
|
|
25457
|
+
} else if (!wikilinkImportMatch && !path5.extname(filePath) && await isFile(notebook, path5.resolve(fileDirectoryPath, filePath))) {
|
|
25458
|
+
absoluteFilePath = path5.resolve(fileDirectoryPath, filePath);
|
|
25407
25459
|
} else {
|
|
25408
25460
|
const currentRelativeDir = path5.relative(
|
|
25409
25461
|
projectDirectoryPath,
|
|
@@ -25435,24 +25487,25 @@ async function transformMarkdown(inputString, {
|
|
|
25435
25487
|
lineNo = lineNo + 1;
|
|
25436
25488
|
outputString = outputString + output2;
|
|
25437
25489
|
continue;
|
|
25438
|
-
} else if (extname14.match(/^\.(apng|avif|gif|jpeg|jpg|png|svg|bmp|webp|emf)/) ||
|
|
25490
|
+
} else if (extname14.match(/^\.(apng|avif|gif|jpeg|jpg|png|svg|bmp|webp|emf)/) || // NOTE: For example, for github image like: 
|
|
25491
|
+
// A local file without an extension is an image only when written
|
|
25492
|
+
// as ``; `@import "Caddyfile"` is shown as a code block below.
|
|
25493
|
+
extname14 === "" && (absoluteFilePath === filePath || !!imageImportMatch)) {
|
|
25439
25494
|
if (importMatch || wikilinkImportMatch) {
|
|
25440
25495
|
let imageSrc = filesCache[filePath];
|
|
25441
25496
|
if (!imageSrc) {
|
|
25442
25497
|
if (protocolsWhiteListRegExp && filePath.match(protocolsWhiteListRegExp)) {
|
|
25443
25498
|
imageSrc = filePath;
|
|
25444
|
-
} else if (useRelativeFilePath) {
|
|
25445
|
-
imageSrc = path5.relative(fileDirectoryPath, absoluteFilePath);
|
|
25446
|
-
if (!forMarkdownExport) {
|
|
25447
|
-
imageSrc += "?" + (timestamp ?? Math.random());
|
|
25448
|
-
}
|
|
25449
25499
|
} else {
|
|
25450
|
-
imageSrc =
|
|
25500
|
+
imageSrc = useRelativeFilePath ? escapeUrlPath(
|
|
25501
|
+
path5.relative(fileDirectoryPath, absoluteFilePath)
|
|
25502
|
+
) : "/" + escapeUrlPath(
|
|
25503
|
+
path5.relative(projectDirectoryPath, absoluteFilePath)
|
|
25504
|
+
);
|
|
25451
25505
|
if (!forMarkdownExport) {
|
|
25452
25506
|
imageSrc += "?" + (timestamp ?? Math.random());
|
|
25453
25507
|
}
|
|
25454
25508
|
}
|
|
25455
|
-
imageSrc = imageSrc.replace(/ /g, "%20").replace(/\\/g, "/");
|
|
25456
25509
|
filesCache[filePath] = imageSrc;
|
|
25457
25510
|
}
|
|
25458
25511
|
output = "![";
|
|
@@ -32167,6 +32220,8 @@ var Notebook = class _Notebook {
|
|
|
32167
32220
|
}
|
|
32168
32221
|
initMarkdownIt(options) {
|
|
32169
32222
|
const md = new import_markdown_it.default(options ?? defaultMarkdownItConfig);
|
|
32223
|
+
const validateLink = md.validateLink.bind(md);
|
|
32224
|
+
md.validateLink = (url) => validateLink(url) || /^data:image\/svg\+xml[;,]/i.test(url.trim());
|
|
32170
32225
|
md.use(import_markdown_it_footnote.default);
|
|
32171
32226
|
md.use(import_markdown_it_sub.default);
|
|
32172
32227
|
md.use(import_markdown_it_sup.default);
|
|
@@ -32682,12 +32737,12 @@ var Notebook = class _Notebook {
|
|
|
32682
32737
|
* front-matter-normalised `markdown` body. No caching — the caller
|
|
32683
32738
|
* decides whether to stash the note into `this.notes`.
|
|
32684
32739
|
*/
|
|
32685
|
-
async loadNoteFromDisk(filePath) {
|
|
32740
|
+
async loadNoteFromDisk(filePath, knownStats) {
|
|
32686
32741
|
filePath = this.resolveNoteRelativePath(filePath);
|
|
32687
32742
|
const absFilePath = this.resolveNoteAbsolutePath(filePath);
|
|
32688
32743
|
let stats;
|
|
32689
32744
|
try {
|
|
32690
|
-
stats = await this.fs.stat(absFilePath);
|
|
32745
|
+
stats = knownStats ?? await this.fs.stat(absFilePath);
|
|
32691
32746
|
} catch {
|
|
32692
32747
|
return null;
|
|
32693
32748
|
}
|
|
@@ -32953,70 +33008,70 @@ var Notebook = class _Notebook {
|
|
|
32953
33008
|
} catch {
|
|
32954
33009
|
return;
|
|
32955
33010
|
}
|
|
33011
|
+
const sizeLimit = this.config.maxNoteFileSize ?? 0;
|
|
33012
|
+
const isIndexableMarkdown = (stats, name) => stats.isFile() && this.config.markdownFileExtensions.includes(path15.extname(name)) && (sizeLimit <= 0 || stats.size <= sizeLimit);
|
|
32956
33013
|
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
|
-
|
|
33014
|
+
await Promise.all(
|
|
33015
|
+
files.map(async (file) => {
|
|
33016
|
+
if (file.match(/^(node_modules|\.git)$/)) {
|
|
33017
|
+
return;
|
|
33018
|
+
}
|
|
33019
|
+
const absFilePath = path15.resolve(dirAbsPath, file);
|
|
33020
|
+
const relFromNotebook = path15.relative(this.notebookPath.fsPath, absFilePath).replace(/\\/g, "/");
|
|
33021
|
+
if (currentStack.length > 0 && isIgnoredByGitignore(relFromNotebook)) {
|
|
33022
|
+
return;
|
|
33023
|
+
}
|
|
33024
|
+
let stats;
|
|
33025
|
+
try {
|
|
33026
|
+
stats = await this.fs.stat(absFilePath);
|
|
33027
|
+
} catch {
|
|
33028
|
+
return;
|
|
33029
|
+
}
|
|
33030
|
+
this.walkedEntriesThisRefresh += 1;
|
|
33031
|
+
if (!this.oversizedWalkWarned && this.walkedEntriesThisRefresh > OVERSIZED_WALK_WARN_THRESHOLD) {
|
|
33032
|
+
this.oversizedWalkWarned = true;
|
|
33033
|
+
console.warn(
|
|
33034
|
+
`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.`
|
|
33035
|
+
);
|
|
33036
|
+
}
|
|
33037
|
+
if (stats.isSymbolicLink()) {
|
|
33038
|
+
return;
|
|
33039
|
+
}
|
|
33040
|
+
if (isIndexableMarkdown(stats, relFromNotebook)) {
|
|
33041
|
+
await onFile({
|
|
33042
|
+
absPath: absFilePath,
|
|
33043
|
+
relPath: relFromNotebook,
|
|
33044
|
+
stats
|
|
33045
|
+
});
|
|
33046
|
+
} else if (stats.isDirectory() && includeSubdirectories) {
|
|
33047
|
+
subdirPromises.push(
|
|
33048
|
+
this._walkNotebookDir(
|
|
33049
|
+
relFromNotebook,
|
|
33050
|
+
includeSubdirectories,
|
|
33051
|
+
currentStack,
|
|
33052
|
+
onFile
|
|
33053
|
+
)
|
|
33054
|
+
);
|
|
33055
|
+
}
|
|
33056
|
+
})
|
|
33057
|
+
);
|
|
32999
33058
|
await Promise.all(subdirPromises);
|
|
33000
33059
|
}
|
|
33001
33060
|
/**
|
|
33002
33061
|
* 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.
|
|
33062
|
+
* file's notebook-relative path → mtimeMs into `out`. The walk
|
|
33063
|
+
* already excludes files that are too large (`maxNoteFileSize`) or
|
|
33064
|
+
* have a non-markdown extension — the same gates `loadNoteFromDisk`
|
|
33065
|
+
* applies — so the incremental refresh never tries to process
|
|
33066
|
+
* something that the loader would reject.
|
|
33008
33067
|
*/
|
|
33009
33068
|
async _collectOnDiskMtimes(dir, includeSubdirectories, gitignoreStack, out) {
|
|
33010
|
-
const sizeLimit = this.config.maxNoteFileSize ?? 0;
|
|
33011
33069
|
await this._walkNotebookDir(
|
|
33012
33070
|
dir,
|
|
33013
33071
|
includeSubdirectories,
|
|
33014
33072
|
gitignoreStack,
|
|
33015
33073
|
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
|
-
}
|
|
33074
|
+
out.set(relPath, Math.floor(stats.mtimeMs));
|
|
33020
33075
|
}
|
|
33021
33076
|
);
|
|
33022
33077
|
}
|
|
@@ -33032,7 +33087,7 @@ var Notebook = class _Notebook {
|
|
|
33032
33087
|
includeSubdirectories,
|
|
33033
33088
|
gitignoreStack,
|
|
33034
33089
|
async ({ relPath, stats }) => {
|
|
33035
|
-
const result = await this.loadNoteFromDisk(relPath);
|
|
33090
|
+
const result = await this.loadNoteFromDisk(relPath, stats);
|
|
33036
33091
|
if (!result) return;
|
|
33037
33092
|
const { note, markdown } = result;
|
|
33038
33093
|
this.notes[note.filePath] = note;
|
|
@@ -34140,7 +34195,7 @@ async function runCodeChunks(codeChunksData, runOptions) {
|
|
|
34140
34195
|
|
|
34141
34196
|
// src/render-enhancers/fenced-diagrams.ts
|
|
34142
34197
|
var import_cross_fetch2 = __toESM(require("cross-fetch"));
|
|
34143
|
-
var
|
|
34198
|
+
var import_html_escaper12 = require("html-escaper");
|
|
34144
34199
|
var YAML6 = __toESM(require("yaml"));
|
|
34145
34200
|
|
|
34146
34201
|
// src/renderers/bitfield.ts
|
|
@@ -34161,10 +34216,26 @@ async function renderBitfield(code, options) {
|
|
|
34161
34216
|
}
|
|
34162
34217
|
}
|
|
34163
34218
|
|
|
34219
|
+
// src/renderers/csv.ts
|
|
34220
|
+
var import_html_escaper9 = require("html-escaper");
|
|
34221
|
+
var Papa2 = __toESM(require("papaparse"));
|
|
34222
|
+
function renderCsv(code) {
|
|
34223
|
+
const { data, errors } = Papa2.parse(code.trim(), {
|
|
34224
|
+
skipEmptyLines: true
|
|
34225
|
+
});
|
|
34226
|
+
const error = errors.find((e) => e.type !== "Delimiter");
|
|
34227
|
+
if (error) {
|
|
34228
|
+
throw new Error(`CSV parse error: ${error.message}`);
|
|
34229
|
+
}
|
|
34230
|
+
const [header = [], ...rows] = data;
|
|
34231
|
+
const tr = (cells, tag) => `<tr>${cells.map((c) => `<${tag}>${(0, import_html_escaper9.escape)(c)}</${tag}>`).join("")}</tr>`;
|
|
34232
|
+
return `<table><thead>${tr(header, "th")}</thead><tbody>${rows.map((r) => tr(r, "td")).join("")}</tbody></table>`;
|
|
34233
|
+
}
|
|
34234
|
+
|
|
34164
34235
|
// src/renderers/d2.ts
|
|
34165
34236
|
var import_child_process10 = require("child_process");
|
|
34166
34237
|
var crypto = __toESM(require("crypto"));
|
|
34167
|
-
var
|
|
34238
|
+
var import_html_escaper10 = require("html-escaper");
|
|
34168
34239
|
var fs12 = __toESM(require("fs"));
|
|
34169
34240
|
var os2 = __toESM(require("os"));
|
|
34170
34241
|
var path17 = __toESM(require("path"));
|
|
@@ -34220,7 +34291,7 @@ async function renderD2(code, opts, fileDirectoryPath) {
|
|
|
34220
34291
|
const code2 = err.code;
|
|
34221
34292
|
const isNotFound = code2 === "ENOENT" || /not recognized as an internal or external command/i.test(msg);
|
|
34222
34293
|
if (isNotFound) return D2_NOT_FOUND;
|
|
34223
|
-
return `<pre class="language-text"><code>D2 error: ${(0,
|
|
34294
|
+
return `<pre class="language-text"><code>D2 error: ${(0, import_html_escaper10.escape)(msg)}</code></pre>`;
|
|
34224
34295
|
} finally {
|
|
34225
34296
|
if (tmpIn) {
|
|
34226
34297
|
fs12.promises.unlink(tmpIn).catch(() => void 0);
|
|
@@ -34230,7 +34301,7 @@ async function renderD2(code, opts, fileDirectoryPath) {
|
|
|
34230
34301
|
}
|
|
34231
34302
|
|
|
34232
34303
|
// src/renderers/tikz.ts
|
|
34233
|
-
var
|
|
34304
|
+
var import_html_escaper11 = require("html-escaper");
|
|
34234
34305
|
var import_async_mutex2 = require("async-mutex");
|
|
34235
34306
|
var TIKZ_NOT_AVAILABLE = /* @__PURE__ */ Symbol("TIKZ_NOT_AVAILABLE");
|
|
34236
34307
|
var mutex = new import_async_mutex2.Mutex();
|
|
@@ -34304,7 +34375,7 @@ ${input}
|
|
|
34304
34375
|
return svg;
|
|
34305
34376
|
} catch (err) {
|
|
34306
34377
|
const msg = err instanceof Error ? err.message : String(err);
|
|
34307
|
-
return `<pre class="language-text"><code>TikZ error: ${(0,
|
|
34378
|
+
return `<pre class="language-text"><code>TikZ error: ${(0, import_html_escaper11.escape)(msg)}</code></pre>`;
|
|
34308
34379
|
}
|
|
34309
34380
|
});
|
|
34310
34381
|
}
|
|
@@ -34468,7 +34539,8 @@ var supportedLanguages = [
|
|
|
34468
34539
|
"vega-lite",
|
|
34469
34540
|
"wsd",
|
|
34470
34541
|
"d2",
|
|
34471
|
-
"tikz"
|
|
34542
|
+
"tikz",
|
|
34543
|
+
"csv"
|
|
34472
34544
|
];
|
|
34473
34545
|
async function enhance7({
|
|
34474
34546
|
$,
|
|
@@ -34572,7 +34644,7 @@ async function renderDiagram({
|
|
|
34572
34644
|
)}>${diagram}</div>`;
|
|
34573
34645
|
graphsCache[checksum] = $output;
|
|
34574
34646
|
} catch (error) {
|
|
34575
|
-
$output = `<pre class="language-text"><code>${(0,
|
|
34647
|
+
$output = `<pre class="language-text"><code>${(0, import_html_escaper12.escape)(
|
|
34576
34648
|
String(error)
|
|
34577
34649
|
)}</code></pre>`;
|
|
34578
34650
|
}
|
|
@@ -34586,7 +34658,7 @@ async function renderDiagram({
|
|
|
34586
34658
|
normalizedInfo.attributes,
|
|
34587
34659
|
normalizedInfo.language
|
|
34588
34660
|
)
|
|
34589
|
-
)}>${(0,
|
|
34661
|
+
)}>${(0, import_html_escaper12.escape)(code)}</div>`;
|
|
34590
34662
|
break;
|
|
34591
34663
|
}
|
|
34592
34664
|
case "wavedrom": {
|
|
@@ -34652,7 +34724,7 @@ async function renderDiagram({
|
|
|
34652
34724
|
spec = JSON.parse(rawSpec);
|
|
34653
34725
|
}
|
|
34654
34726
|
$output = hiddenCode(
|
|
34655
|
-
(0,
|
|
34727
|
+
(0, import_html_escaper12.escape)(JSON.stringify(spec)),
|
|
34656
34728
|
normalizedInfo.attributes,
|
|
34657
34729
|
normalizedInfo.language
|
|
34658
34730
|
);
|
|
@@ -34676,7 +34748,7 @@ async function renderDiagram({
|
|
|
34676
34748
|
const imgUrl = buildWsdImageUrl(code, server, style, apiKey);
|
|
34677
34749
|
$output = `<div ${stringifyBlockAttributes(
|
|
34678
34750
|
ensureClassInAttributes(normalizedInfo.attributes, "wsd")
|
|
34679
|
-
)}><img src="${(0,
|
|
34751
|
+
)}><img src="${(0, import_html_escaper12.escape)(imgUrl)}" alt="Sequence Diagram"></div>`;
|
|
34680
34752
|
break;
|
|
34681
34753
|
}
|
|
34682
34754
|
case "d2": {
|
|
@@ -34737,10 +34809,19 @@ async function renderDiagram({
|
|
|
34737
34809
|
)}>${svg}</div>`;
|
|
34738
34810
|
break;
|
|
34739
34811
|
}
|
|
34812
|
+
case "csv": {
|
|
34813
|
+
$output = `<div ${stringifyBlockAttributes(
|
|
34814
|
+
ensureClassInAttributes(
|
|
34815
|
+
normalizedInfo.attributes,
|
|
34816
|
+
normalizedInfo.language
|
|
34817
|
+
)
|
|
34818
|
+
)}>${renderCsv(code)}</div>`;
|
|
34819
|
+
break;
|
|
34820
|
+
}
|
|
34740
34821
|
}
|
|
34741
34822
|
} catch (error) {
|
|
34742
34823
|
$output = $(
|
|
34743
|
-
`<pre class="language-text"><code>${(0,
|
|
34824
|
+
`<pre class="language-text"><code>${(0, import_html_escaper12.escape)(
|
|
34744
34825
|
String(error)
|
|
34745
34826
|
)}</code></pre>`
|
|
34746
34827
|
);
|
|
@@ -34762,7 +34843,7 @@ var hiddenCode = (code, attributes, language) => `<p ${stringifyBlockAttributes(
|
|
|
34762
34843
|
)}><span style="display: none">${code}</span></p>`;
|
|
34763
34844
|
|
|
34764
34845
|
// src/render-enhancers/fenced-math.ts
|
|
34765
|
-
var
|
|
34846
|
+
var import_html_escaper13 = require("html-escaper");
|
|
34766
34847
|
var supportedLanguages2 = ["math"];
|
|
34767
34848
|
async function enhance8($, renderingOption, mathBlockDelimiters, katexConfig) {
|
|
34768
34849
|
$('[data-role="codeBlock"]').each((i, container) => {
|
|
@@ -34813,7 +34894,7 @@ var renderMath = (code, normalizedInfo, renderingOption, mathBlockDelimiters, ka
|
|
|
34813
34894
|
normalizedInfo.attributes
|
|
34814
34895
|
)}>${mathHtml}</p>`;
|
|
34815
34896
|
} catch (error) {
|
|
34816
|
-
$output = `<pre class="language-text"><code>${(0,
|
|
34897
|
+
$output = `<pre class="language-text"><code>${(0, import_html_escaper13.escape)(
|
|
34817
34898
|
String(error)
|
|
34818
34899
|
)}</code></pre>`;
|
|
34819
34900
|
}
|
|
@@ -34821,7 +34902,42 @@ var renderMath = (code, normalizedInfo, renderingOption, mathBlockDelimiters, ka
|
|
|
34821
34902
|
};
|
|
34822
34903
|
|
|
34823
34904
|
// src/render-enhancers/resolved-image-paths.ts
|
|
34905
|
+
function mapSrcsetUrls(srcset, mapUrl) {
|
|
34906
|
+
const candidates = [];
|
|
34907
|
+
let i = 0;
|
|
34908
|
+
while (i < srcset.length) {
|
|
34909
|
+
while (i < srcset.length && /[\s,]/.test(srcset[i])) {
|
|
34910
|
+
i++;
|
|
34911
|
+
}
|
|
34912
|
+
if (i >= srcset.length) {
|
|
34913
|
+
break;
|
|
34914
|
+
}
|
|
34915
|
+
let j = i;
|
|
34916
|
+
while (j < srcset.length && !/\s/.test(srcset[j])) {
|
|
34917
|
+
j++;
|
|
34918
|
+
}
|
|
34919
|
+
let url = srcset.slice(i, j);
|
|
34920
|
+
let descriptor = "";
|
|
34921
|
+
if (/,$/.test(url)) {
|
|
34922
|
+
url = url.replace(/,+$/, "");
|
|
34923
|
+
} else {
|
|
34924
|
+
const comma = srcset.indexOf(",", j);
|
|
34925
|
+
const end = comma === -1 ? srcset.length : comma;
|
|
34926
|
+
descriptor = srcset.slice(j, end).trim();
|
|
34927
|
+
j = end;
|
|
34928
|
+
}
|
|
34929
|
+
i = j;
|
|
34930
|
+
const mapped = mapUrl(url);
|
|
34931
|
+
candidates.push(descriptor ? `${mapped} ${descriptor}` : mapped);
|
|
34932
|
+
}
|
|
34933
|
+
return candidates.join(", ");
|
|
34934
|
+
}
|
|
34824
34935
|
async function enhance9($, options, resolveFilePath) {
|
|
34936
|
+
const resolve21 = (src) => resolveFilePath(
|
|
34937
|
+
src,
|
|
34938
|
+
options.useRelativeFilePath,
|
|
34939
|
+
options.fileDirectoryPath
|
|
34940
|
+
);
|
|
34825
34941
|
$("img, a").each((i, imgElement) => {
|
|
34826
34942
|
let srcTag = "src";
|
|
34827
34943
|
if (imgElement.name === "a") {
|
|
@@ -34832,14 +34948,15 @@ async function enhance9($, options, resolveFilePath) {
|
|
|
34832
34948
|
if (!src) {
|
|
34833
34949
|
return;
|
|
34834
34950
|
}
|
|
34835
|
-
img.attr(
|
|
34836
|
-
|
|
34837
|
-
|
|
34838
|
-
|
|
34839
|
-
|
|
34840
|
-
|
|
34841
|
-
|
|
34842
|
-
|
|
34951
|
+
img.attr(srcTag, resolve21(src));
|
|
34952
|
+
});
|
|
34953
|
+
$("img[srcset], source[srcset]").each((i, element) => {
|
|
34954
|
+
const $element = $(element);
|
|
34955
|
+
const srcset = $element.attr("srcset");
|
|
34956
|
+
if (!srcset) {
|
|
34957
|
+
return;
|
|
34958
|
+
}
|
|
34959
|
+
$element.attr("srcset", mapSrcsetUrls(srcset, resolve21));
|
|
34843
34960
|
});
|
|
34844
34961
|
}
|
|
34845
34962
|
|
|
@@ -34949,12 +35066,108 @@ function buildMathJaxConfigScript(mathJaxConfig) {
|
|
|
34949
35066
|
|
|
34950
35067
|
// src/renderers/wavedrom-source.ts
|
|
34951
35068
|
var import_json52 = __toESM(require("json5"));
|
|
35069
|
+
|
|
35070
|
+
// src/lib/dangerous-urls.ts
|
|
35071
|
+
var DANGEROUS_URL_PATTERN = /^\s*(javascript|vbscript)\s*:|^\s*data\s*:\s*text\/html/i;
|
|
35072
|
+
var URL_ATTRIBUTES = [
|
|
35073
|
+
"href",
|
|
35074
|
+
"src",
|
|
35075
|
+
"action",
|
|
35076
|
+
"formaction",
|
|
35077
|
+
"xlink:href"
|
|
35078
|
+
];
|
|
35079
|
+
function isDangerousUrl(value) {
|
|
35080
|
+
return DANGEROUS_URL_PATTERN.test(value);
|
|
35081
|
+
}
|
|
35082
|
+
|
|
35083
|
+
// src/renderers/wavedrom-source.ts
|
|
35084
|
+
var DANGEROUS_SVG_TAGS = /* @__PURE__ */ new Set([
|
|
35085
|
+
"script",
|
|
35086
|
+
"handler",
|
|
35087
|
+
// SVG Tiny 1.2 event scripting
|
|
35088
|
+
"listener",
|
|
35089
|
+
// SVG Tiny 1.2 event wiring
|
|
35090
|
+
"foreignobject",
|
|
35091
|
+
// switches to the HTML namespace inside SVG
|
|
35092
|
+
"iframe",
|
|
35093
|
+
"embed",
|
|
35094
|
+
"object",
|
|
35095
|
+
"applet",
|
|
35096
|
+
// SMIL animation elements: <animate attributeName="href" to="javascript:...">
|
|
35097
|
+
"animate",
|
|
35098
|
+
"animatemotion",
|
|
35099
|
+
"animatetransform",
|
|
35100
|
+
"set"
|
|
35101
|
+
]);
|
|
35102
|
+
var TAG_NAME_PATTERN = /^[a-zA-Z][a-zA-Z0-9:._-]*$/;
|
|
35103
|
+
function isPlainObject(value) {
|
|
35104
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
35105
|
+
}
|
|
35106
|
+
function escapeXml(s) {
|
|
35107
|
+
return /[&<>"]/.test(s) ? s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """) : s;
|
|
35108
|
+
}
|
|
35109
|
+
function escapeAttrBag(attrs) {
|
|
35110
|
+
const out = {};
|
|
35111
|
+
for (const [key, val] of Object.entries(attrs)) {
|
|
35112
|
+
const escapedKey = /[&<>"]/.test(key) ? escapeXml(key) : key;
|
|
35113
|
+
out[escapedKey] = Array.isArray(val) ? val.map((v) => typeof v === "string" ? escapeXml(v) : v) : typeof val === "string" ? escapeXml(val) : val;
|
|
35114
|
+
}
|
|
35115
|
+
return out;
|
|
35116
|
+
}
|
|
35117
|
+
function sanitizeWavedromData(value, parentKey) {
|
|
35118
|
+
if (Array.isArray(value)) {
|
|
35119
|
+
const rawTag = value[0];
|
|
35120
|
+
const tag = typeof rawTag === "string" ? rawTag.toLowerCase() : null;
|
|
35121
|
+
if (tag !== null && DANGEROUS_SVG_TAGS.has(tag)) {
|
|
35122
|
+
if (isPlainObject(value[1]) || tag === "script" || tag === "handler") {
|
|
35123
|
+
return "";
|
|
35124
|
+
}
|
|
35125
|
+
}
|
|
35126
|
+
const bag = value[1];
|
|
35127
|
+
const isElement = tag !== null && (isPlainObject(bag) || TAG_NAME_PATTERN.test(tag));
|
|
35128
|
+
if (!isElement || parentKey === "data") {
|
|
35129
|
+
return value.map(
|
|
35130
|
+
(v) => Array.isArray(v) || isPlainObject(v) ? sanitizeWavedromData(v) : v
|
|
35131
|
+
);
|
|
35132
|
+
}
|
|
35133
|
+
const out = [rawTag];
|
|
35134
|
+
let i = 1;
|
|
35135
|
+
if (isPlainObject(bag)) {
|
|
35136
|
+
sanitizeWavedromData(bag);
|
|
35137
|
+
out.push(escapeAttrBag(bag));
|
|
35138
|
+
i = 2;
|
|
35139
|
+
}
|
|
35140
|
+
for (; i < value.length; i++) {
|
|
35141
|
+
const child = value[i];
|
|
35142
|
+
out.push(
|
|
35143
|
+
typeof child === "string" ? escapeXml(child) : sanitizeWavedromData(child)
|
|
35144
|
+
);
|
|
35145
|
+
}
|
|
35146
|
+
return out;
|
|
35147
|
+
}
|
|
35148
|
+
if (isPlainObject(value)) {
|
|
35149
|
+
for (const key of Object.keys(value)) {
|
|
35150
|
+
if (/^on/i.test(key)) {
|
|
35151
|
+
delete value[key];
|
|
35152
|
+
continue;
|
|
35153
|
+
}
|
|
35154
|
+
const attrValue = value[key];
|
|
35155
|
+
if (URL_ATTRIBUTES.includes(key.toLowerCase()) && typeof attrValue === "string" && isDangerousUrl(attrValue)) {
|
|
35156
|
+
delete value[key];
|
|
35157
|
+
continue;
|
|
35158
|
+
}
|
|
35159
|
+
value[key] = sanitizeWavedromData(attrValue, key);
|
|
35160
|
+
}
|
|
35161
|
+
}
|
|
35162
|
+
return value;
|
|
35163
|
+
}
|
|
34952
35164
|
function normalizeWavedromSource(raw) {
|
|
34953
35165
|
try {
|
|
34954
35166
|
const data = import_json52.default.parse(raw);
|
|
34955
35167
|
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
34956
35168
|
return null;
|
|
34957
35169
|
}
|
|
35170
|
+
sanitizeWavedromData(data);
|
|
34958
35171
|
const json = JSON.stringify(data, (_key, value) => {
|
|
34959
35172
|
if (typeof value === "number" && !Number.isFinite(value)) {
|
|
34960
35173
|
throw new SyntaxError("WaveDrom data contains a non-finite number");
|
|
@@ -34968,10 +35181,8 @@ function normalizeWavedromSource(raw) {
|
|
|
34968
35181
|
}
|
|
34969
35182
|
|
|
34970
35183
|
// src/markdown-engine/sanitize.ts
|
|
34971
|
-
var DANGEROUS_URL_PATTERN = /^\s*(javascript|vbscript)\s*:|^\s*data\s*:\s*text\/html/i;
|
|
34972
35184
|
var DANGEROUS_TAGS = ["object", "embed", "applet"];
|
|
34973
35185
|
var SAFE_SCRIPT_TYPES = /* @__PURE__ */ new Set(["wavedrom", "text/tikz"]);
|
|
34974
|
-
var URL_ATTRIBUTES = ["href", "src", "action", "formaction", "xlink:href"];
|
|
34975
35186
|
function sanitizeRenderedHTML($) {
|
|
34976
35187
|
$(DANGEROUS_TAGS.join(", ")).remove();
|
|
34977
35188
|
$("script").each((_, el) => {
|
|
@@ -35002,7 +35213,7 @@ function sanitizeRenderedHTML($) {
|
|
|
35002
35213
|
delete attribs[attr];
|
|
35003
35214
|
continue;
|
|
35004
35215
|
}
|
|
35005
|
-
if (URL_ATTRIBUTES.includes(attr.toLowerCase()) &&
|
|
35216
|
+
if (URL_ATTRIBUTES.includes(attr.toLowerCase()) && isDangerousUrl(attribs[attr])) {
|
|
35006
35217
|
delete attribs[attr];
|
|
35007
35218
|
}
|
|
35008
35219
|
}
|
|
@@ -35035,7 +35246,7 @@ function normalizeMarkdownYoCodeBlocks($) {
|
|
|
35035
35246
|
const code = $code.text();
|
|
35036
35247
|
const parsedInfo = parseBlockInfo(language);
|
|
35037
35248
|
const normalizedInfo = normalizeBlockInfo(parsedInfo);
|
|
35038
|
-
$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,
|
|
35249
|
+
$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));
|
|
35039
35250
|
});
|
|
35040
35251
|
}
|
|
35041
35252
|
function normalizeMarkdownYoHeadings($) {
|
|
@@ -35062,6 +35273,32 @@ function normalizeMarkdownYoHeadings($) {
|
|
|
35062
35273
|
}
|
|
35063
35274
|
});
|
|
35064
35275
|
}
|
|
35276
|
+
function pandocVersionSupportsMathMethod(versionOutput) {
|
|
35277
|
+
const match = versionOutput.match(/pandoc(?:\.exe)?\s+(\d+)\.(\d+)/i);
|
|
35278
|
+
if (!match) {
|
|
35279
|
+
return false;
|
|
35280
|
+
}
|
|
35281
|
+
const [major, minor] = [Number(match[1]), Number(match[2])];
|
|
35282
|
+
return major > 3 || major === 3 && minor >= 11;
|
|
35283
|
+
}
|
|
35284
|
+
var PANDOC_MATH_METHOD_SUPPORT = /* @__PURE__ */ new Map();
|
|
35285
|
+
function pandocSupportsMathMethod(pandocPath) {
|
|
35286
|
+
let support = PANDOC_MATH_METHOD_SUPPORT.get(pandocPath);
|
|
35287
|
+
if (!support) {
|
|
35288
|
+
support = new Promise((resolve21) => {
|
|
35289
|
+
(0, import_child_process11.execFile)(
|
|
35290
|
+
pandocPath,
|
|
35291
|
+
["--version"],
|
|
35292
|
+
{ timeout: 1e4 },
|
|
35293
|
+
(error, stdout) => {
|
|
35294
|
+
resolve21(!error && pandocVersionSupportsMathMethod(String(stdout)));
|
|
35295
|
+
}
|
|
35296
|
+
);
|
|
35297
|
+
});
|
|
35298
|
+
PANDOC_MATH_METHOD_SUPPORT.set(pandocPath, support);
|
|
35299
|
+
}
|
|
35300
|
+
return support;
|
|
35301
|
+
}
|
|
35065
35302
|
function isPathInsideDirectory(parentDirectoryPath, filePath) {
|
|
35066
35303
|
const realpath = (p) => {
|
|
35067
35304
|
try {
|
|
@@ -35606,7 +35843,7 @@ window["initRevealPresentation"] = async function() {
|
|
|
35606
35843
|
<html>
|
|
35607
35844
|
<head>
|
|
35608
35845
|
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
|
|
35609
|
-
<meta id="crossnote-data" data-config="${(0,
|
|
35846
|
+
<meta id="crossnote-data" data-config="${(0, import_html_escaper14.escape)(
|
|
35610
35847
|
JSON.stringify({ ...this.notebook.config, ...config })
|
|
35611
35848
|
)}" data-time="${Date.now()}">
|
|
35612
35849
|
<meta charset="UTF-8">
|
|
@@ -35655,7 +35892,7 @@ window["initRevealPresentation"] = async function() {
|
|
|
35655
35892
|
)}
|
|
35656
35893
|
${head}
|
|
35657
35894
|
</head>
|
|
35658
|
-
<body class="preview-container ${isVSCodeWebExtension2 ? "vscode-web-extension" : ""} ${config.isWiki ? "wiki-readonly" : ""}" data-html="${(0,
|
|
35895
|
+
<body class="preview-container ${isVSCodeWebExtension2 ? "vscode-web-extension" : ""} ${config.isWiki ? "wiki-readonly" : ""}" data-html="${(0, import_html_escaper14.escape)(html)}" ${isPresentationMode ? "data-presentation-mode" : ""}>
|
|
35659
35896
|
${body}
|
|
35660
35897
|
</body>
|
|
35661
35898
|
${this.generateScriptsForPreview(
|
|
@@ -36904,6 +37141,13 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
36904
37141
|
}
|
|
36905
37142
|
}
|
|
36906
37143
|
/**
|
|
37144
|
+
* Resolve a link from the rendered HTML (`src`, `href`, …) to a URL.
|
|
37145
|
+
*
|
|
37146
|
+
* The link is a URL, not a filesystem path: markdown-it has already
|
|
37147
|
+
* percent-encoded it (`图.png` → `%E5%9B%BE.png`), and it may carry a
|
|
37148
|
+
* `?cache-buster` or `#fragment`. The path part is decoded before it is
|
|
37149
|
+
* resolved and the suffix is re-attached afterwards, so the host builds its
|
|
37150
|
+
* URL from a real file path (issues vscode-mpe#2441, vscode-mpe#2328).
|
|
36907
37151
|
*
|
|
36908
37152
|
* @param filePath
|
|
36909
37153
|
* @param relative: whether to use the path relative to filePath or not.
|
|
@@ -36911,28 +37155,24 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
36911
37155
|
resolveFilePath(filePath = "", relative11, fileDirectoryPath = "") {
|
|
36912
37156
|
if (filePath.match(this.protocolsWhiteListRegExp) || filePath.startsWith("data:image/") || filePath.startsWith("tag://") || filePath[0] === "#") {
|
|
36913
37157
|
return filePath;
|
|
36914
|
-
}
|
|
36915
|
-
|
|
36916
|
-
|
|
37158
|
+
}
|
|
37159
|
+
if (relative11 && filePath[0] !== "/") {
|
|
37160
|
+
return filePath;
|
|
37161
|
+
}
|
|
37162
|
+
const { path: linkPath, suffix } = splitUrlReference(filePath);
|
|
37163
|
+
const absolutePath = linkPath[0] === "/" ? path19.resolve(this.projectDirectoryPath.fsPath, "." + linkPath) : path19.resolve(fileDirectoryPath || this.fileDirectoryPath, linkPath);
|
|
37164
|
+
if (relative11) {
|
|
37165
|
+
return escapeUrlPath(
|
|
37166
|
+
path19.relative(
|
|
36917
37167
|
fileDirectoryPath || this.fileDirectoryPath,
|
|
36918
|
-
|
|
36919
|
-
)
|
|
36920
|
-
|
|
36921
|
-
return addFileProtocol(
|
|
36922
|
-
path19.resolve(this.projectDirectoryPath.fsPath, "." + filePath),
|
|
36923
|
-
this.vscodePreviewPanel
|
|
36924
|
-
);
|
|
36925
|
-
}
|
|
36926
|
-
} else {
|
|
36927
|
-
if (relative11) {
|
|
36928
|
-
return filePath;
|
|
36929
|
-
} else {
|
|
36930
|
-
return addFileProtocol(
|
|
36931
|
-
path19.resolve(fileDirectoryPath || this.fileDirectoryPath, filePath),
|
|
36932
|
-
this.vscodePreviewPanel
|
|
36933
|
-
);
|
|
36934
|
-
}
|
|
37168
|
+
absolutePath
|
|
37169
|
+
)
|
|
37170
|
+
) + suffix;
|
|
36935
37171
|
}
|
|
37172
|
+
return appendUrlSuffix(
|
|
37173
|
+
addFileProtocol(absolutePath, this.vscodePreviewPanel),
|
|
37174
|
+
suffix
|
|
37175
|
+
);
|
|
36936
37176
|
}
|
|
36937
37177
|
/**
|
|
36938
37178
|
* Turn the absolute filesystem paths that `resolveRelativeCssUrls` left in
|
|
@@ -37029,7 +37269,7 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37029
37269
|
let tbody2 = "<tbody>";
|
|
37030
37270
|
for (const key in arg) {
|
|
37031
37271
|
if (arg.hasOwnProperty(key)) {
|
|
37032
|
-
tbody2 += `<tr><th>${(0,
|
|
37272
|
+
tbody2 += `<tr><th>${(0, import_html_escaper14.escape)(key)}</th><td>${this.frontMatterToTable(
|
|
37033
37273
|
arg[key],
|
|
37034
37274
|
vertical
|
|
37035
37275
|
)}</td></tr>`;
|
|
@@ -37042,7 +37282,7 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37042
37282
|
let tbody = "<tbody><tr>";
|
|
37043
37283
|
for (const key in arg) {
|
|
37044
37284
|
if (arg.hasOwnProperty(key)) {
|
|
37045
|
-
thead += `<th>${(0,
|
|
37285
|
+
thead += `<th>${(0, import_html_escaper14.escape)(key)}</th>`;
|
|
37046
37286
|
tbody += `<td>${this.frontMatterToTable(arg[key], vertical)}</td>`;
|
|
37047
37287
|
}
|
|
37048
37288
|
}
|
|
@@ -37050,7 +37290,7 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37050
37290
|
tbody += "</tr></tbody>";
|
|
37051
37291
|
return `<table>${thead}${tbody}</table>`;
|
|
37052
37292
|
} else {
|
|
37053
|
-
return (0,
|
|
37293
|
+
return (0, import_html_escaper14.escape)(arg);
|
|
37054
37294
|
}
|
|
37055
37295
|
}
|
|
37056
37296
|
/**
|
|
@@ -37173,13 +37413,16 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37173
37413
|
`;
|
|
37174
37414
|
}
|
|
37175
37415
|
async pandocRender(text = "", args) {
|
|
37416
|
+
const mathMethod = await pandocSupportsMathMethod(
|
|
37417
|
+
this.notebook.config.pandocPath
|
|
37418
|
+
);
|
|
37176
37419
|
let mathRenderer;
|
|
37177
37420
|
switch (this.notebook.config.mathRenderingOption) {
|
|
37178
37421
|
case "MathJax":
|
|
37179
|
-
mathRenderer = "--mathjax";
|
|
37422
|
+
mathRenderer = mathMethod ? "--math-method=mathjax" : "--mathjax";
|
|
37180
37423
|
break;
|
|
37181
37424
|
case "KaTeX":
|
|
37182
|
-
mathRenderer = "--katex";
|
|
37425
|
+
mathRenderer = mathMethod ? "--math-method=katex" : "--katex";
|
|
37183
37426
|
break;
|
|
37184
37427
|
default:
|
|
37185
37428
|
mathRenderer = "";
|
|
@@ -37209,11 +37452,11 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37209
37452
|
const parsedInfo = parseBlockInfo(info);
|
|
37210
37453
|
const normalizedInfo = normalizeBlockInfo(parsedInfo);
|
|
37211
37454
|
codeBlockSpacesAhead = match[1].length;
|
|
37212
|
-
outputString += `${match[1]}\`\`\`{.text data-role="codeBlock" data-info="${(0,
|
|
37455
|
+
outputString += `${match[1]}\`\`\`{.text data-role="codeBlock" data-info="${(0, import_html_escaper14.escape)(
|
|
37213
37456
|
info
|
|
37214
|
-
)}" data-parsed-info="${(0,
|
|
37457
|
+
)}" data-parsed-info="${(0, import_html_escaper14.escape)(
|
|
37215
37458
|
JSON.stringify(parsedInfo)
|
|
37216
|
-
)}" data-normalized-info="${(0,
|
|
37459
|
+
)}" data-normalized-info="${(0, import_html_escaper14.escape)(
|
|
37217
37460
|
JSON.stringify(normalizedInfo)
|
|
37218
37461
|
)}"}
|
|
37219
37462
|
`;
|
|
@@ -37242,7 +37485,7 @@ sidebarTOCBtn.addEventListener('click', function(event) {
|
|
|
37242
37485
|
return reject(error);
|
|
37243
37486
|
} else if (stderr) {
|
|
37244
37487
|
return resolve21(
|
|
37245
|
-
'<pre class="language-text"><code>' + (0,
|
|
37488
|
+
'<pre class="language-text"><code>' + (0, import_html_escaper14.escape)(stderr) + "</code></pre>" + stdout
|
|
37246
37489
|
);
|
|
37247
37490
|
} else {
|
|
37248
37491
|
return resolve21(stdout);
|
|
@@ -37317,7 +37560,7 @@ Check "http://pandoc.org/installing.html" website.`;
|
|
|
37317
37560
|
args = this.notebook.config.pandocArguments.concat(args);
|
|
37318
37561
|
html = await this.pandocRender(outputString, args);
|
|
37319
37562
|
} catch (error) {
|
|
37320
|
-
html = `<pre class="language-text"><code>${(0,
|
|
37563
|
+
html = `<pre class="language-text"><code>${(0, import_html_escaper14.escape)(
|
|
37321
37564
|
String(error)
|
|
37322
37565
|
)}</code></pre>`;
|
|
37323
37566
|
}
|
|
@@ -38885,7 +39128,7 @@ async function startServeServer(options) {
|
|
|
38885
39128
|
if (/^\/(?:files|assets)\//.test(filePath)) {
|
|
38886
39129
|
return filePath;
|
|
38887
39130
|
}
|
|
38888
|
-
return (0,
|
|
39131
|
+
return (0, import_url3.pathToFileURL)(filePath).href;
|
|
38889
39132
|
});
|
|
38890
39133
|
function rootIndexOf(absolutePath) {
|
|
38891
39134
|
const resolved = path26.resolve(absolutePath);
|