mystmd 1.1.56__py3-none-any.whl → 1.2.1__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
@@ -193279,7 +193279,7 @@ var {
193279
193279
  } = import_index.default;
193280
193280
 
193281
193281
  // src/version.ts
193282
- var version = "1.1.56";
193282
+ var version = "1.2.1";
193283
193283
  var version_default = version;
193284
193284
 
193285
193285
  // ../myst-cli/dist/build/build.js
@@ -194274,6 +194274,7 @@ var AFFILIATION_KEYS = [
194274
194274
  ];
194275
194275
  var AFFILIATION_ALIASES = {
194276
194276
  ref: "id",
194277
+ // Used in QMD to reference an affiliation
194277
194278
  region: "state",
194278
194279
  province: "state",
194279
194280
  zipcode: "postal_code",
@@ -194619,6 +194620,7 @@ var PERSON_KEYS = [
194619
194620
  ];
194620
194621
  var PERSON_ALIASES = {
194621
194622
  ref: "id",
194623
+ // Used in QMD to reference a contributor
194622
194624
  role: "roles",
194623
194625
  "equal-contributor": "equal_contributor",
194624
194626
  affiliation: "affiliations",
@@ -194881,7 +194883,6 @@ var FRONTMATTER_ALIASES = {
194881
194883
  // ../myst-frontmatter/dist/project/types.js
194882
194884
  var PROJECT_AND_PAGE_FRONTMATTER_KEYS = [
194883
194885
  "date",
194884
- "name",
194885
194886
  "doi",
194886
194887
  "arxiv",
194887
194888
  "open_access",
@@ -194898,6 +194899,7 @@ var PROJECT_AND_PAGE_FRONTMATTER_KEYS = [
194898
194899
  "exports",
194899
194900
  "downloads",
194900
194901
  "settings",
194902
+ // We maybe want to move this into site frontmatter in the future
194901
194903
  // Do not add any project specific keys here!
194902
194904
  ...SITE_FRONTMATTER_KEYS
194903
194905
  ];
@@ -194924,6 +194926,7 @@ var PAGE_KNOWN_PARTS = [
194924
194926
  var PAGE_FRONTMATTER_KEYS = [
194925
194927
  ...PROJECT_AND_PAGE_FRONTMATTER_KEYS,
194926
194928
  // These keys only exist on the page
194929
+ "label",
194927
194930
  "kernelspec",
194928
194931
  "jupytext",
194929
194932
  "tags",
@@ -197749,6 +197752,54 @@ function fillNumbering(base5, filler) {
197749
197752
  return output2;
197750
197753
  }
197751
197754
 
197755
+ // ../myst-frontmatter/dist/references/types.js
197756
+ var KNOWN_REFERENCE_KINDS = ["myst", "intersphinx"];
197757
+
197758
+ // ../myst-frontmatter/dist/references/validators.js
197759
+ function validateExternalReference(input3, opts) {
197760
+ var _a6;
197761
+ if (typeof input3 === "string") {
197762
+ input3 = { url: input3 };
197763
+ }
197764
+ const value = validateObjectKeys(input3, { required: ["url"], optional: ["kind"] }, opts);
197765
+ if (!value)
197766
+ return void 0;
197767
+ let url = validateUrl(value.url, incrementOptions("url", opts));
197768
+ if (!url)
197769
+ return void 0;
197770
+ if (url.endsWith("/")) {
197771
+ url = url.slice(0, url.length - 1);
197772
+ }
197773
+ const output2 = { url };
197774
+ if (defined(value.kind)) {
197775
+ const kindOpts = incrementOptions(value.kind, opts);
197776
+ let kind = (_a6 = validateString(value.kind, kindOpts)) === null || _a6 === void 0 ? void 0 : _a6.toLowerCase();
197777
+ if (kind === "sphinx" || kind === "inv")
197778
+ kind = "intersphinx";
197779
+ if (kind && !KNOWN_REFERENCE_KINDS.includes(kind)) {
197780
+ validationWarning(`Unknown external reference kind "${kind}"`, kindOpts);
197781
+ }
197782
+ if (kind)
197783
+ output2.kind = kind;
197784
+ }
197785
+ return output2;
197786
+ }
197787
+ function validateExternalReferences(input3, opts) {
197788
+ const value = validateObject(input3, opts);
197789
+ if (!value)
197790
+ return void 0;
197791
+ const output2 = Object.fromEntries(Object.entries(value).map(([key2, ref]) => {
197792
+ const outputKey = validateString(key2, { ...opts, regex: "^[a-zA-Z0-9_-]*$" });
197793
+ if (!outputKey)
197794
+ return void 0;
197795
+ const outputRef = validateExternalReference(ref, incrementOptions(key2, opts));
197796
+ if (!outputRef)
197797
+ return void 0;
197798
+ return [outputKey, outputRef];
197799
+ }).filter((exists2) => !!exists2));
197800
+ return Object.keys(output2).length ? output2 : void 0;
197801
+ }
197802
+
197752
197803
  // ../myst-frontmatter/dist/venues/validators.js
197753
197804
  function validateVenue(input3, opts) {
197754
197805
  let titleOpts;
@@ -198091,9 +198142,6 @@ function validateProjectAndPageFrontmatterKeys(value, opts) {
198091
198142
  if (defined(value.date)) {
198092
198143
  output2.date = validateDate(value.date, incrementOptions("date", opts));
198093
198144
  }
198094
- if (defined(value.name)) {
198095
- output2.name = validateString(value.name, incrementOptions("name", opts));
198096
- }
198097
198145
  if (defined(value.doi)) {
198098
198146
  output2.doi = validateDoi(value.doi, incrementOptions("doi", opts));
198099
198147
  }
@@ -198194,16 +198242,7 @@ function validateProjectFrontmatterKeys(value, opts) {
198194
198242
  output2.id = validateString(value.id, incrementOptions("id", opts));
198195
198243
  }
198196
198244
  if (defined(value.references)) {
198197
- const referencesOpts = incrementOptions("references", opts);
198198
- const references = validateObject(value.references, referencesOpts);
198199
- if (references) {
198200
- output2.references = Object.fromEntries(Object.keys(references).map((key2) => {
198201
- const url = validateUrl(references[key2], incrementOptions(key2, referencesOpts));
198202
- if (!url)
198203
- return void 0;
198204
- return [key2, { url }];
198205
- }).filter((exists2) => !!exists2));
198206
- }
198245
+ output2.references = validateExternalReferences(value.references, incrementOptions("references", opts));
198207
198246
  }
198208
198247
  if (defined(value.thebe)) {
198209
198248
  const result = validateThebe(value.thebe, output2.github, incrementOptions("thebe", opts));
@@ -198226,7 +198265,7 @@ function validateProjectFrontmatterKeys(value, opts) {
198226
198265
  return output2;
198227
198266
  }
198228
198267
  function validateProjectFrontmatter(input3, opts) {
198229
- const value = validateObjectKeys(input3, { optional: PROJECT_FRONTMATTER_KEYS, alias: FRONTMATTER_ALIASES }, opts) || {};
198268
+ const value = validateObjectKeys(input3, { optional: PROJECT_FRONTMATTER_KEYS, alias: { ...FRONTMATTER_ALIASES, name: "label" } }, opts) || {};
198230
198269
  return validateProjectFrontmatterKeys(value, opts);
198231
198270
  }
198232
198271
 
@@ -198254,6 +198293,9 @@ var USE_PROJECT_FALLBACK = [
198254
198293
  ];
198255
198294
  function validatePageFrontmatterKeys(value, opts) {
198256
198295
  const output2 = validateProjectAndPageFrontmatterKeys(value, opts);
198296
+ if (defined(value.label)) {
198297
+ output2.label = validateString(value.label, incrementOptions("label", opts));
198298
+ }
198257
198299
  if (defined(value.kernelspec)) {
198258
198300
  output2.kernelspec = validateKernelSpec(value.kernelspec, incrementOptions("kernelspec", opts));
198259
198301
  }
@@ -198302,7 +198344,7 @@ function validatePageFrontmatterKeys(value, opts) {
198302
198344
  return output2;
198303
198345
  }
198304
198346
  function validatePageFrontmatter(input3, opts) {
198305
- const value = validateObjectKeys(input3, { optional: PAGE_FRONTMATTER_KEYS, alias: FRONTMATTER_ALIASES }, opts) || {};
198347
+ const value = validateObjectKeys(input3, { optional: PAGE_FRONTMATTER_KEYS, alias: { ...FRONTMATTER_ALIASES, name: "label" } }, opts) || {};
198306
198348
  return validatePageFrontmatterKeys(value, opts);
198307
198349
  }
198308
198350
 
@@ -202829,8 +202871,8 @@ var RuleId;
202829
202871
  RuleId2["roleKnown"] = "role-known";
202830
202872
  RuleId2["roleBodyCorrect"] = "role-body-correct";
202831
202873
  RuleId2["tocContentsExist"] = "toc-contents-exist";
202832
- RuleId2["validTocStructure"] = "valid-toc-structure";
202833
- RuleId2["validToc"] = "valid-toc";
202874
+ RuleId2["validTOCStructure"] = "valid-toc-structure";
202875
+ RuleId2["validTOC"] = "valid-toc";
202834
202876
  RuleId2["tocWritten"] = "toc-written";
202835
202877
  RuleId2["imageDownloads"] = "image-downloads";
202836
202878
  RuleId2["imageExists"] = "image-exists";
@@ -202850,10 +202892,12 @@ var RuleId;
202850
202892
  RuleId2["footnoteReferencesDefinition"] = "footnote-references-definition";
202851
202893
  RuleId2["intersphinxReferencesResolve"] = "intersphinx-references-resolve";
202852
202894
  RuleId2["mystLinkValid"] = "myst-link-valid";
202895
+ RuleId2["sphinxLinkValid"] = "sphinx-link-valid";
202853
202896
  RuleId2["rridLinkValid"] = "rrid-link-valid";
202854
202897
  RuleId2["wikipediaLinkValid"] = "wikipedia-link-valid";
202855
202898
  RuleId2["doiLinkValid"] = "doi-link-valid";
202856
202899
  RuleId2["linkResolves"] = "link-resolves";
202900
+ RuleId2["linkTextExists"] = "link-text-exists";
202857
202901
  RuleId2["notebookAttachmentsResolve"] = "notebook-attachments-resolve";
202858
202902
  RuleId2["notebookOutputCopied"] = "notebook-output-copied";
202859
202903
  RuleId2["mdastSnippetImports"] = "mdast-snippet-imports";
@@ -205878,6 +205922,7 @@ var admonitionTitle = (h4, node3) => h4(node3, "p", { class: "admonition-title"
205878
205922
  var admonition = (h4, node3) => h4(node3, "aside", {
205879
205923
  class: (0, import_classnames.default)({
205880
205924
  [node3.class]: node3.class,
205925
+ // The custom class is first!!
205881
205926
  admonition: true,
205882
205927
  [node3.kind]: node3.kind && node3.kind !== "admonition"
205883
205928
  })
@@ -220573,6 +220618,13 @@ var defaultHtmlToMdastOptions = {
220573
220618
  cite(h4, node3) {
220574
220619
  const attrs = addClassAndIdentifier(node3);
220575
220620
  return attrs.label ? h4(node3, "cite", attrs, all5(h4, node3)) : all5(h4, node3);
220621
+ },
220622
+ details(h4, node3) {
220623
+ const attrs = addClassAndIdentifier(node3);
220624
+ return h4(node3, "details", attrs, all5(h4, node3));
220625
+ },
220626
+ summary(h4, node3) {
220627
+ return h4(node3, "summary", all5(h4, node3));
220576
220628
  }
220577
220629
  }
220578
220630
  };
@@ -235842,6 +235894,107 @@ function linksTransform(mdast2, file, opts) {
235842
235894
  });
235843
235895
  }
235844
235896
 
235897
+ // ../myst-transforms/dist/links/myst.js
235898
+ var TRANSFORM_SOURCE3 = "LinkTransform:MystTransformer";
235899
+ function removeMystPrefix(uri, vfile2, link4, source2) {
235900
+ if (uri.startsWith("myst:")) {
235901
+ const normalized = uri.replace(/^myst/, "xref");
235902
+ if (vfile2) {
235903
+ fileWarn(vfile2, `"myst:" prefix is deprecated for external reference "${uri}"`, {
235904
+ note: `Use "${normalized}" instead.`,
235905
+ node: link4,
235906
+ source: source2,
235907
+ ruleId: RuleId.mystLinkValid
235908
+ });
235909
+ }
235910
+ return normalized;
235911
+ }
235912
+ return uri;
235913
+ }
235914
+ var MystTransformer = class {
235915
+ constructor(references) {
235916
+ this.protocol = "xref:myst";
235917
+ this.mystXRefsList = references.filter((ref) => {
235918
+ return ref.kind === "myst";
235919
+ }).filter((ref) => {
235920
+ return !!ref.value;
235921
+ });
235922
+ }
235923
+ test(uri) {
235924
+ if (!uri)
235925
+ return false;
235926
+ const normalizedUri = removeMystPrefix(uri);
235927
+ return !!this.mystXRefsList.find((m2) => m2.key && normalizedUri.startsWith(`xref:${m2.key}`));
235928
+ }
235929
+ transform(link4, file) {
235930
+ var _a6;
235931
+ const urlSource = removeMystPrefix(link4.urlSource || link4.url, file, link4, TRANSFORM_SOURCE3);
235932
+ let url;
235933
+ try {
235934
+ url = new URL(urlSource);
235935
+ } catch (err) {
235936
+ fileError(file, `Could not parse url for "${urlSource}"`, {
235937
+ node: link4,
235938
+ source: TRANSFORM_SOURCE3,
235939
+ ruleId: RuleId.mystLinkValid
235940
+ });
235941
+ return false;
235942
+ }
235943
+ const key2 = url.pathname.split("/")[0];
235944
+ const page = url.pathname.slice(key2.length);
235945
+ const identifier = (_a6 = url.hash) === null || _a6 === void 0 ? void 0 : _a6.replace(/^#/, "");
235946
+ const mystXRefs = this.mystXRefsList.find((m2) => m2.key === key2);
235947
+ if (!mystXRefs || !mystXRefs.value) {
235948
+ fileError(file, `Unknown project "${key2}" for link: ${urlSource}`, {
235949
+ node: link4,
235950
+ source: TRANSFORM_SOURCE3,
235951
+ ruleId: RuleId.mystLinkValid
235952
+ });
235953
+ return false;
235954
+ }
235955
+ let match3;
235956
+ if (identifier) {
235957
+ match3 = mystXRefs.value.references.find((ref) => {
235958
+ if (page && ref.url !== page)
235959
+ return false;
235960
+ if (!page && ref.implicit)
235961
+ return false;
235962
+ return ref.identifier === identifier || ref.html_id === identifier;
235963
+ });
235964
+ } else {
235965
+ match3 = mystXRefs.value.references.find((ref) => {
235966
+ if (ref.kind !== "page")
235967
+ return false;
235968
+ if (!page && ref.url === "/")
235969
+ return true;
235970
+ return ref.url === page;
235971
+ });
235972
+ }
235973
+ if (!match3) {
235974
+ fileError(file, `"${urlSource}" not found in MyST project ${mystXRefs.key} (${mystXRefs.url})`, {
235975
+ node: link4,
235976
+ source: TRANSFORM_SOURCE3,
235977
+ ruleId: RuleId.mystLinkValid
235978
+ });
235979
+ return false;
235980
+ }
235981
+ link4.internal = false;
235982
+ link4.url = `${mystXRefs.url}${match3.url}`;
235983
+ link4.dataUrl = `${mystXRefs.url}${match3.data}`;
235984
+ if (match3.kind === "page") {
235985
+ link4.protocol = "file";
235986
+ } else {
235987
+ const xref = link4;
235988
+ xref.type = "crossReference";
235989
+ xref.remote = true;
235990
+ xref.identifier = match3.identifier;
235991
+ xref.label = match3.identifier;
235992
+ xref.html_id = match3.html_id;
235993
+ }
235994
+ return true;
235995
+ }
235996
+ };
235997
+
235845
235998
  // ../myst-transforms/dist/links/utils.js
235846
235999
  function withoutHttp(url) {
235847
236000
  return url === null || url === void 0 ? void 0 : url.replace(/https?:\/\//, "");
@@ -235861,58 +236014,61 @@ function updateLinkTextIfEmpty(link4, title) {
235861
236014
  }
235862
236015
  }
235863
236016
 
235864
- // ../myst-transforms/dist/links/myst.js
235865
- var TRANSFORM_SOURCE3 = "LinkTransform:MystTransformer";
235866
- var MystTransformer = class {
235867
- constructor(intersphinx) {
235868
- this.protocol = "myst";
235869
- this.intersphinx = intersphinx;
236017
+ // ../myst-transforms/dist/links/sphinx.js
236018
+ var TRANSFORM_SOURCE4 = "LinkTransform:SphinxTransformer";
236019
+ var SphinxTransformer = class {
236020
+ constructor(references) {
236021
+ this.protocol = "xref:sphinx";
236022
+ this.intersphinx = references.filter((ref) => {
236023
+ return ref.kind === "intersphinx";
236024
+ }).filter((ref) => {
236025
+ var _a6;
236026
+ return !!((_a6 = ref.value) === null || _a6 === void 0 ? void 0 : _a6._loaded);
236027
+ }).map((ref) => ref.value);
235870
236028
  }
235871
236029
  test(uri) {
235872
- return !!(uri === null || uri === void 0 ? void 0 : uri.startsWith("myst:"));
236030
+ if (!uri)
236031
+ return false;
236032
+ const normalizedUri = removeMystPrefix(uri);
236033
+ return !!this.intersphinx.find((i2) => i2.id && normalizedUri.startsWith(`xref:${i2.id}`));
235873
236034
  }
235874
236035
  transform(link4, file) {
235875
236036
  var _a6, _b;
235876
- const urlSource = link4.urlSource || link4.url;
236037
+ const urlSource = removeMystPrefix(link4.urlSource || link4.url, file, link4, TRANSFORM_SOURCE4);
235877
236038
  let url;
235878
236039
  try {
235879
236040
  url = new URL(urlSource);
235880
236041
  } catch (err) {
235881
236042
  fileError(file, `Could not parse url for "${urlSource}"`, {
235882
236043
  node: link4,
235883
- source: TRANSFORM_SOURCE3,
235884
- ruleId: RuleId.mystLinkValid
236044
+ source: TRANSFORM_SOURCE4,
236045
+ ruleId: RuleId.sphinxLinkValid
235885
236046
  });
235886
236047
  return false;
235887
236048
  }
236049
+ const id = url.pathname;
235888
236050
  const target = (_b = (_a6 = url.hash) === null || _a6 === void 0 ? void 0 : _a6.replace(/^#/, "")) !== null && _b !== void 0 ? _b : "";
235889
- const project = this.intersphinx.find((i2) => {
235890
- if (url.pathname)
235891
- return i2.id === url.pathname;
235892
- if (target)
235893
- return !!i2.getEntry({ name: target });
235894
- return false;
235895
- });
236051
+ const project = this.intersphinx.find((i2) => i2.id === id);
235896
236052
  if (!project || !project.path) {
235897
- fileWarn(file, `Unknown project "${url.pathname}" for link: ${urlSource}`, {
236053
+ fileError(file, `Unknown project "${id}" for link: ${urlSource}`, {
235898
236054
  node: link4,
235899
- source: TRANSFORM_SOURCE3,
235900
- ruleId: RuleId.mystLinkValid
236055
+ source: TRANSFORM_SOURCE4,
236056
+ ruleId: RuleId.sphinxLinkValid
235901
236057
  });
235902
236058
  return false;
235903
236059
  }
235904
- if (!url.hash) {
236060
+ if (!target) {
235905
236061
  link4.internal = false;
235906
236062
  link4.url = project.path;
235907
236063
  updateLinkTextIfEmpty(link4, project.id || "(see documentation)");
235908
- return false;
236064
+ return true;
235909
236065
  }
235910
236066
  const entry = project.getEntry({ name: target });
235911
236067
  if (!entry) {
235912
- fileWarn(file, `"${urlSource}" not found intersphinx ${project.id} (${project.path})`, {
236068
+ fileError(file, `"${urlSource}" not found in intersphinx ${project.id} (${project.path})`, {
235913
236069
  node: link4,
235914
- source: TRANSFORM_SOURCE3,
235915
- ruleId: RuleId.mystLinkValid
236070
+ source: TRANSFORM_SOURCE4,
236071
+ ruleId: RuleId.sphinxLinkValid
235916
236072
  });
235917
236073
  return false;
235918
236074
  }
@@ -235926,7 +236082,7 @@ var MystTransformer = class {
235926
236082
  // ../myst-transforms/dist/links/wiki.js
235927
236083
  var DEFAULT_LANGUAGE = "en";
235928
236084
  var ANY_WIKIPEDIA_ORG = /^(?:https?:\/\/)?(?:([a-z]+)\.)?wikipedia\.org\/wiki\/(.+)$/;
235929
- var TRANSFORM_SOURCE4 = "LinkTransform:WikiTransformer";
236085
+ var TRANSFORM_SOURCE5 = "LinkTransform:WikiTransformer";
235930
236086
  function removeWiki(url, replace = "") {
235931
236087
  return url.replace(/\/?(wiki\/?)?$/, replace).replace(/^\/?(wiki\/)/, "");
235932
236088
  }
@@ -235969,7 +236125,7 @@ var WikiTransformer = class {
235969
236125
  fileWarn(file, `Wikipedia pagenames should not contain spaces in link: ${urlSource}`, {
235970
236126
  node: link4,
235971
236127
  note: "Replace spaces with underscores",
235972
- source: TRANSFORM_SOURCE4,
236128
+ source: TRANSFORM_SOURCE5,
235973
236129
  ruleId: RuleId.wikipediaLinkValid
235974
236130
  });
235975
236131
  return false;
@@ -235979,7 +236135,7 @@ var WikiTransformer = class {
235979
236135
  fileWarn(file, `Wikipedia pagenames should not contain spaces in link: ${urlSource}`, {
235980
236136
  node: link4,
235981
236137
  note: "Replace spaces with underscores",
235982
- source: TRANSFORM_SOURCE4,
236138
+ source: TRANSFORM_SOURCE5,
235983
236139
  ruleId: RuleId.wikipediaLinkValid
235984
236140
  });
235985
236141
  }
@@ -235987,7 +236143,7 @@ var WikiTransformer = class {
235987
236143
  fileError(file, `Wikipedia pagenames should not contain "/" in link: ${urlSource}`, {
235988
236144
  node: link4,
235989
236145
  note: "Only point to the final page name, do not include any other parts of the Wikipedia URL.",
235990
- source: TRANSFORM_SOURCE4,
236146
+ source: TRANSFORM_SOURCE5,
235991
236147
  ruleId: RuleId.wikipediaLinkValid
235992
236148
  });
235993
236149
  return false;
@@ -236008,7 +236164,7 @@ var WikiTransformer = class {
236008
236164
 
236009
236165
  // ../myst-transforms/dist/links/rrid.js
236010
236166
  var RESOLVER = "https://scicrunch.org/resolver/";
236011
- var TRANSFORM_SOURCE5 = "LinkTransform:RRIDTransformer";
236167
+ var TRANSFORM_SOURCE6 = "LinkTransform:RRIDTransformer";
236012
236168
  function isValid(rrid) {
236013
236169
  return !!rrid;
236014
236170
  }
@@ -236038,7 +236194,7 @@ var RRIDTransformer = class {
236038
236194
  if (!isValid(rrid)) {
236039
236195
  fileWarn(file, `RRID is not valid: ${urlSource}`, {
236040
236196
  node: link4,
236041
- source: TRANSFORM_SOURCE5,
236197
+ source: TRANSFORM_SOURCE6,
236042
236198
  ruleId: RuleId.rridLinkValid
236043
236199
  });
236044
236200
  return false;
@@ -236052,7 +236208,7 @@ var RRIDTransformer = class {
236052
236208
  };
236053
236209
 
236054
236210
  // ../myst-transforms/dist/links/doi.js
236055
- var TRANSFORM_SOURCE6 = "LinkTransform:DOITransformer";
236211
+ var TRANSFORM_SOURCE7 = "LinkTransform:DOITransformer";
236056
236212
  var DOITransformer = class {
236057
236213
  constructor() {
236058
236214
  this.protocol = "doi";
@@ -236071,7 +236227,7 @@ var DOITransformer = class {
236071
236227
  if (!doiUrl2) {
236072
236228
  fileError(file, `DOI is not valid: ${urlSource}`, {
236073
236229
  node: link4,
236074
- source: TRANSFORM_SOURCE6,
236230
+ source: TRANSFORM_SOURCE7,
236075
236231
  ruleId: RuleId.doiLinkValid
236076
236232
  });
236077
236233
  return false;
@@ -236160,6 +236316,22 @@ var GithubTransformer = class {
236160
236316
  }
236161
236317
  };
236162
236318
 
236319
+ // ../myst-transforms/dist/links/check.js
236320
+ function checkLinkTextTransform(mdast2, vfile2) {
236321
+ const linkNodes = selectAll("link,linkBlock,card,crossReference", mdast2);
236322
+ if (linkNodes.length === 0)
236323
+ return;
236324
+ linkNodes.forEach((node3) => {
236325
+ var _a6;
236326
+ if (!toText(node3.children) && !select("image", node3)) {
236327
+ fileWarn(vfile2, `Link text is empty for <${(_a6 = node3.urlSource) !== null && _a6 !== void 0 ? _a6 : node3.url}>`, {
236328
+ node: node3,
236329
+ ruleId: RuleId.linkTextExists
236330
+ });
236331
+ }
236332
+ });
236333
+ }
236334
+
236163
236335
  // ../myst-transforms/dist/targets.js
236164
236336
  function mystTargetsTransform(tree) {
236165
236337
  visit(tree, "mystTarget", (node3, index4, parent2) => {
@@ -236336,7 +236508,18 @@ var abbreviationPlugin = (opts) => (tree) => {
236336
236508
  };
236337
236509
 
236338
236510
  // ../myst-transforms/dist/include.js
236339
- async function includeDirectiveTransform(tree, vfile2, opts) {
236511
+ function updateFrontmatterFromInclude(frontmatter, includeFrontmatter) {
236512
+ if (frontmatter.math || (includeFrontmatter === null || includeFrontmatter === void 0 ? void 0 : includeFrontmatter.math)) {
236513
+ frontmatter.math = { ...frontmatter.math, ...includeFrontmatter === null || includeFrontmatter === void 0 ? void 0 : includeFrontmatter.math };
236514
+ }
236515
+ if (frontmatter.abbreviations || (includeFrontmatter === null || includeFrontmatter === void 0 ? void 0 : includeFrontmatter.abbreviations)) {
236516
+ frontmatter.abbreviations = {
236517
+ ...frontmatter.abbreviations,
236518
+ ...includeFrontmatter === null || includeFrontmatter === void 0 ? void 0 : includeFrontmatter.abbreviations
236519
+ };
236520
+ }
236521
+ }
236522
+ async function includeDirectiveTransform(tree, frontmatter, vfile2, opts) {
236340
236523
  const includeNodes = selectAll("include", tree);
236341
236524
  if (includeNodes.length === 0)
236342
236525
  return;
@@ -236408,12 +236591,14 @@ async function includeDirectiveTransform(tree, vfile2, opts) {
236408
236591
  children = [container4];
236409
236592
  }
236410
236593
  } else {
236411
- children = await opts.parseContent(fullFile, content3, vfile2);
236594
+ const parsed = await opts.parseContent(fullFile, content3);
236595
+ children = parsed.mdast.children;
236596
+ updateFrontmatterFromInclude(frontmatter, parsed.frontmatter);
236412
236597
  }
236413
236598
  node3.children = children;
236414
236599
  if (!((_b = node3.children) === null || _b === void 0 ? void 0 : _b.length))
236415
236600
  return;
236416
- await includeDirectiveTransform(node3, vfile2, {
236601
+ await includeDirectiveTransform(node3, frontmatter, vfile2, {
236417
236602
  ...opts,
236418
236603
  stack: [...(_c = opts.stack) !== null && _c !== void 0 ? _c : [], fullFile],
236419
236604
  sourceFile: fullFile
@@ -236893,7 +237078,7 @@ var ReferenceState = class {
236893
237078
  return;
236894
237079
  if (node3.implicit)
236895
237080
  return;
236896
- fileWarn(this.vfile, `Duplicate identifier "${node3.identifier}" for node of type ${node3.type}`, {
237081
+ fileWarn(this.vfile, `Duplicate identifier in file "${node3.identifier}"`, {
236897
237082
  node: node3,
236898
237083
  source: TRANSFORM_NAME2,
236899
237084
  ruleId: RuleId.identifierIsUnique
@@ -236949,6 +237134,9 @@ var ReferenceState = class {
236949
237134
  node3.enumerator = enumerator;
236950
237135
  return enumerator;
236951
237136
  }
237137
+ getIdentifiers() {
237138
+ return [...this.identifiers, ...Object.keys(this.targets)];
237139
+ }
236952
237140
  getTarget(identifier) {
236953
237141
  if (!identifier)
236954
237142
  return void 0;
@@ -236961,7 +237149,6 @@ var ReferenceState = class {
236961
237149
  return this;
236962
237150
  }
236963
237151
  resolveReferenceContent(node3) {
236964
- var _a6, _b, _c;
236965
237152
  const fileTarget = this.getFileTarget(node3.identifier);
236966
237153
  if (fileTarget) {
236967
237154
  const { url, title, dataUrl } = fileTarget;
@@ -236982,26 +237169,32 @@ var ReferenceState = class {
236982
237169
  return;
236983
237170
  }
236984
237171
  node3.kind = target.kind;
236985
- const noNodeChildren = !((_a6 = node3.children) === null || _a6 === void 0 ? void 0 : _a6.length);
236986
- if (target.kind === TargetKind.heading) {
236987
- const numberHeading = shouldEnumerate(target.node, TargetKind.heading, this.numbering);
236988
- const template = getReferenceTemplate(target, this.numbering, numberHeading, true);
236989
- fillReferenceEnumerators2(this.vfile, node3, template, target.node, copyNode(target.node).children);
236990
- } else {
236991
- const caption3 = select("caption", target.node) || select("admonitionTitle", target.node) || select("definitionTerm", target.node);
236992
- const captionParagraph = caption3 ? (_b = select("paragraph", caption3)) !== null && _b !== void 0 ? _b : caption3 : caption3;
236993
- const title = captionParagraph ? (_c = copyNode(captionParagraph)) === null || _c === void 0 ? void 0 : _c.children : void 0;
236994
- if (title && node3.kind === ReferenceKind2.ref && noNodeChildren) {
236995
- node3.children = title;
236996
- }
236997
- const template = getReferenceTemplate(target, this.numbering, !!target.node.enumerator, !!title);
236998
- fillReferenceEnumerators2(this.vfile, node3, template, target.node, title);
236999
- }
237000
- node3.resolved = true;
237001
- node3.identifier = target.node.identifier;
237002
- node3.html_id = target.node.html_id;
237172
+ addChildrenFromTargetNode(node3, target.node, this.numbering, this.vfile);
237003
237173
  }
237004
237174
  };
237175
+ function addChildrenFromTargetNode(node3, targetNode, numbering, vfile2) {
237176
+ var _a6, _b, _c;
237177
+ numbering = fillNumbering(numbering, DEFAULT_NUMBERING);
237178
+ const kind = kindFromNode2(targetNode);
237179
+ const noNodeChildren = !((_a6 = node3.children) === null || _a6 === void 0 ? void 0 : _a6.length);
237180
+ if (kind === TargetKind.heading) {
237181
+ const numberHeading = shouldEnumerate(targetNode, TargetKind.heading, numbering);
237182
+ const template = getReferenceTemplate({ node: targetNode, kind }, numbering, numberHeading, true);
237183
+ fillReferenceEnumerators2(vfile2, node3, template, targetNode, copyNode(targetNode).children);
237184
+ } else {
237185
+ const caption3 = select("caption", targetNode) || select("admonitionTitle", targetNode) || select("definitionTerm", targetNode);
237186
+ const captionParagraph = caption3 ? (_b = select("paragraph", caption3)) !== null && _b !== void 0 ? _b : caption3 : caption3;
237187
+ const title = captionParagraph ? (_c = copyNode(captionParagraph)) === null || _c === void 0 ? void 0 : _c.children : void 0;
237188
+ if (title && node3.kind === ReferenceKind2.ref && noNodeChildren) {
237189
+ node3.children = title;
237190
+ }
237191
+ const template = getReferenceTemplate({ node: targetNode, kind }, numbering, !!targetNode.enumerator, !!title);
237192
+ fillReferenceEnumerators2(vfile2, node3, template, targetNode, title);
237193
+ }
237194
+ node3.resolved = true;
237195
+ node3.identifier = targetNode.identifier;
237196
+ node3.html_id = targetNode.html_id;
237197
+ }
237005
237198
  function warnNodeTargetNotFound(node3, vfile2) {
237006
237199
  if (!vfile2)
237007
237200
  return;
@@ -237027,6 +237220,9 @@ var MultiPageReferenceResolver = class {
237027
237220
  });
237028
237221
  return pageXRefs;
237029
237222
  }
237223
+ getIdentifiers() {
237224
+ return this.states.map((state) => state.getIdentifiers()).flat();
237225
+ }
237030
237226
  getTarget(identifier, page) {
237031
237227
  const pageXRefs = this.resolveStateProvider(identifier, page);
237032
237228
  return pageXRefs === null || pageXRefs === void 0 ? void 0 : pageXRefs.getTarget(identifier);
@@ -237207,6 +237403,8 @@ function unnestCrossReferencesTransform(tree) {
237207
237403
  }
237208
237404
  var resolveCrossReferencesTransform = (tree, opts) => {
237209
237405
  visit(tree, "crossReference", (node3) => {
237406
+ if (node3.protocol)
237407
+ return;
237210
237408
  opts.state.resolveReferenceContent(node3);
237211
237409
  });
237212
237410
  };
@@ -237298,7 +237496,7 @@ function getFrontmatter(file, tree, opts = { propagateTargets: true }) {
237298
237496
  const nextNodeIsH1 = (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type) === "heading" && nextNode.depth === 1;
237299
237497
  if (nextNodeIsH1 && !titleNull) {
237300
237498
  const title = toText(nextNode.children);
237301
- if (frontmatter.title && frontmatter.title === title) {
237499
+ if (frontmatter.title && frontmatter.title === title && !opts.keepTitleNode) {
237302
237500
  nextNode.type = "__delete__";
237303
237501
  frontmatter.content_includes_title = false;
237304
237502
  if (nextNode.label) {
@@ -239775,13 +239973,20 @@ function frontmatterValidationOpts(vfile2, opts) {
239775
239973
  }
239776
239974
  };
239777
239975
  }
239778
- function getPageFrontmatter(session, tree, vfile2, preFrontmatter) {
239976
+ function getPageFrontmatter(session, tree, vfile2, preFrontmatter, keepTitleNode) {
239977
+ var _a6;
239779
239978
  const { frontmatter: rawPageFrontmatter, identifiers } = getFrontmatter(vfile2, tree, {
239780
239979
  propagateTargets: true,
239781
- preFrontmatter
239980
+ preFrontmatter,
239981
+ keepTitleNode
239782
239982
  });
239783
239983
  unnestKernelSpec(rawPageFrontmatter);
239784
239984
  const pageFrontmatter = validatePageFrontmatter(rawPageFrontmatter, frontmatterValidationOpts(vfile2));
239985
+ if (pageFrontmatter.label) {
239986
+ const { identifier } = (_a6 = normalizeLabel(pageFrontmatter.label)) !== null && _a6 !== void 0 ? _a6 : {};
239987
+ if (identifier)
239988
+ identifiers.push(identifier);
239989
+ }
239785
239990
  logMessagesFromVFile(session, vfile2);
239786
239991
  return { frontmatter: pageFrontmatter, identifiers };
239787
239992
  }
@@ -240498,7 +240703,9 @@ var LatexSpecialSymbols = {
240498
240703
  textdegree: "\xBA",
240499
240704
  textasciitilde: "~",
240500
240705
  textvisiblespace: " ",
240706
+ // Not sure this will work, but close enough
240501
240707
  " ": " ",
240708
+ // this is a single backslash followed by a space
240502
240709
  ",": THIN_SPACE
240503
240710
  // this is a thin space (https://en.wikipedia.org/wiki/Thin_space) `\,` in latex
240504
240711
  };
@@ -240541,6 +240748,7 @@ var textOnlyReplacements = {
240541
240748
  "'": "\u2019",
240542
240749
  "`": "\u2018",
240543
240750
  "---": "\u2014",
240751
+ // must be above the next one
240544
240752
  "--": "\u2013",
240545
240753
  "~": "\u202F"
240546
240754
  };
@@ -276221,6 +276429,7 @@ function parseArgument(node3, next) {
276221
276429
  type: "argument",
276222
276430
  content: [],
276223
276431
  openMark: next.content,
276432
+ // will `closeMark` in next pass
276224
276433
  position: { start: (_a6 = next.position) === null || _a6 === void 0 ? void 0 : _a6.start }
276225
276434
  });
276226
276435
  return true;
@@ -276439,24 +276648,43 @@ var SECTION_HANDLERS = {
276439
276648
  var colors = {
276440
276649
  // Standard html colors:
276441
276650
  black: "black",
276651
+ // #000000
276442
276652
  blue: "blue",
276653
+ // #0000FF
276443
276654
  brown: "brown",
276655
+ // #A52A2A
276444
276656
  cyan: "cyan",
276657
+ // #00FFFF
276445
276658
  darkgray: "darkgray",
276659
+ // #A9A9A9
276446
276660
  gray: "gray",
276661
+ // #808080
276447
276662
  green: "green",
276663
+ // #008000
276448
276664
  lightgray: "lightgray",
276665
+ // #D3D3D3
276449
276666
  lime: "lime",
276667
+ // #00FF00
276450
276668
  magenta: "magenta",
276669
+ // #FF00FF
276451
276670
  olive: "olive",
276671
+ // #808000
276452
276672
  orange: "orange",
276673
+ // #FFA500
276453
276674
  pink: "pink",
276675
+ // #FFC0CB
276454
276676
  purple: "purple",
276677
+ // #800080
276455
276678
  red: "red",
276679
+ // #FF0000
276456
276680
  teal: "teal",
276681
+ // #008080
276457
276682
  violet: "violet",
276683
+ // #EE82EE
276458
276684
  white: "white",
276685
+ // #FFFFFF
276459
276686
  yellow: "yellow",
276687
+ // #FFFF00
276460
276688
  // Other named latex colors
276461
276689
  Apricot: "#FBB982",
276462
276690
  Aquamarine: "#00B5BE",
@@ -277758,36 +277986,62 @@ var UNITS = {
277758
277986
  litre: "L",
277759
277987
  liter: "L",
277760
277988
  arcminute: "\u2032",
277989
+ // minute (plane angle) U+2032
277761
277990
  minute: "min",
277991
+ // minute (time)
277762
277992
  arcsecond: "\u2033",
277993
+ // second (plane angle) U+2033
277763
277994
  neper: "Np",
277764
277995
  tonne: "t",
277765
277996
  celsius: "\u2103"
277766
277997
  };
277767
277998
  var PREFIXES = {
277768
277999
  quecto: "q",
278000
+ // -30
277769
278001
  ronto: "r",
278002
+ // -27
277770
278003
  yocto: "y",
278004
+ // -24
277771
278005
  zepto: "z",
278006
+ // -21
277772
278007
  atto: "a",
278008
+ // -18
277773
278009
  femto: "f",
278010
+ // -15
277774
278011
  pico: "p",
278012
+ // -12
277775
278013
  nano: "n",
278014
+ // -9
277776
278015
  micro: "\xB5",
278016
+ // -6
277777
278017
  milli: "m",
278018
+ // -3
277778
278019
  centi: "c",
278020
+ // -2
277779
278021
  deci: "d",
278022
+ // -1
277780
278023
  deca: "da",
278024
+ // 1
277781
278025
  hecto: "h",
278026
+ // 2
277782
278027
  kilo: "k",
278028
+ // 3
277783
278029
  mega: "M",
278030
+ // 6
277784
278031
  giga: "G",
278032
+ // 9
277785
278033
  tera: "T",
278034
+ // 12
277786
278035
  peta: "P",
278036
+ // 15
277787
278037
  exa: "E",
278038
+ // 18
277788
278039
  zetta: "Z",
278040
+ // 21
277789
278041
  yotta: "Y",
278042
+ // 24
277790
278043
  ronna: "R",
278044
+ // 27
277791
278045
  quetta: "Q"
277792
278046
  // 30
277793
278047
  };
@@ -277851,7 +278105,9 @@ var ABBREVIATIONS = {
277851
278105
  GPa: "giga pascal",
277852
278106
  mohm: "milli ohm",
277853
278107
  kohm: "kilo ohm",
278108
+ // kilohm
277854
278109
  Mohm: "mega ohm",
278110
+ // megohm
277855
278111
  pV: "pico volt",
277856
278112
  nV: "nano volt",
277857
278113
  uV: "micro volt",
@@ -283966,31 +284222,54 @@ var UNITS2 = {
283966
284222
  litre: "L",
283967
284223
  liter: "L",
283968
284224
  arcminute: "\u2032",
284225
+ // minute (plane angle) U+2032
283969
284226
  minute: "min",
284227
+ // minute (time)
283970
284228
  arcsecond: "\u2033",
284229
+ // second (plane angle) U+2033
283971
284230
  neper: "Np",
283972
284231
  tonne: "t",
283973
284232
  // SI prefixes
283974
284233
  yocto: "y",
284234
+ // -24
283975
284235
  zepto: "z",
284236
+ // -21
283976
284237
  atto: "a",
284238
+ // -18
283977
284239
  femto: "f",
284240
+ // -15
283978
284241
  pico: "p",
284242
+ // -12
283979
284243
  nano: "n",
284244
+ // -9
283980
284245
  micro: "\xB5",
284246
+ // -6
283981
284247
  milli: "m",
284248
+ // -3
283982
284249
  centi: "c",
284250
+ // -2
283983
284251
  deci: "d",
284252
+ // -1
283984
284253
  deca: "da",
284254
+ // 1
283985
284255
  hecto: "h",
284256
+ // 2
283986
284257
  kilo: "k",
284258
+ // 3
283987
284259
  mega: "M",
284260
+ // 6
283988
284261
  giga: "G",
284262
+ // 9
283989
284263
  tera: "T",
284264
+ // 12
283990
284265
  peta: "P",
284266
+ // 15
283991
284267
  exa: "E",
284268
+ // 18
283992
284269
  zetta: "Z",
284270
+ // 21
283993
284271
  yotta: "Y",
284272
+ // 24
283994
284273
  // Special
283995
284274
  angstrom: "\xC5"
283996
284275
  };
@@ -285270,10 +285549,15 @@ var tlds = [
285270
285549
  var MARKDOWN_IT_CONFIG = {
285271
285550
  options: {
285272
285551
  html: true,
285552
+ // Enable HTML tags in source
285273
285553
  xhtmlOut: true,
285554
+ // Use '/' to close single tags (<br />)
285274
285555
  breaks: false,
285556
+ // Convert '\n' in paragraphs into <br>
285275
285557
  langPrefix: "language-",
285558
+ // CSS language prefix for fenced blocks
285276
285559
  linkify: false,
285560
+ // autoconvert URL-like texts to links
285277
285561
  // Enable some language-neutral replacements + quotes beautification
285278
285562
  typographer: false,
285279
285563
  // Double + single quotes replacement pairs, when typographer enabled,
@@ -285601,7 +285885,9 @@ var defaultMdast = {
285601
285885
  ...normalizeLabel(name3),
285602
285886
  class: getClassName(t2),
285603
285887
  showLineNumbers: showLineNumbers || void 0,
285888
+ // Only add to MDAST if true
285604
285889
  startingLineNumber: showLineNumbers ? startingLineNumber : void 0,
285890
+ // Only if showing line numbers!
285605
285891
  emphasizeLines,
285606
285892
  value: withoutTrailingNewline(t2.content)
285607
285893
  };
@@ -285797,6 +286083,7 @@ var defaultMdast = {
285797
286083
  label,
285798
286084
  kind: t2.meta.kind,
285799
286085
  partial: t2.meta.partial,
286086
+ // author or year
285800
286087
  // TODO: can use the parsed version in the future
285801
286088
  prefix: (_b = t2.meta.prefix) === null || _b === void 0 ? void 0 : _b[0].content,
285802
286089
  suffix: (_c = t2.meta.suffix) === null || _c === void 0 ? void 0 : _c[0].content
@@ -286877,6 +287164,7 @@ var tabSetDirective = {
286877
287164
  var tabItemDirective = {
286878
287165
  name: "tab-item",
286879
287166
  alias: ["tabItem", "tab"],
287167
+ // TODO: A transform is necessary for stray `tab`s
286880
287168
  arg: {
286881
287169
  type: String
286882
287170
  },
@@ -286942,7 +287230,7 @@ var import_node_path17 = __toESM(require("path"), 1);
286942
287230
  var import_nbtx = __toESM(require_cjs2(), 1);
286943
287231
 
286944
287232
  // ../myst-cli/dist/version.js
286945
- var version2 = "1.1.56";
287233
+ var version2 = "1.2.1";
286946
287234
  var version_default2 = version2;
286947
287235
 
286948
287236
  // ../myst-cli/dist/utils/headers.js
@@ -287006,7 +287294,7 @@ ${source_default.bold.blue(docLinks.installNode)}
287006
287294
  `;
287007
287295
  async function getNodeVersion(session) {
287008
287296
  const result = new Promise((resolve7) => {
287009
- (0, import_check_node_version.default)({ node: ">= 16.0.0", npm: ">=7" }, (error, results) => {
287297
+ (0, import_check_node_version.default)({ node: ">= 18.0.0", npm: ">=8.6.0" }, (error, results) => {
287010
287298
  if (error) {
287011
287299
  session.log.error(error);
287012
287300
  resolve7(null);
@@ -287163,8 +287451,8 @@ var tocFile = (filename) => {
287163
287451
  return filename;
287164
287452
  return (0, import_node_path14.join)(filename, "_toc.yml");
287165
287453
  };
287166
- function upgradeOldJupyterBookToc(oldToc) {
287167
- const [root6, ...parts] = oldToc;
287454
+ function upgradeOldJupyterBookTOC(oldTOC) {
287455
+ const [root6, ...parts] = oldTOC;
287168
287456
  const toc = {
287169
287457
  root: root6.file,
287170
287458
  format: TOC_FORMAT,
@@ -287180,7 +287468,7 @@ function readTOC(log, opts) {
287180
287468
  const toc = js_yaml_default.load(import_node_fs7.default.readFileSync(filename).toString());
287181
287469
  if (Array.isArray(toc)) {
287182
287470
  try {
287183
- const old = upgradeOldJupyterBookToc(toc);
287471
+ const old = upgradeOldJupyterBookTOC(toc);
287184
287472
  log.warn(`${filename} is out of date: see https://executablebooks.org/en/latest/blog/2021-06-18-update-toc`);
287185
287473
  return old;
287186
287474
  } catch (error) {
@@ -287211,7 +287499,7 @@ function validateTOC(session, path42) {
287211
287499
  addWarningForFile(session, filename, `Table of Contents (ToC) file did not pass validation:
287212
287500
  - ${message}
287213
287501
  - An implicit ToC will be used instead
287214
- `, "error", { ruleId: RuleId.validTocStructure });
287502
+ `, "error", { ruleId: RuleId.validTOCStructure });
287215
287503
  return false;
287216
287504
  }
287217
287505
  }
@@ -288095,6 +288383,38 @@ function checkCache(cache, content3, file) {
288095
288383
  const useCache = (mdast2 === null || mdast2 === void 0 ? void 0 : mdast2.pre) && mdast2.sha256 === sha256;
288096
288384
  return { useCache, sha256 };
288097
288385
  }
288386
+ function loadMdFile(session, content3, file, opts) {
288387
+ const vfile2 = new VFile();
288388
+ vfile2.path = file;
288389
+ const mdast2 = parseMyst(session, content3, file);
288390
+ const { frontmatter, identifiers } = getPageFrontmatter(session, mdast2, vfile2, opts === null || opts === void 0 ? void 0 : opts.preFrontmatter, opts === null || opts === void 0 ? void 0 : opts.keepTitleNode);
288391
+ return { kind: SourceFileKind.Article, mdast: mdast2, frontmatter, identifiers };
288392
+ }
288393
+ async function loadNotebookFile(session, content3, file, opts) {
288394
+ const vfile2 = new VFile();
288395
+ vfile2.path = file;
288396
+ const mdast2 = await processNotebook(session, file, content3);
288397
+ const { frontmatter, identifiers } = getPageFrontmatter(session, mdast2, vfile2, opts === null || opts === void 0 ? void 0 : opts.preFrontmatter, opts === null || opts === void 0 ? void 0 : opts.keepTitleNode);
288398
+ return { kind: SourceFileKind.Notebook, mdast: mdast2, frontmatter, identifiers };
288399
+ }
288400
+ function loadTexFile(session, content3, file, opts) {
288401
+ var _a6;
288402
+ const vfile2 = new VFile();
288403
+ vfile2.path = file;
288404
+ const tex = new TexParser(content3, vfile2);
288405
+ const frontmatter = validatePageFrontmatter({
288406
+ title: toText(tex.data.frontmatter.title),
288407
+ short_title: toText(tex.data.frontmatter.short_title),
288408
+ authors: tex.data.frontmatter.authors,
288409
+ // TODO: affiliations: tex.data.frontmatter.affiliations,
288410
+ keywords: tex.data.frontmatter.keywords,
288411
+ math: tex.data.macros,
288412
+ bibliography: tex.data.bibliography,
288413
+ ...(_a6 = opts === null || opts === void 0 ? void 0 : opts.preFrontmatter) !== null && _a6 !== void 0 ? _a6 : {}
288414
+ }, frontmatterValidationOpts(vfile2));
288415
+ logMessagesFromVFile(session, vfile2);
288416
+ return { kind: SourceFileKind.Article, mdast: tex.ast, frontmatter };
288417
+ }
288098
288418
  async function loadFile(session, file, projectPath, extension, opts) {
288099
288419
  var _a6, _b;
288100
288420
  await session.loadPlugins();
@@ -288107,35 +288427,26 @@ async function loadFile(session, file, projectPath, extension, opts) {
288107
288427
  location4 = `/${import_node_path18.default.relative(projectPath, file)}`;
288108
288428
  }
288109
288429
  location4 = location4.replaceAll("\\", "/");
288110
- const vfile2 = new VFile();
288111
- vfile2.path = file;
288112
288430
  try {
288431
+ const content3 = import_node_fs11.default.readFileSync(file).toString();
288432
+ const { sha256, useCache } = checkCache(cache, content3, file);
288433
+ if (useCache) {
288434
+ session.log.debug(toc(`loadFile: ${file} already loaded.`));
288435
+ return (_a6 = cache.$getMdast(file)) === null || _a6 === void 0 ? void 0 : _a6.pre;
288436
+ }
288113
288437
  const ext2 = extension || import_node_path18.default.extname(file).toLowerCase();
288438
+ let loadResult;
288114
288439
  switch (ext2) {
288115
288440
  case ".md": {
288116
- const content3 = import_node_fs11.default.readFileSync(file).toString();
288117
- const { sha256, useCache } = checkCache(cache, content3, file);
288118
- if (useCache)
288119
- break;
288120
- const mdast2 = parseMyst(session, content3, file);
288121
- const { frontmatter, identifiers } = getPageFrontmatter(session, mdast2, vfile2, opts === null || opts === void 0 ? void 0 : opts.preFrontmatter);
288122
- cache.$setMdast(file, {
288123
- sha256,
288124
- pre: { kind: SourceFileKind.Article, file, location: location4, mdast: mdast2, frontmatter, identifiers }
288125
- });
288441
+ loadResult = loadMdFile(session, content3, file, opts);
288126
288442
  break;
288127
288443
  }
288128
288444
  case ".ipynb": {
288129
- const content3 = import_node_fs11.default.readFileSync(file).toString();
288130
- const { sha256, useCache } = checkCache(cache, content3, file);
288131
- if (useCache)
288132
- break;
288133
- const mdast2 = await processNotebook(cache, file, content3);
288134
- const { frontmatter, identifiers } = getPageFrontmatter(session, mdast2, vfile2, opts === null || opts === void 0 ? void 0 : opts.preFrontmatter);
288135
- cache.$setMdast(file, {
288136
- sha256,
288137
- pre: { kind: SourceFileKind.Notebook, file, location: location4, mdast: mdast2, frontmatter, identifiers }
288138
- });
288445
+ loadResult = await loadNotebookFile(session, content3, file, opts);
288446
+ break;
288447
+ }
288448
+ case ".tex": {
288449
+ loadResult = loadTexFile(session, content3, file, opts);
288139
288450
  break;
288140
288451
  }
288141
288452
  case ".bib": {
@@ -288143,35 +288454,6 @@ async function loadFile(session, file, projectPath, extension, opts) {
288143
288454
  cache.$citationRenderers[file] = renderer;
288144
288455
  break;
288145
288456
  }
288146
- case ".tex": {
288147
- const content3 = import_node_fs11.default.readFileSync(file).toString();
288148
- const { sha256, useCache } = checkCache(cache, content3, file);
288149
- if (useCache)
288150
- break;
288151
- const tex = new TexParser(content3, vfile2);
288152
- const frontmatter = validatePageFrontmatter({
288153
- title: toText(tex.data.frontmatter.title),
288154
- short_title: toText(tex.data.frontmatter.short_title),
288155
- authors: tex.data.frontmatter.authors,
288156
- // TODO: affiliations: tex.data.frontmatter.affiliations,
288157
- keywords: tex.data.frontmatter.keywords,
288158
- math: tex.data.macros,
288159
- bibliography: tex.data.bibliography,
288160
- ...(_a6 = opts === null || opts === void 0 ? void 0 : opts.preFrontmatter) !== null && _a6 !== void 0 ? _a6 : {}
288161
- }, frontmatterValidationOpts(vfile2));
288162
- logMessagesFromVFile(session, vfile2);
288163
- cache.$setMdast(file, {
288164
- sha256,
288165
- pre: {
288166
- kind: SourceFileKind.Article,
288167
- file,
288168
- mdast: tex.ast,
288169
- location: location4,
288170
- frontmatter
288171
- }
288172
- });
288173
- break;
288174
- }
288175
288457
  default:
288176
288458
  addWarningForFile(session, file, "Unrecognized extension", "error", {
288177
288459
  ruleId: RuleId.mystFileLoads
@@ -288179,6 +288461,12 @@ async function loadFile(session, file, projectPath, extension, opts) {
288179
288461
  session.log.info(`"${file}": Please rerun the build with "-c" to ensure the built files are cleared.`);
288180
288462
  success = false;
288181
288463
  }
288464
+ if (loadResult) {
288465
+ cache.$setMdast(file, {
288466
+ sha256,
288467
+ pre: { file, location: location4, ...loadResult }
288468
+ });
288469
+ }
288182
288470
  } catch (error) {
288183
288471
  session.log.debug(`
288184
288472
 
@@ -294622,7 +294910,7 @@ var glob = Object.assign(glob_, {
294622
294910
  });
294623
294911
  glob.glob = glob;
294624
294912
 
294625
- // ../myst-cli/dist/project/fromToc.js
294913
+ // ../myst-cli/dist/project/fromTOC.js
294626
294914
  var import_node_fs12 = __toESM(require("fs"), 1);
294627
294915
  var import_node_path19 = require("path");
294628
294916
  function pagesFromChapters(session, path42, chapters, pages = [], level = 1, pageSlugs) {
@@ -294646,7 +294934,7 @@ function pagesFromChapters(session, path42, chapters, pages = [], level = 1, pag
294646
294934
  });
294647
294935
  return pages;
294648
294936
  }
294649
- function projectFromToc(session, path42, level = 1) {
294937
+ function projectFromTOC(session, path42, level = 1) {
294650
294938
  const filename = tocFile(path42);
294651
294939
  if (!import_node_fs12.default.existsSync(filename)) {
294652
294940
  throw new Error(`Could not find TOC "${filename}". Please create a '_toc.yml'.`);
@@ -294684,8 +294972,8 @@ function projectFromToc(session, path42, level = 1) {
294684
294972
  }
294685
294973
  return { path: dir || ".", file: indexFile, index: slug, pages };
294686
294974
  }
294687
- function pagesFromToc(session, path42, level) {
294688
- const { file, index: index4, pages } = projectFromToc(session, path42, nextLevel(level));
294975
+ function pagesFromTOC(session, path42, level) {
294976
+ const { file, index: index4, pages } = projectFromTOC(session, path42, nextLevel(level));
294689
294977
  pages.unshift({ file, slug: index4, level });
294690
294978
  return pages;
294691
294979
  }
@@ -294708,10 +294996,10 @@ function projectPagesFromPath(session, path42, level, pageSlugs, opts) {
294708
294996
  if (contents.includes((0, import_node_path20.join)(path42, "_toc.yml"))) {
294709
294997
  const prevLevel = level < 2 ? 1 : level - 1;
294710
294998
  try {
294711
- return pagesFromToc(session, path42, prevLevel);
294999
+ return pagesFromTOC(session, path42, prevLevel);
294712
295000
  } catch {
294713
295001
  if (!suppressWarnings) {
294714
- addWarningForFile(session, (0, import_node_path20.join)(path42, "_toc.yml"), `Invalid table of contents ignored`, "warn", { ruleId: RuleId.validToc });
295002
+ addWarningForFile(session, (0, import_node_path20.join)(path42, "_toc.yml"), `Invalid table of contents ignored`, "warn", { ruleId: RuleId.validTOC });
294715
295003
  }
294716
295004
  }
294717
295005
  }
@@ -294796,7 +295084,7 @@ async function projectFromPath(session, path42, indexFile) {
294796
295084
  return { file: indexFile, index: slug, path: path42, pages, implicitIndex };
294797
295085
  }
294798
295086
 
294799
- // ../myst-cli/dist/project/toToc.js
295087
+ // ../myst-cli/dist/project/toTOC.js
294800
295088
  var import_node_fs14 = __toESM(require("fs"), 1);
294801
295089
  var import_node_path21 = require("path");
294802
295090
  function getRelativeDocumentLink(file, path42) {
@@ -294861,7 +295149,7 @@ function tocFromProject(project, path42 = ".") {
294861
295149
  };
294862
295150
  return toc;
294863
295151
  }
294864
- function writeTocFromProject(project, path42) {
295152
+ function writeTOCFromProject(project, path42) {
294865
295153
  const filename = (0, import_node_path21.join)(path42, "_toc.yml");
294866
295154
  const content3 = `${GENERATED_TOC_HEADER}${js_yaml_default.dump(tocFromProject(project, path42))}`;
294867
295155
  import_node_fs14.default.writeFileSync(filename, content3);
@@ -294882,13 +295170,13 @@ async function loadProjectFromDisk(session, path42, opts) {
294882
295170
  Consider running "myst init --project" in that directory`, "warn", { ruleId: RuleId.projectConfigExists });
294883
295171
  }
294884
295172
  let newProject;
294885
- let { index: index4, writeToc } = opts || {};
295173
+ let { index: index4, writeTOC } = opts || {};
294886
295174
  const projectConfigFile = selectors_exports.selectLocalConfigFile(session.store.getState(), path42);
294887
295175
  if (validateTOC(session, path42)) {
294888
- newProject = projectFromToc(session, path42);
294889
- if (writeToc)
295176
+ newProject = projectFromTOC(session, path42);
295177
+ if (writeTOC)
294890
295178
  session.log.warn("Not writing the table of contents, it already exists!");
294891
- writeToc = false;
295179
+ writeTOC = false;
294892
295180
  } else {
294893
295181
  const project2 = selectors_exports.selectLocalProject(session.store.getState(), path42);
294894
295182
  if (!index4 && !(project2 === null || project2 === void 0 ? void 0 : project2.implicitIndex) && (project2 === null || project2 === void 0 ? void 0 : project2.file)) {
@@ -294899,11 +295187,11 @@ Consider running "myst init --project" in that directory`, "warn", { ruleId: Rul
294899
295187
  if (!newProject) {
294900
295188
  throw new Error(`Could not load project from ${path42}`);
294901
295189
  }
294902
- if (writeToc) {
295190
+ if (writeTOC) {
294903
295191
  try {
294904
295192
  session.log.info(`\u{1F4D3} Writing '_toc.yml' file to ${path42 === "." ? "the current directory" : path42}`);
294905
- writeTocFromProject(newProject, path42);
294906
- newProject = projectFromToc(session, path42);
295193
+ writeTOCFromProject(newProject, path42);
295194
+ newProject = projectFromTOC(session, path42);
294907
295195
  } catch {
294908
295196
  addWarningForFile(session, projectConfigFile, `Error writing '_toc.yml' file to ${path42}`, "error", { ruleId: RuleId.tocWritten });
294909
295197
  }
@@ -297521,7 +297809,7 @@ function resolveArticlesFromTOC(session, exp, tocPath, vfile2) {
297521
297809
  ExportFormats.pdf,
297522
297810
  ExportFormats.pdftex
297523
297811
  ].includes(exp.format);
297524
- const proj = projectFromToc(session, tocPath, allowLevelLessThanOne ? -1 : 1);
297812
+ const proj = projectFromTOC(session, tocPath, allowLevelLessThanOne ? -1 : 1);
297525
297813
  return resolveArticlesFromProject(exp, proj, vfile2);
297526
297814
  }
297527
297815
  function resolveTemplate(sourceFile, exp, disableTemplate) {
@@ -297574,9 +297862,9 @@ function resolveArticles(session, sourceFile, vfile2, exp, projectPath) {
297574
297862
  const { articles, sub_articles } = exp;
297575
297863
  let resolved = { articles, sub_articles };
297576
297864
  if (exp.toc && !resolved.articles && !resolved.sub_articles) {
297577
- const resolvedToc = import_node_path28.default.resolve(import_node_path28.default.dirname(sourceFile), exp.toc);
297578
- if (validateTOC(session, resolvedToc)) {
297579
- resolved = resolveArticlesFromTOC(session, exp, resolvedToc, vfile2);
297865
+ const resolvedTOC = import_node_path28.default.resolve(import_node_path28.default.dirname(sourceFile), exp.toc);
297866
+ if (validateTOC(session, resolvedTOC)) {
297867
+ resolved = resolveArticlesFromTOC(session, exp, resolvedTOC, vfile2);
297580
297868
  }
297581
297869
  }
297582
297870
  if (!resolved.articles && SOURCE_EXTENSIONS.includes(import_node_path28.default.extname(sourceFile))) {
@@ -297990,79 +298278,127 @@ async function getSiteManifest(session, opts) {
297990
298278
  return manifest;
297991
298279
  }
297992
298280
 
297993
- // ../myst-cli/dist/process/loadIntersphinx.js
298281
+ // ../myst-cli/dist/process/loadReferences.js
297994
298282
  var import_node_fs23 = __toESM(require("fs"), 1);
297995
298283
  var import_node_path30 = require("path");
297996
- function inventoryCacheFile(session, id, path42) {
298284
+ function inventoryCacheFile(session, refKind, id, path42) {
297997
298285
  const hashcontent = `${id}${path42}`;
297998
- const filename = `intersphinx-${computeHash(hashcontent)}.inv`;
298286
+ const ext2 = refKind === "intersphinx" ? "inv" : "json";
298287
+ const filename = `${refKind}-${computeHash(hashcontent)}.${ext2}`;
297999
298288
  const cacheFolder = (0, import_node_path30.join)(session.buildPath(), "cache");
298000
298289
  if (!import_node_fs23.default.existsSync(cacheFolder))
298001
298290
  import_node_fs23.default.mkdirSync(cacheFolder, { recursive: true });
298002
298291
  return (0, import_node_path30.join)(cacheFolder, filename);
298003
298292
  }
298004
- async function loadIntersphinx(session, opts) {
298005
- const state = session.store.getState();
298006
- const projectConfig = selectors_exports.selectLocalProjectConfig(state, opts.projectPath);
298007
- const configFile = selectors_exports.selectLocalConfigFile(state, opts.projectPath);
298008
- if (!(projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.references) || !configFile)
298009
- return [];
298010
- const vfile2 = new VFile();
298011
- vfile2.path = configFile;
298012
- const cache = castSession(session);
298013
- const references = await Promise.all(Object.entries(projectConfig.references).filter(([key2, object]) => {
298014
- if (isUrl(object.url))
298015
- return true;
298016
- fileError(vfile2, `${key2} references is not a valid url: "${object.url}"`, {
298017
- ruleId: RuleId.intersphinxReferencesResolve
298018
- });
298019
- return false;
298020
- }).map(async ([key2, object]) => {
298021
- if (!cache.$externalReferences[key2] || opts.force) {
298022
- const inventory = new Inventory({ id: key2, path: object.url });
298023
- const cachePath = inventoryCacheFile(session, key2, inventory.path);
298024
- if (import_node_fs23.default.existsSync(cachePath) && !opts.force) {
298025
- const localInventory = new Inventory({ id: key2, path: cachePath });
298026
- session.log.debug(`Loading cached inventory file for ${inventory.path}: ${cachePath}`);
298027
- const toc = tic();
298028
- await localInventory.load();
298029
- inventory.project = localInventory.project;
298030
- inventory.version = localInventory.version;
298031
- inventory.data = localInventory.data;
298032
- inventory._loaded = true;
298033
- session.log.info(toc(`\u{1F3EB} Read ${inventory.numEntries} references links for "${inventory.id}" in %s.`));
298034
- }
298035
- cache.$externalReferences[key2] = inventory;
298036
- }
298037
- return cache.$externalReferences[key2];
298038
- }).filter((exists2) => !!exists2));
298039
- await Promise.all(references.map(async (loader2) => {
298040
- if (loader2._loaded)
298293
+ async function preloadReference(session, key2, reference) {
298294
+ const ref = {
298295
+ key: key2,
298296
+ url: reference.url,
298297
+ kind: reference.kind
298298
+ };
298299
+ const mystCachePath = inventoryCacheFile(session, "myst", key2, reference.url);
298300
+ const intersphinxCachePath = inventoryCacheFile(session, "intersphinx", key2, reference.url);
298301
+ if ((!ref.kind || ref.kind === "myst") && import_node_fs23.default.existsSync(mystCachePath)) {
298302
+ const toc = tic();
298303
+ const xrefs = JSON.parse(import_node_fs23.default.readFileSync(mystCachePath).toString());
298304
+ session.log.debug(`Loading cached inventory file for ${reference.url}: ${mystCachePath}`);
298305
+ session.log.info(toc(`\u{1F3EB} Read ${xrefs.references.length} references links for "${key2}" in %s.`));
298306
+ ref.kind = "myst";
298307
+ ref.value = xrefs;
298308
+ } else if ((!ref.kind || ref.kind === "intersphinx") && import_node_fs23.default.existsSync(intersphinxCachePath)) {
298309
+ const inventory = new Inventory({ id: key2, path: reference.url });
298310
+ const localInventory = new Inventory({ id: key2, path: intersphinxCachePath });
298311
+ session.log.debug(`Loading cached inventory file for ${reference.url}: ${intersphinxCachePath}`);
298312
+ const toc = tic();
298313
+ await localInventory.load();
298314
+ inventory.project = localInventory.project;
298315
+ inventory.version = localInventory.version;
298316
+ inventory.data = localInventory.data;
298317
+ inventory._loaded = true;
298318
+ session.log.info(toc(`\u{1F3EB} Read ${inventory.numEntries} references links for "${key2}" in %s.`));
298319
+ ref.kind = "intersphinx";
298320
+ ref.value = inventory;
298321
+ }
298322
+ return ref;
298323
+ }
298324
+ async function loadReference(session, vfile2, reference) {
298325
+ var _a6;
298326
+ if (reference.kind === "myst" && reference.value) {
298327
+ return reference;
298328
+ }
298329
+ if (reference.kind === "intersphinx" && ((_a6 = reference.value) === null || _a6 === void 0 ? void 0 : _a6._loaded)) {
298330
+ return reference;
298331
+ }
298332
+ if (!reference.kind || reference.kind === "myst") {
298333
+ const mystXRefsUrl = `${reference.url}/myst.xref.json`;
298334
+ session.log.debug(`Attempting to load MyST xref file: ${mystXRefsUrl}`);
298335
+ const toc = tic();
298336
+ const mystXRefsResp = await fetch2(mystXRefsUrl);
298337
+ if (mystXRefsResp.status === 200) {
298338
+ reference.kind = "myst";
298339
+ const mystXRefs = await mystXRefsResp.json();
298340
+ reference.value = mystXRefs;
298341
+ const cachePath = inventoryCacheFile(session, "myst", reference.key, reference.url);
298342
+ session.log.debug(`Saving remote myst xref file to cache ${reference.url}: ${cachePath}`);
298343
+ writeFileToFolder(cachePath, JSON.stringify(mystXRefs));
298344
+ session.log.info(toc(`\u{1F3EB} Read ${mystXRefs.references.length} references for "${reference.key}" in %s.`));
298345
+ return reference;
298346
+ } else if (reference.kind === "myst") {
298347
+ fileError(vfile2, `Problem fetching references entry: ${reference.key} (${mystXRefsUrl})`, {
298348
+ ruleId: RuleId.intersphinxReferencesResolve
298349
+ });
298041
298350
  return;
298351
+ } else {
298352
+ session.log.debug(`Unable to load reference "${reference.key}" as MyST cross-references`);
298353
+ }
298354
+ }
298355
+ if (!reference.kind || reference.kind === "intersphinx") {
298356
+ const inventory = new Inventory({ id: reference.key, path: reference.url });
298042
298357
  const toc = tic();
298043
298358
  try {
298044
- session.log.debug(`Loading inventory file ${loader2.path}`);
298045
- await loader2.load();
298359
+ session.log.debug(`Attempting to load inventory file ${inventory.path}/objects.inv`);
298360
+ await inventory.load();
298046
298361
  } catch (error) {
298047
- session.log.debug(`
298362
+ if (reference.kind === "intersphinx") {
298363
+ session.log.debug(`
298048
298364
 
298049
298365
  ${error === null || error === void 0 ? void 0 : error.stack}
298050
298366
 
298051
298367
  `);
298052
- fileError(vfile2, `Problem fetching references entry: ${loader2.id} (${loader2.path})`, {
298053
- ruleId: RuleId.intersphinxReferencesResolve
298054
- });
298368
+ fileError(vfile2, `Problem fetching references entry: ${inventory.id} (${inventory.path})`, {
298369
+ ruleId: RuleId.intersphinxReferencesResolve
298370
+ });
298371
+ } else {
298372
+ session.log.debug(`Unable to load reference "${reference.key}" as intersphinx`);
298373
+ }
298055
298374
  return null;
298056
298375
  }
298057
- const cachePath = inventoryCacheFile(session, loader2.id, loader2.path);
298058
- if (!import_node_fs23.default.existsSync(cachePath) && isUrl(loader2.path)) {
298059
- session.log.debug(`Saving remote inventory file to cache ${loader2.path}: ${cachePath}`);
298060
- loader2.write(cachePath);
298376
+ const cachePath = inventoryCacheFile(session, "intersphinx", inventory.id, inventory.path);
298377
+ if (!import_node_fs23.default.existsSync(cachePath) && isUrl(inventory.path)) {
298378
+ session.log.debug(`Saving remote inventory file to cache ${inventory.path}: ${cachePath}`);
298379
+ inventory.write(cachePath);
298380
+ }
298381
+ session.log.info(toc(`\u{1F3EB} Read ${inventory.numEntries} references for "${inventory.id}" in %s.`));
298382
+ }
298383
+ }
298384
+ async function loadReferences(session, opts) {
298385
+ const state = session.store.getState();
298386
+ const projectConfig = selectors_exports.selectLocalProjectConfig(state, opts.projectPath);
298387
+ const configFile = selectors_exports.selectLocalConfigFile(state, opts.projectPath);
298388
+ if (!(projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.references) || !configFile)
298389
+ return [];
298390
+ const vfile2 = new VFile();
298391
+ vfile2.path = configFile;
298392
+ const cache = castSession(session);
298393
+ const references = await Promise.all(Object.entries(projectConfig.references).map(async ([key2, val]) => {
298394
+ if (!cache.$externalReferences[key2]) {
298395
+ cache.$externalReferences[key2] = await preloadReference(session, key2, val);
298061
298396
  }
298062
- session.log.info(toc(`\u{1F3EB} Read ${loader2.numEntries} references links for "${loader2.id}" in %s.`));
298397
+ return cache.$externalReferences[key2];
298398
+ }).filter((exists2) => !!exists2));
298399
+ return Promise.all(references.map(async (ref) => {
298400
+ await loadReference(session, vfile2, ref);
298063
298401
  }));
298064
- logMessagesFromVFile(session, vfile2);
298065
- return references;
298066
298402
  }
298067
298403
 
298068
298404
  // ../myst-cli/dist/process/mdast.js
@@ -298320,6 +298656,59 @@ function transformLiftCodeBlocksInJupytext(mdast2) {
298320
298656
  mdast2.children = flattened;
298321
298657
  }
298322
298658
 
298659
+ // ../myst-cli/dist/transforms/crossReferences.js
298660
+ async function transformMystXRefs(session, vfile2, mdast2, frontmatter) {
298661
+ const toc = tic();
298662
+ const nodes = selectAll("link,crossReference", mdast2).filter((node3) => {
298663
+ return node3.protocol === "xref:myst" && node3.dataUrl;
298664
+ }).filter((node3) => {
298665
+ var _a6;
298666
+ if (!((_a6 = node3.children) === null || _a6 === void 0 ? void 0 : _a6.length))
298667
+ return true;
298668
+ return !!node3.identifier;
298669
+ });
298670
+ if (nodes.length === 0)
298671
+ return;
298672
+ session.log.debug(`Updating link text for ${plural("%s external MyST reference(s)", nodes)}`);
298673
+ let number2 = 0;
298674
+ let data;
298675
+ await Promise.all([
298676
+ ...nodes.map(async (node3) => {
298677
+ var _a6, _b, _c;
298678
+ try {
298679
+ const resp = await fetch(node3.dataUrl);
298680
+ if (resp.ok) {
298681
+ data = await resp.json();
298682
+ }
298683
+ } catch {
298684
+ }
298685
+ if (!data) {
298686
+ fileWarn(vfile2, `Unable to resolve link text from external MyST reference: ${node3.urlSource}`, { ruleId: RuleId.mystLinkValid, note: "Could not load data from external project" });
298687
+ return;
298688
+ }
298689
+ if (!node3.identifier) {
298690
+ node3.children = [{ type: "text", value: (_c = (_b = (_a6 = data.frontmatter) === null || _a6 === void 0 ? void 0 : _a6.title) !== null && _b !== void 0 ? _b : data.slug) !== null && _c !== void 0 ? _c : "" }];
298691
+ } else {
298692
+ const targets = selectAll(`[identifier=${node3.identifier}]`, data.mdast);
298693
+ const target = targets.find((t2) => {
298694
+ return !["crossReference", "cite", "footnoteDefinition", "footnoteReference"].includes(t2.type);
298695
+ });
298696
+ if (!target) {
298697
+ fileWarn(vfile2, `Unable to resolve link text from external MyST reference: ${node3.urlSource}`, {
298698
+ ruleId: RuleId.mystLinkValid,
298699
+ note: `Could not locate identifier ${node3.identifier} in page content`
298700
+ });
298701
+ return;
298702
+ }
298703
+ addChildrenFromTargetNode(node3, target, frontmatter.numbering, vfile2);
298704
+ }
298705
+ number2 += 1;
298706
+ })
298707
+ ]);
298708
+ const denominator = number2 === nodes.length ? "" : `/${nodes.length}`;
298709
+ session.log.info(toc(`\u{1FA84} Updated link text for ${plural(`%s${denominator} external MyST reference(s)`, number2)} in %s seconds`));
298710
+ }
298711
+
298323
298712
  // ../myst-cli/dist/transforms/dois.js
298324
298713
  var import_node_fs24 = __toESM(require("fs"), 1);
298325
298714
  var import_node_path31 = require("path");
@@ -298701,26 +299090,25 @@ var makeFileLoader = (session, baseFile) => (fullFile) => {
298701
299090
  }));
298702
299091
  return import_node_fs25.default.readFileSync(fullFile).toString();
298703
299092
  };
298704
- var makeContentParser = (session) => async (filename, content3, vfile2) => {
298705
- var _a6;
299093
+ var makeContentParser = (session, file) => async (filename, content3) => {
298706
299094
  if (filename.toLowerCase().endsWith(".html")) {
298707
- return [{ type: "html", value: content3 }];
299095
+ const mdast2 = { type: "root", children: [{ type: "html", value: content3 }] };
299096
+ return { mdast: mdast2, kind: SourceFileKind.Article };
298708
299097
  }
299098
+ const opts = { keepTitleNode: true };
298709
299099
  if (filename.toLowerCase().endsWith(".tex")) {
298710
- const subTex = new TexParser(content3, vfile2);
298711
- return (_a6 = subTex.ast.children) !== null && _a6 !== void 0 ? _a6 : [];
299100
+ return loadTexFile(session, content3, file, opts);
298712
299101
  }
298713
299102
  if (filename.toLowerCase().endsWith(".ipynb")) {
298714
- const mdast2 = await processNotebook(session, filename, content3);
298715
- return mdast2.children;
299103
+ return loadNotebookFile(session, content3, file, opts);
298716
299104
  }
298717
- return parseMyst(session, content3, filename).children;
299105
+ return loadMdFile(session, content3, file, opts);
298718
299106
  };
298719
- async function includeFilesTransform(session, baseFile, tree, vfile2) {
298720
- const parseContent = makeContentParser(session);
299107
+ async function includeFilesTransform(session, baseFile, tree, frontmatter, vfile2) {
299108
+ const parseContent = makeContentParser(session, baseFile);
298721
299109
  const loadFile2 = makeFileLoader(session, baseFile);
298722
299110
  const resolveFile = makeFileResolver(baseFile);
298723
- await includeDirectiveTransform(tree, vfile2, {
299111
+ await includeDirectiveTransform(tree, frontmatter, vfile2, {
298724
299112
  resolveFile,
298725
299113
  loadFile: loadFile2,
298726
299114
  parseContent,
@@ -300017,7 +300405,7 @@ async function transformMdast(session, opts) {
300017
300405
  cache.$internalReferences[file] = state;
300018
300406
  frontmatterPartsTransform(session, file, mdast2, frontmatter);
300019
300407
  importMdastFromJson(session, file, mdast2);
300020
- await includeFilesTransform(session, file, mdast2, vfile2);
300408
+ await includeFilesTransform(session, file, mdast2, frontmatter, vfile2);
300021
300409
  rawDirectiveTransform(mdast2, vfile2);
300022
300410
  liftCodeMetadataToBlock(session, vfile2, mdast2);
300023
300411
  const pipe = unified().use(reconstructHtmlPlugin).use(htmlPlugin, { htmlHandlers }).use(basicTransformationsPlugin, {
@@ -300031,15 +300419,17 @@ async function transformMdast(session, opts) {
300031
300419
  });
300032
300420
  await pipe.run(mdast2, vfile2);
300033
300421
  propagateBlockDataToCode(session, vfile2, mdast2);
300034
- const intersphinx = projectPath ? await loadIntersphinx(session, { projectPath }) : [];
300035
300422
  const transformers = [
300036
300423
  new WikiTransformer(),
300037
300424
  new GithubTransformer(),
300038
300425
  new RRIDTransformer(),
300039
300426
  new DOITransformer(),
300040
- new MystTransformer(intersphinx)
300427
+ // This also is picked up in the next transform
300428
+ new MystTransformer(Object.values(cache.$externalReferences)),
300429
+ new SphinxTransformer(Object.values(cache.$externalReferences))
300041
300430
  ];
300042
300431
  linksTransform(mdast2, vfile2, { transformers, selector: LINKS_SELECTOR });
300432
+ await transformMystXRefs(session, vfile2, mdast2, frontmatter);
300043
300433
  cache.$citationRenderers[file] = await transformLinkedDOIs(session, vfile2, mdast2, cache.$doiRenderers, file);
300044
300434
  const rendererFiles = [file];
300045
300435
  if (projectPath) {
@@ -300131,11 +300521,12 @@ async function postProcessMdast(session, { file, checkLinks, pageReferenceStates
300131
300521
  });
300132
300522
  await pipe.run(mdast2, vfile2);
300133
300523
  keysTransform(mdast2);
300524
+ checkLinkTextTransform(mdast2, vfile2);
300134
300525
  logMessagesFromVFile(session, fileState.vfile);
300135
300526
  logMessagesFromVFile(session, vfile2);
300136
300527
  log.debug(toc(`Transformed mdast cross references and links for "${file}" in %s`));
300137
300528
  if (checkLinks)
300138
- await checkLinksTransform(session, file, mdastPost.mdast);
300529
+ await checkLinksTransform(session, file, mdast2);
300139
300530
  }
300140
300531
  async function finalizeMdast(session, mdast2, frontmatter, file, { imageWriteFolder, useExistingImages, imageAltOutputFolder, imageExtensions, optimizeWebp, simplifyFigures, processThumbnail, maxSizeWebp }) {
300141
300532
  var _a6;
@@ -300220,10 +300611,45 @@ function getReferenceTitleAsText(targetNode) {
300220
300611
  if (caption3)
300221
300612
  return toText(caption3);
300222
300613
  }
300223
- async function addProjectReferencesToObjectsInv(session, inv, opts) {
300224
- const { pages } = await loadProject(session, opts.projectPath);
300225
- const pageReferenceStates = selectPageReferenceStates(session, pages);
300226
- pageReferenceStates.forEach((state) => {
300614
+ async function writeMystXRefJson(session, states) {
300615
+ const mystXRefs = {
300616
+ version: "1",
300617
+ myst: version_default2,
300618
+ references: states.filter((state) => {
300619
+ return !!state.url && !!state.dataUrl;
300620
+ }).map((state) => {
300621
+ const { url, dataUrl } = state;
300622
+ const data = `/content${dataUrl}`;
300623
+ const pageRef = { kind: "page", data, url };
300624
+ const pageIdRefs = state.identifiers.map((identifier) => {
300625
+ return { identifier, kind: "page", data, url };
300626
+ });
300627
+ const targetRefs = Object.values(state.targets).map((target) => {
300628
+ var _a6;
300629
+ const { identifier, html_id } = (_a6 = target.node) !== null && _a6 !== void 0 ? _a6 : {};
300630
+ return {
300631
+ identifier,
300632
+ html_id: html_id !== identifier ? html_id : void 0,
300633
+ kind: target.kind,
300634
+ data,
300635
+ url,
300636
+ implicit: target.node.implicit
300637
+ };
300638
+ });
300639
+ return [pageRef, ...pageIdRefs, ...targetRefs];
300640
+ }).flat()
300641
+ };
300642
+ const filename = (0, import_node_path39.join)(session.sitePath(), "myst.xref.json");
300643
+ session.log.debug(`Writing myst.xref.json file: ${filename}`);
300644
+ writeFileToFolder(filename, JSON.stringify(mystXRefs));
300645
+ }
300646
+ async function writeObjectsInv(session, states, siteConfig) {
300647
+ const inv = new Inventory({
300648
+ project: siteConfig === null || siteConfig === void 0 ? void 0 : siteConfig.title,
300649
+ // TODO: allow a version on the project?!
300650
+ version: String(siteConfig === null || siteConfig === void 0 ? void 0 : siteConfig.version)
300651
+ });
300652
+ states.forEach((state) => {
300227
300653
  var _a6;
300228
300654
  inv.setEntry({
300229
300655
  type: Domains.stdDoc,
@@ -300244,7 +300670,9 @@ async function addProjectReferencesToObjectsInv(session, inv, opts) {
300244
300670
  });
300245
300671
  });
300246
300672
  });
300247
- return inv;
300673
+ const filename = (0, import_node_path39.join)(session.sitePath(), "objects.inv");
300674
+ session.log.debug(`Writing objects.inv file: ${filename}`);
300675
+ inv.write(filename);
300248
300676
  }
300249
300677
  async function loadProject(session, projectPath, opts) {
300250
300678
  const project = await loadProjectFromDisk(session, projectPath, {
@@ -300254,7 +300682,28 @@ async function loadProject(session, projectPath, opts) {
300254
300682
  const pages = filterPages(project);
300255
300683
  return { project, pages };
300256
300684
  }
300257
- function selectPageReferenceStates(session, pages) {
300685
+ function warnOnDuplicateIdentifiers(session, states) {
300686
+ const collisions = {};
300687
+ states.forEach((state) => {
300688
+ state.getIdentifiers().forEach((identifier) => {
300689
+ var _a6, _b;
300690
+ const target = state.getTarget(identifier);
300691
+ if ((_a6 = target === null || target === void 0 ? void 0 : target.node) === null || _a6 === void 0 ? void 0 : _a6.implicit)
300692
+ return;
300693
+ (_b = collisions[identifier]) !== null && _b !== void 0 ? _b : collisions[identifier] = [];
300694
+ collisions[identifier].push(state.filePath);
300695
+ });
300696
+ });
300697
+ Object.entries(collisions).forEach(([identifier, files]) => {
300698
+ if (files.length <= 1)
300699
+ return;
300700
+ addWarningForFile(session, files[0], `Duplicate identifier in project "${identifier}"`, "warn", {
300701
+ note: `In files: ${files.join(", ")}`,
300702
+ ruleId: RuleId.identifierIsUnique
300703
+ });
300704
+ });
300705
+ }
300706
+ function selectPageReferenceStates(session, pages, opts) {
300258
300707
  const cache = castSession(session);
300259
300708
  const pageReferenceStates = pages.map((page) => {
300260
300709
  const state = cache.$internalReferences[page.file];
@@ -300270,6 +300719,8 @@ function selectPageReferenceStates(session, pages) {
300270
300719
  }
300271
300720
  return void 0;
300272
300721
  }).filter((state) => !!state);
300722
+ if (!(opts === null || opts === void 0 ? void 0 : opts.suppressWarnings))
300723
+ warnOnDuplicateIdentifiers(session, pageReferenceStates);
300273
300724
  return pageReferenceStates;
300274
300725
  }
300275
300726
  async function resolvePageSource(session, file) {
@@ -300349,7 +300800,7 @@ async function processProject(session, siteProject, opts) {
300349
300800
  var _a6;
300350
300801
  const toc = tic();
300351
300802
  const { log } = session;
300352
- const { imageWriteFolder, imageAltOutputFolder, imageExtensions, extraLinkTransformers, extraTransforms, watchMode, writeToc, writeFiles = true, reloadProject, execute, maxSizeWebp, checkLinks, strict } = opts || {};
300803
+ const { imageWriteFolder, imageAltOutputFolder, imageExtensions, extraLinkTransformers, extraTransforms, watchMode, writeTOC, writeFiles = true, reloadProject, execute, maxSizeWebp, checkLinks, strict } = opts || {};
300353
300804
  if (!siteProject.path) {
300354
300805
  const slugSuffix = siteProject.slug ? `: ${siteProject.slug}` : "";
300355
300806
  log.error(`No local path for site project${slugSuffix}`);
@@ -300358,7 +300809,7 @@ async function processProject(session, siteProject, opts) {
300358
300809
  throw Error("Unable to process project");
300359
300810
  }
300360
300811
  const { project, pages } = await loadProject(session, siteProject.path, {
300361
- writeToc: writeFiles && writeToc,
300812
+ writeTOC: writeFiles && writeTOC,
300362
300813
  reloadProject
300363
300814
  });
300364
300815
  if (!watchMode) {
@@ -300368,7 +300819,7 @@ async function processProject(session, siteProject, opts) {
300368
300819
  // Load all content (.md and .ipynb)
300369
300820
  ...pages.map((page) => loadFile(session, page.file, siteProject.path, void 0)),
300370
300821
  // Load up all the intersphinx references
300371
- loadIntersphinx(session, { projectPath: siteProject.path })
300822
+ loadReferences(session, { projectPath: siteProject.path })
300372
300823
  ]);
300373
300824
  }
300374
300825
  combineProjectCitationRenderers(session, siteProject.path);
@@ -300417,7 +300868,7 @@ async function processProject(session, siteProject, opts) {
300417
300868
  return project;
300418
300869
  }
300419
300870
  async function processSite(session, opts) {
300420
- var _a6, _b, _c;
300871
+ var _a6, _b;
300421
300872
  try {
300422
300873
  reloadAllConfigsForCurrentSite(session);
300423
300874
  } catch (error) {
@@ -300470,20 +300921,17 @@ ${page.file}
300470
300921
  }
300471
300922
  if ((_b = opts === null || opts === void 0 ? void 0 : opts.writeFiles) !== null && _b !== void 0 ? _b : true) {
300472
300923
  await writeSiteManifest(session, opts);
300473
- const inv = new Inventory({
300474
- project: siteConfig === null || siteConfig === void 0 ? void 0 : siteConfig.title,
300475
- // TODO: allow a version on the project?!
300476
- version: String((_c = siteConfig === null || siteConfig === void 0 ? void 0 : siteConfig.version) !== null && _c !== void 0 ? _c : "1")
300477
- });
300924
+ const states = [];
300478
300925
  await Promise.all(siteConfig.projects.map(async (project) => {
300479
300926
  if (!project.path)
300480
300927
  return;
300481
- await addProjectReferencesToObjectsInv(session, inv, {
300482
- projectPath: project.path
300483
- });
300928
+ const { pages } = await loadProject(session, project.path);
300929
+ states.push(...selectPageReferenceStates(session, pages, {
300930
+ suppressWarnings: true
300931
+ }));
300484
300932
  }));
300485
- const filename = (0, import_node_path39.join)(session.sitePath(), "objects.inv");
300486
- inv.write(filename);
300933
+ await writeObjectsInv(session, states, siteConfig);
300934
+ await writeMystXRefJson(session, states);
300487
300935
  }
300488
300936
  return true;
300489
300937
  }
@@ -300649,6 +301097,7 @@ function getDefaultEnv(template) {
300649
301097
  const env7 = import_nunjucks.default.configure(template.templatePath, {
300650
301098
  trimBlocks: true,
300651
301099
  autoescape: false,
301100
+ // Ensures that we are not writing to HTML!
300652
301101
  tags: {
300653
301102
  blockStart: "[#",
300654
301103
  blockEnd: "#]",
@@ -301024,6 +301473,7 @@ var textOnlyReplacements2 = {
301024
301473
  "\u201C": "``",
301025
301474
  // guillemots
301026
301475
  "\xBB": ">>",
301476
+ // These could be improved
301027
301477
  "\xAB": "<<",
301028
301478
  "\u2026": "\\dots",
301029
301479
  "\u2013": "--",
@@ -301049,9 +301499,13 @@ var arrows = {
301049
301499
  };
301050
301500
  var symbols2 = {
301051
301501
  "\u2212": "-",
301502
+ // minus
301052
301503
  "-": "-",
301504
+ // hyphen minus
301053
301505
  "\uFE63": "-",
301506
+ // Small hyphen minus
301054
301507
  "\uFF0D": "-",
301508
+ // Full-width Hyphen-minus
301055
301509
  "\uFF0B": "+"
301056
301510
  // Full-width Plus
301057
301511
  };
@@ -301776,6 +302230,12 @@ var handlers3 = {
301776
302230
  mystDirective(node3, state) {
301777
302231
  state.renderChildren(node3, false);
301778
302232
  },
302233
+ div(node3, state) {
302234
+ state.renderChildren(node3, false);
302235
+ },
302236
+ span(node3, state) {
302237
+ state.renderChildren(node3, true);
302238
+ },
301779
302239
  comment(node3, state) {
301780
302240
  var _a6, _b;
301781
302241
  state.ensureNewLine();
@@ -302086,7 +302546,7 @@ async function getFileContent(session, files, { projectPath, imageExtensions, ex
302086
302546
  });
302087
302547
  }),
302088
302548
  // Load up all the intersphinx references
302089
- loadIntersphinx(session, { projectPath })
302549
+ loadReferences(session, { projectPath })
302090
302550
  ]);
302091
302551
  combineProjectCitationRenderers(session, projectPath);
302092
302552
  await Promise.all(allFiles.map(async (file, ind) => {
@@ -302586,9 +303046,13 @@ var arrows2 = {
302586
303046
  };
302587
303047
  var symbols3 = {
302588
303048
  "\u2212": "-",
303049
+ // minus
302589
303050
  "-": "-",
303051
+ // hyphen minus
302590
303052
  "\uFE63": "-",
303053
+ // Small hyphen minus
302591
303054
  "\uFF0D": "-",
303055
+ // Full-width Hyphen-minus
302592
303056
  "\uFF0B": "+"
302593
303057
  // Full-width Plus
302594
303058
  };
@@ -303468,7 +303932,7 @@ ${node3.value}
303468
303932
  state.write(next ? `#[@${id}]` : `@${id}`);
303469
303933
  },
303470
303934
  citeGroup(node3, state) {
303471
- state.renderChildren(node3, 0, " ");
303935
+ state.renderChildren(node3, 0, { delim: " " });
303472
303936
  },
303473
303937
  cite(node3, state) {
303474
303938
  const needsLabel = !/^[a-zA-Z0-9_\-:.]+$/.test(node3.label);
@@ -303502,7 +303966,7 @@ ${node3.value}
303502
303966
  state.write("]");
303503
303967
  },
303504
303968
  footnoteDefinition() {
303505
- }
303969
+ },
303506
303970
  // si(node, state) {
303507
303971
  // // state.useMacro('siunitx');
303508
303972
  // if (node.number == null) {
@@ -303513,6 +303977,12 @@ ${node3.value}
303513
303977
  // );
303514
303978
  // }
303515
303979
  // },
303980
+ div(node3, state) {
303981
+ state.renderChildren(node3, 1);
303982
+ },
303983
+ span(node3, state) {
303984
+ state.renderChildren(node3, 0, { trimEnd: false });
303985
+ }
303516
303986
  };
303517
303987
  var TypstSerializer = class {
303518
303988
  constructor(file, tree, opts) {
@@ -303554,7 +304024,7 @@ var TypstSerializer = class {
303554
304024
  return;
303555
304025
  this.addNewLine();
303556
304026
  }
303557
- renderChildren(node3, trailingNewLines = 0, delim = "") {
304027
+ renderChildren(node3, trailingNewLines = 0, { delim = "", trimEnd: trimEnd2 = true } = {}) {
303558
304028
  var _a6, _b, _c;
303559
304029
  const numChildren = (_b = (_a6 = node3.children) === null || _a6 === void 0 ? void 0 : _a6.length) !== null && _b !== void 0 ? _b : 0;
303560
304030
  (_c = node3.children) === null || _c === void 0 ? void 0 : _c.forEach((child, index4) => {
@@ -303572,7 +304042,8 @@ var TypstSerializer = class {
303572
304042
  if (delim && index4 + 1 < numChildren)
303573
304043
  this.write(delim);
303574
304044
  });
303575
- this.trimEnd();
304045
+ if (trimEnd2)
304046
+ this.trimEnd();
303576
304047
  for (let i2 = trailingNewLines; i2--; )
303577
304048
  this.addNewLine();
303578
304049
  }
@@ -307014,6 +307485,7 @@ var JatsDocument = class {
307014
307485
  "xmlns:xlink": "http://www.w3.org/1999/xlink",
307015
307486
  "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
307016
307487
  "xmlns:ali": "http://www.niso.org/schemas/ali/1.0/",
307488
+ // Used for the licensing
307017
307489
  "dtd-version": "1.3",
307018
307490
  "xml:lang": "en"
307019
307491
  };
@@ -307693,7 +308165,7 @@ To resolve this, run: myst build --all`, {
307693
308165
  if (import_node_fs38.default.existsSync(import_node_path51.default.join(projectPath, "_toc.yml"))) {
307694
308166
  copyFileToFolder(session, import_node_path51.default.join(projectPath, "_toc.yml"), bundle, fileCopyErrorLogFn);
307695
308167
  } else {
307696
- writeTocFromProject(project, bundle);
308168
+ writeTOCFromProject(project, bundle);
307697
308169
  }
307698
308170
  addManifestItem(manifestItems, "article-source", mecaFolder, import_node_path51.default.join(bundle, "_toc.yml"));
307699
308171
  const projectPages = [
@@ -312573,6 +313045,7 @@ async function startContentServer(session, opts) {
312573
313045
  app.use("/content", import_express.default.static(session.contentPath()));
312574
313046
  app.use("/config.json", import_express.default.static((0, import_node_path55.join)(session.sitePath(), "config.json")));
312575
313047
  app.use("/objects.inv", import_express.default.static((0, import_node_path55.join)(session.sitePath(), "objects.inv")));
313048
+ app.use("/myst.xref.json", import_express.default.static((0, import_node_path55.join)(session.sitePath(), "myst.xref.json")));
312576
313049
  const server = app.listen(port, () => {
312577
313050
  session.log.debug(`Content server listening on port ${port}`);
312578
313051
  });
@@ -312685,9 +313158,10 @@ async function currentSiteRoutes(session, host, baseurl, opts) {
312685
313158
  var _a7, _b2;
312686
313159
  const projSlug = proj.slug ? `/${proj.slug}` : "";
312687
313160
  const siteIndex = baseurl ? `/${proj.index}` : "";
313161
+ const pages = proj.pages.filter((page) => !!page.slug);
312688
313162
  return [
312689
313163
  { url: `${host}${projSlug}${siteIndex}`, path: import_node_path56.default.join((_a7 = proj.slug) !== null && _a7 !== void 0 ? _a7 : "", "index.html") },
312690
- ...proj.pages.map((page) => {
313164
+ ...pages.map((page) => {
312691
313165
  var _a8;
312692
313166
  return {
312693
313167
  url: `${host}${projSlug}/${page.slug}`,
@@ -312699,7 +313173,7 @@ async function currentSiteRoutes(session, host, baseurl, opts) {
312699
313173
  url: `${host}${projSlug}/${proj.index}.json`,
312700
313174
  path: import_node_path56.default.join((_b2 = proj.slug) !== null && _b2 !== void 0 ? _b2 : "", `${proj.index}.json`)
312701
313175
  },
312702
- ...proj.pages.map((page) => {
313176
+ ...pages.map((page) => {
312703
313177
  var _a8;
312704
313178
  return {
312705
313179
  url: `${host}${projSlug}/${page.slug}.json`,
@@ -312707,7 +313181,7 @@ async function currentSiteRoutes(session, host, baseurl, opts) {
312707
313181
  };
312708
313182
  }),
312709
313183
  // Download other assets
312710
- ...["favicon.ico", "robots.txt"].map((asset) => ({
313184
+ ...["favicon.ico", "robots.txt", "myst-theme.css"].map((asset) => ({
312711
313185
  url: `${host}/${asset}`,
312712
313186
  path: asset
312713
313187
  }))
@@ -312761,6 +313235,10 @@ async function buildHtml(session, opts) {
312761
313235
  const routes = await currentSiteRoutes(session, host, baseurl, opts);
312762
313236
  await Promise.all(routes.map(async (page) => {
312763
313237
  const resp = await session.fetch(page.url);
313238
+ if (!resp.ok) {
313239
+ session.log.error(`Error fetching ${page.url}`);
313240
+ return;
313241
+ }
312764
313242
  const content3 = await resp.text();
312765
313243
  writeFileToFolder(import_node_path56.default.join(htmlDir, page.path), content3);
312766
313244
  }));
@@ -312768,8 +313246,9 @@ async function buildHtml(session, opts) {
312768
313246
  const templateBuildDir = import_node_path56.default.join(template.templatePath, "public");
312769
313247
  import_fs_extra.default.copySync(templateBuildDir, htmlDir);
312770
313248
  import_fs_extra.default.copySync(session.publicPath(), import_node_path56.default.join(htmlDir, "build"));
312771
- import_fs_extra.default.copySync(import_node_path56.default.join(session.sitePath(), "objects.inv"), import_node_path56.default.join(htmlDir, "objects.inv"));
312772
313249
  import_fs_extra.default.copySync(import_node_path56.default.join(session.sitePath(), "config.json"), import_node_path56.default.join(htmlDir, "config.json"));
313250
+ import_fs_extra.default.copySync(import_node_path56.default.join(session.sitePath(), "objects.inv"), import_node_path56.default.join(htmlDir, "objects.inv"));
313251
+ import_fs_extra.default.copySync(import_node_path56.default.join(session.sitePath(), "myst.xref.json"), import_node_path56.default.join(htmlDir, "myst.xref.json"));
312773
313252
  rewriteAssetsFolder(htmlDir, baseurl);
312774
313253
  process.exit(0);
312775
313254
  }
@@ -315740,12 +316219,12 @@ Learn more about this CLI and MyST Markdown at: ${source_default.bold("https://m
315740
316219
 
315741
316220
  `;
315742
316221
  async function init2(session, opts) {
315743
- const { project, site, writeToc, ghPages, ghCurvenote } = opts;
316222
+ const { project, site, writeTOC, ghPages, ghCurvenote } = opts;
315744
316223
  if (ghPages)
315745
316224
  return githubPagesAction(session);
315746
316225
  if (ghCurvenote)
315747
316226
  return githubCurvenoteAction(session);
315748
- if (!project && !site && !writeToc) {
316227
+ if (!project && !site && !writeTOC) {
315749
316228
  session.log.info(WELCOME());
315750
316229
  }
315751
316230
  loadConfig(session, ".");
@@ -315793,11 +316272,11 @@ async function init2(session, opts) {
315793
316272
  session.log.info(`\u{1F4BE} Writing new ${configDoc} config file: ${source_default.blue(import_node_path60.default.resolve(configFile))}`);
315794
316273
  import_node_fs41.default.writeFileSync(configFile, configData2);
315795
316274
  }
315796
- if (writeToc) {
316275
+ if (writeTOC) {
315797
316276
  loadConfig(session, ".");
315798
- await loadProjectFromDisk(session, ".", { writeToc });
316277
+ await loadProjectFromDisk(session, ".", { writeTOC });
315799
316278
  }
315800
- if (writeToc || project || site)
316279
+ if (writeTOC || project || site)
315801
316280
  return;
315802
316281
  session.log.info("");
315803
316282
  const promptStart = await inquirer_default.prompt([
@@ -323281,11 +323760,11 @@ var source_default8 = chalk6;
323281
323760
  function makeProjectOption(description) {
323282
323761
  return new Option("--project", description).default(false);
323283
323762
  }
323284
- function makeWriteTocOption() {
323763
+ function makeWriteTOCOption() {
323285
323764
  return new Option(
323286
323765
  "--write-toc",
323287
323766
  "Generate editable _toc.yml file for project if it does not exist"
323288
- ).default(false);
323767
+ ).default(false).implies({ writeTOC: true });
323289
323768
  }
323290
323769
  function makeGithubPagesOption() {
323291
323770
  return new Option(
@@ -323302,7 +323781,7 @@ function makeGithubCurvenoteOption() {
323302
323781
 
323303
323782
  // src/init.ts
323304
323783
  function makeInitCLI(program3) {
323305
- const command = new Command("init").description("Initialize a MyST project in the current directory").addOption(makeProjectOption("Initialize config for MyST project content")).addOption(makeSiteOption("Initialize config for MyST site")).addOption(makeWriteTocOption()).addOption(makeGithubPagesOption()).addOption(makeGithubCurvenoteOption()).action(clirun2(Session, init2, program3));
323784
+ const command = new Command("init").description("Initialize a MyST project in the current directory").addOption(makeProjectOption("Initialize config for MyST project content")).addOption(makeSiteOption("Initialize config for MyST site")).addOption(makeWriteTOCOption()).addOption(makeGithubPagesOption()).addOption(makeGithubCurvenoteOption()).action(clirun2(Session, init2, program3));
323306
323785
  return command;
323307
323786
  }
323308
323787
  function addDefaultCommand(program3) {