mystmd 1.1.47__py3-none-any.whl → 1.1.49__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
@@ -129890,7 +129890,7 @@ var require_environment = __commonJS({
129890
129890
  }
129891
129891
  return this.tests[name3];
129892
129892
  };
129893
- _proto.resolveTemplate = function resolveTemplate(loader2, parentName, filename) {
129893
+ _proto.resolveTemplate = function resolveTemplate2(loader2, parentName, filename) {
129894
129894
  var isRelative = loader2.isRelative && parentName ? loader2.isRelative(filename) : false;
129895
129895
  return isRelative && loader2.resolve ? loader2.resolve(parentName, filename) : filename;
129896
129896
  };
@@ -195964,7 +195964,7 @@ var {
195964
195964
  } = import_index.default;
195965
195965
 
195966
195966
  // src/version.ts
195967
- var version = "1.1.47";
195967
+ var version = "1.1.49";
195968
195968
  var version_default = version;
195969
195969
 
195970
195970
  // ../myst-cli/dist/build/build.js
@@ -196746,7 +196746,13 @@ function stashPlaceholder(value) {
196746
196746
  return { id: value, name: value };
196747
196747
  }
196748
196748
  function isStashPlaceholder(object) {
196749
- return Object.keys(object).length === 2 && object.name && object.id && object.name === object.id;
196749
+ var _a6;
196750
+ if (!object.name || !object.id || object.name !== object.id)
196751
+ return false;
196752
+ const nKeys = Object.keys(object).length;
196753
+ if (nKeys === 2)
196754
+ return true;
196755
+ return nKeys === 3 && ((_a6 = object.nameParsed) === null || _a6 === void 0 ? void 0 : _a6.literal) === object.id;
196750
196756
  }
196751
196757
  function validateAndStashObject(input3, stash, kind, validateFn, opts) {
196752
196758
  var _a6, _b, _c;
@@ -196967,12 +196973,17 @@ function validateAffiliation(input3, opts) {
196967
196973
  const value = validateObjectKeys(input3, { optional: AFFILIATION_KEYS, alias: AFFILIATION_ALIASES }, opts);
196968
196974
  if (value === void 0)
196969
196975
  return void 0;
196976
+ if (Object.keys(value).length === 1 && value.id) {
196977
+ value.name = value.id;
196978
+ }
196970
196979
  const output2 = {};
196971
196980
  if (defined(value.id)) {
196972
196981
  output2.id = validateString(value.id, incrementOptions("id", opts));
196973
196982
  }
196974
196983
  if (defined(value.name)) {
196975
196984
  output2.name = validateString(value.name, incrementOptions("name", opts));
196985
+ } else {
196986
+ validationWarning("affiliation should include name/institution", opts);
196976
196987
  }
196977
196988
  if (defined(value.department)) {
196978
196989
  output2.department = validateString(value.department, incrementOptions("department", opts));
@@ -197026,11 +197037,6 @@ function validateAffiliation(input3, opts) {
197026
197037
  if (defined(value.fax)) {
197027
197038
  output2.fax = validateString(value.fax, incrementOptions("fax", opts));
197028
197039
  }
197029
- if (Object.keys(output2).length === 1 && output2.id) {
197030
- return stashPlaceholder(output2.id);
197031
- } else if (!output2.name) {
197032
- validationWarning("affiliation should include name/institution", opts);
197033
- }
197034
197040
  return output2;
197035
197041
  }
197036
197042
 
@@ -197140,6 +197146,33 @@ var credit = {
197140
197146
  buildUrl: buildUrl2
197141
197147
  };
197142
197148
 
197149
+ // ../../node_modules/orcid/dist/index.js
197150
+ var ORCID_URL = "https://orcid.org";
197151
+ var ORCID_REGEX_STRICT = "^([0-9]{4}-){3}[0-9]{3}[0-9X]$";
197152
+ var ORCID_REGEX = "^((http(s)?://)?(www.)?orcid.org/)?([0-9]{4}-){3}[0-9]{3}[0-9X]$";
197153
+ function validate3(value, opts) {
197154
+ const match3 = value === null || value === void 0 ? void 0 : value.match((opts === null || opts === void 0 ? void 0 : opts.strict) ? ORCID_REGEX_STRICT : ORCID_REGEX);
197155
+ if (!match3)
197156
+ return false;
197157
+ return true;
197158
+ }
197159
+ function normalize3(value, opts) {
197160
+ if (!value || !validate3(value, opts))
197161
+ return void 0;
197162
+ return value.replace(/^(https?:\/\/)?(www\.)?orcid\.org\//, "");
197163
+ }
197164
+ function buildUrl3(value, opts) {
197165
+ const orcid2 = normalize3(value, opts);
197166
+ if (!orcid2)
197167
+ return void 0;
197168
+ return `${ORCID_URL}/${orcid2}`;
197169
+ }
197170
+ var orcid = {
197171
+ validate: validate3,
197172
+ normalize: normalize3,
197173
+ buildUrl: buildUrl3
197174
+ };
197175
+
197143
197176
  // ../myst-frontmatter/dist/utils/parseName.js
197144
197177
  function startsWithUpperCase(word) {
197145
197178
  for (const letter of word) {
@@ -197248,35 +197281,8 @@ function formatName(name3, alwaysReversed = false) {
197248
197281
  return output2;
197249
197282
  }
197250
197283
 
197251
- // ../../node_modules/orcid/dist/index.js
197252
- var ORCID_URL = "https://orcid.org";
197253
- var ORCID_REGEX_STRICT = "^([0-9]{4}-){3}[0-9]{3}[0-9X]$";
197254
- var ORCID_REGEX = "^((http(s)?://)?(www.)?orcid.org/)?([0-9]{4}-){3}[0-9]{3}[0-9X]$";
197255
- function validate3(value, opts) {
197256
- const match3 = value === null || value === void 0 ? void 0 : value.match((opts === null || opts === void 0 ? void 0 : opts.strict) ? ORCID_REGEX_STRICT : ORCID_REGEX);
197257
- if (!match3)
197258
- return false;
197259
- return true;
197260
- }
197261
- function normalize3(value, opts) {
197262
- if (!value || !validate3(value, opts))
197263
- return void 0;
197264
- return value.replace(/^(https?:\/\/)?(www\.)?orcid\.org\//, "");
197265
- }
197266
- function buildUrl3(value, opts) {
197267
- const orcid2 = normalize3(value, opts);
197268
- if (!orcid2)
197269
- return void 0;
197270
- return `${ORCID_URL}/${orcid2}`;
197271
- }
197272
- var orcid = {
197273
- validate: validate3,
197274
- normalize: normalize3,
197275
- buildUrl: buildUrl3
197276
- };
197277
-
197278
197284
  // ../myst-frontmatter/dist/contributors/validators.js
197279
- var CONTRIBUTOR_KEYS = [
197285
+ var PERSON_KEYS = [
197280
197286
  "id",
197281
197287
  "userId",
197282
197288
  "name",
@@ -197296,7 +197302,8 @@ var CONTRIBUTOR_KEYS = [
197296
197302
  "phone",
197297
197303
  "fax"
197298
197304
  ];
197299
- var CONTRIBUTOR_ALIASES = {
197305
+ var PERSON_ALIASES = {
197306
+ ref: "id",
197300
197307
  role: "roles",
197301
197308
  "equal-contributor": "equal_contributor",
197302
197309
  affiliation: "affiliations",
@@ -197321,8 +197328,10 @@ var NAME_ALIASES = {
197321
197328
  };
197322
197329
  function validateName(input3, opts) {
197323
197330
  let output2;
197331
+ let raiseCommaWarnings = false;
197324
197332
  if (typeof input3 === "string") {
197325
197333
  output2 = parseName(input3);
197334
+ raiseCommaWarnings = true;
197326
197335
  } else {
197327
197336
  const value = validateObjectKeys(input3, { optional: NAME_KEYS, alias: NAME_ALIASES }, opts);
197328
197337
  if (value === void 0)
@@ -197348,36 +197357,50 @@ function validateName(input3, opts) {
197348
197357
  }
197349
197358
  if (Object.keys(output2).length === 1 && output2.literal) {
197350
197359
  output2 = { ...output2, ...parseName(output2.literal) };
197360
+ raiseCommaWarnings = true;
197351
197361
  } else if (!output2.literal) {
197352
197362
  output2.literal = formatName(output2);
197363
+ if (output2.literal.startsWith(",")) {
197364
+ validationWarning(`unexpected comma at beginning of name: ${output2.literal} - you may need to define 'name.literal' explicitly`, opts);
197365
+ }
197353
197366
  }
197354
197367
  }
197355
- const warnOnComma = (part, o) => {
197356
- if (part && part.includes(",")) {
197357
- validationWarning(`unexpected comma in name part: ${part}`, o);
197358
- }
197359
- };
197360
- warnOnComma(output2.given, incrementOptions("given", opts));
197361
- warnOnComma(output2.family, incrementOptions("family", opts));
197362
- warnOnComma(output2.non_dropping_particle, incrementOptions("non_dropping_particle", opts));
197363
- warnOnComma(output2.dropping_particle, incrementOptions("dropping_particle", opts));
197364
- warnOnComma(output2.suffix, incrementOptions("suffix", opts));
197365
- if (!output2.family) {
197366
- validationWarning(`No family name for name '${output2.literal}'`, opts);
197367
- }
197368
- if (!output2.given) {
197369
- validationWarning(`No given name for name '${output2.literal}'`, opts);
197368
+ if (raiseCommaWarnings) {
197369
+ const warnOnComma = (part, o) => {
197370
+ if (part && part.includes(",")) {
197371
+ validationWarning(`unexpected comma in name part: ${part} - you may need to define 'name' explicitly as an object`, o);
197372
+ }
197373
+ };
197374
+ warnOnComma(output2.given, incrementOptions("given", opts));
197375
+ warnOnComma(output2.family, incrementOptions("family", opts));
197376
+ warnOnComma(output2.non_dropping_particle, incrementOptions("non_dropping_particle", opts));
197377
+ warnOnComma(output2.dropping_particle, incrementOptions("dropping_particle", opts));
197378
+ warnOnComma(output2.suffix, incrementOptions("suffix", opts));
197370
197379
  }
197371
197380
  return output2;
197372
197381
  }
197373
197382
  function validateContributor(input3, stash, opts) {
197374
197383
  var _a6, _b, _c;
197384
+ const inputAff = validateObjectKeys(input3, { optional: AFFILIATION_KEYS, alias: AFFILIATION_ALIASES }, {
197385
+ ...opts,
197386
+ suppressErrors: true,
197387
+ suppressWarnings: true
197388
+ });
197389
+ if ((inputAff === null || inputAff === void 0 ? void 0 : inputAff.collaboration) === true) {
197390
+ return validateAffiliation(input3, opts);
197391
+ }
197375
197392
  if (typeof input3 === "string") {
197376
- input3 = { id: input3, name: input3 };
197393
+ input3 = stashPlaceholder(input3);
197377
197394
  }
197378
- const value = validateObjectKeys(input3, { optional: CONTRIBUTOR_KEYS, alias: CONTRIBUTOR_ALIASES }, opts);
197395
+ const value = validateObjectKeys(input3, { optional: PERSON_KEYS, alias: PERSON_ALIASES }, opts);
197379
197396
  if (value === void 0)
197380
197397
  return void 0;
197398
+ if (inputAff && Object.keys(inputAff).length > Object.keys(value).length) {
197399
+ validationWarning('contributor may be a collaboration, not a person - if so, add "collaboration: true"', opts);
197400
+ }
197401
+ if (Object.keys(value).length === 1 && value.id) {
197402
+ value.name = value.id;
197403
+ }
197381
197404
  const output2 = {};
197382
197405
  if (defined(value.id)) {
197383
197406
  output2.id = validateString(value.id, incrementOptions("id", opts));
@@ -197475,6 +197498,17 @@ function validateContributor(input3, stash, opts) {
197475
197498
  if (defined(value.note)) {
197476
197499
  output2.note = validateString(value.note, incrementOptions("note", opts));
197477
197500
  }
197501
+ if (isStashPlaceholder(output2) || !output2.nameParsed)
197502
+ return output2;
197503
+ if (value.nameParsed || value.name && typeof value.name !== "string")
197504
+ return output2;
197505
+ const suffix = " - if this is intended, you may define 'name' explicitly as an object";
197506
+ if (!output2.nameParsed.given) {
197507
+ validationWarning(`No given name for name '${output2.nameParsed.literal}'${suffix}`, opts);
197508
+ }
197509
+ if (!output2.nameParsed.family) {
197510
+ validationWarning(`No family name for name '${output2.nameParsed.literal}'${suffix}`, opts);
197511
+ }
197478
197512
  return output2;
197479
197513
  }
197480
197514
 
@@ -197599,16 +197633,21 @@ var SITE_FRONTMATTER_KEYS = [
197599
197633
  "banner",
197600
197634
  "bannerOptimized",
197601
197635
  "authors",
197636
+ "reviewers",
197637
+ "editors",
197602
197638
  "contributors",
197603
197639
  "venue",
197604
197640
  "github",
197605
197641
  "keywords",
197606
197642
  "affiliations",
197607
197643
  "funding",
197644
+ "copyright",
197608
197645
  "options"
197609
197646
  ];
197610
197647
  var FRONTMATTER_ALIASES = {
197611
197648
  author: "authors",
197649
+ reviewer: "reviewers",
197650
+ editor: "editors",
197612
197651
  contributor: "contributors",
197613
197652
  affiliation: "affiliations",
197614
197653
  export: "exports",
@@ -197617,9 +197656,17 @@ var FRONTMATTER_ALIASES = {
197617
197656
  ack: "acknowledgments",
197618
197657
  acknowledgements: "acknowledgments",
197619
197658
  availability: "data_availability",
197620
- plain_language_summary: "summary",
197659
+ dataAvailability: "data_availability",
197660
+ "data-availability": "data_availability",
197621
197661
  quote: "epigraph",
197662
+ plain_language_summary: "summary",
197663
+ "plain-language-summary": "summary",
197664
+ plainLanguageSummary: "summary",
197622
197665
  lay_summary: "summary",
197666
+ "lay-summary": "summary",
197667
+ keyPoints: "keypoints",
197668
+ key_points: "keypoints",
197669
+ "key-points": "keypoints",
197623
197670
  image: "thumbnail"
197624
197671
  };
197625
197672
  function validateSiteFrontmatterKeys(value, opts) {
@@ -197666,6 +197713,16 @@ function validateSiteFrontmatterKeys(value, opts) {
197666
197713
  return validateAndStashObject(contributor, stash, "contributors", (v, o) => validateContributor(v, stash, o), incrementOptions(`contributors.${index4}`, opts));
197667
197714
  });
197668
197715
  }
197716
+ if (defined(value.reviewers)) {
197717
+ output2.reviewers = validateList(value.reviewers, { coerce: true, ...incrementOptions("reviewers", opts) }, (reviewer, ind) => {
197718
+ return validateAndStashObject(reviewer, stash, "contributors", (v, o) => validateContributor(v, stash, o), incrementOptions(`reviewers.${ind}`, opts));
197719
+ });
197720
+ }
197721
+ if (defined(value.editors)) {
197722
+ output2.editors = validateList(value.editors, { coerce: true, ...incrementOptions("editors", opts) }, (editor, ind) => {
197723
+ return validateAndStashObject(editor, stash, "contributors", (v, o) => validateContributor(v, stash, o), incrementOptions(`editors.${ind}`, opts));
197724
+ });
197725
+ }
197669
197726
  if (defined(value.venue)) {
197670
197727
  output2.venue = validateVenue(value.venue, incrementOptions("venue", opts));
197671
197728
  }
@@ -197686,6 +197743,9 @@ function validateSiteFrontmatterKeys(value, opts) {
197686
197743
  return validateFunding(fund, stash, incrementOptions(`funding.${index4}`, opts));
197687
197744
  });
197688
197745
  }
197746
+ if (defined(value.copyright)) {
197747
+ output2.copyright = validateString(value.copyright, incrementOptions("copyright", opts));
197748
+ }
197689
197749
  if (defined(value.options)) {
197690
197750
  const optionsOptions = incrementOptions("options", opts);
197691
197751
  const options = validateObject(value.options, optionsOptions);
@@ -197710,10 +197770,10 @@ function validateSiteFrontmatterKeys(value, opts) {
197710
197770
  });
197711
197771
  if (stashContribAuthors === null || stashContribAuthors === void 0 ? void 0 : stashContribAuthors.length) {
197712
197772
  output2.authors = stashContribAuthors;
197713
- const corresponding = (_c = output2.authors) === null || _c === void 0 ? void 0 : _c.find((a2) => a2.corresponding !== void 0);
197714
- const email = (_d2 = output2.authors) === null || _d2 === void 0 ? void 0 : _d2.find((a2) => a2.email);
197715
- if (!corresponding && email) {
197716
- email.corresponding = true;
197773
+ const correspondingAuthor = (_c = output2.authors) === null || _c === void 0 ? void 0 : _c.find((a2) => a2.corresponding);
197774
+ const personWithEmail = (_d2 = output2.authors) === null || _d2 === void 0 ? void 0 : _d2.find((a2) => a2.email && !a2.collaboration && a2.corresponding === void 0);
197775
+ if (!correspondingAuthor && personWithEmail) {
197776
+ personWithEmail.corresponding = true;
197717
197777
  }
197718
197778
  }
197719
197779
  if (stashContribNonAuthors === null || stashContribNonAuthors === void 0 ? void 0 : stashContribNonAuthors.length) {
@@ -197781,7 +197841,17 @@ var PAGE_FRONTMATTER_KEYS = [
197781
197841
  // ../myst-frontmatter/dist/exports/validators.js
197782
197842
  var EXPORT_KEY_OBJECT = {
197783
197843
  required: [],
197784
- optional: ["format", "template", "output", "id", "name", "renderer", "articles", "sub_articles"],
197844
+ optional: [
197845
+ "format",
197846
+ "template",
197847
+ "output",
197848
+ "zip",
197849
+ "id",
197850
+ "name",
197851
+ "renderer",
197852
+ "articles",
197853
+ "sub_articles"
197854
+ ],
197785
197855
  alias: {
197786
197856
  article: "articles",
197787
197857
  sub_article: "sub_articles"
@@ -197882,17 +197952,13 @@ function validateExport(input3, opts) {
197882
197952
  if (typeof input3 === "string") {
197883
197953
  let format2;
197884
197954
  let output3;
197885
- if (input3.includes(".")) {
197955
+ if (input3.startsWith(".")) {
197886
197956
  Object.entries(EXT_TO_FORMAT).forEach(([ext2, fmt]) => {
197887
- if (input3 === ext2) {
197957
+ if (input3 === ext2)
197888
197958
  format2 = fmt;
197889
- } else if (input3.endsWith(ext2)) {
197890
- output3 = input3;
197891
- }
197892
197959
  });
197893
- if (!format2 && !output3) {
197894
- output3 = input3;
197895
- }
197960
+ } else if (input3.includes(".")) {
197961
+ output3 = input3;
197896
197962
  }
197897
197963
  if (!format2 && !output3) {
197898
197964
  format2 = validateExportFormat(input3, opts);
@@ -197917,26 +197983,33 @@ function validateExport(input3, opts) {
197917
197983
  template = validateString(value.template, incrementOptions("template", opts));
197918
197984
  }
197919
197985
  if (defined(value.output)) {
197920
- output2 = validateString(value.output, incrementOptions("output", opts));
197986
+ const outputOpts = incrementOptions("output", opts);
197987
+ const outputString = validateString(value.output, outputOpts);
197988
+ if (outputString) {
197989
+ Object.keys(EXT_TO_FORMAT).forEach((ext2) => {
197990
+ if (outputString.endsWith(ext2))
197991
+ output2 = outputString;
197992
+ });
197993
+ if (!outputString.slice(1).includes(".")) {
197994
+ output2 = outputString;
197995
+ }
197996
+ if (!output2) {
197997
+ return validationError(`unknown export output extension: ${outputString}`, outputOpts);
197998
+ }
197999
+ }
197921
198000
  }
197922
198001
  if (defined(value.format)) {
197923
198002
  format = validateExportFormat(value.format, incrementOptions("format", opts));
197924
198003
  if (!format)
197925
198004
  return void 0;
197926
- } else if (output2) {
197927
- Object.entries(EXT_TO_FORMAT).forEach(([ext2, fmt]) => {
197928
- if (output2 === null || output2 === void 0 ? void 0 : output2.endsWith(ext2))
197929
- format = fmt;
197930
- });
197931
- if (!format) {
197932
- return validationError(`unable to infer export format from export: ${output2}`, opts);
197933
- }
197934
- } else {
197935
- return validationError("unable to determine export format", opts);
197936
198005
  }
197937
- if (format === void 0 && template === void 0)
197938
- return void 0;
198006
+ if (!format && !template && !output2) {
198007
+ return validationError("export must specify one of: format, template, or output", opts);
198008
+ }
197939
198009
  const validExport = { ...value, format, output: output2, template };
198010
+ if (defined(value.zip)) {
198011
+ validExport.zip = validateBoolean(value.zip, incrementOptions("zip", opts));
198012
+ }
197940
198013
  if (defined(value.articles)) {
197941
198014
  const articles = validateList(value.articles, { coerce: true, ...incrementOptions("articles", opts) }, (item, ind) => validateExportArticle(item, incrementOptions(`articles.${ind}`, opts)));
197942
198015
  const singleArticle = singleArticleWithFile(articles);
@@ -200777,6 +200850,8 @@ function validateProjectFrontmatter(input3, opts) {
200777
200850
  // ../myst-frontmatter/dist/page/validators.js
200778
200851
  var USE_PROJECT_FALLBACK = [
200779
200852
  "authors",
200853
+ "reviewers",
200854
+ "editors",
200780
200855
  "date",
200781
200856
  "doi",
200782
200857
  "arxiv",
@@ -200791,6 +200866,7 @@ var USE_PROJECT_FALLBACK = [
200791
200866
  "numbering",
200792
200867
  "keywords",
200793
200868
  "funding",
200869
+ "copyright",
200794
200870
  "affiliations"
200795
200871
  ];
200796
200872
  function validatePageFrontmatterKeys(value, opts) {
@@ -200849,7 +200925,7 @@ function validatePageFrontmatter(input3, opts) {
200849
200925
 
200850
200926
  // ../myst-frontmatter/dist/utils/fillPageFrontmatter.js
200851
200927
  function fillPageFrontmatter(pageFrontmatter, projectFrontmatter, opts) {
200852
- var _a6, _b, _c, _d2, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
200928
+ var _a6, _b, _c, _d2, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x2;
200853
200929
  const frontmatter = fillMissingKeys(pageFrontmatter, projectFrontmatter, USE_PROJECT_FALLBACK);
200854
200930
  if (pageFrontmatter.numbering || projectFrontmatter.numbering) {
200855
200931
  frontmatter.numbering = fillNumbering(pageFrontmatter.numbering, projectFrontmatter.numbering);
@@ -200892,12 +200968,18 @@ function fillPageFrontmatter(pageFrontmatter, projectFrontmatter, opts) {
200892
200968
  });
200893
200969
  });
200894
200970
  });
200895
- if (((_k = frontmatter.authors) === null || _k === void 0 ? void 0 : _k.length) || contributorIds.size) {
200971
+ (_k = frontmatter.reviewers) === null || _k === void 0 ? void 0 : _k.forEach((reviewer) => {
200972
+ contributorIds.add(reviewer);
200973
+ });
200974
+ (_l = frontmatter.editors) === null || _l === void 0 ? void 0 : _l.forEach((editor) => {
200975
+ contributorIds.add(editor);
200976
+ });
200977
+ if (((_m = frontmatter.authors) === null || _m === void 0 ? void 0 : _m.length) || contributorIds.size) {
200896
200978
  const people = [
200897
- ...(_l = pageFrontmatter.authors) !== null && _l !== void 0 ? _l : [],
200898
- ...(_m = projectFrontmatter.authors) !== null && _m !== void 0 ? _m : [],
200899
- ...(_o = pageFrontmatter.contributors) !== null && _o !== void 0 ? _o : [],
200900
- ...(_p = projectFrontmatter.contributors) !== null && _p !== void 0 ? _p : []
200979
+ ...(_o = pageFrontmatter.authors) !== null && _o !== void 0 ? _o : [],
200980
+ ...(_p = projectFrontmatter.authors) !== null && _p !== void 0 ? _p : [],
200981
+ ...(_q = pageFrontmatter.contributors) !== null && _q !== void 0 ? _q : [],
200982
+ ...(_r = projectFrontmatter.contributors) !== null && _r !== void 0 ? _r : []
200901
200983
  ];
200902
200984
  const peopleLookup = {};
200903
200985
  people.forEach((auth) => {
@@ -200909,7 +200991,7 @@ function fillPageFrontmatter(pageFrontmatter, projectFrontmatter, opts) {
200909
200991
  validationWarning(`Duplicate contributor id within project: ${auth.id}`, incrementOptions("authors", opts));
200910
200992
  }
200911
200993
  });
200912
- if ((_q = frontmatter.authors) === null || _q === void 0 ? void 0 : _q.length) {
200994
+ if ((_s = frontmatter.authors) === null || _s === void 0 ? void 0 : _s.length) {
200913
200995
  frontmatter.authors = frontmatter.authors.map((auth) => {
200914
200996
  var _a7;
200915
200997
  if (!auth.id)
@@ -200925,20 +201007,20 @@ function fillPageFrontmatter(pageFrontmatter, projectFrontmatter, opts) {
200925
201007
  });
200926
201008
  }
200927
201009
  }
200928
- [...(_r = frontmatter.authors) !== null && _r !== void 0 ? _r : [], ...(_s = frontmatter.contributors) !== null && _s !== void 0 ? _s : []].forEach((auth) => {
201010
+ [...(_t = frontmatter.authors) !== null && _t !== void 0 ? _t : [], ...(_u = frontmatter.contributors) !== null && _u !== void 0 ? _u : []].forEach((auth) => {
200929
201011
  var _a7;
200930
201012
  (_a7 = auth.affiliations) === null || _a7 === void 0 ? void 0 : _a7.forEach((aff) => {
200931
201013
  affiliationIds.add(aff);
200932
201014
  });
200933
201015
  });
200934
- (_t = frontmatter.affiliations) === null || _t === void 0 ? void 0 : _t.forEach((aff) => {
201016
+ (_v = frontmatter.affiliations) === null || _v === void 0 ? void 0 : _v.forEach((aff) => {
200935
201017
  if (aff.id)
200936
201018
  affiliationIds.add(aff.id);
200937
201019
  });
200938
201020
  if (affiliationIds.size) {
200939
201021
  const affiliations2 = [
200940
- ...(_u = pageFrontmatter.affiliations) !== null && _u !== void 0 ? _u : [],
200941
- ...(_v = projectFrontmatter.affiliations) !== null && _v !== void 0 ? _v : []
201022
+ ...(_w = pageFrontmatter.affiliations) !== null && _w !== void 0 ? _w : [],
201023
+ ...(_x2 = projectFrontmatter.affiliations) !== null && _x2 !== void 0 ? _x2 : []
200942
201024
  ];
200943
201025
  const affiliationLookup = {};
200944
201026
  affiliations2.forEach((aff) => {
@@ -201756,7 +201838,7 @@ function createId() {
201756
201838
  function normalizeLabel(label) {
201757
201839
  if (!label)
201758
201840
  return void 0;
201759
- const identifier = label.replace(/[\t\n\r ]+/g, " ").trim().toLowerCase();
201841
+ const identifier = label.replace(/[\t\n\r ]+/g, " ").replace(/['‘’"“”]+/g, "").trim().toLowerCase();
201760
201842
  const html_id = createHtmlId(identifier);
201761
201843
  return { identifier, label, html_id };
201762
201844
  }
@@ -202491,30 +202573,94 @@ function createState(selector, tree) {
202491
202573
  }
202492
202574
 
202493
202575
  // ../myst-common/dist/extractParts.js
202494
- function selectBlockParts(tree, part) {
202576
+ function coercePart(part) {
202495
202577
  if (!part) {
202496
202578
  return [];
202497
202579
  }
202580
+ return typeof part === "string" ? [part.toLowerCase()] : part.map((s5) => s5.toLowerCase());
202581
+ }
202582
+ function selectBlockParts(tree, part) {
202583
+ const parts = coercePart(part);
202584
+ if (parts.length === 0)
202585
+ return [];
202498
202586
  const blockParts = selectAll("block", tree).filter((block5) => {
202499
- const parts = typeof part === "string" ? [part] : part;
202500
- return parts.map((p5) => {
202501
- var _a6, _b;
202502
- return ((_a6 = block5.data) === null || _a6 === void 0 ? void 0 : _a6.part) === p5 || ((_b = block5.data) === null || _b === void 0 ? void 0 : _b.tags) && Array.isArray(block5.data.tags) && block5.data.tags.includes(p5);
202503
- }).reduce((a2, b) => a2 || b, false);
202587
+ var _a6, _b, _c;
202588
+ const blockTags = (((_a6 = block5.data) === null || _a6 === void 0 ? void 0 : _a6.tags) && Array.isArray(block5.data.tags) ? block5.data.tags : []).map((tag) => tag === null || tag === void 0 ? void 0 : tag.toLowerCase());
202589
+ const blockPart = (_c = (_b = block5.data) === null || _b === void 0 ? void 0 : _b.part) === null || _c === void 0 ? void 0 : _c.toLowerCase();
202590
+ return parts.map((p5) => blockPart === p5 || blockTags.includes(p5)).reduce((a2, b) => a2 || b, false);
202504
202591
  });
202505
202592
  return blockParts;
202506
202593
  }
202594
+ function createPartBlock(children, part, opts) {
202595
+ var _a6;
202596
+ const block5 = { type: "block", children };
202597
+ if (!(opts === null || opts === void 0 ? void 0 : opts.removePartData)) {
202598
+ (_a6 = block5.data) !== null && _a6 !== void 0 ? _a6 : block5.data = {};
202599
+ block5.data.part = part;
202600
+ }
202601
+ return block5;
202602
+ }
202603
+ function extractImplicitPart(tree, part, opts) {
202604
+ const parts = coercePart(part);
202605
+ if (parts.length === 0)
202606
+ return;
202607
+ let insideImplicitPart = false;
202608
+ const blockParts = [];
202609
+ let paragraphs = [];
202610
+ tree.children.forEach((child, index4) => {
202611
+ var _a6;
202612
+ if (insideImplicitPart && child.type === "paragraph") {
202613
+ paragraphs.push(copyNode(child));
202614
+ child.type = "__part_delete__";
202615
+ }
202616
+ if (child.type !== "__part_delete__" || index4 === tree.children.length - 1) {
202617
+ insideImplicitPart = false;
202618
+ if (paragraphs.length > 0) {
202619
+ blockParts.push(createPartBlock(paragraphs, parts[0], opts));
202620
+ paragraphs = [];
202621
+ selectAll("__part_heading__", tree).forEach((node3) => {
202622
+ node3.type = "__part_delete__";
202623
+ });
202624
+ }
202625
+ }
202626
+ if (child.type === "block") {
202627
+ if ((_a6 = child.data) === null || _a6 === void 0 ? void 0 : _a6.part)
202628
+ return;
202629
+ if (tree.type !== "root")
202630
+ return;
202631
+ const blockPartsTree = extractImplicitPart(child, parts);
202632
+ if (blockPartsTree)
202633
+ blockParts.push(...blockPartsTree.children);
202634
+ } else if (child.type === "heading" && parts.includes(toText(child).toLowerCase())) {
202635
+ insideImplicitPart = true;
202636
+ child.type = "__part_heading__";
202637
+ }
202638
+ });
202639
+ selectAll("__part_heading__", tree).forEach((node3) => {
202640
+ node3.type = "heading";
202641
+ });
202642
+ if (blockParts.length === 0)
202643
+ return;
202644
+ const partsTree = { type: "root", children: blockParts };
202645
+ remove(tree, "__part_delete__");
202646
+ return partsTree;
202647
+ }
202507
202648
  function extractPart(tree, part, opts) {
202508
- const partStrings = typeof part === "string" ? [part] : part;
202649
+ const partStrings = coercePart(part);
202650
+ if (partStrings.length === 0)
202651
+ return;
202509
202652
  const blockParts = selectBlockParts(tree, part);
202510
- if (blockParts.length === 0)
202511
- return void 0;
202653
+ if (blockParts.length === 0) {
202654
+ if (opts === null || opts === void 0 ? void 0 : opts.requireExplicitPart)
202655
+ return;
202656
+ return extractImplicitPart(tree, partStrings);
202657
+ }
202512
202658
  const children = copyNode(blockParts).map((block5) => {
202513
202659
  var _a6;
202514
202660
  (_a6 = block5.data) !== null && _a6 !== void 0 ? _a6 : block5.data = {};
202515
202661
  block5.data.part = partStrings[0];
202516
- if (block5.data.tags && Array.isArray(block5.data.tags) && block5.data.tags.reduce((a2, t2) => a2 || partStrings.includes(t2), false)) {
202517
- block5.data.tags = block5.data.tags.filter((tag) => !partStrings.includes(tag));
202662
+ if (block5.data.tags && Array.isArray(block5.data.tags) && block5.data.tags.reduce((a2, t2) => a2 || partStrings.includes(t2.toLowerCase()), false)) {
202663
+ block5.data.tags = block5.data.tags.filter((tag) => !partStrings.includes(tag.toLowerCase()));
202518
202664
  if (block5.data.tags.length === 0) {
202519
202665
  delete block5.data.tags;
202520
202666
  }
@@ -202557,6 +202703,7 @@ var RuleId;
202557
202703
  RuleId2["texRenders"] = "tex-renders";
202558
202704
  RuleId2["exportExtensionCorrect"] = "export-extension-correct";
202559
202705
  RuleId2["exportArticleExists"] = "export-article-exists";
202706
+ RuleId2["exportFormatDetermined"] = "export-format-determined";
202560
202707
  RuleId2["texParses"] = "tex-parses";
202561
202708
  RuleId2["jatsParses"] = "jats-parses";
202562
202709
  RuleId2["mystFileLoads"] = "myst-file-loads";
@@ -237702,6 +237849,32 @@ function renderEquation(file, node3, opts) {
237702
237849
  }
237703
237850
  }
237704
237851
  function mathNestingTransform(tree, file) {
237852
+ const paragraphs = selectAll("paragraph", tree);
237853
+ paragraphs.forEach((paragraph4) => {
237854
+ if (paragraph4.children.length === 1)
237855
+ return;
237856
+ paragraph4.children.forEach((child, index4) => {
237857
+ var _a6, _b, _c, _d2;
237858
+ if (child.type !== "math")
237859
+ return;
237860
+ const math7 = child;
237861
+ const before = paragraph4.children[index4 - 1];
237862
+ const after = paragraph4.children[index4 + 1];
237863
+ if (index4 === 0) {
237864
+ math7.tight = "after";
237865
+ } else if (index4 === paragraph4.children.length - 1) {
237866
+ math7.tight = "before";
237867
+ } else {
237868
+ math7.tight = true;
237869
+ }
237870
+ if ((before === null || before === void 0 ? void 0 : before.type) === "text") {
237871
+ before.value = (_b = (_a6 = before.value) === null || _a6 === void 0 ? void 0 : _a6.replace(/\n$/, "")) !== null && _b !== void 0 ? _b : "";
237872
+ }
237873
+ if ((after === null || after === void 0 ? void 0 : after.type) === "text") {
237874
+ after.value = (_d2 = (_c = after.value) === null || _c === void 0 ? void 0 : _c.replace(/^\n/, "")) !== null && _d2 !== void 0 ? _d2 : "";
237875
+ }
237876
+ });
237877
+ });
237705
237878
  unnestTransform(tree, "paragraph", "math");
237706
237879
  }
237707
237880
  function mathLabelTransform(tree, file) {
@@ -277934,6 +278107,8 @@ var macros17 = {
277934
278107
  multicolumn: 3,
277935
278108
  subfigure: 2,
277936
278109
  tabularx: 2,
278110
+ longtable: 2,
278111
+ ["longtable*"]: 2,
277937
278112
  supertabular: 1,
277938
278113
  cmidrule: 2,
277939
278114
  cline: 1,
@@ -278577,7 +278752,7 @@ function addAffiliation(node3, state) {
278577
278752
  state.closeParagraph();
278578
278753
  const renderedAffil = state.stack.pop();
278579
278754
  const fmAffil = { id: affilNumber, name: getContentFromRenderedSpan(renderedAffil) };
278580
- if (!affilNumber) {
278755
+ if (!affilNumber && fm.authors.length > 0) {
278581
278756
  const lastAuthor = fm.authors[fm.authors.length - 1];
278582
278757
  if (!lastAuthor.affiliations)
278583
278758
  lastAuthor.affiliations = [];
@@ -278955,60 +279130,221 @@ var MISC_HANDLERS = {
278955
279130
  };
278956
279131
 
278957
279132
  // ../tex-to-myst/dist/tables.js
278958
- function createTable(node3, state) {
278959
- state.closeParagraph();
278960
- const table5 = {
278961
- rows: [],
278962
- cells: [],
278963
- cell: []
278964
- };
278965
- const IGNORE = /* @__PURE__ */ new Set([
278966
- "cline",
278967
- "hline",
278968
- "rule",
278969
- "midrule",
278970
- "cmidrule",
278971
- "toprule",
278972
- "bottomrule"
278973
- ]);
278974
- node3.content.forEach((n) => {
278975
- if (n.type === "macro" && IGNORE.has(n.content))
278976
- return;
278977
- if (n.type === "macro" && (n.content === "\\" || n.content === "tabularnewline")) {
279133
+ var ALIGNMENT_MAP = { c: "center", l: "left", r: "right" };
279134
+ function getTabularAlignment(arg2) {
279135
+ if (!arg2 || !arg2.content.reduce((b, { type: type2 }) => b && ["string", "whitespace"].includes(type2), true)) {
279136
+ return;
279137
+ }
279138
+ const spec = texToText(arg2.content).replace(/[\s|]/g, "");
279139
+ if (!spec.match(/([lrc]*)/))
279140
+ return;
279141
+ return spec.split("").map((a2) => ALIGNMENT_MAP[a2]);
279142
+ }
279143
+ function fixTable(vfile2, table5, alignments) {
279144
+ if ((table5 === null || table5 === void 0 ? void 0 : table5.type) !== "table")
279145
+ return;
279146
+ const multirowTracker = {};
279147
+ const rowSizes = table5.children.map((tr3) => ({
279148
+ tr: tr3,
279149
+ size: tr3.children.reduce((size, td) => {
279150
+ var _a6;
279151
+ return size + ((_a6 = td.colspan) !== null && _a6 !== void 0 ? _a6 : 1);
279152
+ }, 0)
279153
+ }));
279154
+ const uniqueSizes = [...new Set(rowSizes.map(({ size }) => size))];
279155
+ if (uniqueSizes.length !== 1) {
279156
+ fileWarn(vfile2, `Uneven table found, please check your rows to get an even table.`, {
279157
+ node: table5,
279158
+ note: `Row sizes are: ${rowSizes.map(({ size }) => size).join(", ")}`
279159
+ });
279160
+ rowSizes.reduce((rows, row2, index4) => {
279161
+ if (index4 > 0 && rowSizes[index4 - 1].size !== row2.size) {
279162
+ rows.push({ ...row2, previous: rowSizes[index4 - 1].size });
279163
+ }
279164
+ return rows;
279165
+ }, []).forEach(({ tr: tr3, size, previous }) => {
279166
+ fileWarn(vfile2, `Table row of size (${size}) does not match previous row size (${previous})`, {
279167
+ node: tr3
279168
+ });
279169
+ });
279170
+ }
279171
+ let useAlignments = false;
279172
+ if (alignments && uniqueSizes.length === 1 && (uniqueSizes[0] === alignments.length || alignments.length === 1)) {
279173
+ useAlignments = true;
279174
+ } else if (alignments && uniqueSizes.length === 1 && uniqueSizes[0] !== alignments.length) {
279175
+ fileWarn(vfile2, `Table alignment argument does not match number of columns`, { node: table5 });
279176
+ }
279177
+ table5.children.forEach((tr3, rowIndex) => {
279178
+ Object.keys(multirowTracker).forEach((key2) => {
279179
+ const colIndex = key2;
279180
+ if (multirowTracker[colIndex] > 1) {
279181
+ multirowTracker[colIndex]--;
279182
+ } else {
279183
+ delete multirowTracker[colIndex];
279184
+ }
279185
+ });
279186
+ const columnIndex = tr3.children.reduce((info, td) => {
279187
+ var _a6;
279188
+ info.columnIndex.push(info.size);
279189
+ info.size += (_a6 = td.colspan) !== null && _a6 !== void 0 ? _a6 : 1;
279190
+ return info;
279191
+ }, { columnIndex: [], size: 0 }).columnIndex;
279192
+ tr3.children = tr3.children.filter((td, index4) => {
279193
+ var _a6, _b;
279194
+ const colIndex = columnIndex[index4];
279195
+ if (td.rowspan && td.rowspan > 1) {
279196
+ for (let col = 0; col < ((_a6 = td.colspan) !== null && _a6 !== void 0 ? _a6 : 1); col++) {
279197
+ multirowTracker[colIndex + col] = td.rowspan;
279198
+ }
279199
+ }
279200
+ if (alignments && useAlignments && !td.align) {
279201
+ const align = (_b = alignments[colIndex]) !== null && _b !== void 0 ? _b : alignments[0];
279202
+ if (align !== "left")
279203
+ td.align = align;
279204
+ }
279205
+ if (multirowTracker[colIndex] && td.rowspan !== multirowTracker[colIndex]) {
279206
+ if (!isEmptyCell(td)) {
279207
+ fileWarn(vfile2, `Non-empty placeholder cell found at row ${rowIndex}, column ${colIndex}.`, { node: table5 });
279208
+ }
279209
+ return false;
279210
+ }
279211
+ return true;
279212
+ });
279213
+ });
279214
+ }
279215
+ function isEmptyCell(cell3) {
279216
+ return toText(cell3).trim() === "";
279217
+ }
279218
+ var createTable = (addContainer = false) => {
279219
+ return (node3, state) => {
279220
+ state.closeParagraph();
279221
+ const table5 = {
279222
+ rows: [],
279223
+ cells: [],
279224
+ cell: [],
279225
+ // These are used for longtable
279226
+ caption: void 0,
279227
+ label: void 0,
279228
+ firstHead: [],
279229
+ head: [],
279230
+ foot: [],
279231
+ lastFoot: []
279232
+ };
279233
+ const IGNORE = /* @__PURE__ */ new Set([
279234
+ "cline",
279235
+ "hline",
279236
+ "rule",
279237
+ "midrule",
279238
+ "cmidrule",
279239
+ "toprule",
279240
+ "bottomrule"
279241
+ ]);
279242
+ const alignments = getTabularAlignment(node3.args[node3.args.length - 1]);
279243
+ node3.content.forEach((n) => {
279244
+ if (n.type === "comment")
279245
+ return;
279246
+ if (n.type === "macro" && IGNORE.has(n.content))
279247
+ return;
279248
+ if (n.type === "macro" && n.content === "label" && !table5.label) {
279249
+ table5.label = n;
279250
+ return;
279251
+ }
279252
+ if (n.type === "macro" && n.content === "caption") {
279253
+ table5.caption = n;
279254
+ return;
279255
+ }
279256
+ if (n.type === "macro" && n.content === "endfirsthead") {
279257
+ table5.firstHead = table5.rows;
279258
+ table5.rows = [];
279259
+ return;
279260
+ }
279261
+ if (n.type === "macro" && n.content === "endhead") {
279262
+ table5.head = table5.rows;
279263
+ table5.rows = [];
279264
+ return;
279265
+ }
279266
+ if (n.type === "macro" && n.content === "endfoot") {
279267
+ table5.foot = table5.rows;
279268
+ table5.rows = [];
279269
+ return;
279270
+ }
279271
+ if (n.type === "macro" && n.content === "endlastfoot") {
279272
+ table5.lastFoot = table5.rows;
279273
+ table5.rows = [];
279274
+ return;
279275
+ }
279276
+ if (n.type === "macro" && (n.content === "\\" || n.content === "tabularnewline")) {
279277
+ table5.cells.push(table5.cell);
279278
+ if (table5.cells.flat().length > 0)
279279
+ table5.rows.push(table5.cells);
279280
+ table5.cell = [];
279281
+ table5.cells = [];
279282
+ return;
279283
+ }
279284
+ if (n.type === "string" && n.content === "&") {
279285
+ table5.cells.push(table5.cell);
279286
+ table5.cell = [];
279287
+ return;
279288
+ }
279289
+ if (table5.cell.length === 0 && (n.type === "whitespace" || n.type === "parbreak"))
279290
+ return;
279291
+ table5.cell.push(n);
279292
+ });
279293
+ if (table5.cell.length > 0)
278978
279294
  table5.cells.push(table5.cell);
279295
+ if (table5.cells.length > 0)
278979
279296
  table5.rows.push(table5.cells);
278980
- table5.cell = [];
278981
- table5.cells = [];
278982
- return;
279297
+ if (table5.firstHead.length > 0) {
279298
+ table5.rows.unshift(...table5.firstHead);
279299
+ } else {
279300
+ table5.rows.unshift(...table5.head);
278983
279301
  }
278984
- if (n.type === "string" && n.content === "&") {
278985
- table5.cells.push(table5.cell);
278986
- table5.cell = [];
278987
- return;
279302
+ if (table5.lastFoot.length > 0) {
279303
+ table5.rows.push(...table5.lastFoot);
279304
+ } else {
279305
+ table5.rows.push(...table5.foot);
278988
279306
  }
278989
- if (table5.cell.length === 0 && n.type === "whitespace")
278990
- return;
278991
- table5.cell.push(n);
278992
- });
278993
- if (table5.cell.length > 0)
278994
- table5.cells.push(table5.cell);
278995
- if (table5.cells.length > 0)
278996
- table5.rows.push(table5.cells);
278997
- state.openNode("table");
278998
- table5.rows.forEach((row2, rowIndex) => {
278999
- state.openNode("tableRow");
279000
- row2.forEach((cell3) => {
279001
- state.openNode("tableCell", rowIndex === 0 ? { header: true } : void 0);
279002
- trimWhitespace(cell3);
279003
- state.renderChildren({ content: [{ type: "group", content: cell3 }] });
279307
+ if (addContainer) {
279308
+ state.openNode("container", { kind: "table" });
279309
+ if (table5.caption) {
279310
+ state.renderChildren({ content: [{ type: "group", content: [table5.caption] }] });
279311
+ }
279312
+ if (table5.label) {
279313
+ state.renderChildren({ content: [{ type: "group", content: [table5.label] }] });
279314
+ }
279315
+ }
279316
+ state.openNode("table");
279317
+ table5.rows.forEach((row2) => {
279318
+ state.openNode("tableRow");
279319
+ row2.forEach((cell3) => {
279320
+ state.openNode("tableCell");
279321
+ state.renderChildren({
279322
+ content: [
279323
+ {
279324
+ // Putting things in a group helps with floating `\bf` commands
279325
+ // For example:
279326
+ // `& \bf title &` --> `& {\bf title} &`
279327
+ type: "group",
279328
+ // Ignore ending whitespace "title &" should become "title"
279329
+ content: trimWhitespace(cell3)
279330
+ }
279331
+ ]
279332
+ });
279333
+ state.closeParagraph();
279334
+ unnestParagraphs(state.top(), "tableCell");
279335
+ state.closeNode("tableCell");
279336
+ });
279337
+ state.closeNode("tableRow");
279338
+ });
279339
+ const tableNode = state.top();
279340
+ fixTable(state.file, tableNode, alignments);
279341
+ state.closeNode("table");
279342
+ if (addContainer) {
279004
279343
  state.closeParagraph();
279005
- unnestParagraphs(state.top(), "tableCell");
279006
279344
  state.closeNode();
279007
- });
279008
- state.closeNode();
279009
- });
279010
- state.closeNode();
279011
- }
279345
+ }
279346
+ };
279347
+ };
279012
279348
  var TABLE_HANDLERS = {
279013
279349
  env_table(node3, state) {
279014
279350
  state.closeParagraph();
@@ -279024,9 +279360,11 @@ var TABLE_HANDLERS = {
279024
279360
  state.closeParagraph();
279025
279361
  state.closeNode();
279026
279362
  },
279027
- env_tabular: createTable,
279028
- env_tabularx: createTable,
279029
- env_supertabular: createTable,
279363
+ env_tabular: createTable(),
279364
+ env_tabularx: createTable(),
279365
+ env_supertabular: createTable(),
279366
+ env_longtable: createTable(true),
279367
+ "env_longtable*": createTable(true),
279030
279368
  env_threeparttable(node3, state) {
279031
279369
  state.closeParagraph();
279032
279370
  const envId = createId();
@@ -279099,7 +279437,9 @@ var TABLE_HANDLERS = {
279099
279437
  if ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === "tableCell" && Number.isInteger(rowspan)) {
279100
279438
  currentNode.rowspan = rowspan;
279101
279439
  }
279102
- state.renderChildren(node3.args[node3.args.length - 1]);
279440
+ const cell3 = node3.args[node3.args.length - 1];
279441
+ cell3.content = trimWhitespace(cell3.content);
279442
+ state.renderChildren(cell3);
279103
279443
  state.closeParagraph();
279104
279444
  },
279105
279445
  macro_multicolumn(node3, state) {
@@ -279107,20 +279447,34 @@ var TABLE_HANDLERS = {
279107
279447
  const ncolArg = node3.args[0];
279108
279448
  const colspan = Number((_b = (_a6 = ncolArg === null || ncolArg === void 0 ? void 0 : ncolArg.content) === null || _a6 === void 0 ? void 0 : _a6[0]) === null || _b === void 0 ? void 0 : _b.content);
279109
279449
  const currentNode = state.top();
279110
- if ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === "tableCell" && Number.isInteger(colspan)) {
279111
- currentNode.colspan = colspan;
279450
+ const td = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === "tableCell" ? currentNode : void 0;
279451
+ if (td && Number.isInteger(colspan)) {
279452
+ td.colspan = colspan;
279453
+ }
279454
+ if (td && node3.args.length === 3) {
279455
+ const alignmentText = texToText(node3.args[1].content).replace(/([|\s])/g, "");
279456
+ const align = ALIGNMENT_MAP[alignmentText] || void 0;
279457
+ if (align && align !== "left") {
279458
+ td.align = align;
279459
+ }
279112
279460
  }
279113
- state.renderChildren(node3.args[node3.args.length - 1]);
279461
+ const cell3 = node3.args[node3.args.length - 1];
279462
+ cell3.content = trimWhitespace(cell3.content);
279463
+ state.renderChildren(cell3);
279114
279464
  state.closeNode();
279115
279465
  }
279116
279466
  };
279117
279467
  function trimWhitespace(content3) {
279118
- var _a6;
279119
- if (((_a6 = content3.slice(-1)[0]) === null || _a6 === void 0 ? void 0 : _a6.type) === "whitespace") {
279120
- content3.pop();
279121
- return trimWhitespace(content3);
279468
+ var _a6, _b;
279469
+ let startIndex = 0;
279470
+ let endIndex = content3.length - 1;
279471
+ while (startIndex <= endIndex && ((_a6 = content3[startIndex]) === null || _a6 === void 0 ? void 0 : _a6.type) === "whitespace") {
279472
+ startIndex++;
279122
279473
  }
279123
- return content3;
279474
+ while (endIndex >= startIndex && ((_b = content3[endIndex]) === null || _b === void 0 ? void 0 : _b.type) === "whitespace") {
279475
+ endIndex--;
279476
+ }
279477
+ return content3.slice(startIndex, endIndex + 1);
279124
279478
  }
279125
279479
 
279126
279480
  // ../tex-to-myst/dist/footnotes.js
@@ -279803,7 +280157,9 @@ var TexParser = class {
279803
280157
  }
279804
280158
  this.closeNode();
279805
280159
  }
279806
- closeNode() {
280160
+ closeNode(type2) {
280161
+ if (type2 && this.top().type !== type2)
280162
+ return this.top();
279807
280163
  const node3 = this.stack.pop();
279808
280164
  this.pushNode(node3);
279809
280165
  return node3;
@@ -280205,6 +280561,13 @@ function stateError(state, message) {
280205
280561
 
280206
280562
  // ../markdown-it-myst/dist/directives.js
280207
280563
  var COLON_OPTION_REGEX = /^:(?<option>[^:\s]+?):(\s*(?<value>.*)){0,1}\s*$/;
280564
+ function computeBlockTightness(src, map6) {
280565
+ const lines = src.split("\n");
280566
+ const tightBefore = typeof (map6 === null || map6 === void 0 ? void 0 : map6[0]) === "number" && map6[0] > 0 ? lines[map6[0] - 1].trim() !== "" : false;
280567
+ const tightAfter = typeof (map6 === null || map6 === void 0 ? void 0 : map6[1]) === "number" && map6[1] < lines.length ? lines[map6[1]].trim() !== "" : false;
280568
+ const tight = tightBefore && tightAfter ? true : tightBefore ? "before" : tightAfter ? "after" : false;
280569
+ return tight;
280570
+ }
280208
280571
  function replaceFences(state) {
280209
280572
  for (const token of state.tokens) {
280210
280573
  if (token.type === "fence" || token.type === "colon_fence") {
@@ -280241,7 +280604,9 @@ function runDirectives(state) {
280241
280604
  directiveOpen.map = map6;
280242
280605
  directiveOpen.meta = {
280243
280606
  arg: arg2,
280244
- options: simplifyDirectiveOptions(options)
280607
+ options: simplifyDirectiveOptions(options),
280608
+ // Tightness is computed for all directives (are they separated by a newline before/after)
280609
+ tight: computeBlockTightness(state.src, token.map)
280245
280610
  };
280246
280611
  const startLineNumber = map6 ? map6[0] : 0;
280247
280612
  const argTokens = directiveArgToTokens(arg2, startLineNumber, state);
@@ -281353,8 +281718,10 @@ var dropdownDirective = {
281353
281718
  // ../myst-directives/dist/embed.js
281354
281719
  var embedDirective = {
281355
281720
  name: "embed",
281721
+ doc: "The embed directive allows you to duplicate content from another part of your project. This can also be done through the figure directive.",
281356
281722
  arg: {
281357
281723
  type: String,
281724
+ doc: "The label of the node that you are embedding.",
281358
281725
  required: true
281359
281726
  },
281360
281727
  options: {
@@ -281959,20 +282326,21 @@ var listTableDirective = {
281959
282326
  }
281960
282327
  };
281961
282328
 
281962
- // ../myst-directives/dist/margin.js
281963
- var marginDirective = {
281964
- name: "margin",
282329
+ // ../myst-directives/dist/aside.js
282330
+ var asideDirective = {
282331
+ name: "aside",
282332
+ alias: ["margin", "sidebar"],
281965
282333
  body: {
281966
282334
  type: "myst",
281967
282335
  required: true
281968
282336
  },
281969
282337
  run(data) {
281970
- return [
281971
- {
281972
- type: "margin",
281973
- children: data.body
281974
- }
281975
- ];
282338
+ const aside = {
282339
+ type: "aside",
282340
+ kind: data.name == "aside" || data.name == "margin" ? void 0 : data.name,
282341
+ children: data.body
282342
+ };
282343
+ return [aside];
281976
282344
  }
281977
282345
  };
281978
282346
 
@@ -282009,14 +282377,16 @@ var mathDirective = {
282009
282377
  run(data) {
282010
282378
  var _a6;
282011
282379
  const { label, identifier } = normalizeLabel((_a6 = data.options) === null || _a6 === void 0 ? void 0 : _a6.label) || {};
282012
- return [
282013
- {
282014
- type: "math",
282015
- identifier,
282016
- label,
282017
- value: data.body
282018
- }
282019
- ];
282380
+ const math7 = {
282381
+ type: "math",
282382
+ identifier,
282383
+ label,
282384
+ value: data.body
282385
+ };
282386
+ if (data.node.tight) {
282387
+ math7.tight = data.node.tight;
282388
+ }
282389
+ return [math7];
282020
282390
  }
282021
282391
  };
282022
282392
 
@@ -282193,7 +282563,7 @@ var defaultDirectives = [
282193
282563
  includeDirective,
282194
282564
  tableDirective,
282195
282565
  listTableDirective,
282196
- marginDirective,
282566
+ asideDirective,
282197
282567
  glossaryDirective,
282198
282568
  mathDirective,
282199
282569
  mdastDirective,
@@ -282604,6 +282974,25 @@ var underlineRole = {
282604
282974
  }
282605
282975
  };
282606
282976
 
282977
+ // ../myst-roles/dist/keyboard.js
282978
+ var keyboardRole = {
282979
+ name: "keyboard",
282980
+ doc: 'The keyboard role denote textual user input from a keyboard, such as "Ctrl" + "Space".',
282981
+ alias: ["kbd"],
282982
+ body: {
282983
+ type: String,
282984
+ required: true
282985
+ },
282986
+ run(data) {
282987
+ const body3 = data.body;
282988
+ const node3 = {
282989
+ type: "keyboard",
282990
+ children: [{ type: "text", value: body3 }]
282991
+ };
282992
+ return [node3];
282993
+ }
282994
+ };
282995
+
282607
282996
  // ../myst-roles/dist/index.js
282608
282997
  var defaultRoles = [
282609
282998
  abbreviationRole,
@@ -282620,7 +283009,8 @@ var defaultRoles = [
282620
283009
  smallcapsRole,
282621
283010
  subscriptRole,
282622
283011
  superscriptRole,
282623
- underlineRole
283012
+ underlineRole,
283013
+ keyboardRole
282624
283014
  ];
282625
283015
 
282626
283016
  // ../myst-parser/dist/tlds.js
@@ -283872,7 +284262,8 @@ function withoutTrailingNewline(str2) {
283872
284262
  return str2[str2.length - 1] == "\n" ? str2.slice(0, str2.length - 1) : str2;
283873
284263
  }
283874
284264
  var MarkdownParseState = class {
283875
- constructor(handlers6) {
284265
+ constructor(src, handlers6) {
284266
+ this.src = src;
283876
284267
  this.stack = [u2("root", [])];
283877
284268
  this.handlers = getTokenHandlers(handlers6);
283878
284269
  }
@@ -283918,8 +284309,9 @@ var MarkdownParseState = class {
283918
284309
  if (token.hidden && !UNHIDDEN_TOKENS.has(token.type))
283919
284310
  return;
283920
284311
  const handler = this.handlers[token.type];
283921
- if (!handler)
284312
+ if (!handler) {
283922
284313
  throw new Error(`Token type ${token.type} not supported by tokensToMyst parser`);
284314
+ }
283923
284315
  handler(this, token, tokens, index4);
283924
284316
  });
283925
284317
  }
@@ -283942,9 +284334,9 @@ var MarkdownParseState = class {
283942
284334
  }
283943
284335
  }
283944
284336
  };
283945
- function getAttrs(spec, token, tokens, index4) {
284337
+ function getAttrs(state, spec, token, tokens, index4) {
283946
284338
  var _a6;
283947
- const attrs = ((_a6 = spec.getAttrs) === null || _a6 === void 0 ? void 0 : _a6.call(spec, token, tokens, index4)) || spec.attrs || {};
284339
+ const attrs = ((_a6 = spec.getAttrs) === null || _a6 === void 0 ? void 0 : _a6.call(spec, token, tokens, index4, state)) || spec.attrs || {};
283948
284340
  if ("type" in attrs)
283949
284341
  throw new Error('You can not have "type" as attrs.');
283950
284342
  if ("children" in attrs)
@@ -283961,15 +284353,15 @@ function getTokenHandlers(specHandlers) {
283961
284353
  if (noCloseToken(spec, type2)) {
283962
284354
  handlers6[type2] = (state, tok, tokens, i2) => {
283963
284355
  if (spec.isText) {
283964
- state.addText(withoutTrailingNewline(tok.content), tok, spec.type, getAttrs(spec, tok, tokens, i2));
284356
+ state.addText(withoutTrailingNewline(tok.content), tok, spec.type, getAttrs(state, spec, tok, tokens, i2));
283965
284357
  return;
283966
284358
  }
283967
- state.openNode(nodeType, tok, getAttrs(spec, tok, tokens, i2), spec.isLeaf);
284359
+ state.openNode(nodeType, tok, getAttrs(state, spec, tok, tokens, i2), spec.isLeaf);
283968
284360
  state.addText(withoutTrailingNewline(tok.content), tok);
283969
284361
  state.closeNode();
283970
284362
  };
283971
284363
  } else {
283972
- handlers6[type2 + "_open"] = (state, tok, tokens, i2) => state.openNode(nodeType, tok, getAttrs(spec, tok, tokens, i2));
284364
+ handlers6[type2 + "_open"] = (state, tok, tokens, i2) => state.openNode(nodeType, tok, getAttrs(state, spec, tok, tokens, i2));
283973
284365
  handlers6[type2 + "_close"] = (state) => state.closeNode();
283974
284366
  }
283975
284367
  });
@@ -283980,6 +284372,15 @@ function getTokenHandlers(specHandlers) {
283980
284372
  }
283981
284373
 
283982
284374
  // ../myst-parser/dist/tokensToMyst.js
284375
+ function computeAmsmathTightness(src, map6) {
284376
+ var _a6;
284377
+ const lines = src.split("\n");
284378
+ const tightBefore = typeof (map6 === null || map6 === void 0 ? void 0 : map6[0]) === "number" && map6[0] > 0 ? lines[map6[0] - 1].trim() !== "" : false;
284379
+ const last = typeof (map6 === null || map6 === void 0 ? void 0 : map6[1]) === "number" ? (map6 === null || map6 === void 0 ? void 0 : map6[1]) + 1 : void 0;
284380
+ const tightAfter = typeof last === "number" && last < lines.length ? ((_a6 = lines[last]) === null || _a6 === void 0 ? void 0 : _a6.trim()) !== "" : false;
284381
+ const tight = tightBefore && tightAfter ? true : tightBefore ? "before" : tightAfter ? "after" : false;
284382
+ return tight;
284383
+ }
283983
284384
  var NUMBERED_CLASS = /^numbered$/;
283984
284385
  var ALIGN_CLASS = /(?:(?:align-)|^)(left|right|center)/;
283985
284386
  function getClassName(token, exclude) {
@@ -284256,11 +284657,15 @@ var defaultMdast = {
284256
284657
  type: "math",
284257
284658
  noCloseToken: true,
284258
284659
  isText: true,
284259
- getAttrs(t2) {
284660
+ getAttrs(t2, tokens, index4, state) {
284260
284661
  var _a6;
284261
- return {
284662
+ const tight = computeAmsmathTightness(state.src, t2.map);
284663
+ const attrs = {
284262
284664
  enumerated: (_a6 = t2.meta) === null || _a6 === void 0 ? void 0 : _a6.enumerated
284263
284665
  };
284666
+ if (tight)
284667
+ attrs.tight = tight;
284668
+ return attrs;
284264
284669
  }
284265
284670
  },
284266
284671
  footnote_ref: {
@@ -284317,12 +284722,13 @@ var defaultMdast = {
284317
284722
  parsed_directive: {
284318
284723
  type: "mystDirective",
284319
284724
  getAttrs(t2) {
284320
- var _a6, _b;
284725
+ var _a6, _b, _c;
284321
284726
  return {
284322
284727
  name: t2.info,
284323
284728
  args: (_a6 = t2.meta) === null || _a6 === void 0 ? void 0 : _a6.arg,
284324
284729
  options: (_b = t2.meta) === null || _b === void 0 ? void 0 : _b.options,
284325
- value: t2.content || void 0
284730
+ value: t2.content || void 0,
284731
+ tight: ((_c = t2.meta) === null || _c === void 0 ? void 0 : _c.tight) || void 0
284326
284732
  };
284327
284733
  }
284328
284734
  },
@@ -284449,14 +284855,14 @@ var defaultOptions2 = {
284449
284855
  hoistSingleImagesOutofParagraphs: true,
284450
284856
  nestBlocks: true
284451
284857
  };
284452
- function tokensToMyst(tokens, options = defaultOptions2) {
284858
+ function tokensToMyst(src, tokens, options = defaultOptions2) {
284453
284859
  var _a6;
284454
284860
  const opts = {
284455
284861
  ...defaultOptions2,
284456
284862
  ...options,
284457
284863
  handlers: { ...defaultOptions2.handlers, ...options === null || options === void 0 ? void 0 : options.handlers }
284458
284864
  };
284459
- const state = new MarkdownParseState(opts.handlers);
284865
+ const state = new MarkdownParseState(src, opts.handlers);
284460
284866
  state.parseTokens(tokens);
284461
284867
  let tree;
284462
284868
  do {
@@ -284854,7 +285260,7 @@ function mystParse(content3, opts) {
284854
285260
  const { vfile: vfile2 } = opts || {};
284855
285261
  const parsedOpts = parseOptions(opts);
284856
285262
  const tokenizer = createTokenizer(parsedOpts);
284857
- const tree = tokensToMyst(tokenizer.parse(content3, { vfile: vfile2 }), parsedOpts.mdast);
285263
+ const tree = tokensToMyst(content3, tokenizer.parse(content3, { vfile: vfile2 }), parsedOpts.mdast);
284858
285264
  applyDirectives(tree, parsedOpts.directives, parsedOpts.vfile);
284859
285265
  applyRoles(tree, parsedOpts.roles, parsedOpts.vfile);
284860
285266
  return tree;
@@ -285403,7 +285809,7 @@ var import_node_path16 = __toESM(require("path"), 1);
285403
285809
  var import_nbtx = __toESM(require_cjs2(), 1);
285404
285810
 
285405
285811
  // ../myst-cli/dist/version.js
285406
- var version2 = "1.1.47";
285812
+ var version2 = "1.1.49";
285407
285813
  var version_default2 = version2;
285408
285814
 
285409
285815
  // ../myst-cli/dist/utils/headers.js
@@ -287744,7 +288150,7 @@ async function getRawFrontmatterFromFile(session, file, projectPath) {
287744
288150
  return void 0;
287745
288151
  return result.pre.frontmatter;
287746
288152
  }
287747
- function getExportListFromRawFrontmatter(session, formats, rawFrontmatter, file) {
288153
+ function getExportListFromRawFrontmatter(session, rawFrontmatter, file) {
287748
288154
  var _a6;
287749
288155
  const vfile2 = new VFile();
287750
288156
  vfile2.path = file;
@@ -287753,10 +288159,7 @@ function getExportListFromRawFrontmatter(session, formats, rawFrontmatter, file)
287753
288159
  ruleId: RuleId.validFrontmatterExportList
287754
288160
  }));
287755
288161
  logMessagesFromVFile(session, vfile2);
287756
- if (!exports2)
287757
- return [];
287758
- const exportOptions = exports2.filter((exp) => !!exp && formats.includes(exp.format));
287759
- return exportOptions;
288162
+ return exports2 !== null && exports2 !== void 0 ? exports2 : [];
287760
288163
  }
287761
288164
  function updateFileInfoFromFrontmatter(session, file, frontmatter, url, dataUrl) {
287762
288165
  session.store.dispatch(watch.actions.updateFileInfo({
@@ -297151,121 +297554,235 @@ function getDefaultExportFilename(session, file, projectPath) {
297151
297554
  const slug = slugFromProject || createSlug(name3);
297152
297555
  return slug;
297153
297556
  }
297154
- function getDefaultExportFolder(session, file, projectPath, ext2) {
297557
+ function getDefaultExportFolder(session, file, format, projectPath) {
297155
297558
  const subpaths = [projectPath || import_node_path32.default.parse(file).dir, "_build", "exports"];
297156
- if (ext2 === "tex")
297559
+ if (format === ExportFormats.tex) {
297157
297560
  subpaths.push(`${getDefaultExportFilename(session, file, projectPath)}_tex`);
297158
- if (ext2 === "typ")
297561
+ }
297562
+ if (format === ExportFormats.typst) {
297159
297563
  subpaths.push(`${getDefaultExportFilename(session, file, projectPath)}_typst`);
297564
+ }
297160
297565
  return import_node_path32.default.join(...subpaths);
297161
297566
  }
297162
297567
 
297163
297568
  // ../myst-cli/dist/build/utils/collectExportOptions.js
297164
297569
  var SOURCE_EXTENSIONS = [".ipynb", ".md", ".tex"];
297165
- function assignArticlesFromProject(exp, proj, vfile2) {
297570
+ function resolveArticlesFromProject(exp, proj, vfile2) {
297166
297571
  var _a6;
297167
297572
  const { file, pages } = proj;
297168
297573
  const fileAsPage = { file, level: 1 };
297169
297574
  const articles = (pages === null || pages === void 0 ? void 0 : pages.length) ? pages : [fileAsPage];
297170
297575
  if (MULTI_ARTICLE_EXPORT_FORMATS.includes(exp.format)) {
297171
- exp.articles = articles;
297172
- } else if (exp.format === ExportFormats.xml) {
297173
- exp.articles = [fileAsPage];
297174
- exp.sub_articles = pages.map((page) => page.file).filter((pageFile) => !!pageFile);
297576
+ return { articles };
297577
+ }
297578
+ if (exp.format === ExportFormats.xml) {
297579
+ return {
297580
+ articles: [fileAsPage],
297581
+ sub_articles: pages.map((page) => page.file).filter((pageFile) => !!pageFile)
297582
+ };
297175
297583
  } else {
297176
- fileError(vfile2, "multiple articles are only supported for 'tex', 'typst', and 'pdf' exports", {
297177
- ruleId: RuleId.validFrontmatterExportList
297178
- });
297179
- exp.articles = [(_a6 = singleArticleWithFile(articles)) !== null && _a6 !== void 0 ? _a6 : fileAsPage];
297584
+ if (articles.length > 1) {
297585
+ fileError(vfile2, "multiple articles are only supported for 'tex', 'typst', and 'pdf' exports", {
297586
+ ruleId: RuleId.validFrontmatterExportList
297587
+ });
297588
+ }
297589
+ return { articles: [(_a6 = singleArticleWithFile(articles)) !== null && _a6 !== void 0 ? _a6 : fileAsPage] };
297180
297590
  }
297181
297591
  }
297182
- function assignArticlesFromTOC(session, exp, tocPath, vfile2) {
297592
+ function resolveArticlesFromTOC(session, exp, tocPath, vfile2) {
297183
297593
  const allowLevelLessThanOne = [
297184
297594
  ExportFormats.tex,
297185
297595
  ExportFormats.pdf,
297186
297596
  ExportFormats.pdftex
297187
297597
  ].includes(exp.format);
297188
297598
  const proj = projectFromToc(session, tocPath, allowLevelLessThanOne ? -1 : 1);
297189
- assignArticlesFromProject(exp, proj, vfile2);
297599
+ return resolveArticlesFromProject(exp, proj, vfile2);
297190
297600
  }
297191
- async function prepareExportOptions(session, sourceFile, formats, projectPath, opts) {
297192
- const { disableTemplate, filename, template } = opts;
297193
- const vfile2 = new VFile();
297194
- vfile2.path = sourceFile;
297195
- let rawFrontmatter;
297196
- const state = session.store.getState();
297197
- if (projectPath && import_node_path33.default.resolve(sourceFile) === selectors_exports.selectLocalConfigFile(state, projectPath)) {
297198
- rawFrontmatter = selectors_exports.selectLocalProjectConfig(state, projectPath);
297199
- } else {
297200
- rawFrontmatter = await getRawFrontmatterFromFile(session, sourceFile, projectPath);
297201
- }
297202
- let exportOptions = getExportListFromRawFrontmatter(session, formats, rawFrontmatter, sourceFile);
297203
- if (exportOptions.length === 0 && formats.length && opts.force) {
297204
- exportOptions = [{ format: formats[0] }];
297601
+ function resolveTemplate(sourceFile, exp, disableTemplate) {
297602
+ if (disableTemplate)
297603
+ return null;
297604
+ if (exp.template) {
297605
+ const resolvedTemplatePath = import_node_path33.default.resolve(import_node_path33.default.dirname(sourceFile), exp.template);
297606
+ if (import_node_fs26.default.existsSync(resolvedTemplatePath)) {
297607
+ return resolvedTemplatePath;
297608
+ }
297205
297609
  }
297206
- if (filename || disableTemplate || template) {
297207
- exportOptions = exportOptions.slice(0, 1);
297610
+ return exp.template;
297611
+ }
297612
+ function resolveFormat(vfile2, exp) {
297613
+ if (exp.format && exp.format !== ExportFormats.pdf) {
297614
+ return exp.format;
297208
297615
  }
297209
- exportOptions.forEach((exp) => {
297210
- var _a6, _b, _c, _d2, _e, _f, _g, _h;
297211
- if (exp.toc && !((_a6 = exp.articles) === null || _a6 === void 0 ? void 0 : _a6.length) && !((_b = exp.sub_articles) === null || _b === void 0 ? void 0 : _b.length)) {
297212
- const resolvedToc = import_node_path33.default.resolve(import_node_path33.default.dirname(sourceFile), exp.toc);
297213
- if (validateTOC(session, resolvedToc)) {
297214
- assignArticlesFromTOC(session, exp, resolvedToc, vfile2);
297215
- }
297216
- }
297217
- if (!((_c = exp.articles) === null || _c === void 0 ? void 0 : _c.length) && SOURCE_EXTENSIONS.includes(import_node_path33.default.extname(sourceFile))) {
297218
- exp.articles = [{ file: import_node_path33.default.resolve(sourceFile) }];
297219
- }
297220
- if (((_d2 = exp.articles) === null || _d2 === void 0 ? void 0 : _d2.length) === 1 && exp.articles[0].level == null) {
297221
- exp.articles[0].level = 0;
297616
+ let suggestedPdfFormat = ExportFormats.pdf;
297617
+ let suggestedOutputFormat;
297618
+ if (exp.output) {
297619
+ const ext2 = import_node_path33.default.extname(exp.output);
297620
+ if (!ext2) {
297621
+ suggestedPdfFormat = ExportFormats.pdftex;
297622
+ } else {
297623
+ suggestedOutputFormat = EXT_TO_FORMAT[ext2];
297624
+ }
297625
+ }
297626
+ if (!exp.template) {
297627
+ if (exp.format)
297628
+ return suggestedPdfFormat;
297629
+ return suggestedOutputFormat !== null && suggestedOutputFormat !== void 0 ? suggestedOutputFormat : suggestedPdfFormat;
297630
+ }
297631
+ if (exp.template.endsWith("-tex"))
297632
+ return suggestedPdfFormat;
297633
+ if (exp.template.endsWith("-typst"))
297634
+ return ExportFormats.typst;
297635
+ if (exp.template.endsWith("-docx"))
297636
+ return ExportFormats.docx;
297637
+ if (import_node_fs26.default.existsSync(exp.template)) {
297638
+ const templateFiles = import_node_fs26.default.readdirSync(exp.template);
297639
+ const templateTexFiles = templateFiles.filter((file) => file.endsWith(".tex"));
297640
+ const templateTypFiles = templateFiles.filter((file) => file.endsWith(".typ"));
297641
+ if (templateTexFiles.length && !templateTypFiles.length)
297642
+ return suggestedPdfFormat;
297643
+ if (!templateTexFiles.length && templateTypFiles.length)
297644
+ return ExportFormats.typst;
297645
+ }
297646
+ fileError(vfile2, `Cannot determine export type from template ${exp.template} - you must specify export 'format'`, { ruleId: RuleId.exportFormatDetermined });
297647
+ return void 0;
297648
+ }
297649
+ function resolveArticles(session, sourceFile, vfile2, exp, projectPath) {
297650
+ var _a6, _b, _c, _d2;
297651
+ const { articles, sub_articles } = exp;
297652
+ let resolved = { articles, sub_articles };
297653
+ if (exp.toc && !resolved.articles && !resolved.sub_articles) {
297654
+ const resolvedToc = import_node_path33.default.resolve(import_node_path33.default.dirname(sourceFile), exp.toc);
297655
+ if (validateTOC(session, resolvedToc)) {
297656
+ resolved = resolveArticlesFromTOC(session, exp, resolvedToc, vfile2);
297222
297657
  }
297223
- if (!((_e = exp.articles) === null || _e === void 0 ? void 0 : _e.length) && !((_f = exp.sub_articles) === null || _f === void 0 ? void 0 : _f.length)) {
297224
- if (validateTOC(session, projectPath !== null && projectPath !== void 0 ? projectPath : ".")) {
297225
- assignArticlesFromTOC(session, exp, projectPath !== null && projectPath !== void 0 ? projectPath : ".", vfile2);
297226
- } else {
297227
- const cachedProject = selectors_exports.selectLocalProject(session.store.getState(), projectPath !== null && projectPath !== void 0 ? projectPath : ".");
297228
- if (cachedProject) {
297229
- assignArticlesFromProject(exp, cachedProject, vfile2);
297230
- }
297658
+ }
297659
+ if (!resolved.articles && SOURCE_EXTENSIONS.includes(import_node_path33.default.extname(sourceFile))) {
297660
+ resolved.articles = [{ file: import_node_path33.default.resolve(sourceFile) }];
297661
+ }
297662
+ if (((_a6 = resolved.articles) === null || _a6 === void 0 ? void 0 : _a6.length) === 1 && resolved.articles[0].level == null) {
297663
+ resolved.articles[0].level = 0;
297664
+ }
297665
+ if (!resolved.articles && !resolved.sub_articles) {
297666
+ if (validateTOC(session, projectPath !== null && projectPath !== void 0 ? projectPath : ".")) {
297667
+ resolved = resolveArticlesFromTOC(session, exp, projectPath !== null && projectPath !== void 0 ? projectPath : ".", vfile2);
297668
+ } else {
297669
+ const cachedProject = selectors_exports.selectLocalProject(session.store.getState(), projectPath !== null && projectPath !== void 0 ? projectPath : ".");
297670
+ if (cachedProject) {
297671
+ resolved = resolveArticlesFromProject(exp, cachedProject, vfile2);
297231
297672
  }
297232
297673
  }
297233
- exp.articles = (_g = exp.articles) === null || _g === void 0 ? void 0 : _g.map((article) => {
297234
- if (!article.file)
297235
- return article;
297236
- const resolvedFile = import_node_path33.default.resolve(import_node_path33.default.dirname(sourceFile), article.file);
297237
- if (!import_node_fs26.default.existsSync(resolvedFile)) {
297238
- fileError(vfile2, `Invalid export article '${article.file}' in source: ${sourceFile}`, {
297239
- ruleId: RuleId.exportArticleExists
297240
- });
297241
- return void 0;
297242
- }
297243
- return { ...article, file: resolvedFile };
297244
- }).filter((article) => !!article);
297245
- exp.sub_articles = (_h = exp.sub_articles) === null || _h === void 0 ? void 0 : _h.map((file) => {
297246
- const resolvedFile = import_node_path33.default.resolve(import_node_path33.default.dirname(sourceFile), file);
297247
- if (!import_node_fs26.default.existsSync(resolvedFile)) {
297248
- fileError(vfile2, `Invalid export sub_article '${file}' in source: ${sourceFile}`, {
297249
- ruleId: RuleId.exportArticleExists
297250
- });
297251
- return void 0;
297252
- } else {
297253
- return resolvedFile;
297254
- }
297255
- }).filter((resolvedFile) => !!resolvedFile);
297256
- });
297257
- const filteredExportOptions = exportOptions.map((exp) => {
297258
- var _a6;
297259
- if ((_a6 = exp.articles) === null || _a6 === void 0 ? void 0 : _a6.length)
297260
- return exp;
297261
- if (exp.format === ExportFormats.meca)
297262
- return exp;
297263
- if (!opts.force) {
297264
- fileError(vfile2, `Invalid export - unable to resolve 'articles' to export: ${sourceFile}`, {
297674
+ }
297675
+ if (!((_b = resolved.articles) === null || _b === void 0 ? void 0 : _b.length) && exp.format !== ExportFormats.meca) {
297676
+ fileError(vfile2, `Unable to resolve any 'articles' to export`, {
297677
+ ruleId: RuleId.exportArticleExists
297678
+ });
297679
+ return resolved;
297680
+ }
297681
+ resolved.articles = (_c = resolved.articles) === null || _c === void 0 ? void 0 : _c.map((article) => {
297682
+ if (!article.file)
297683
+ return article;
297684
+ const resolvedFile = import_node_path33.default.resolve(import_node_path33.default.dirname(sourceFile), article.file);
297685
+ if (!import_node_fs26.default.existsSync(resolvedFile)) {
297686
+ fileError(vfile2, `Invalid export article - '${article.file}' does not exist`, {
297265
297687
  ruleId: RuleId.exportArticleExists
297266
297688
  });
297689
+ return void 0;
297267
297690
  }
297691
+ return { ...article, file: resolvedFile };
297692
+ }).filter((article) => !!article);
297693
+ resolved.sub_articles = (_d2 = resolved.sub_articles) === null || _d2 === void 0 ? void 0 : _d2.map((file) => {
297694
+ const resolvedFile = import_node_path33.default.resolve(import_node_path33.default.dirname(sourceFile), file);
297695
+ if (!import_node_fs26.default.existsSync(resolvedFile)) {
297696
+ fileError(vfile2, `Invalid export sub_article - '${file}' does not exist`, {
297697
+ ruleId: RuleId.exportArticleExists
297698
+ });
297699
+ return void 0;
297700
+ } else {
297701
+ return resolvedFile;
297702
+ }
297703
+ }).filter((resolvedFile) => !!resolvedFile);
297704
+ return resolved;
297705
+ }
297706
+ var ALLOWED_EXTENSIONS = {
297707
+ [ExportFormats.docx]: [".doc", ".docx"],
297708
+ [ExportFormats.md]: [".md"],
297709
+ [ExportFormats.meca]: [".zip", ".meca"],
297710
+ [ExportFormats.pdf]: [".pdf"],
297711
+ [ExportFormats.pdftex]: [".pdf", ".tex", ".zip"],
297712
+ [ExportFormats.tex]: [".tex", ".zip"],
297713
+ [ExportFormats.typst]: [".pdf", ".typ", ".typst", ".zip"],
297714
+ [ExportFormats.xml]: [".xml", ".jats"]
297715
+ };
297716
+ function resolveOutput(session, sourceFile, vfile2, exp, projectPath) {
297717
+ var _a6, _b, _c, _d2, _e;
297718
+ let output2;
297719
+ if (exp.output) {
297720
+ output2 = import_node_path33.default.resolve(import_node_path33.default.dirname(sourceFile), exp.output);
297721
+ } else {
297722
+ output2 = getDefaultExportFolder(session, sourceFile, exp.format, projectPath);
297723
+ }
297724
+ if (exp.format === ExportFormats.meca && exp.zip === false) {
297725
+ fileWarn(vfile2, `ignoring "zip: false" for export of format "${ExportFormats.meca}"`);
297726
+ }
297727
+ if (exp.zip && !((_a6 = ALLOWED_EXTENSIONS[exp.format]) === null || _a6 === void 0 ? void 0 : _a6.includes(".zip"))) {
297728
+ fileWarn(vfile2, `ignoring "zip: true" for export of format "${exp.format}"`);
297729
+ exp.zip = false;
297730
+ }
297731
+ if (!import_node_path33.default.extname(output2)) {
297732
+ const basename3 = getDefaultExportFilename(session, (_c = (_b = singleArticleWithFile(exp.articles)) === null || _b === void 0 ? void 0 : _b.file) !== null && _c !== void 0 ? _c : sourceFile, projectPath);
297733
+ const ext2 = exp.zip ? ".zip" : (_d2 = ALLOWED_EXTENSIONS[exp.format]) === null || _d2 === void 0 ? void 0 : _d2[0];
297734
+ output2 = import_node_path33.default.join(output2, `${basename3}${ext2 !== null && ext2 !== void 0 ? ext2 : ""}`);
297735
+ }
297736
+ if (!((_e = ALLOWED_EXTENSIONS[exp.format]) === null || _e === void 0 ? void 0 : _e.includes(import_node_path33.default.extname(output2)))) {
297737
+ fileError(vfile2, `Output file "${output2}" has invalid extension for export format of "${exp.format}"`, { ruleId: RuleId.exportExtensionCorrect });
297268
297738
  return void 0;
297739
+ }
297740
+ if (exp.zip && import_node_path33.default.extname(output2) !== ".zip") {
297741
+ fileWarn(vfile2, `Output file "${output2}" has non-zip extension but "zip: true" is specified; ignoring "zip: true"`, { ruleId: RuleId.exportExtensionCorrect });
297742
+ }
297743
+ return output2;
297744
+ }
297745
+ async function getExportListFromFile(session, sourceFile, projectPath, opts) {
297746
+ const { disableTemplate } = opts;
297747
+ let rawFrontmatter;
297748
+ const state = session.store.getState();
297749
+ if (projectPath && import_node_path33.default.resolve(sourceFile) === selectors_exports.selectLocalConfigFile(state, projectPath)) {
297750
+ rawFrontmatter = selectors_exports.selectLocalProjectConfig(state, projectPath);
297751
+ } else {
297752
+ rawFrontmatter = await getRawFrontmatterFromFile(session, sourceFile, projectPath);
297753
+ }
297754
+ const exportList = getExportListFromRawFrontmatter(session, rawFrontmatter, sourceFile);
297755
+ const exportListWithTemplate = exportList.map((exp) => {
297756
+ const template = resolveTemplate(sourceFile, exp, disableTemplate);
297757
+ return { ...exp, template };
297758
+ }).filter((exp) => !!exp);
297759
+ return exportListWithTemplate;
297760
+ }
297761
+ function resolveExportListFormats(session, sourceFile, formats, exportList) {
297762
+ const vfile2 = new VFile();
297763
+ vfile2.path = sourceFile;
297764
+ const exportListWithFormat = exportList.map((exp) => {
297765
+ const format = resolveFormat(vfile2, exp);
297766
+ if (!format || !formats.includes(format))
297767
+ return void 0;
297768
+ return { ...exp, format };
297769
+ }).filter((exp) => !!exp);
297770
+ logMessagesFromVFile(session, vfile2);
297771
+ return exportListWithFormat;
297772
+ }
297773
+ function resolveExportListArticles(session, sourceFile, exportList, projectPath, opts) {
297774
+ const { renderer } = opts;
297775
+ const vfile2 = new VFile();
297776
+ vfile2.path = sourceFile;
297777
+ const filteredExportOptions = exportList.map((exp) => {
297778
+ const { articles, sub_articles } = resolveArticles(session, sourceFile, vfile2, exp, projectPath);
297779
+ if (!(articles === null || articles === void 0 ? void 0 : articles.length) && exp.format !== ExportFormats.meca) {
297780
+ return void 0;
297781
+ }
297782
+ const output2 = resolveOutput(session, sourceFile, vfile2, exp, projectPath);
297783
+ if (!output2)
297784
+ return void 0;
297785
+ return { ...exp, output: output2, articles, sub_articles, renderer };
297269
297786
  }).filter((exp) => !!exp);
297270
297787
  logMessagesFromVFile(session, vfile2);
297271
297788
  return filteredExportOptions;
@@ -297282,93 +297799,6 @@ function filterAndMakeUnique(exports2) {
297282
297799
  };
297283
297800
  });
297284
297801
  }
297285
- function getOutput(session, sourceFile, exp, filename, extension, formats, projectPath) {
297286
- var _a6, _b;
297287
- let output2;
297288
- if (filename) {
297289
- output2 = filename;
297290
- } else if (exp.output) {
297291
- output2 = import_node_path33.default.resolve(import_node_path33.default.dirname(sourceFile), exp.output);
297292
- } else {
297293
- output2 = getDefaultExportFolder(session, sourceFile, projectPath, formats.includes(ExportFormats.tex) ? "tex" : formats.includes(ExportFormats.typst) ? "typ" : void 0);
297294
- }
297295
- if (!import_node_path33.default.extname(output2)) {
297296
- const basename3 = getDefaultExportFilename(session, (_b = (_a6 = singleArticleWithFile(exp.articles)) === null || _a6 === void 0 ? void 0 : _a6.file) !== null && _b !== void 0 ? _b : sourceFile, projectPath);
297297
- output2 = import_node_path33.default.join(output2, `${basename3}.${extension}`);
297298
- }
297299
- if (!output2.endsWith(`.${extension}`)) {
297300
- addWarningForFile(session, sourceFile, `The filename must end with '.${extension}': "${output2}"`, "error", { ruleId: RuleId.exportExtensionCorrect });
297301
- return void 0;
297302
- }
297303
- return output2;
297304
- }
297305
- async function collectTexExportOptions(session, sourceFile, extension, formats, projectPath, opts) {
297306
- const exportOptions = await prepareExportOptions(session, sourceFile, formats, projectPath, opts);
297307
- const { disableTemplate, filename, template, zip: zip2 } = opts;
297308
- if (disableTemplate && template) {
297309
- throw new Error("Conflicting tex export options: disableTemplate requested but a template was provided");
297310
- }
297311
- const resolvedExportOptions = filterAndMakeUnique(exportOptions.map((exp) => {
297312
- const rawOutput = filename || exp.output || "";
297313
- const useZip = (extension === "tex" || extension === "typ") && (zip2 || import_node_path33.default.extname(rawOutput) === ".zip");
297314
- const usePdf = extension === "typ" && import_node_path33.default.extname(rawOutput) === ".pdf";
297315
- const expExtension = useZip ? "zip" : usePdf ? "pdf" : extension;
297316
- const output2 = getOutput(session, sourceFile, exp, filename, expExtension, formats, projectPath);
297317
- if (!output2)
297318
- return void 0;
297319
- const resolvedOptions = { output: output2 };
297320
- if (disableTemplate) {
297321
- resolvedOptions.template = null;
297322
- } else if (template) {
297323
- resolvedOptions.template = template;
297324
- } else if (exp.template) {
297325
- const resolvedTemplatePath = import_node_path33.default.resolve(import_node_path33.default.dirname(sourceFile), exp.template);
297326
- if (import_node_fs26.default.existsSync(resolvedTemplatePath)) {
297327
- resolvedOptions.template = resolvedTemplatePath;
297328
- } else {
297329
- resolvedOptions.template = exp.template;
297330
- }
297331
- }
297332
- return { ...exp, ...resolvedOptions };
297333
- }));
297334
- return resolvedExportOptions;
297335
- }
297336
- async function collectBasicExportOptions(session, sourceFile, extension, formats, projectPath, opts) {
297337
- const exportOptions = await prepareExportOptions(session, sourceFile, formats, projectPath, opts);
297338
- const { filename } = opts;
297339
- const resolvedExportOptions = filterAndMakeUnique(exportOptions.map((exp) => {
297340
- const output2 = getOutput(session, sourceFile, exp, filename, extension, formats, projectPath);
297341
- if (!output2)
297342
- return void 0;
297343
- return { ...exp, output: output2 };
297344
- }));
297345
- return resolvedExportOptions;
297346
- }
297347
- async function collectWordExportOptions(session, sourceFile, extension, formats, projectPath, opts) {
297348
- const exportOptions = await prepareExportOptions(session, sourceFile, formats, projectPath, opts);
297349
- const { template, filename, renderer } = opts;
297350
- const resolvedExportOptions = filterAndMakeUnique(exportOptions.map((exp) => {
297351
- const output2 = getOutput(session, sourceFile, exp, filename, extension, formats, projectPath);
297352
- if (!output2)
297353
- return void 0;
297354
- const resolvedOptions = { output: output2 };
297355
- if (renderer) {
297356
- resolvedOptions.renderer = renderer;
297357
- }
297358
- if (template) {
297359
- resolvedOptions.template = template;
297360
- } else if (exp.template) {
297361
- const resolvedTemplatePath = import_node_path33.default.resolve(import_node_path33.default.dirname(sourceFile), exp.template);
297362
- if (import_node_fs26.default.existsSync(resolvedTemplatePath)) {
297363
- resolvedOptions.template = resolvedTemplatePath;
297364
- } else {
297365
- resolvedOptions.template = exp.template;
297366
- }
297367
- }
297368
- return { ...exp, ...resolvedOptions };
297369
- }));
297370
- return resolvedExportOptions;
297371
- }
297372
297802
  async function collectExportOptions(session, files, formats, opts) {
297373
297803
  const { projectPath } = opts;
297374
297804
  const sourceFiles = [...files];
@@ -297388,29 +297818,10 @@ async function collectExportOptions(session, files, formats, opts) {
297388
297818
  } else {
297389
297819
  fileProjectPath = projectPath;
297390
297820
  }
297391
- const fileExportOptionsList = [];
297392
- if (formats.includes(ExportFormats.docx)) {
297393
- fileExportOptionsList.push(...await collectWordExportOptions(session, file, "docx", [ExportFormats.docx], fileProjectPath, opts));
297394
- }
297395
- if (formats.includes(ExportFormats.pdf) || formats.includes(ExportFormats.pdftex)) {
297396
- fileExportOptionsList.push(...await collectTexExportOptions(session, file, "pdf", [ExportFormats.pdf, ExportFormats.pdftex], fileProjectPath, opts));
297397
- }
297398
- if (formats.includes(ExportFormats.tex)) {
297399
- fileExportOptionsList.push(...await collectTexExportOptions(session, file, "tex", [ExportFormats.tex], fileProjectPath, opts));
297400
- }
297401
- if (formats.includes(ExportFormats.typst)) {
297402
- fileExportOptionsList.push(...await collectTexExportOptions(session, file, "typ", [ExportFormats.typst], fileProjectPath, opts));
297403
- }
297404
- if (formats.includes(ExportFormats.xml)) {
297405
- fileExportOptionsList.push(...await collectBasicExportOptions(session, file, "xml", [ExportFormats.xml], fileProjectPath, opts));
297406
- }
297407
- if (formats.includes(ExportFormats.md)) {
297408
- fileExportOptionsList.push(...await collectBasicExportOptions(session, file, "md", [ExportFormats.md], fileProjectPath, opts));
297409
- }
297410
- if (formats.includes(ExportFormats.meca)) {
297411
- fileExportOptionsList.push(...await collectBasicExportOptions(session, file, "zip", [ExportFormats.meca], fileProjectPath, opts));
297412
- }
297413
- exportOptionsList.push(...fileExportOptionsList.map((exportOptions) => {
297821
+ const fileExports = await getExportListFromFile(session, file, fileProjectPath, opts);
297822
+ const fileExportsWithFormat = resolveExportListFormats(session, file, formats, fileExports);
297823
+ const fileExportsResolved = resolveExportListArticles(session, file, fileExportsWithFormat, fileProjectPath, opts);
297824
+ exportOptionsList.push(...fileExportsResolved.map((exportOptions) => {
297414
297825
  return { ...exportOptions, $file: file, $project: fileProjectPath };
297415
297826
  }));
297416
297827
  }));
@@ -300482,6 +300893,33 @@ function getClasses2(className) {
300482
300893
  }
300483
300894
 
300484
300895
  // ../myst-to-tex/dist/math.js
300896
+ var ENVIRONMENTS2 = [
300897
+ "equation",
300898
+ "multline",
300899
+ "gather",
300900
+ "align",
300901
+ "alignat",
300902
+ "flalign",
300903
+ "matrix",
300904
+ "pmatrix",
300905
+ "bmatrix",
300906
+ "Bmatrix",
300907
+ "vmatrix",
300908
+ "Vmatrix",
300909
+ "eqnarray"
300910
+ ];
300911
+ var RE_OPEN2 = new RegExp(`^\\\\begin{(${ENVIRONMENTS2.join("|")})([*]?)}`);
300912
+ function isAmsmathEnvironment(value) {
300913
+ const matchOpen = value.trim().match(RE_OPEN2);
300914
+ if (!matchOpen)
300915
+ return false;
300916
+ const [, environment2, star3] = matchOpen;
300917
+ const end = `\\end{${environment2}${star3}}`;
300918
+ const matchClose = value.trim().endsWith(end);
300919
+ if (!matchClose)
300920
+ return false;
300921
+ return true;
300922
+ }
300485
300923
  function addMacrosToState(value, state) {
300486
300924
  if (!state.options.math)
300487
300925
  return;
@@ -300510,6 +300948,11 @@ function withRecursiveCommands(state, plugins2 = state.data.mathPlugins) {
300510
300948
  }
300511
300949
  var math4 = (node3, state) => {
300512
300950
  const { label, enumerated } = node3;
300951
+ const tightBefore = node3.tight === true || node3.tight === "before";
300952
+ const tightAfter = node3.tight === true || node3.tight === "after";
300953
+ if (tightBefore) {
300954
+ state.ensureNewLine(true);
300955
+ }
300513
300956
  state.usePackages("amsmath");
300514
300957
  addMacrosToState(node3.value, state);
300515
300958
  if (state.data.isInTable) {
@@ -300517,18 +300960,30 @@ var math4 = (node3, state) => {
300517
300960
  state.write(node3.value);
300518
300961
  state.write(" \\)");
300519
300962
  } else {
300520
- state.write(`\\begin{equation${enumerated === false ? "*" : ""}}
300963
+ const isAmsMath = isAmsmathEnvironment(node3.value);
300964
+ if (isAmsMath) {
300965
+ state.ensureNewLine();
300966
+ state.write(node3.value);
300967
+ state.ensureNewLine(true);
300968
+ } else {
300969
+ state.write(`\\begin{equation${enumerated === false ? "*" : ""}}
300521
300970
  `);
300522
- if (label) {
300523
- state.write(`\\label{${label}}`);
300971
+ if (label) {
300972
+ state.write(`\\label{${label}}`);
300973
+ }
300974
+ state.ensureNewLine();
300975
+ state.write(node3.value);
300976
+ state.ensureNewLine(true);
300977
+ state.write(`\\end{equation${enumerated === false ? "*" : ""}}`);
300524
300978
  }
300525
- state.ensureNewLine();
300526
- state.write(node3.value);
300527
- state.ensureNewLine(true);
300528
- state.write(`\\end{equation${enumerated === false ? "*" : ""}}`);
300529
300979
  }
300530
- if (!state.data.isInTable)
300980
+ if (state.data.isInTable)
300981
+ return;
300982
+ if (tightAfter) {
300983
+ state.ensureNewLine(true);
300984
+ } else {
300531
300985
  state.closeBlock(node3);
300986
+ }
300532
300987
  };
300533
300988
  var inlineMath2 = (node3, state) => {
300534
300989
  state.usePackages("amsmath");
@@ -302646,7 +303101,9 @@ ${node3.value}
302646
303101
  state.renderChildren(node3, 0, " ");
302647
303102
  },
302648
303103
  cite(node3, state) {
302649
- state.write(`#cite(<${node3.label}>`);
303104
+ const needsLabel = !/^[a-zA-Z0-9_\-:.]+$/.test(node3.label);
303105
+ const label = needsLabel ? `label("${node3.label}")` : `<${node3.label}>`;
303106
+ state.write(`#cite(${label}`);
302650
303107
  if (node3.kind === "narrative")
302651
303108
  state.write(`, form: "prose"`);
302652
303109
  if (node3.suffix)
@@ -302794,8 +303251,7 @@ function isTypstAvailable() {
302794
303251
  }
302795
303252
  async function runTypstExecutable(session, typstFile) {
302796
303253
  if (!isTypstAvailable()) {
302797
- session.log.debug("typst CLI must be installed to build PDFs from typst");
302798
- return;
303254
+ throw new Error("The typst CLI must be installed to build PDFs with typst");
302799
303255
  }
302800
303256
  if (import_node_path49.default.extname(typstFile) !== ".typ") {
302801
303257
  throw new Error(`invalid input file for typst executable: ${typstFile}`);
@@ -303067,7 +303523,7 @@ async function runTypstPdfExport(session, file, exportOptions, opts) {
303067
303523
  exportOptions.output = import_node_path49.default.join(typFolder, `${import_node_path49.default.basename(pdfOutput, import_node_path49.default.extname(pdfOutput))}.typ`);
303068
303524
  await runTypstExport(session, file, exportOptions, { ...opts !== null && opts !== void 0 ? opts : {}, clean: false });
303069
303525
  const writeFolder = import_node_path49.default.dirname(pdfOutput);
303070
- session.log.info(`\u{1F5A8} Rendering typst pdf to ${pdfOutput}`);
303526
+ session.log.info(`\u{1F5A8} Rendering typst pdf to ${pdfOutput}`);
303071
303527
  if (!import_node_fs34.default.existsSync(writeFolder))
303072
303528
  import_node_fs34.default.mkdirSync(writeFolder, { recursive: true });
303073
303529
  import_node_fs34.default.copyFileSync(exportOptions.output.replace(".typ", ".pdf"), pdfOutput);
@@ -306365,7 +306821,12 @@ async function runJatsExport(session, sourceFile, exportOptions, opts) {
306365
306821
  abstractParts: [
306366
306822
  { part: "abstract" },
306367
306823
  {
306368
- part: ["plain-language-summary", "plain-language-abstract", "summary"],
306824
+ part: [
306825
+ "plain-language-summary",
306826
+ "plain-language-abstract",
306827
+ "summary",
306828
+ "plain language summary"
306829
+ ],
306369
306830
  type: "plain-language-summary",
306370
306831
  title: "Plain Language Summary"
306371
306832
  },
@@ -306373,7 +306834,7 @@ async function runJatsExport(session, sourceFile, exportOptions, opts) {
306373
306834
  ],
306374
306835
  backSections: [
306375
306836
  {
306376
- part: ["data-availability", "data_availability", "availability"],
306837
+ part: ["data-availability", "data_availability", "availability", "data availability"],
306377
306838
  type: "data-availability",
306378
306839
  title: "Data Availability"
306379
306840
  }
@@ -311394,24 +311855,45 @@ function hasAnyExplicitExportFormat(opts) {
311394
311855
  const { docx, pdf, tex, typst, xml: xml2, md, meca } = opts;
311395
311856
  return docx || pdf || tex || typst || xml2 || md || meca || false;
311396
311857
  }
311397
- function getExportFormats(opts) {
311398
- const { docx, pdf, tex, typst, xml: xml2, md, meca, all: all10, explicit, extension } = opts;
311858
+ function getAllowedExportFormats(opts) {
311859
+ const { docx, pdf, tex, typst, xml: xml2, md, meca, all: all10, explicit } = opts;
311399
311860
  const formats = [];
311400
311861
  const any = hasAnyExplicitExportFormat(opts);
311401
- const override = all10 || !any && explicit && !extension;
311402
- if (docx || override || extension === ".docx")
311862
+ const override = all10 || !any && explicit;
311863
+ if (docx || override)
311864
+ formats.push(ExportFormats.docx);
311865
+ if (pdf || override) {
311866
+ formats.push(ExportFormats.pdf, ExportFormats.pdftex, ExportFormats.typst);
311867
+ }
311868
+ if (tex || override) {
311869
+ formats.push(ExportFormats.tex, ExportFormats.pdftex);
311870
+ }
311871
+ if (typst || override)
311872
+ formats.push(ExportFormats.typst);
311873
+ if (xml2 || override)
311874
+ formats.push(ExportFormats.xml);
311875
+ if (md || override)
311876
+ formats.push(ExportFormats.md);
311877
+ if (meca || override)
311878
+ formats.push(ExportFormats.meca);
311879
+ return [...new Set(formats)];
311880
+ }
311881
+ function getRequestedExportFormats(opts) {
311882
+ const { docx, pdf, tex, typst, xml: xml2, md, meca } = opts;
311883
+ const formats = [];
311884
+ if (docx)
311403
311885
  formats.push(ExportFormats.docx);
311404
- if (pdf || override || extension === ".pdf")
311886
+ if (pdf)
311405
311887
  formats.push(ExportFormats.pdf);
311406
- if (tex || override || extension === ".tex")
311888
+ if (tex)
311407
311889
  formats.push(ExportFormats.tex);
311408
- if (typst || override || extension === ".typ")
311890
+ if (typst)
311409
311891
  formats.push(ExportFormats.typst);
311410
- if (xml2 || override || extension === ".xml")
311892
+ if (xml2)
311411
311893
  formats.push(ExportFormats.xml);
311412
- if (md || override || extension === ".md")
311894
+ if (md)
311413
311895
  formats.push(ExportFormats.md);
311414
- if (meca || override)
311896
+ if (meca)
311415
311897
  formats.push(ExportFormats.meca);
311416
311898
  return formats;
311417
311899
  }
@@ -311430,46 +311912,61 @@ function getProjectPaths(session) {
311430
311912
  return uniqueArray(projectPaths);
311431
311913
  }
311432
311914
  async function collectAllBuildExportOptions(session, files, opts) {
311433
- const { force, output: output2 } = opts;
311915
+ var _a6;
311916
+ const { output: output2 } = opts;
311434
311917
  files = files.map((file) => import_node_path57.default.resolve(file));
311435
311918
  if (output2 && files.length !== 1) {
311436
311919
  throw new Error("When specifying a named output for export, you must list exactly one file.");
311437
311920
  }
311438
- const formats = getExportFormats({
311439
- ...opts,
311440
- explicit: files.length > 0,
311441
- extension: output2 ? import_node_path57.default.extname(output2) : void 0
311442
- });
311443
- if (output2 && formats.length !== 1) {
311444
- throw new Error(`Unrecognized file extension for output: ${import_node_path57.default.extname(output2)}`);
311921
+ const requestedFormats = getRequestedExportFormats(opts);
311922
+ if (output2 && requestedFormats.length > 1) {
311923
+ throw new Error(`When specifying output, you can only request one format`);
311445
311924
  }
311446
- session.log.debug(`Exporting formats: "${formats.join('", "')}"`);
311447
311925
  let exportOptionsList;
311448
- if (files.length) {
311449
- exportOptionsList = await collectExportOptions(session, files, formats, {
311450
- // If there is an output and file specified, force is implied
311451
- force: force || !!output2 || hasAnyExplicitExportFormat(opts)
311452
- });
311453
- if (output2) {
311454
- if (exportOptionsList.length !== 1) {
311455
- throw new Error("Expecting only a single export when using output");
311456
- }
311457
- exportOptionsList[0].output = import_node_path57.default.join(import_node_path57.default.resolve("."), output2);
311926
+ const projectPath = findCurrentProjectAndLoad(session, files[0] ? import_node_path57.default.dirname(files[0]) : ".");
311927
+ if (projectPath)
311928
+ await loadProjectFromDisk(session, projectPath);
311929
+ if (output2) {
311930
+ session.log.debug(`Exporting formats: "${requestedFormats.join('", "')}"`);
311931
+ const format = (_a6 = requestedFormats[0]) !== null && _a6 !== void 0 ? _a6 : EXT_TO_FORMAT[import_node_path57.default.extname(output2)];
311932
+ if (!format) {
311933
+ throw new Error(`Cannot specify format from output "${output2}" - please specify format option, e.g. --pdf`);
311458
311934
  }
311935
+ exportOptionsList = resolveExportListArticles(session, files[0], [{ format, output: import_node_path57.default.join(import_node_path57.default.resolve("."), output2) }], projectPath, opts).map((exp) => {
311936
+ return { ...exp, $file: files[0], $project: projectPath };
311937
+ });
311938
+ } else if (files.length) {
311939
+ const allowedFormats = getAllowedExportFormats({
311940
+ ...opts,
311941
+ explicit: true
311942
+ });
311943
+ session.log.debug(`Exporting formats: "${allowedFormats.join('", "')}"`);
311944
+ exportOptionsList = (await Promise.all(files.map(async (file) => {
311945
+ const fileExportOptionsList = await collectExportOptions(session, [file], allowedFormats, {});
311946
+ if (fileExportOptionsList.length > 0) {
311947
+ return fileExportOptionsList;
311948
+ }
311949
+ return resolveExportListArticles(session, file, requestedFormats.map((format) => {
311950
+ return { format };
311951
+ }), projectPath, opts).map((exp) => {
311952
+ return { ...exp, $file: files[0], $project: projectPath };
311953
+ });
311954
+ }))).flat();
311459
311955
  } else {
311956
+ const allowedFormats = getAllowedExportFormats(opts);
311957
+ session.log.debug(`Exporting formats: "${allowedFormats.join('", "')}"`);
311460
311958
  const projectPaths = getProjectPaths(session);
311461
- exportOptionsList = (await Promise.all(projectPaths.map(async (projectPath) => {
311959
+ exportOptionsList = (await Promise.all(projectPaths.map(async (projPath) => {
311462
311960
  try {
311463
- const project = await loadProjectFromDisk(session, projectPath);
311961
+ const project = await loadProjectFromDisk(session, projPath);
311464
311962
  files = filterPages(project).map((page) => page.file);
311465
311963
  } catch (err) {
311466
- session.log.debug(`Unable to load any content from project at: ${projectPath}
311964
+ session.log.debug(`Unable to load any content from project at: ${projPath}
311467
311965
  ${err}`);
311468
311966
  return [];
311469
311967
  }
311470
- const exportOptions = await collectExportOptions(session, files, formats, {
311471
- force,
311472
- projectPath
311968
+ const exportOptions = await collectExportOptions(session, files, allowedFormats, {
311969
+ projectPath: projPath
311473
311970
  });
311474
311971
  return exportOptions;
311475
311972
  }))).flat();
@@ -311498,7 +311995,7 @@ async function build(session, files, opts) {
311498
311995
  });
311499
311996
  if (exportLogList.length === 0) {
311500
311997
  if (!(site || performSiteBuild)) {
311501
- const kinds = Object.entries(opts).filter(([k, v]) => k !== "force" && k !== "output" && k !== "checkLinks" && k !== "site" && v).map(([k]) => k);
311998
+ const kinds = Object.entries(opts).filter(([k, v]) => !["force", "output", "checkLinks", "site", "maxSizeWebp"].includes(k) && v).map(([k]) => k);
311502
311999
  session.log.info(`\u{1F4ED} No file exports${kinds.length > 0 ? ` with kind "${kinds.map(extToKind).join('", "')}"` : ""} found.`);
311503
312000
  if (kinds.length) {
311504
312001
  session.log.info(source_default.dim(`You may need to add an 'exports' field to the frontmatter of the file(s) you wish to export: