mystmd 1.1.52__py3-none-any.whl → 1.1.53__py3-none-any.whl

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.
mystmd_py/myst.cjs CHANGED
@@ -100662,14 +100662,14 @@ var require_node_domexception = __commonJS({
100662
100662
  });
100663
100663
 
100664
100664
  // ../../node_modules/fetch-blob/from.js
100665
- var import_node_fs20, import_node_domexception, stat, _path2, _start, _BlobDataItem, BlobDataItem;
100665
+ var import_node_fs19, import_node_domexception, stat, _path2, _start, _BlobDataItem, BlobDataItem;
100666
100666
  var init_from = __esm({
100667
100667
  "../../node_modules/fetch-blob/from.js"() {
100668
- import_node_fs20 = require("fs");
100668
+ import_node_fs19 = require("fs");
100669
100669
  import_node_domexception = __toESM(require_node_domexception(), 1);
100670
100670
  init_file();
100671
100671
  init_fetch_blob();
100672
- ({ stat } = import_node_fs20.promises);
100672
+ ({ stat } = import_node_fs19.promises);
100673
100673
  _BlobDataItem = class {
100674
100674
  constructor(options) {
100675
100675
  __privateAdd(this, _path2, void 0);
@@ -100696,7 +100696,7 @@ var init_from = __esm({
100696
100696
  if (mtimeMs > this.lastModified) {
100697
100697
  throw new import_node_domexception.default("The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.", "NotReadableError");
100698
100698
  }
100699
- yield* (0, import_node_fs20.createReadStream)(__privateGet(this, _path2), {
100699
+ yield* (0, import_node_fs19.createReadStream)(__privateGet(this, _path2), {
100700
100700
  start: __privateGet(this, _start),
100701
100701
  end: __privateGet(this, _start) + this.size - 1
100702
100702
  });
@@ -193279,7 +193279,7 @@ var {
193279
193279
  } = import_index.default;
193280
193280
 
193281
193281
  // src/version.ts
193282
- var version = "1.1.52";
193282
+ var version = "1.1.53";
193283
193283
  var version_default = version;
193284
193284
 
193285
193285
  // ../myst-cli/dist/build/build.js
@@ -198434,8 +198434,8 @@ function unnestKernelSpec(pageFrontmatter) {
198434
198434
  }
198435
198435
 
198436
198436
  // ../myst-cli/dist/project/load.js
198437
- var import_node_fs16 = __toESM(require("fs"), 1);
198438
- var import_node_path23 = require("path");
198437
+ var import_node_fs15 = __toESM(require("fs"), 1);
198438
+ var import_node_path22 = require("path");
198439
198439
 
198440
198440
  // ../myst-cli-utils/node_modules/chalk/source/vendor/ansi-styles/index.js
198441
198441
  var ANSI_BACKGROUND_OFFSET2 = 10;
@@ -235593,6 +235593,9 @@ function codeTransform(mdast2, file, opts) {
235593
235593
  if (node3.lang.toLowerCase().includes("python") && (opts === null || opts === void 0 ? void 0 : opts.transformPython) !== false) {
235594
235594
  node3.lang = "python";
235595
235595
  }
235596
+ if (node3.lang.toLowerCase() === "r" && (opts === null || opts === void 0 ? void 0 : opts.transformR) !== false) {
235597
+ node3.lang = "r";
235598
+ }
235596
235599
  });
235597
235600
  }
235598
235601
  var codePlugin = (opts) => (tree, file) => {
@@ -236255,10 +236258,23 @@ async function includeDirectiveTransform(tree, vfile2, opts) {
236255
236258
  const includeNodes = selectAll("include", tree);
236256
236259
  if (includeNodes.length === 0)
236257
236260
  return;
236261
+ if (!(opts === null || opts === void 0 ? void 0 : opts.stack))
236262
+ opts.stack = [opts.sourceFile];
236258
236263
  await Promise.all(includeNodes.map(async (node3) => {
236264
+ var _a6, _b, _c;
236259
236265
  if (node3.children && node3.children.length > 0)
236260
236266
  return;
236261
- const rawContent = await opts.loadFile(node3.file);
236267
+ const fullFile = opts.resolveFile(node3.file, opts.sourceFile, vfile2);
236268
+ if (!fullFile)
236269
+ return;
236270
+ if ((_a6 = opts.stack) === null || _a6 === void 0 ? void 0 : _a6.includes(fullFile)) {
236271
+ fileError(vfile2, `Include Directive: "${fullFile}" depends on itself`, {
236272
+ ruleId: RuleId.includeContentLoads,
236273
+ note: [...opts.stack, fullFile].join(" > ")
236274
+ });
236275
+ return;
236276
+ }
236277
+ const rawContent = await opts.loadFile(fullFile);
236262
236278
  if (rawContent == null)
236263
236279
  return;
236264
236280
  const { content: content3, startingLineNumber } = filterIncludedContent(vfile2, node3.filter, rawContent);
@@ -236310,9 +236326,16 @@ async function includeDirectiveTransform(tree, vfile2, opts) {
236310
236326
  children = [container4];
236311
236327
  }
236312
236328
  } else {
236313
- children = await opts.parseContent(node3.file, content3);
236329
+ children = await opts.parseContent(fullFile, content3, vfile2);
236314
236330
  }
236315
236331
  node3.children = children;
236332
+ if (!((_b = node3.children) === null || _b === void 0 ? void 0 : _b.length))
236333
+ return;
236334
+ await includeDirectiveTransform(node3, vfile2, {
236335
+ ...opts,
236336
+ stack: [...(_c = opts.stack) !== null && _c !== void 0 ? _c : [], fullFile],
236337
+ sourceFile: fullFile
236338
+ });
236316
236339
  }));
236317
236340
  }
236318
236341
  function index3(n, total) {
@@ -240014,6 +240037,7 @@ var import_node_fs3 = __toESM(require("fs"), 1);
240014
240037
 
240015
240038
  // ../citation-js-utils/dist/index.js
240016
240039
  var import_core4 = __toESM(require_lib6(), 1);
240040
+ var import_csl = __toESM(require_csl(), 1);
240017
240041
  var import_sanitize_html = __toESM(require_sanitize_html(), 1);
240018
240042
 
240019
240043
  // ../citation-js-utils/node_modules/@citation-js/plugin-bibtex/lib/index.js
@@ -240077,12 +240101,6 @@ var InlineCite;
240077
240101
  InlineCite2["p"] = "p";
240078
240102
  InlineCite2["t"] = "t";
240079
240103
  })(InlineCite || (InlineCite = {}));
240080
- var defaultString = {
240081
- format: "string",
240082
- lang: "en-US",
240083
- type: "html",
240084
- style: CitationJSStyles.apa
240085
- };
240086
240104
  function yearFromCitation(data) {
240087
240105
  var _a6, _b, _c, _d2, _e, _f;
240088
240106
  let year = (_c = (_b = (_a6 = data.issued) === null || _a6 === void 0 ? void 0 : _a6["date-parts"]) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c[0];
@@ -240094,6 +240112,7 @@ function yearFromCitation(data) {
240094
240112
  return "n.d.";
240095
240113
  }
240096
240114
  function getInlineCitation(data, kind, opts) {
240115
+ var _a6;
240097
240116
  let authors = data.author;
240098
240117
  if (!authors || authors.length === 0) {
240099
240118
  authors = data.editor;
@@ -240122,7 +240141,7 @@ function getInlineCitation(data, kind, opts) {
240122
240141
  }
240123
240142
  if (authors.length > 2) {
240124
240143
  return [
240125
- { type: "text", value: `${prefix2}${authors[0].family} ` },
240144
+ { type: "text", value: `${prefix2}${(_a6 = authors[0].family) !== null && _a6 !== void 0 ? _a6 : authors[0].literal} ` },
240126
240145
  { type: "emphasis", children: [{ type: "text", value: "et al." }] },
240127
240146
  { type: "text", value: `${yearPart}` }
240128
240147
  ];
@@ -240164,10 +240183,22 @@ function firstNonDoiUrl(str2, doi2) {
240164
240183
  const matches4 = [...str2.matchAll(URL_REGEX)];
240165
240184
  return matches4.map((match3) => match3[0]).find((match3) => !doi2 || !match3.includes(doi2));
240166
240185
  }
240167
- async function getCitations(bibtex) {
240186
+ function parseCitationStyle(style3) {
240187
+ const [styleType, styleFormat] = style3.split("-");
240188
+ if (styleType !== "citation") {
240189
+ throw new Error(`unexpected citation style: ${style3}`);
240190
+ }
240191
+ return styleFormat;
240192
+ }
240193
+ function parseBibTeX(source2) {
240194
+ return new import_core4.Cite(source2).data;
240195
+ }
240196
+ function parseCSLJSON(source2) {
240197
+ return (0, import_csl.clean)(source2);
240198
+ }
240199
+ async function getCitationRenderers(data) {
240168
240200
  const cite3 = new import_core4.Cite();
240169
- const p5 = await import_core4.Cite.async(bibtex);
240170
- return Object.fromEntries(p5.data.map((c) => {
240201
+ return Object.fromEntries(data.map((c) => {
240171
240202
  var _a6, _b, _c;
240172
240203
  const matchDoi = (_b = (_a6 = c.URL) === null || _a6 === void 0 ? void 0 : _a6.match(DOI_IN_TEXT)) !== null && _b !== void 0 ? _b : (_c = c.note) === null || _c === void 0 ? void 0 : _c.match(DOI_IN_TEXT);
240173
240204
  if (!c.DOI && matchDoi) {
@@ -240180,16 +240211,32 @@ async function getCitations(bibtex) {
240180
240211
  return getInlineCitation(c, kind, opts);
240181
240212
  },
240182
240213
  render(style3) {
240183
- return replaceUrlsWithAnchorElement(cleanRef(cite3.set(c).get({ ...defaultString, style: style3 !== null && style3 !== void 0 ? style3 : CitationJSStyles.apa })), c.DOI);
240214
+ return replaceUrlsWithAnchorElement(cleanRef(cite3.set(c).format("bibliography", {
240215
+ template: parseCitationStyle(style3 !== null && style3 !== void 0 ? style3 : CitationJSStyles.apa),
240216
+ format: "html",
240217
+ lang: "en-US"
240218
+ })), c.DOI);
240184
240219
  },
240185
240220
  getDOI() {
240186
240221
  return c.DOI || void 0;
240187
240222
  },
240188
240223
  getURL() {
240189
240224
  var _a7;
240190
- return (_a7 = firstNonDoiUrl(cleanRef(cite3.set(c).get(defaultString)), c.DOI)) !== null && _a7 !== void 0 ? _a7 : doiUrl(c.DOI);
240225
+ return (_a7 = firstNonDoiUrl(cleanRef(cite3.set(c).format("bibliography", {
240226
+ template: parseCitationStyle(CitationJSStyles.apa),
240227
+ format: "html",
240228
+ lang: "en-US"
240229
+ })), c.DOI)) !== null && _a7 !== void 0 ? _a7 : doiUrl(c.DOI);
240230
+ },
240231
+ cite: c,
240232
+ getLabel() {
240233
+ var _a7;
240234
+ const bibtexObjects = cite3.set(c).format("bibtex", { format: "object" });
240235
+ return (_a7 = bibtexObjects[0]) === null || _a7 === void 0 ? void 0 : _a7.label;
240191
240236
  },
240192
- cite: c
240237
+ exportBibTeX() {
240238
+ return cite3.set(c).format("bibtex", { format: "text" });
240239
+ }
240193
240240
  }
240194
240241
  ];
240195
240242
  }));
@@ -240221,7 +240268,7 @@ function castSession(session) {
240221
240268
  }
240222
240269
 
240223
240270
  // ../myst-cli/dist/process/citations.js
240224
- async function loadCitations(session, path42) {
240271
+ async function loadBibTeXCitationRenderers(session, path42) {
240225
240272
  const toc = tic();
240226
240273
  let data;
240227
240274
  if (isUrl(path42)) {
@@ -240236,7 +240283,8 @@ async function loadCitations(session, path42) {
240236
240283
  session.log.debug(`Loading citations at "${path42}"`);
240237
240284
  data = import_node_fs3.default.readFileSync(path42).toString();
240238
240285
  }
240239
- const renderer = await getCitations(data);
240286
+ const csl = parseBibTeX(data);
240287
+ const renderer = await getCitationRenderers(csl);
240240
240288
  session.log.debug(toc(`Read ${plural("%s citations(s)", renderer)} from ${path42} in %s.`));
240241
240289
  return renderer;
240242
240290
  }
@@ -240265,8 +240313,8 @@ function combineProjectCitationRenderers(session, projectPath) {
240265
240313
  }
240266
240314
 
240267
240315
  // ../myst-cli/dist/process/file.js
240268
- var import_node_fs12 = __toESM(require("fs"), 1);
240269
- var import_node_path19 = __toESM(require("path"), 1);
240316
+ var import_node_fs11 = __toESM(require("fs"), 1);
240317
+ var import_node_path18 = __toESM(require("path"), 1);
240270
240318
  var import_node_crypto2 = require("crypto");
240271
240319
 
240272
240320
  // ../tex-to-myst/dist/utils.js
@@ -283620,7 +283668,7 @@ var import_node_path17 = __toESM(require("path"), 1);
283620
283668
  var import_nbtx = __toESM(require_cjs2(), 1);
283621
283669
 
283622
283670
  // ../myst-cli/dist/version.js
283623
- var version2 = "1.1.52";
283671
+ var version2 = "1.1.53";
283624
283672
  var version_default2 = version2;
283625
283673
 
283626
283674
  // ../myst-cli/dist/utils/headers.js
@@ -284765,35 +284813,6 @@ async function processNotebook(session, file, content3) {
284765
284813
  return { type: "root", children: items };
284766
284814
  }
284767
284815
 
284768
- // ../myst-cli/dist/transforms/include.js
284769
- var import_node_path18 = __toESM(require("path"), 1);
284770
- var import_node_fs11 = __toESM(require("fs"), 1);
284771
- var makeFileLoader = (session, vfile2, baseFile) => (filename) => {
284772
- const dir = import_node_path18.default.dirname(baseFile);
284773
- const fullFile = import_node_path18.default.join(dir, filename);
284774
- if (!import_node_fs11.default.existsSync(fullFile)) {
284775
- fileError(vfile2, `Include Directive: Could not find "${fullFile}" in "${baseFile}"`, {
284776
- ruleId: RuleId.includeContentLoads
284777
- });
284778
- return;
284779
- }
284780
- session.store.dispatch(watch.actions.addLocalDependency({
284781
- path: baseFile,
284782
- dependency: fullFile
284783
- }));
284784
- return import_node_fs11.default.readFileSync(fullFile).toString();
284785
- };
284786
- async function includeFilesTransform(session, baseFile, tree, vfile2) {
284787
- const parseContent = (filename, content3) => {
284788
- if (filename.toLowerCase().endsWith(".html")) {
284789
- return [{ type: "html", value: content3 }];
284790
- }
284791
- return parseMyst(session, content3, filename).children;
284792
- };
284793
- const loadFile2 = makeFileLoader(session, vfile2, baseFile);
284794
- await includeDirectiveTransform(tree, vfile2, { loadFile: loadFile2, parseContent });
284795
- }
284796
-
284797
284816
  // ../myst-cli/dist/process/file.js
284798
284817
  function checkCache(cache, content3, file) {
284799
284818
  const sha256 = (0, import_node_crypto2.createHash)("sha256").update(content3).digest("hex");
@@ -284811,16 +284830,16 @@ async function loadFile(session, file, projectPath, extension, opts) {
284811
284830
  let success = true;
284812
284831
  let location4 = file;
284813
284832
  if (projectPath) {
284814
- location4 = `/${import_node_path19.default.relative(projectPath, file)}`;
284833
+ location4 = `/${import_node_path18.default.relative(projectPath, file)}`;
284815
284834
  }
284816
284835
  location4 = location4.replaceAll("\\", "/");
284817
284836
  const vfile2 = new VFile();
284818
284837
  vfile2.path = file;
284819
284838
  try {
284820
- const ext2 = extension || import_node_path19.default.extname(file).toLowerCase();
284839
+ const ext2 = extension || import_node_path18.default.extname(file).toLowerCase();
284821
284840
  switch (ext2) {
284822
284841
  case ".md": {
284823
- const content3 = import_node_fs12.default.readFileSync(file).toString();
284842
+ const content3 = import_node_fs11.default.readFileSync(file).toString();
284824
284843
  const { sha256, useCache } = checkCache(cache, content3, file);
284825
284844
  if (useCache)
284826
284845
  break;
@@ -284833,7 +284852,7 @@ async function loadFile(session, file, projectPath, extension, opts) {
284833
284852
  break;
284834
284853
  }
284835
284854
  case ".ipynb": {
284836
- const content3 = import_node_fs12.default.readFileSync(file).toString();
284855
+ const content3 = import_node_fs11.default.readFileSync(file).toString();
284837
284856
  const { sha256, useCache } = checkCache(cache, content3, file);
284838
284857
  if (useCache)
284839
284858
  break;
@@ -284846,24 +284865,16 @@ async function loadFile(session, file, projectPath, extension, opts) {
284846
284865
  break;
284847
284866
  }
284848
284867
  case ".bib": {
284849
- const renderer = await loadCitations(session, file);
284868
+ const renderer = await loadBibTeXCitationRenderers(session, file);
284850
284869
  cache.$citationRenderers[file] = renderer;
284851
284870
  break;
284852
284871
  }
284853
284872
  case ".tex": {
284854
- const content3 = import_node_fs12.default.readFileSync(file).toString();
284873
+ const content3 = import_node_fs11.default.readFileSync(file).toString();
284855
284874
  const { sha256, useCache } = checkCache(cache, content3, file);
284856
284875
  if (useCache)
284857
284876
  break;
284858
284877
  const tex = new TexParser(content3, vfile2);
284859
- await includeDirectiveTransform(tex.ast, vfile2, {
284860
- loadFile: makeFileLoader(session, vfile2, file),
284861
- parseContent: (filename, input3) => {
284862
- var _a7;
284863
- const subTex = new TexParser(input3, vfile2);
284864
- return (_a7 = subTex.ast.children) !== null && _a7 !== void 0 ? _a7 : [];
284865
- }
284866
- });
284867
284878
  const frontmatter = validatePageFrontmatter({
284868
284879
  title: toText(tex.data.frontmatter.title),
284869
284880
  short_title: toText(tex.data.frontmatter.short_title),
@@ -284910,9 +284921,9 @@ ${error === null || error === void 0 ? void 0 : error.stack}
284910
284921
  return (_b = cache.$getMdast(file)) === null || _b === void 0 ? void 0 : _b.pre;
284911
284922
  }
284912
284923
  async function bibFilesInDir(session, dir, load2 = true) {
284913
- const bibFiles = await Promise.all(import_node_fs12.default.readdirSync(dir).map(async (f3) => {
284914
- if (import_node_path19.default.extname(f3).toLowerCase() === ".bib") {
284915
- const bibFile = import_node_path19.default.join(dir, f3);
284924
+ const bibFiles = await Promise.all(import_node_fs11.default.readdirSync(dir).map(async (f3) => {
284925
+ if (import_node_path18.default.extname(f3).toLowerCase() === ".bib") {
284926
+ const bibFile = import_node_path18.default.join(dir, f3);
284916
284927
  if (load2)
284917
284928
  await loadFile(session, bibFile);
284918
284929
  return bibFile;
@@ -284940,7 +284951,7 @@ function selectFile(session, file) {
284940
284951
  }
284941
284952
  async function getRawFrontmatterFromFile(session, file, projectPath) {
284942
284953
  const state = session.store.getState();
284943
- if (projectPath && import_node_path19.default.resolve(file) === selectors_exports.selectLocalConfigFile(state, projectPath)) {
284954
+ if (projectPath && import_node_path18.default.resolve(file) === selectors_exports.selectLocalConfigFile(state, projectPath)) {
284944
284955
  return selectors_exports.selectLocalProjectConfig(state, projectPath);
284945
284956
  }
284946
284957
  const cache = castSession(session);
@@ -284953,8 +284964,8 @@ async function getRawFrontmatterFromFile(session, file, projectPath) {
284953
284964
  }
284954
284965
 
284955
284966
  // ../myst-cli/dist/project/fromPath.js
284956
- var import_node_fs14 = __toESM(require("fs"), 1);
284957
- var import_node_path21 = require("path");
284967
+ var import_node_fs13 = __toESM(require("fs"), 1);
284968
+ var import_node_path20 = require("path");
284958
284969
 
284959
284970
  // ../../node_modules/glob/node_modules/minimatch/dist/mjs/index.js
284960
284971
  var import_brace_expansion = __toESM(require_brace_expansion(), 1);
@@ -285653,11 +285664,11 @@ var qmarksTestNoExtDot = ([$0]) => {
285653
285664
  return (f3) => f3.length === len && f3 !== "." && f3 !== "..";
285654
285665
  };
285655
285666
  var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
285656
- var path15 = {
285667
+ var path14 = {
285657
285668
  win32: { sep: "\\" },
285658
285669
  posix: { sep: "/" }
285659
285670
  };
285660
- var sep2 = defaultPlatform === "win32" ? path15.win32.sep : path15.posix.sep;
285671
+ var sep2 = defaultPlatform === "win32" ? path14.win32.sep : path14.posix.sep;
285661
285672
  minimatch.sep = sep2;
285662
285673
  var GLOBSTAR = Symbol("globstar **");
285663
285674
  minimatch.GLOBSTAR = GLOBSTAR;
@@ -291338,13 +291349,13 @@ var glob = Object.assign(glob_, {
291338
291349
  glob.glob = glob;
291339
291350
 
291340
291351
  // ../myst-cli/dist/project/fromToc.js
291341
- var import_node_fs13 = __toESM(require("fs"), 1);
291342
- var import_node_path20 = require("path");
291352
+ var import_node_fs12 = __toESM(require("fs"), 1);
291353
+ var import_node_path19 = require("path");
291343
291354
  function pagesFromChapters(session, path42, chapters, pages = [], level = 1, pageSlugs) {
291344
291355
  const filename = tocFile(path42);
291345
- const { dir } = (0, import_node_path20.parse)(filename);
291356
+ const { dir } = (0, import_node_path19.parse)(filename);
291346
291357
  chapters.forEach((chapter) => {
291347
- const file = chapter.file ? resolveExtension((0, import_node_path20.join)(dir, chapter.file)) : void 0;
291358
+ const file = chapter.file ? resolveExtension((0, import_node_path19.join)(dir, chapter.file)) : void 0;
291348
291359
  if (file) {
291349
291360
  const { slug } = fileInfo2(file, pageSlugs);
291350
291361
  pages.push({ file, level, slug });
@@ -291363,16 +291374,16 @@ function pagesFromChapters(session, path42, chapters, pages = [], level = 1, pag
291363
291374
  }
291364
291375
  function projectFromToc(session, path42, level = 1) {
291365
291376
  const filename = tocFile(path42);
291366
- if (!import_node_fs13.default.existsSync(filename)) {
291377
+ if (!import_node_fs12.default.existsSync(filename)) {
291367
291378
  throw new Error(`Could not find TOC "${filename}". Please create a '_toc.yml'.`);
291368
291379
  }
291369
- const { dir, base: base5 } = (0, import_node_path20.parse)(filename);
291380
+ const { dir, base: base5 } = (0, import_node_path19.parse)(filename);
291370
291381
  const toc = readTOC(session.log, { filename: base5, path: dir });
291371
291382
  const pageSlugs = {};
291372
- const indexFile = resolveExtension((0, import_node_path20.join)(dir, toc.root));
291383
+ const indexFile = resolveExtension((0, import_node_path19.join)(dir, toc.root));
291373
291384
  if (!indexFile) {
291374
291385
  throw Error(`The table of contents defined in "${tocFile(path42)}" could not find file "${toc.root}" defined as the "root:" page. Please ensure that one of these files is defined:
291375
- - ${VALID_FILE_EXTENSIONS.map((ext2) => (0, import_node_path20.join)(dir, `${toc.root}${ext2}`)).join("\n- ")}
291386
+ - ${VALID_FILE_EXTENSIONS.map((ext2) => (0, import_node_path19.join)(dir, `${toc.root}${ext2}`)).join("\n- ")}
291376
291387
  `);
291377
291388
  }
291378
291389
  const { slug } = fileInfo2(indexFile, pageSlugs);
@@ -291415,18 +291426,18 @@ function sortByNumber(a2, b) {
291415
291426
  }
291416
291427
  function projectPagesFromPath(session, path42, level, pageSlugs, opts) {
291417
291428
  const { ignore: ignore3, suppressWarnings } = opts || {};
291418
- const contents = import_node_fs14.default.readdirSync(path42).filter((file) => !shouldIgnoreFile(session, file)).map((file) => (0, import_node_path21.join)(path42, file)).filter((file) => !ignore3 || !ignore3.includes(file)).sort(sortByNumber);
291419
- if (session.configFiles.filter((file) => contents.includes((0, import_node_path21.join)(path42, file))).length) {
291429
+ const contents = import_node_fs13.default.readdirSync(path42).filter((file) => !shouldIgnoreFile(session, file)).map((file) => (0, import_node_path20.join)(path42, file)).filter((file) => !ignore3 || !ignore3.includes(file)).sort(sortByNumber);
291430
+ if (session.configFiles.filter((file) => contents.includes((0, import_node_path20.join)(path42, file))).length) {
291420
291431
  session.log.debug(`\u{1F50D} Found config file, ignoring subdirectory: ${path42}`);
291421
291432
  return [];
291422
291433
  }
291423
- if (contents.includes((0, import_node_path21.join)(path42, "_toc.yml"))) {
291434
+ if (contents.includes((0, import_node_path20.join)(path42, "_toc.yml"))) {
291424
291435
  const prevLevel = level < 2 ? 1 : level - 1;
291425
291436
  try {
291426
291437
  return pagesFromToc(session, path42, prevLevel);
291427
291438
  } catch {
291428
291439
  if (!suppressWarnings) {
291429
- addWarningForFile(session, (0, import_node_path21.join)(path42, "_toc.yml"), `Invalid table of contents ignored`, "warn", { ruleId: RuleId.validToc });
291440
+ addWarningForFile(session, (0, import_node_path20.join)(path42, "_toc.yml"), `Invalid table of contents ignored`, "warn", { ruleId: RuleId.validToc });
291430
291441
  }
291431
291442
  }
291432
291443
  }
@@ -291455,7 +291466,7 @@ function indexFileFromPages(pages, path42) {
291455
291466
  const files = pages.filter((page) => "file" in page).map((page) => page.file);
291456
291467
  const matcher = (ext2) => {
291457
291468
  let match3;
291458
- DEFAULT_INDEX_FILENAMES.map((index4) => `${index4}${ext2}`).map((index4) => (0, import_node_path21.join)(path42, index4).toLowerCase()).forEach((index4) => {
291469
+ DEFAULT_INDEX_FILENAMES.map((index4) => `${index4}${ext2}`).map((index4) => (0, import_node_path20.join)(path42, index4).toLowerCase()).forEach((index4) => {
291459
291470
  if (match3)
291460
291471
  return;
291461
291472
  files.forEach((file) => {
@@ -291468,7 +291479,7 @@ function indexFileFromPages(pages, path42) {
291468
291479
  if (!indexFile)
291469
291480
  indexFile = matcher(".md");
291470
291481
  if (!indexFile)
291471
- [indexFile] = files.filter((file) => (0, import_node_path21.extname)(file) === ".md");
291482
+ [indexFile] = files.filter((file) => (0, import_node_path20.extname)(file) === ".md");
291472
291483
  if (!indexFile)
291473
291484
  indexFile = matcher(".ipynb");
291474
291485
  if (!indexFile)
@@ -291481,15 +291492,15 @@ async function projectFromPath(session, path42, indexFile) {
291481
291492
  if (indexFile) {
291482
291493
  if (!isValidFile(indexFile))
291483
291494
  throw Error(`Index file ${indexFile} has invalid extension; must be ${ext_string}}`);
291484
- if (!import_node_fs14.default.existsSync(indexFile))
291495
+ if (!import_node_fs13.default.existsSync(indexFile))
291485
291496
  throw Error(`Index file ${indexFile} not found`);
291486
291497
  }
291487
- const rootConfigYamls = session.configFiles.map((file) => (0, import_node_path21.join)(path42, file));
291498
+ const rootConfigYamls = session.configFiles.map((file) => (0, import_node_path20.join)(path42, file));
291488
291499
  const projectConfig = selectors_exports.selectLocalProjectConfig(session.store.getState(), path42);
291489
291500
  const excludePatterns = (_a6 = projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.exclude) !== null && _a6 !== void 0 ? _a6 : [];
291490
291501
  const excludeFiles = (await Promise.all(excludePatterns.map(async (pattern) => {
291491
- const matches4 = await glob(pattern.split(import_node_path21.sep).join("/"));
291492
- return matches4.map((match3) => match3.split("/").join(import_node_path21.sep)).filter((match3) => isValidFile(match3));
291502
+ const matches4 = await glob(pattern.split(import_node_path20.sep).join("/"));
291503
+ return matches4.map((match3) => match3.split("/").join(import_node_path20.sep)).filter((match3) => isValidFile(match3));
291493
291504
  }))).flat();
291494
291505
  const ignoreFiles = [...rootConfigYamls, ...excludeFiles];
291495
291506
  let implicitIndex = false;
@@ -291512,12 +291523,12 @@ async function projectFromPath(session, path42, indexFile) {
291512
291523
  }
291513
291524
 
291514
291525
  // ../myst-cli/dist/project/toToc.js
291515
- var import_node_fs15 = __toESM(require("fs"), 1);
291516
- var import_node_path22 = require("path");
291526
+ var import_node_fs14 = __toESM(require("fs"), 1);
291527
+ var import_node_path21 = require("path");
291517
291528
  function getRelativeDocumentLink(file, path42) {
291518
291529
  if (path42 === ".")
291519
291530
  return removeExtension(file);
291520
- return removeExtension((0, import_node_path22.relative)(path42, file));
291531
+ return removeExtension((0, import_node_path21.relative)(path42, file));
291521
291532
  }
291522
291533
  var GENERATED_TOC_HEADER = `# Table of Contents
291523
291534
  #
@@ -291577,21 +291588,21 @@ function tocFromProject(project, path42 = ".") {
291577
291588
  return toc;
291578
291589
  }
291579
291590
  function writeTocFromProject(project, path42) {
291580
- const filename = (0, import_node_path22.join)(path42, "_toc.yml");
291591
+ const filename = (0, import_node_path21.join)(path42, "_toc.yml");
291581
291592
  const content3 = `${GENERATED_TOC_HEADER}${js_yaml_default.dump(tocFromProject(project, path42))}`;
291582
- import_node_fs15.default.writeFileSync(filename, content3);
291593
+ import_node_fs14.default.writeFileSync(filename, content3);
291583
291594
  }
291584
291595
 
291585
291596
  // ../myst-cli/dist/project/load.js
291586
291597
  async function loadProjectFromDisk(session, path42, opts) {
291587
- path42 = path42 || (0, import_node_path23.resolve)(".");
291598
+ path42 = path42 || (0, import_node_path22.resolve)(".");
291588
291599
  if (!(opts === null || opts === void 0 ? void 0 : opts.reloadProject)) {
291589
291600
  const cachedProject = selectors_exports.selectLocalProject(session.store.getState(), path42);
291590
291601
  if (cachedProject)
291591
291602
  return cachedProject;
291592
291603
  }
291593
291604
  const projectConfig = selectors_exports.selectLocalProjectConfig(session.store.getState(), path42);
291594
- const file = (0, import_node_path23.join)(path42, session.configFiles[0]);
291605
+ const file = (0, import_node_path22.join)(path42, session.configFiles[0]);
291595
291606
  if (!projectConfig && (opts === null || opts === void 0 ? void 0 : opts.warnOnNoConfig)) {
291596
291607
  addWarningForFile(session, file, `Loading project from path with no config file: ${path42}
291597
291608
  Consider running "myst init --project" in that directory`, "warn", { ruleId: RuleId.projectConfigExists });
@@ -291632,7 +291643,7 @@ Consider running "myst init --project" in that directory`, "warn", { ruleId: Rul
291632
291643
  return true;
291633
291644
  if (isUrl(bib))
291634
291645
  return true;
291635
- if (import_node_fs16.default.existsSync(bib)) {
291646
+ if (import_node_fs15.default.existsSync(bib)) {
291636
291647
  allBibFiles.push(bib);
291637
291648
  return true;
291638
291649
  }
@@ -291668,20 +291679,20 @@ var import_fs_extra = __toESM(require_lib16(), 1);
291668
291679
  var import_node_path42 = __toESM(require("path"), 1);
291669
291680
 
291670
291681
  // ../myst-cli/dist/build/site/manifest.js
291671
- var import_node_fs23 = __toESM(require("fs"), 1);
291672
- var import_node_path30 = __toESM(require("path"), 1);
291682
+ var import_node_fs22 = __toESM(require("fs"), 1);
291683
+ var import_node_path29 = __toESM(require("path"), 1);
291673
291684
 
291674
291685
  // ../myst-cli/dist/build/site/template.js
291675
- var import_node_fs21 = __toESM(require("fs"), 1);
291676
- var import_node_path27 = require("path");
291686
+ var import_node_fs20 = __toESM(require("fs"), 1);
291687
+ var import_node_path26 = require("path");
291677
291688
 
291678
291689
  // ../myst-templates/dist/template.js
291679
- var import_node_fs19 = __toESM(require("fs"), 1);
291680
- var import_node_path26 = require("path");
291690
+ var import_node_fs18 = __toESM(require("fs"), 1);
291691
+ var import_node_path25 = require("path");
291681
291692
 
291682
291693
  // ../myst-templates/dist/download.js
291683
- var import_node_fs17 = __toESM(require("fs"), 1);
291684
- var import_node_path24 = require("path");
291694
+ var import_node_fs16 = __toESM(require("fs"), 1);
291695
+ var import_node_path23 = require("path");
291685
291696
  var import_node_crypto3 = require("crypto");
291686
291697
  var import_adm_zip = __toESM(require_adm_zip(), 1);
291687
291698
  var TEMPLATE_YML = "template.yml";
@@ -291739,19 +291750,19 @@ function defaultPath(template, hash, opts) {
291739
291750
  subdirs.push(kind);
291740
291751
  subdirs.push((0, import_node_crypto3.createHash)("sha256").update(template).digest("hex"));
291741
291752
  } else {
291742
- subdirs.push((0, import_node_path24.join)(...template.split("/")));
291753
+ subdirs.push((0, import_node_path23.join)(...template.split("/")));
291743
291754
  }
291744
- return (0, import_node_path24.join)(...subdirs);
291755
+ return (0, import_node_path23.join)(...subdirs);
291745
291756
  }
291746
291757
  function resolveInputs(session, opts) {
291747
291758
  let templateUrl;
291748
291759
  let templatePath;
291749
- if (opts.template && import_node_fs17.default.existsSync(opts.template)) {
291750
- const { base: base5, dir } = (0, import_node_path24.parse)(opts.template);
291751
- if (base5 === TEMPLATE_YML || Object.values(KIND_TO_EXT).filter(Boolean).includes((0, import_node_path24.extname)(base5))) {
291760
+ if (opts.template && import_node_fs16.default.existsSync(opts.template)) {
291761
+ const { base: base5, dir } = (0, import_node_path23.parse)(opts.template);
291762
+ if (base5 === TEMPLATE_YML || Object.values(KIND_TO_EXT).filter(Boolean).includes((0, import_node_path23.extname)(base5))) {
291752
291763
  templatePath = dir;
291753
- } else if (import_node_fs17.default.lstatSync(opts.template).isDirectory()) {
291754
- if (import_node_fs17.default.existsSync((0, import_node_path24.join)(opts.template, TEMPLATE_YML))) {
291764
+ } else if (import_node_fs16.default.lstatSync(opts.template).isDirectory()) {
291765
+ if (import_node_fs16.default.existsSync((0, import_node_path23.join)(opts.template, TEMPLATE_YML))) {
291755
291766
  templatePath = opts.template;
291756
291767
  }
291757
291768
  }
@@ -291774,26 +291785,26 @@ function resolveInputs(session, opts) {
291774
291785
  }
291775
291786
  async function unnestTemplate(session, path42) {
291776
291787
  var _a6;
291777
- const content3 = import_node_fs17.default.readdirSync(path42);
291788
+ const content3 = import_node_fs16.default.readdirSync(path42);
291778
291789
  if (content3.includes(TEMPLATE_YML))
291779
291790
  return;
291780
291791
  let nestedPath;
291781
291792
  content3.forEach((dir) => {
291782
- const templateYmlFile2 = (0, import_node_path24.join)(path42, dir, TEMPLATE_YML);
291783
- if (!nestedPath && import_node_fs17.default.existsSync(templateYmlFile2)) {
291784
- nestedPath = (0, import_node_path24.join)(path42, dir);
291793
+ const templateYmlFile2 = (0, import_node_path23.join)(path42, dir, TEMPLATE_YML);
291794
+ if (!nestedPath && import_node_fs16.default.existsSync(templateYmlFile2)) {
291795
+ nestedPath = (0, import_node_path23.join)(path42, dir);
291785
291796
  }
291786
291797
  });
291787
291798
  if (!nestedPath)
291788
291799
  return;
291789
- const templateYmlFile = (0, import_node_path24.join)(nestedPath, TEMPLATE_YML);
291790
- import_node_fs17.default.copyFileSync(templateYmlFile, (0, import_node_path24.join)(path42, TEMPLATE_YML));
291791
- const templateYml = js_yaml_default.load(import_node_fs17.default.readFileSync(templateYmlFile).toString());
291800
+ const templateYmlFile = (0, import_node_path23.join)(nestedPath, TEMPLATE_YML);
291801
+ import_node_fs16.default.copyFileSync(templateYmlFile, (0, import_node_path23.join)(path42, TEMPLATE_YML));
291802
+ const templateYml = js_yaml_default.load(import_node_fs16.default.readFileSync(templateYmlFile).toString());
291792
291803
  if ((_a6 = templateYml.files) === null || _a6 === void 0 ? void 0 : _a6.length) {
291793
291804
  await Promise.all(templateYml.files.map(async (file) => {
291794
- const resolvedEntry = [...nestedPath.split(import_node_path24.sep), file].join("/");
291805
+ const resolvedEntry = [...nestedPath.split(import_node_path23.sep), file].join("/");
291795
291806
  const matches4 = await glob(resolvedEntry);
291796
- matches4.map((match3) => match3.split("/").join(import_node_path24.sep)).filter((match3) => !isDirectory(match3)).forEach((match3) => {
291807
+ matches4.map((match3) => match3.split("/").join(import_node_path23.sep)).filter((match3) => !isDirectory(match3)).forEach((match3) => {
291797
291808
  copyFileMaintainPath(session, match3, nestedPath, path42);
291798
291809
  });
291799
291810
  }));
@@ -291841,9 +291852,9 @@ async function downloadAndUnzipTemplate(session, downloadUrl, opts) {
291841
291852
  throw new Error(`Problem downloading template "${downloadUrl}": ${res.status} ${res.statusText}`);
291842
291853
  }
291843
291854
  const { templatePath } = opts;
291844
- const zipFile = (0, import_node_path24.join)(templatePath, "template.zip");
291845
- (0, import_node_fs17.mkdirSync)(templatePath, { recursive: true });
291846
- const fileStream = (0, import_node_fs17.createWriteStream)(zipFile);
291855
+ const zipFile = (0, import_node_path23.join)(templatePath, "template.zip");
291856
+ (0, import_node_fs16.mkdirSync)(templatePath, { recursive: true });
291857
+ const fileStream = (0, import_node_fs16.createWriteStream)(zipFile);
291847
291858
  await new Promise((resolve7, reject) => {
291848
291859
  var _a6, _b;
291849
291860
  (_a6 = res.body) === null || _a6 === void 0 ? void 0 : _a6.pipe(fileStream);
@@ -291986,19 +291997,19 @@ function debugLogger(session) {
291986
291997
  }
291987
291998
 
291988
291999
  // ../myst-templates/dist/validators.js
291989
- var import_node_fs18 = __toESM(require("fs"), 1);
291990
- var import_node_path25 = __toESM(require("path"), 1);
292000
+ var import_node_fs17 = __toESM(require("fs"), 1);
292001
+ var import_node_path24 = __toESM(require("path"), 1);
291991
292002
  function validateFile(session, input3, opts) {
291992
292003
  const filename = validateString(input3, opts);
291993
292004
  if (!filename)
291994
292005
  return;
291995
292006
  let resolvedFile;
291996
292007
  if (opts.file) {
291997
- resolvedFile = import_node_path25.default.resolve(import_node_path25.default.dirname(opts.file), filename);
292008
+ resolvedFile = import_node_path24.default.resolve(import_node_path24.default.dirname(opts.file), filename);
291998
292009
  } else {
291999
- resolvedFile = import_node_path25.default.resolve(filename);
292010
+ resolvedFile = import_node_path24.default.resolve(filename);
292000
292011
  }
292001
- if (!import_node_fs18.default.existsSync(resolvedFile)) {
292012
+ if (!import_node_fs17.default.existsSync(resolvedFile)) {
292002
292013
  return validationError(`unable to resolve file: ${filename}`, opts);
292003
292014
  }
292004
292015
  const { copyFolder, relativePathFrom } = opts;
@@ -292007,10 +292018,10 @@ function validateFile(session, input3, opts) {
292007
292018
  if (!hashedFile) {
292008
292019
  return validationError(`unable to copy file: ${resolvedFile} -> ${copyFolder}`, opts);
292009
292020
  }
292010
- resolvedFile = import_node_path25.default.join(copyFolder, hashedFile);
292021
+ resolvedFile = import_node_path24.default.join(copyFolder, hashedFile);
292011
292022
  }
292012
292023
  if (relativePathFrom) {
292013
- return import_node_path25.default.relative(relativePathFrom, resolvedFile);
292024
+ return import_node_path24.default.relative(relativePathFrom, resolvedFile);
292014
292025
  }
292015
292026
  return resolvedFile;
292016
292027
  }
@@ -292477,8 +292488,8 @@ function validateTemplateYml(session, input3, opts) {
292477
292488
  const fileOpts = incrementOptions(`files.${ind}`, opts);
292478
292489
  const file = validateString(val, fileOpts);
292479
292490
  if (file && opts.templateDir) {
292480
- const filePath = [...opts.templateDir.split(import_node_path25.default.sep), file].join("/");
292481
- const matches4 = globSync(filePath).map((match3) => match3.split("/").join(import_node_path25.default.sep));
292491
+ const filePath = [...opts.templateDir.split(import_node_path24.default.sep), file].join("/");
292492
+ const matches4 = globSync(filePath).map((match3) => match3.split("/").join(import_node_path24.default.sep));
292482
292493
  const files = matches4.filter((match3) => !isDirectory(match3));
292483
292494
  if (!matches4.length) {
292484
292495
  validationError(`file does not exist: ${filePath}`, fileOpts);
@@ -292492,12 +292503,12 @@ function validateTemplateYml(session, input3, opts) {
292492
292503
  if (defined(value.template)) {
292493
292504
  const templateOpts = incrementOptions("template", opts);
292494
292505
  const template = validateString(value.template, templateOpts);
292495
- if (template && output2.kind && import_node_path25.default.extname(template) !== KIND_TO_EXT[output2.kind]) {
292496
- validationError(`template extension "${import_node_path25.default.extname(template)}" must match kind "${KIND_TO_EXT[output2.kind]}"`, templateOpts);
292506
+ if (template && output2.kind && import_node_path24.default.extname(template) !== KIND_TO_EXT[output2.kind]) {
292507
+ validationError(`template extension "${import_node_path24.default.extname(template)}" must match kind "${KIND_TO_EXT[output2.kind]}"`, templateOpts);
292497
292508
  }
292498
292509
  if (template && opts.templateDir) {
292499
- const templatePath = [...opts.templateDir.split(import_node_path25.default.sep), template].join("/");
292500
- const matches4 = globSync(templatePath).map((match3) => match3.split("/").join(import_node_path25.default.sep));
292510
+ const templatePath = [...opts.templateDir.split(import_node_path24.default.sep), template].join("/");
292511
+ const matches4 = globSync(templatePath).map((match3) => match3.split("/").join(import_node_path24.default.sep));
292501
292512
  const files = matches4.filter((match3) => !isDirectory(match3));
292502
292513
  if (!matches4.length) {
292503
292514
  validationError(`template does not exist: ${templatePath}`, templateOpts);
@@ -292537,14 +292548,14 @@ var MystTemplate = class {
292537
292548
  this.kind = opts.kind;
292538
292549
  }
292539
292550
  getTemplateYmlPath() {
292540
- return (0, import_node_path26.join)(this.templatePath, TEMPLATE_YML);
292551
+ return (0, import_node_path25.join)(this.templatePath, TEMPLATE_YML);
292541
292552
  }
292542
292553
  getTemplateYml() {
292543
292554
  const templateYmlPath = this.getTemplateYmlPath();
292544
- if (!import_node_fs19.default.existsSync(templateYmlPath)) {
292555
+ if (!import_node_fs18.default.existsSync(templateYmlPath)) {
292545
292556
  throw new Error(`The template yml at "${templateYmlPath}" does not exist`);
292546
292557
  }
292547
- const content3 = import_node_fs19.default.readFileSync(templateYmlPath).toString();
292558
+ const content3 = import_node_fs18.default.readFileSync(templateYmlPath).toString();
292548
292559
  return js_yaml_default.load(content3);
292549
292560
  }
292550
292561
  getValidatedTemplateYml() {
@@ -292625,7 +292636,7 @@ var MystTemplate = class {
292625
292636
  return validatedDoc;
292626
292637
  }
292627
292638
  async ensureTemplateExistsOnPath(force) {
292628
- if (!force && import_node_fs19.default.existsSync((0, import_node_path26.join)(this.templatePath, TEMPLATE_YML))) {
292639
+ if (!force && import_node_fs18.default.existsSync((0, import_node_path25.join)(this.templatePath, TEMPLATE_YML))) {
292629
292640
  this.session.log.debug(`Template found: ${this.templatePath}`);
292630
292641
  } else if (!this.templateUrl) {
292631
292642
  throw new Error(`No template on path and no download URL to fetch from: ${this.templatePath}`);
@@ -292648,12 +292659,12 @@ To list valid templates, try the command "myst templates list"`);
292648
292659
  }
292649
292660
  }
292650
292661
  prepare(opts) {
292651
- if (!import_node_fs19.default.existsSync((0, import_node_path26.join)(this.templatePath, TEMPLATE_YML))) {
292652
- throw new Error(`The template at "${(0, import_node_path26.join)(this.templatePath, TEMPLATE_YML)}" does not exist`);
292662
+ if (!import_node_fs18.default.existsSync((0, import_node_path25.join)(this.templatePath, TEMPLATE_YML))) {
292663
+ throw new Error(`The template at "${(0, import_node_path25.join)(this.templatePath, TEMPLATE_YML)}" does not exist`);
292653
292664
  }
292654
292665
  const fileOpts = { copyFolder: opts.filesPath };
292655
292666
  if (opts.outputPath) {
292656
- fileOpts.relativePathFrom = (0, import_node_path26.dirname)(opts.outputPath);
292667
+ fileOpts.relativePathFrom = (0, import_node_path25.dirname)(opts.outputPath);
292657
292668
  }
292658
292669
  const options = this.validateOptions(opts.options, opts.sourceFile, fileOpts);
292659
292670
  const parts = this.validateParts(opts.parts, options, opts.sourceFile);
@@ -292667,17 +292678,17 @@ To list valid templates, try the command "myst templates list"`);
292667
292678
  (_a6 = templateYml.files) === null || _a6 === void 0 ? void 0 : _a6.forEach((file) => {
292668
292679
  if (file === this.getTemplateFilename())
292669
292680
  return;
292670
- const source2 = (0, import_node_path26.join)(this.templatePath, ...file.split("/"));
292671
- const dest = (0, import_node_path26.join)(outputDir, ...file.split("/"));
292672
- if (import_node_fs19.default.existsSync(dest)) {
292681
+ const source2 = (0, import_node_path25.join)(this.templatePath, ...file.split("/"));
292682
+ const dest = (0, import_node_path25.join)(outputDir, ...file.split("/"));
292683
+ if (import_node_fs18.default.existsSync(dest)) {
292673
292684
  if (!(opts === null || opts === void 0 ? void 0 : opts.force)) {
292674
292685
  this.session.log.debug(`Template files ${file} already exists, not copying.`);
292675
292686
  return;
292676
292687
  }
292677
- import_node_fs19.default.rmSync(dest);
292688
+ import_node_fs18.default.rmSync(dest);
292678
292689
  }
292679
- import_node_fs19.default.mkdirSync((0, import_node_path26.dirname)(dest), { recursive: true });
292680
- import_node_fs19.default.copyFileSync(source2, dest);
292690
+ import_node_fs18.default.mkdirSync((0, import_node_path25.dirname)(dest), { recursive: true });
292691
+ import_node_fs18.default.copyFileSync(source2, dest);
292681
292692
  });
292682
292693
  }
292683
292694
  };
@@ -294001,7 +294012,7 @@ async function getMystTemplate(session, opts) {
294001
294012
  }
294002
294013
  async function installSiteTemplate(session, mystTemplate) {
294003
294014
  var _a6, _b;
294004
- if (import_node_fs21.default.existsSync((0, import_node_path27.join)(mystTemplate.templatePath, "node_modules")))
294015
+ if (import_node_fs20.default.existsSync((0, import_node_path26.join)(mystTemplate.templatePath, "node_modules")))
294005
294016
  return;
294006
294017
  const toc = tic();
294007
294018
  session.log.info("\u2935\uFE0F Installing web libraries (can take up to 60 s)");
@@ -294012,26 +294023,26 @@ async function installSiteTemplate(session, mystTemplate) {
294012
294023
  }
294013
294024
 
294014
294025
  // ../myst-cli/dist/build/utils/collectExportOptions.js
294015
- var import_node_fs22 = __toESM(require("fs"), 1);
294016
- var import_node_path29 = __toESM(require("path"), 1);
294026
+ var import_node_fs21 = __toESM(require("fs"), 1);
294027
+ var import_node_path28 = __toESM(require("path"), 1);
294017
294028
 
294018
294029
  // ../myst-cli/dist/build/utils/defaultNames.js
294019
- var import_node_path28 = __toESM(require("path"), 1);
294030
+ var import_node_path27 = __toESM(require("path"), 1);
294020
294031
  function getDefaultExportFilename(session, file, projectPath) {
294021
- const { name: name3 } = import_node_path28.default.parse(file);
294032
+ const { name: name3 } = import_node_path27.default.parse(file);
294022
294033
  const slugFromProject = projectPath ? selectPageSlug(session.store.getState(), projectPath, file) : void 0;
294023
294034
  const slug = slugFromProject || createSlug(name3);
294024
294035
  return slug;
294025
294036
  }
294026
294037
  function getDefaultExportFolder(session, file, format, projectPath) {
294027
- const subpaths = [projectPath || import_node_path28.default.parse(file).dir, "_build", "exports"];
294038
+ const subpaths = [projectPath || import_node_path27.default.parse(file).dir, "_build", "exports"];
294028
294039
  if (format === ExportFormats.tex) {
294029
294040
  subpaths.push(`${getDefaultExportFilename(session, file, projectPath)}_tex`);
294030
294041
  }
294031
294042
  if (format === ExportFormats.typst) {
294032
294043
  subpaths.push(`${getDefaultExportFilename(session, file, projectPath)}_typst`);
294033
294044
  }
294034
- return import_node_path28.default.join(...subpaths);
294045
+ return import_node_path27.default.join(...subpaths);
294035
294046
  }
294036
294047
 
294037
294048
  // ../myst-cli/dist/build/utils/collectExportOptions.js
@@ -294071,8 +294082,8 @@ function resolveTemplate(sourceFile, exp, disableTemplate) {
294071
294082
  if (disableTemplate)
294072
294083
  return null;
294073
294084
  if (exp.template) {
294074
- const resolvedTemplatePath = import_node_path29.default.resolve(import_node_path29.default.dirname(sourceFile), exp.template);
294075
- if (import_node_fs22.default.existsSync(resolvedTemplatePath)) {
294085
+ const resolvedTemplatePath = import_node_path28.default.resolve(import_node_path28.default.dirname(sourceFile), exp.template);
294086
+ if (import_node_fs21.default.existsSync(resolvedTemplatePath)) {
294076
294087
  return resolvedTemplatePath;
294077
294088
  }
294078
294089
  }
@@ -294086,7 +294097,7 @@ function resolveFormat(vfile2, exp) {
294086
294097
  let suggestedPdfFormat = ExportFormats.pdf;
294087
294098
  let suggestedOutputFormat;
294088
294099
  if (exp.output) {
294089
- const ext2 = import_node_path29.default.extname(exp.output);
294100
+ const ext2 = import_node_path28.default.extname(exp.output);
294090
294101
  if (!ext2) {
294091
294102
  suggestedPdfFormat = ExportFormats.pdftex;
294092
294103
  } else {
@@ -294099,8 +294110,8 @@ function resolveFormat(vfile2, exp) {
294099
294110
  return ExportFormats.typst;
294100
294111
  if ((_c = exp.template) === null || _c === void 0 ? void 0 : _c.endsWith("-docx"))
294101
294112
  return ExportFormats.docx;
294102
- if (exp.template && import_node_fs22.default.existsSync(exp.template)) {
294103
- const templateFiles = import_node_fs22.default.readdirSync(exp.template);
294113
+ if (exp.template && import_node_fs21.default.existsSync(exp.template)) {
294114
+ const templateFiles = import_node_fs21.default.readdirSync(exp.template);
294104
294115
  const templateTexFiles = templateFiles.filter((file) => file.endsWith(".tex"));
294105
294116
  const templateTypFiles = templateFiles.filter((file) => file.endsWith(".typ"));
294106
294117
  if (templateTexFiles.length && !templateTypFiles.length)
@@ -294117,13 +294128,13 @@ function resolveArticles(session, sourceFile, vfile2, exp, projectPath) {
294117
294128
  const { articles, sub_articles } = exp;
294118
294129
  let resolved = { articles, sub_articles };
294119
294130
  if (exp.toc && !resolved.articles && !resolved.sub_articles) {
294120
- const resolvedToc = import_node_path29.default.resolve(import_node_path29.default.dirname(sourceFile), exp.toc);
294131
+ const resolvedToc = import_node_path28.default.resolve(import_node_path28.default.dirname(sourceFile), exp.toc);
294121
294132
  if (validateTOC(session, resolvedToc)) {
294122
294133
  resolved = resolveArticlesFromTOC(session, exp, resolvedToc, vfile2);
294123
294134
  }
294124
294135
  }
294125
- if (!resolved.articles && SOURCE_EXTENSIONS.includes(import_node_path29.default.extname(sourceFile))) {
294126
- resolved.articles = [{ file: import_node_path29.default.resolve(sourceFile) }];
294136
+ if (!resolved.articles && SOURCE_EXTENSIONS.includes(import_node_path28.default.extname(sourceFile))) {
294137
+ resolved.articles = [{ file: import_node_path28.default.resolve(sourceFile) }];
294127
294138
  }
294128
294139
  if (((_a6 = resolved.articles) === null || _a6 === void 0 ? void 0 : _a6.length) === 1 && resolved.articles[0].level == null) {
294129
294140
  resolved.articles[0].level = 0;
@@ -294147,8 +294158,8 @@ function resolveArticles(session, sourceFile, vfile2, exp, projectPath) {
294147
294158
  resolved.articles = (_c = resolved.articles) === null || _c === void 0 ? void 0 : _c.map((article) => {
294148
294159
  if (!article.file)
294149
294160
  return article;
294150
- const resolvedFile = import_node_path29.default.resolve(import_node_path29.default.dirname(sourceFile), article.file);
294151
- if (!import_node_fs22.default.existsSync(resolvedFile)) {
294161
+ const resolvedFile = import_node_path28.default.resolve(import_node_path28.default.dirname(sourceFile), article.file);
294162
+ if (!import_node_fs21.default.existsSync(resolvedFile)) {
294152
294163
  fileError(vfile2, `Invalid export article - '${article.file}' does not exist`, {
294153
294164
  ruleId: RuleId.exportArticleExists
294154
294165
  });
@@ -294157,8 +294168,8 @@ function resolveArticles(session, sourceFile, vfile2, exp, projectPath) {
294157
294168
  return { ...article, file: resolvedFile };
294158
294169
  }).filter((article) => !!article);
294159
294170
  resolved.sub_articles = (_d2 = resolved.sub_articles) === null || _d2 === void 0 ? void 0 : _d2.map((file) => {
294160
- const resolvedFile = import_node_path29.default.resolve(import_node_path29.default.dirname(sourceFile), file);
294161
- if (!import_node_fs22.default.existsSync(resolvedFile)) {
294171
+ const resolvedFile = import_node_path28.default.resolve(import_node_path28.default.dirname(sourceFile), file);
294172
+ if (!import_node_fs21.default.existsSync(resolvedFile)) {
294162
294173
  fileError(vfile2, `Invalid export sub_article - '${file}' does not exist`, {
294163
294174
  ruleId: RuleId.exportArticleExists
294164
294175
  });
@@ -294183,7 +294194,7 @@ function resolveOutput(session, sourceFile, vfile2, exp, projectPath) {
294183
294194
  var _a6, _b, _c, _d2, _e;
294184
294195
  let output2;
294185
294196
  if (exp.output) {
294186
- output2 = import_node_path29.default.resolve(import_node_path29.default.dirname(sourceFile), exp.output);
294197
+ output2 = import_node_path28.default.resolve(import_node_path28.default.dirname(sourceFile), exp.output);
294187
294198
  } else {
294188
294199
  output2 = getDefaultExportFolder(session, sourceFile, exp.format, projectPath);
294189
294200
  }
@@ -294194,16 +294205,16 @@ function resolveOutput(session, sourceFile, vfile2, exp, projectPath) {
294194
294205
  fileWarn(vfile2, `ignoring "zip: true" for export of format "${exp.format}"`);
294195
294206
  exp.zip = false;
294196
294207
  }
294197
- if (!import_node_path29.default.extname(output2)) {
294208
+ if (!import_node_path28.default.extname(output2)) {
294198
294209
  const basename3 = getDefaultExportFilename(session, (_c = (_b = singleArticleWithFile(exp.articles)) === null || _b === void 0 ? void 0 : _b.file) !== null && _c !== void 0 ? _c : sourceFile, projectPath);
294199
294210
  const ext2 = exp.zip ? ".zip" : (_d2 = ALLOWED_EXTENSIONS[exp.format]) === null || _d2 === void 0 ? void 0 : _d2[0];
294200
- output2 = import_node_path29.default.join(output2, `${basename3}${ext2 !== null && ext2 !== void 0 ? ext2 : ""}`);
294211
+ output2 = import_node_path28.default.join(output2, `${basename3}${ext2 !== null && ext2 !== void 0 ? ext2 : ""}`);
294201
294212
  }
294202
- if (!((_e = ALLOWED_EXTENSIONS[exp.format]) === null || _e === void 0 ? void 0 : _e.includes(import_node_path29.default.extname(output2)))) {
294213
+ if (!((_e = ALLOWED_EXTENSIONS[exp.format]) === null || _e === void 0 ? void 0 : _e.includes(import_node_path28.default.extname(output2)))) {
294203
294214
  fileError(vfile2, `Output file "${output2}" has invalid extension for export format of "${exp.format}"`, { ruleId: RuleId.exportExtensionCorrect });
294204
294215
  return void 0;
294205
294216
  }
294206
- if (exp.zip && import_node_path29.default.extname(output2) !== ".zip") {
294217
+ if (exp.zip && import_node_path28.default.extname(output2) !== ".zip") {
294207
294218
  fileWarn(vfile2, `Output file "${output2}" has non-zip extension but "zip: true" is specified; ignoring "zip: true"`, { ruleId: RuleId.exportExtensionCorrect });
294208
294219
  }
294209
294220
  return output2;
@@ -294252,10 +294263,10 @@ function filterAndMakeUnique(exports2) {
294252
294263
  const nMatch = (a2) => a2.filter((e2) => e2.output === exp.output).length;
294253
294264
  if (nMatch(arr) === 1)
294254
294265
  return { ...exp };
294255
- const { dir, name: name3, ext: ext2 } = import_node_path29.default.parse(exp.output);
294266
+ const { dir, name: name3, ext: ext2 } = import_node_path28.default.parse(exp.output);
294256
294267
  return {
294257
294268
  ...exp,
294258
- output: import_node_path29.default.join(dir, `${name3}_${nMatch(arr.slice(0, ind))}${ext2}`)
294269
+ output: import_node_path28.default.join(dir, `${name3}_${nMatch(arr.slice(0, ind))}${ext2}`)
294259
294270
  };
294260
294271
  });
294261
294272
  }
@@ -294272,7 +294283,7 @@ async function collectExportOptions(session, files, formats, opts) {
294272
294283
  await Promise.all(sourceFiles.map(async (file) => {
294273
294284
  let fileProjectPath;
294274
294285
  if (!projectPath) {
294275
- fileProjectPath = findCurrentProjectAndLoad(session, import_node_path29.default.dirname(file));
294286
+ fileProjectPath = findCurrentProjectAndLoad(session, import_node_path28.default.dirname(file));
294276
294287
  if (fileProjectPath)
294277
294288
  await loadProjectFromDisk(session, fileProjectPath);
294278
294289
  } else {
@@ -294298,9 +294309,9 @@ async function resolvePageExports(session, file) {
294298
294309
  ExportFormats.xml,
294299
294310
  ExportFormats.meca
294300
294311
  ], {})).filter((exp) => {
294301
- return [".docx", ".pdf", ".zip", ".xml"].includes(import_node_path30.default.extname(exp.output));
294312
+ return [".docx", ".pdf", ".zip", ".xml"].includes(import_node_path29.default.extname(exp.output));
294302
294313
  }).filter((exp) => {
294303
- return import_node_fs23.default.existsSync(exp.output);
294314
+ return import_node_fs22.default.existsSync(exp.output);
294304
294315
  });
294305
294316
  const exportsAsDownloads = exports2.map((exp) => {
294306
294317
  const { format, output: output2 } = exp;
@@ -294309,7 +294320,7 @@ async function resolvePageExports(session, file) {
294309
294320
  ruleId: RuleId.exportFileCopied
294310
294321
  });
294311
294322
  });
294312
- return { format, filename: import_node_path30.default.basename(output2), url: `/${fileHash}` };
294323
+ return { format, filename: import_node_path29.default.basename(output2), url: `/${fileHash}` };
294313
294324
  });
294314
294325
  return exportsAsDownloads;
294315
294326
  }
@@ -294333,7 +294344,7 @@ async function resolvePageDownloads(session, file, projectPath) {
294333
294344
  const resolvedDownloads = (_a6 = pageFrontmatter === null || pageFrontmatter === void 0 ? void 0 : pageFrontmatter.downloads) === null || _a6 === void 0 ? void 0 : _a6.map((download) => {
294334
294345
  var _a7;
294335
294346
  if (download.id && !expLookup[download.id]) {
294336
- addWarningForFile(session, file, `Locate download file by export id "${download.id}"`, "error", {
294347
+ addWarningForFile(session, file, `Unable to locate download file by export id "${download.id}"`, "error", {
294337
294348
  ruleId: RuleId.exportFileCopied
294338
294349
  });
294339
294350
  return void 0;
@@ -294399,8 +294410,8 @@ async function localToManifestProject(session, projectPath, projectSlug) {
294399
294410
  const projConfigFile = selectors_exports.selectLocalConfigFile(state, projectPath);
294400
294411
  const exports2 = projConfigFile ? await resolvePageExports(session, projConfigFile) : [];
294401
294412
  const downloads = projConfigFile ? await resolvePageDownloads(session, projConfigFile, projectPath) : void 0;
294402
- const banner = await transformBanner(session, import_node_path30.default.join(projectPath, "myst.yml"), projFrontmatter, session.publicPath(), { altOutputFolder: "/" });
294403
- const thumbnail = await transformThumbnail(session, null, import_node_path30.default.join(projectPath, "myst.yml"), projFrontmatter, session.publicPath(), { altOutputFolder: "/" });
294413
+ const banner = await transformBanner(session, import_node_path29.default.join(projectPath, "myst.yml"), projFrontmatter, session.publicPath(), { altOutputFolder: "/" });
294414
+ const thumbnail = await transformThumbnail(session, null, import_node_path29.default.join(projectPath, "myst.yml"), projFrontmatter, session.publicPath(), { altOutputFolder: "/" });
294404
294415
  return {
294405
294416
  ...projFrontmatter,
294406
294417
  // TODO: a null in the project frontmatter should not fall back to index page
@@ -294464,8 +294475,8 @@ function resolveSiteAction(session, action, file, property) {
294464
294475
  static: false
294465
294476
  };
294466
294477
  }
294467
- const resolvedFile = import_node_path30.default.resolve(import_node_path30.default.dirname(file), action.url);
294468
- if (!import_node_fs23.default.existsSync(resolvedFile)) {
294478
+ const resolvedFile = import_node_path29.default.resolve(import_node_path29.default.dirname(file), action.url);
294479
+ if (!import_node_fs22.default.existsSync(resolvedFile)) {
294469
294480
  if (action.static) {
294470
294481
  addWarningForFile(session, file, `Could not find static resource at "${action.url}" in ${property}`, "error", { ruleId: RuleId.staticActionFileCopied });
294471
294482
  return void 0;
@@ -294498,12 +294509,12 @@ function resolveSiteAction(session, action, file, property) {
294498
294509
  if (!title) {
294499
294510
  addWarningForFile(session, file, `using filename for title of resource "${action.url}" in ${property}`);
294500
294511
  }
294501
- const filename = (_a6 = action.filename) !== null && _a6 !== void 0 ? _a6 : import_node_path30.default.basename(resolvedFile);
294512
+ const filename = (_a6 = action.filename) !== null && _a6 !== void 0 ? _a6 : import_node_path29.default.basename(resolvedFile);
294502
294513
  return {
294503
294514
  title: (_b = action.title) !== null && _b !== void 0 ? _b : filename,
294504
294515
  url: `/${fileHash}`,
294505
294516
  filename,
294506
- format: (_c = action.format) !== null && _c !== void 0 ? _c : EXT_TO_FORMAT[import_node_path30.default.extname(resolvedFile)],
294517
+ format: (_c = action.format) !== null && _c !== void 0 ? _c : EXT_TO_FORMAT[import_node_path29.default.extname(resolvedFile)],
294507
294518
  static: true
294508
294519
  };
294509
294520
  }
@@ -294907,15 +294918,15 @@ var Domains;
294907
294918
  })(Domains || (Domains = {}));
294908
294919
 
294909
294920
  // ../myst-cli/dist/process/loadIntersphinx.js
294910
- var import_node_fs24 = __toESM(require("fs"), 1);
294911
- var import_node_path31 = require("path");
294921
+ var import_node_fs23 = __toESM(require("fs"), 1);
294922
+ var import_node_path30 = require("path");
294912
294923
  function inventoryCacheFile(session, id, path42) {
294913
294924
  const hashcontent = `${id}${path42}`;
294914
294925
  const filename = `intersphinx-${computeHash(hashcontent)}.inv`;
294915
- const cacheFolder = (0, import_node_path31.join)(session.buildPath(), "cache");
294916
- if (!import_node_fs24.default.existsSync(cacheFolder))
294917
- import_node_fs24.default.mkdirSync(cacheFolder, { recursive: true });
294918
- return (0, import_node_path31.join)(cacheFolder, filename);
294926
+ const cacheFolder = (0, import_node_path30.join)(session.buildPath(), "cache");
294927
+ if (!import_node_fs23.default.existsSync(cacheFolder))
294928
+ import_node_fs23.default.mkdirSync(cacheFolder, { recursive: true });
294929
+ return (0, import_node_path30.join)(cacheFolder, filename);
294919
294930
  }
294920
294931
  async function loadIntersphinx(session, opts) {
294921
294932
  const state = session.store.getState();
@@ -294937,7 +294948,7 @@ async function loadIntersphinx(session, opts) {
294937
294948
  if (!cache.$externalReferences[key2] || opts.force) {
294938
294949
  const inventory = new Inventory({ id: key2, path: object.url });
294939
294950
  const cachePath = inventoryCacheFile(session, key2, inventory.path);
294940
- if (import_node_fs24.default.existsSync(cachePath) && !opts.force) {
294951
+ if (import_node_fs23.default.existsSync(cachePath) && !opts.force) {
294941
294952
  const localInventory = new Inventory({ id: key2, path: cachePath });
294942
294953
  session.log.debug(`Loading cached inventory file for ${inventory.path}: ${cachePath}`);
294943
294954
  const toc = tic();
@@ -294971,7 +294982,7 @@ ${error === null || error === void 0 ? void 0 : error.stack}
294971
294982
  return null;
294972
294983
  }
294973
294984
  const cachePath = inventoryCacheFile(session, loader2.id, loader2.path);
294974
- if (!import_node_fs24.default.existsSync(cachePath) && isUrl(loader2.path)) {
294985
+ if (!import_node_fs23.default.existsSync(cachePath) && isUrl(loader2.path)) {
294975
294986
  session.log.debug(`Saving remote inventory file to cache ${loader2.path}: ${cachePath}`);
294976
294987
  loader2.write(cachePath);
294977
294988
  }
@@ -295237,58 +295248,102 @@ function transformLiftCodeBlocksInJupytext(mdast2) {
295237
295248
  }
295238
295249
 
295239
295250
  // ../myst-cli/dist/transforms/dois.js
295240
- var import_node_fs25 = __toESM(require("fs"), 1);
295241
- var import_node_path32 = require("path");
295242
- function doiBibtexCacheFile(session, normalizedDoi) {
295243
- const filename = `doi-${computeHash(normalizedDoi)}.bib`;
295244
- const cacheFolder = (0, import_node_path32.join)(session.buildPath(), "cache");
295245
- if (!import_node_fs25.default.existsSync(cacheFolder))
295246
- import_node_fs25.default.mkdirSync(cacheFolder, { recursive: true });
295247
- return (0, import_node_path32.join)(cacheFolder, filename);
295251
+ var import_node_fs24 = __toESM(require("fs"), 1);
295252
+ var import_node_path31 = require("path");
295253
+ var CSL_JSON_MIMETYPE = "application/vnd.citationstyles.csl+json";
295254
+ var BIBTEX_MIMETYPE = "application/x-bibtex";
295255
+ function doiCSLJSONCacheFile(session, normalizedDoi) {
295256
+ const filename = `doi-${computeHash(normalizedDoi)}.csl.json`;
295257
+ const cacheFolder = (0, import_node_path31.join)(session.buildPath(), "cache");
295258
+ if (!import_node_fs24.default.existsSync(cacheFolder))
295259
+ import_node_fs24.default.mkdirSync(cacheFolder, { recursive: true });
295260
+ return (0, import_node_path31.join)(cacheFolder, filename);
295248
295261
  }
295249
295262
  function doiResolvesCacheFile(session, normalizedDoi) {
295250
295263
  const filename = `doi-${computeHash(normalizedDoi)}.txt`;
295251
- const cacheFolder = (0, import_node_path32.join)(session.buildPath(), "cache");
295252
- if (!import_node_fs25.default.existsSync(cacheFolder))
295253
- import_node_fs25.default.mkdirSync(cacheFolder, { recursive: true });
295254
- return (0, import_node_path32.join)(cacheFolder, filename);
295264
+ const cacheFolder = (0, import_node_path31.join)(session.buildPath(), "cache");
295265
+ if (!import_node_fs24.default.existsSync(cacheFolder))
295266
+ import_node_fs24.default.mkdirSync(cacheFolder, { recursive: true });
295267
+ return (0, import_node_path31.join)(cacheFolder, filename);
295255
295268
  }
295256
- async function getDoiOrgBibtex(session, doiString) {
295257
- const normalizedDoi = doi.normalize(doiString);
295258
- const url = doi.buildUrl(normalizedDoi);
295259
- if (!doi.validate(doiString) || !normalizedDoi || !url)
295260
- return null;
295261
- const cachePath = doiBibtexCacheFile(session, normalizedDoi);
295262
- if (import_node_fs25.default.existsSync(cachePath)) {
295263
- const bibtex2 = import_node_fs25.default.readFileSync(cachePath).toString();
295264
- session.log.debug(`Loaded cached reference bibtex for doi:${normalizedDoi}`);
295265
- return bibtex2;
295269
+ async function resolveDOIAsBibTeX(session, url) {
295270
+ session.log.debug("Fetching DOI BibTeX from doi.org");
295271
+ const response = await session.fetch(url, {
295272
+ headers: [["Accept", BIBTEX_MIMETYPE]]
295273
+ }).catch(() => {
295274
+ session.log.debug(`Request to ${url} failed.`);
295275
+ return void 0;
295276
+ });
295277
+ if (!response || !response.ok) {
295278
+ session.log.debug(`doi.org fetch failed for ${url}`);
295279
+ return void 0;
295266
295280
  }
295267
- const toc = tic();
295268
- session.log.debug("Fetching DOI bibtex from doi.org");
295281
+ const data = await response.text();
295282
+ return parseBibTeX(data);
295283
+ }
295284
+ async function resolveDOIAsCSLJSON(session, url) {
295285
+ session.log.debug("Fetching DOI CSL JSON from doi.org");
295269
295286
  const response = await session.fetch(url, {
295270
- headers: [["Accept", "application/x-bibtex"]]
295287
+ headers: [["Accept", CSL_JSON_MIMETYPE]]
295271
295288
  }).catch(() => {
295272
295289
  session.log.debug(`Request to ${url} failed.`);
295273
- return null;
295290
+ return void 0;
295274
295291
  });
295275
295292
  if (!response || !response.ok) {
295276
- session.log.debug(`doi.org fetch failed for ${doiString}`);
295277
- return null;
295293
+ session.log.debug(`doi.org fetch failed for ${url}`);
295294
+ return void 0;
295278
295295
  }
295279
- const bibtex = await response.text();
295280
- session.log.debug(toc(`Fetched reference bibtex for doi:${normalizedDoi} in %s`));
295281
- session.log.debug(`Saving doi bibtex to cache ${cachePath}`);
295282
- import_node_fs25.default.writeFileSync(cachePath, bibtex);
295283
- return bibtex;
295296
+ const data = await response.json();
295297
+ return parseCSLJSON([data]);
295298
+ }
295299
+ async function resolveDoiOrg(session, doiString) {
295300
+ const normalizedDoi = doi.normalize(doiString);
295301
+ const url = doi.buildUrl(doiString);
295302
+ if (!doi.validate(doiString) || !normalizedDoi || !url)
295303
+ return void 0;
295304
+ const cachePath = doiCSLJSONCacheFile(session, normalizedDoi);
295305
+ if (import_node_fs24.default.existsSync(cachePath)) {
295306
+ const cached = import_node_fs24.default.readFileSync(cachePath).toString();
295307
+ session.log.debug(`Loaded cached reference CSL-JSON for doi:${normalizedDoi}`);
295308
+ return JSON.parse(cached);
295309
+ }
295310
+ const toc = tic();
295311
+ let data;
295312
+ try {
295313
+ data = await resolveDOIAsBibTeX(session, url);
295314
+ if (data) {
295315
+ session.log.debug(toc(`Fetched reference BibTeX for doi:${normalizedDoi} in %s`));
295316
+ } else {
295317
+ session.log.debug(`BibTeX not available from doi.org for doi:${normalizedDoi}, trying CSL-JSON`);
295318
+ }
295319
+ } catch (error) {
295320
+ session.log.debug(`BibTeX from doi.org was malformed for doi:${normalizedDoi}, trying CSL-JSON`);
295321
+ }
295322
+ if (!data) {
295323
+ try {
295324
+ data = await resolveDOIAsCSLJSON(session, url);
295325
+ if (data) {
295326
+ session.log.debug(toc(`Fetched reference CSL-JSON for doi:${normalizedDoi} in %s`));
295327
+ } else {
295328
+ session.log.debug(`CSL-JSON not available from doi.org for doi:${normalizedDoi}`);
295329
+ }
295330
+ } catch (error) {
295331
+ session.log.debug(`CSL-JSON from doi.org was malformed for doi:${normalizedDoi}`);
295332
+ }
295333
+ }
295334
+ if (!data)
295335
+ return void 0;
295336
+ session.log.debug(`Saving DOI CSL-JSON to cache ${cachePath}`);
295337
+ import_node_fs24.default.writeFileSync(cachePath, JSON.stringify(data));
295338
+ return data;
295284
295339
  }
295285
295340
  async function doiOrgResolves(session, doiString) {
295286
295341
  const normalizedDoi = doi.normalize(doiString);
295287
- const url = doi.buildUrl(normalizedDoi);
295342
+ const url = doi.buildUrl(doiString);
295288
295343
  if (!doi.validate(doiString) || !normalizedDoi || !url)
295289
295344
  return false;
295290
295345
  const cachePath = doiResolvesCacheFile(session, normalizedDoi);
295291
- if (import_node_fs25.default.existsSync(cachePath)) {
295346
+ if (import_node_fs24.default.existsSync(cachePath)) {
295292
295347
  session.log.debug(`Loaded cached resolution result for doi:${normalizedDoi}`);
295293
295348
  return true;
295294
295349
  }
@@ -295304,35 +295359,48 @@ async function doiOrgResolves(session, doiString) {
295304
295359
  }
295305
295360
  session.log.debug(toc(`Resolved doi existence for doi:${normalizedDoi} in %s`));
295306
295361
  session.log.debug(`Saving resolution result to cache ${cachePath}`);
295307
- import_node_fs25.default.writeFileSync(cachePath, "ok");
295362
+ import_node_fs24.default.writeFileSync(cachePath, "ok");
295308
295363
  return true;
295309
295364
  }
295310
295365
  async function getCitation(session, vfile2, doiString, node3) {
295311
295366
  if (!doi.validate(doiString))
295312
295367
  return null;
295313
- const bibtex = await getDoiOrgBibtex(session, doiString);
295314
- if (!bibtex) {
295368
+ const data = await resolveDoiOrg(session, doiString);
295369
+ if (!data) {
295315
295370
  const resolves = await doiOrgResolves(session, doiString);
295316
295371
  const normalizedDoi = doi.normalize(doiString);
295317
295372
  let message;
295318
295373
  let note;
295319
295374
  if (resolves) {
295320
- message = `No bibtex available from doi.org for doi:${normalizedDoi}`;
295321
- note = `To resolve this error, visit ${doi.buildUrl(normalizedDoi)} and add citation info to .bib file`;
295375
+ message = `Citation data from doi.org was not available or malformed for doi:${normalizedDoi}`;
295376
+ note = `To resolve this error, visit ${doi.buildUrl(doiString)} and add citation info to local BibTeX file`;
295322
295377
  } else {
295323
- message = `Could not find DOI from link: ${doiString} as ${normalizedDoi}`;
295378
+ message = `Could not find DOI "${doiString}" from doi.org as doi:${normalizedDoi}`;
295379
+ note = "Please check the DOI and, if correct, add citation info to local BibTeX file";
295324
295380
  }
295325
- fileWarn(vfile2, message, {
295381
+ fileError(vfile2, message, {
295326
295382
  node: node3,
295327
295383
  ruleId: RuleId.doiLinkValid,
295328
295384
  note
295329
295385
  });
295330
295386
  return null;
295331
295387
  }
295332
- const renderer = await getCitations(bibtex);
295333
- const id = Object.keys(renderer)[0];
295334
- const render3 = renderer[id];
295335
- return { id, render: render3 };
295388
+ try {
295389
+ const renderer = await getCitationRenderers(data);
295390
+ const id = Object.keys(renderer)[0];
295391
+ const render3 = renderer[id];
295392
+ return { id, render: render3 };
295393
+ } catch (error) {
295394
+ fileError(vfile2, `Citation data from doi.org was malformed, please edit and add to your local references`, {
295395
+ node: node3,
295396
+ ruleId: RuleId.doiLinkValid,
295397
+ note: `Citation data from ${doiString}:
295398
+
295399
+ ${JSON.stringify(data)}
295400
+ `
295401
+ });
295402
+ return null;
295403
+ }
295336
295404
  }
295337
295405
  async function transformLinkedDOIs(session, vfile2, mdast2, doiRenderer, path42) {
295338
295406
  const toc = tic();
@@ -295366,11 +295434,12 @@ async function transformLinkedDOIs(session, vfile2, mdast2, doiRenderer, path42)
295366
295434
  return false;
295367
295435
  }
295368
295436
  doiRenderer[node3.url] = cite3;
295369
- renderer[cite3.id] = cite3.render;
295437
+ const label = cite3.render.getLabel();
295438
+ renderer[label] = cite3.render;
295370
295439
  const citeNode = node3;
295371
295440
  citeNode.type = "cite";
295372
295441
  citeNode.kind = "narrative";
295373
- citeNode.label = cite3.id;
295442
+ citeNode.label = label;
295374
295443
  if (doi.validate(toText(citeNode.children))) {
295375
295444
  citeNode.children = [];
295376
295445
  }
@@ -295386,8 +295455,9 @@ async function transformLinkedDOIs(session, vfile2, mdast2, doiRenderer, path42)
295386
295455
  return false;
295387
295456
  }
295388
295457
  doiRenderer[node3.label] = cite3;
295389
- renderer[cite3.id] = cite3.render;
295390
- node3.label = cite3.id;
295458
+ const label = cite3.render.getLabel();
295459
+ renderer[label] = cite3.render;
295460
+ node3.label = label;
295391
295461
  return true;
295392
295462
  })
295393
295463
  ]);
@@ -295537,6 +295607,54 @@ function embedTransform(session, mdast2, file, dependencies, state) {
295537
295607
  liftChildren(mdast2, "_lift");
295538
295608
  }
295539
295609
 
295610
+ // ../myst-cli/dist/transforms/include.js
295611
+ var import_node_path32 = __toESM(require("path"), 1);
295612
+ var import_node_fs25 = __toESM(require("fs"), 1);
295613
+ var makeFileResolver = (baseFile) => (relativeFile, sourceFile, vfile2) => {
295614
+ const base5 = sourceFile.toLowerCase().endsWith(".tex") ? baseFile : sourceFile;
295615
+ const fullFile = import_node_path32.default.resolve(import_node_path32.default.dirname(base5), relativeFile);
295616
+ if (!import_node_fs25.default.existsSync(fullFile)) {
295617
+ fileError(vfile2, `Include Directive: Could not find "${relativeFile}" relative to "${base5}"`, {
295618
+ ruleId: RuleId.includeContentLoads
295619
+ });
295620
+ return;
295621
+ }
295622
+ return fullFile;
295623
+ };
295624
+ var makeFileLoader = (session, baseFile) => (fullFile) => {
295625
+ session.store.dispatch(watch.actions.addLocalDependency({
295626
+ path: baseFile,
295627
+ dependency: fullFile
295628
+ }));
295629
+ return import_node_fs25.default.readFileSync(fullFile).toString();
295630
+ };
295631
+ var makeContentParser = (session) => async (filename, content3, vfile2) => {
295632
+ var _a6;
295633
+ if (filename.toLowerCase().endsWith(".html")) {
295634
+ return [{ type: "html", value: content3 }];
295635
+ }
295636
+ if (filename.toLowerCase().endsWith(".tex")) {
295637
+ const subTex = new TexParser(content3, vfile2);
295638
+ return (_a6 = subTex.ast.children) !== null && _a6 !== void 0 ? _a6 : [];
295639
+ }
295640
+ if (filename.toLowerCase().endsWith(".ipynb")) {
295641
+ const mdast2 = await processNotebook(session, filename, content3);
295642
+ return mdast2.children;
295643
+ }
295644
+ return parseMyst(session, content3, filename).children;
295645
+ };
295646
+ async function includeFilesTransform(session, baseFile, tree, vfile2) {
295647
+ const parseContent = makeContentParser(session);
295648
+ const loadFile2 = makeFileLoader(session, baseFile);
295649
+ const resolveFile = makeFileResolver(baseFile);
295650
+ await includeDirectiveTransform(tree, vfile2, {
295651
+ resolveFile,
295652
+ loadFile: loadFile2,
295653
+ parseContent,
295654
+ sourceFile: baseFile
295655
+ });
295656
+ }
295657
+
295540
295658
  // ../myst-cli/dist/transforms/links.js
295541
295659
  var import_node_fs26 = __toESM(require("fs"), 1);
295542
295660
  var import_node_path33 = __toESM(require("path"), 1);
@@ -299279,24 +299397,6 @@ function cleanOutput(session, output2) {
299279
299397
  // ../myst-cli/dist/build/utils/bibtex.js
299280
299398
  var import_node_fs33 = __toESM(require("fs"), 1);
299281
299399
  var import_node_path47 = __toESM(require("path"), 1);
299282
- function extractBibtex(key2, bibtex) {
299283
- const match3 = bibtex.match(new RegExp(`@[a-zA-Z]*{${key2}`, "g"));
299284
- if (!match3)
299285
- return;
299286
- const start = bibtex.indexOf(match3[0]);
299287
- let bracketCount = 0;
299288
- let ind = start + match3[0].length;
299289
- while (bibtex[ind] && (bibtex[ind] !== "}" || bracketCount !== 0)) {
299290
- if (bibtex[ind - 1] && bibtex[ind - 1] !== "\\") {
299291
- if (bibtex[ind] === "{")
299292
- bracketCount++;
299293
- if (bibtex[ind] === "}")
299294
- bracketCount--;
299295
- }
299296
- ind++;
299297
- }
299298
- return bibtex[ind] ? bibtex.substring(start, ind + 1) : void 0;
299299
- }
299300
299400
  function writeBibtexFromCitationRenderers(session, output2, content3) {
299301
299401
  const order3 = content3.map(({ references }) => {
299302
299402
  var _a6, _b;
@@ -299308,13 +299408,7 @@ function writeBibtexFromCitationRenderers(session, output2, content3) {
299308
299408
  const citationLookup = {};
299309
299409
  Object.values(cache.$citationRenderers).forEach((renderers) => {
299310
299410
  Object.entries(renderers).forEach(([key2, renderer]) => {
299311
- var _a6;
299312
- const bibtexContent2 = renderer.cite._graph.find((item) => {
299313
- return item.type === "@biblatex/text";
299314
- });
299315
- if (bibtexContent2 === null || bibtexContent2 === void 0 ? void 0 : bibtexContent2.data) {
299316
- citationLookup[key2] = (_a6 = extractBibtex(key2, bibtexContent2.data)) !== null && _a6 !== void 0 ? _a6 : bibtexContent2.data;
299317
- }
299411
+ citationLookup[key2] = renderer.exportBibTeX();
299318
299412
  });
299319
299413
  });
299320
299414
  const bibtexContent = [];
@@ -300642,10 +300736,10 @@ ${node3.value}
300642
300736
  state.write(`)`);
300643
300737
  },
300644
300738
  embed(node3, state) {
300645
- state.renderChildren(node3);
300739
+ state.renderChildren(node3, 2);
300646
300740
  },
300647
300741
  include(node3, state) {
300648
- state.renderChildren(node3);
300742
+ state.renderChildren(node3, 2);
300649
300743
  },
300650
300744
  footnoteReference(node3, state) {
300651
300745
  if (!node3.identifier)