mystmd 1.1.36__py3-none-any.whl → 1.1.37__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mystmd
3
- Version: 1.1.36
3
+ Version: 1.1.37
4
4
  Summary: Command line tools for MyST Markdown
5
5
  Home-page: https://github.com/executablebooks/mystmd
6
6
  Author: Franklin Koch
@@ -0,0 +1,9 @@
1
+ mystmd_py/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ mystmd_py/main.py,sha256=_dRwNvYQ3xult25BmsZgXMWe1asD_wuSW8JeWV-S3c0,1411
3
+ mystmd_py/myst.cjs,sha256=-RtQzP98jUGZY-VuxlsgtSnXLxGb2sC1-LfGOPT1fPU,13218580
4
+ mystmd-1.1.37.dist-info/LICENSE,sha256=vgXlcTOVbxYpGiMuE9NqgguIBXAH0hJAktlaxiyZ2wg,1088
5
+ mystmd-1.1.37.dist-info/METADATA,sha256=j5YUSLWWqZogUNpMKCi0JWUGIrmITzXdZSG4gHzwuGU,2601
6
+ mystmd-1.1.37.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
7
+ mystmd-1.1.37.dist-info/entry_points.txt,sha256=eC2ol2gqS2q5E-ktkMrBSvV0tckGUcNGS-c4hEQ-_V4,45
8
+ mystmd-1.1.37.dist-info/top_level.txt,sha256=__Xz3ZzAj4SsfBUP5OFexvriJM7gBwu8L2r3TL6UXKE,10
9
+ mystmd-1.1.37.dist-info/RECORD,,
mystmd_py/myst.cjs CHANGED
@@ -145290,7 +145290,7 @@ var require_node_loaders = __commonJS({
145290
145290
  var Loader = require_loader();
145291
145291
  var _require = require_precompiled_loader();
145292
145292
  var PrecompiledLoader = _require.PrecompiledLoader;
145293
- var chokidar2;
145293
+ var chokidar3;
145294
145294
  var FileSystemLoader = /* @__PURE__ */ function(_Loader) {
145295
145295
  _inheritsLoose(FileSystemLoader2, _Loader);
145296
145296
  function FileSystemLoader2(searchPaths, opts) {
@@ -145310,12 +145310,12 @@ var require_node_loaders = __commonJS({
145310
145310
  }
145311
145311
  if (opts.watch) {
145312
145312
  try {
145313
- chokidar2 = require_chokidar();
145313
+ chokidar3 = require_chokidar();
145314
145314
  } catch (e2) {
145315
145315
  throw new Error("watch requires chokidar to be installed");
145316
145316
  }
145317
145317
  var paths = _this.searchPaths.filter(fs42.existsSync);
145318
- var watcher = chokidar2.watch(paths);
145318
+ var watcher = chokidar3.watch(paths);
145319
145319
  watcher.on("all", function(event, fullname) {
145320
145320
  fullname = path39.resolve(fullname);
145321
145321
  if (event === "change" && fullname in _this.pathsToNames) {
@@ -145364,11 +145364,11 @@ var require_node_loaders = __commonJS({
145364
145364
  _this2.noCache = !!opts.noCache;
145365
145365
  if (opts.watch) {
145366
145366
  try {
145367
- chokidar2 = require_chokidar();
145367
+ chokidar3 = require_chokidar();
145368
145368
  } catch (e2) {
145369
145369
  throw new Error("watch requires chokidar to be installed");
145370
145370
  }
145371
- _this2.watcher = chokidar2.watch();
145371
+ _this2.watcher = chokidar3.watch();
145372
145372
  _this2.watcher.on("change", function(fullname) {
145373
145373
  _this2.emit("update", _this2.pathsToNames[fullname], fullname);
145374
145374
  });
@@ -199098,7 +199098,7 @@ var {
199098
199098
  } = import_index.default;
199099
199099
 
199100
199100
  // src/version.ts
199101
- var version = "1.1.36";
199101
+ var version = "1.1.37";
199102
199102
  var version_default = version;
199103
199103
 
199104
199104
  // ../myst-cli/dist/build/build.js
@@ -200635,13 +200635,26 @@ var ExportFormats;
200635
200635
 
200636
200636
  // ../myst-frontmatter/dist/exports/validators.js
200637
200637
  var EXPORT_KEY_OBJECT = {
200638
- required: ["format"],
200639
- optional: ["template", "output", "id", "name", "renderer", "articles", "sub_articles"],
200638
+ required: [],
200639
+ optional: ["format", "template", "output", "id", "name", "renderer", "articles", "sub_articles"],
200640
200640
  alias: {
200641
200641
  article: "articles",
200642
200642
  sub_article: "sub_articles"
200643
200643
  }
200644
200644
  };
200645
+ var EXT_TO_FORMAT = {
200646
+ ".pdf": ExportFormats.pdf,
200647
+ ".tex": ExportFormats.tex,
200648
+ ".doc": ExportFormats.docx,
200649
+ ".docx": ExportFormats.docx,
200650
+ ".md": ExportFormats.md,
200651
+ ".zip": ExportFormats.meca,
200652
+ ".meca": ExportFormats.meca,
200653
+ ".xml": ExportFormats.xml,
200654
+ ".jats": ExportFormats.xml,
200655
+ ".typ": ExportFormats.typst,
200656
+ ".typst": ExportFormats.typst
200657
+ };
200645
200658
  var RESERVED_EXPORT_KEYS = [
200646
200659
  ...EXPORT_KEY_OBJECT.required,
200647
200660
  ...EXPORT_KEY_OBJECT.optional,
@@ -200669,10 +200682,26 @@ function validateExportFormat(input3, opts) {
200669
200682
  }
200670
200683
  function validateExport(input3, opts) {
200671
200684
  if (typeof input3 === "string") {
200672
- const format2 = validateExportFormat(input3, opts);
200673
- if (!format2)
200674
- return void 0;
200675
- input3 = { format: format2 };
200685
+ let format2;
200686
+ let output3;
200687
+ if (input3.includes(".")) {
200688
+ Object.entries(EXT_TO_FORMAT).forEach(([ext2, fmt]) => {
200689
+ if (input3 === ext2) {
200690
+ format2 = fmt;
200691
+ } else if (input3.endsWith(ext2)) {
200692
+ output3 = input3;
200693
+ }
200694
+ });
200695
+ if (!format2 && !output3) {
200696
+ output3 = input3;
200697
+ }
200698
+ }
200699
+ if (!format2 && !output3) {
200700
+ format2 = validateExportFormat(input3, opts);
200701
+ if (!format2)
200702
+ return void 0;
200703
+ }
200704
+ input3 = { format: format2, output: output3 };
200676
200705
  }
200677
200706
  const value = validateObjectKeys(input3, EXPORT_KEY_OBJECT, {
200678
200707
  ...opts,
@@ -200681,42 +200710,59 @@ function validateExport(input3, opts) {
200681
200710
  });
200682
200711
  if (value === void 0)
200683
200712
  return void 0;
200684
- const format = validateExportFormat(value.format, incrementOptions("format", opts));
200685
- if (format === void 0)
200686
- return void 0;
200687
- const output2 = { ...value, format };
200713
+ let format;
200714
+ let output2;
200715
+ let template;
200688
200716
  if (value.template === null) {
200689
- output2.template = null;
200717
+ template = null;
200690
200718
  } else if (defined(value.template)) {
200691
- output2.template = validateString(value.template, incrementOptions("template", opts));
200719
+ template = validateString(value.template, incrementOptions("template", opts));
200692
200720
  }
200693
200721
  if (defined(value.output)) {
200694
- output2.output = validateString(value.output, incrementOptions("output", opts));
200722
+ output2 = validateString(value.output, incrementOptions("output", opts));
200695
200723
  }
200724
+ if (defined(value.format)) {
200725
+ format = validateExportFormat(value.format, incrementOptions("format", opts));
200726
+ if (!format)
200727
+ return void 0;
200728
+ } else if (output2) {
200729
+ Object.entries(EXT_TO_FORMAT).forEach(([ext2, fmt]) => {
200730
+ if (output2 === null || output2 === void 0 ? void 0 : output2.endsWith(ext2))
200731
+ format = fmt;
200732
+ });
200733
+ if (!format) {
200734
+ return validationError(`unable to infer export format from export: ${output2}`, opts);
200735
+ }
200736
+ } else {
200737
+ return validationError("unable to determine export format", opts);
200738
+ }
200739
+ if (format === void 0 && template === void 0)
200740
+ return void 0;
200741
+ const validExport = { ...value, format, output: output2, template };
200696
200742
  if (defined(value.articles)) {
200697
200743
  const articles = validateList(value.articles, { coerce: true, ...incrementOptions("articles", opts) }, (item, ind) => validateString(item, incrementOptions(`articles.${ind}`, opts)));
200698
- if ((articles === null || articles === void 0 ? void 0 : articles.length) && articles.length > 1 && ![ExportFormats.pdf, ExportFormats.tex, ExportFormats.pdftex].includes(output2.format)) {
200699
- if (output2.format === ExportFormats.xml && !defined(value.sub_articles)) {
200744
+ if ((articles === null || articles === void 0 ? void 0 : articles.length) && articles.length > 1 && validExport.format && ![ExportFormats.pdf, ExportFormats.tex, ExportFormats.pdftex].includes(validExport.format)) {
200745
+ if (validExport.format === ExportFormats.xml && !defined(value.sub_articles)) {
200700
200746
  validationError("multiple articles are not supported for 'jats' export - instead specify one article with additional sub_articles", opts);
200701
200747
  } else {
200702
200748
  validationError("multiple articles are only supported for 'tex' and 'pdf' exports", opts);
200703
200749
  }
200704
- output2.articles = [articles[0]];
200750
+ validExport.articles = [articles[0]];
200705
200751
  } else {
200706
- output2.articles = articles;
200752
+ validExport.articles = articles;
200707
200753
  }
200708
200754
  }
200709
200755
  if (defined(value.sub_articles)) {
200710
- if (output2.format !== ExportFormats.xml) {
200756
+ if (validExport.format !== ExportFormats.xml) {
200711
200757
  validationError("sub_articles are only supported for 'jats' export", opts);
200712
- output2.sub_articles = void 0;
200758
+ validExport.sub_articles = void 0;
200713
200759
  } else {
200714
- output2.sub_articles = validateList(value.sub_articles, { coerce: true, ...incrementOptions("sub_articles", opts) }, (file, ind) => {
200760
+ validExport.sub_articles = validateList(value.sub_articles, { coerce: true, ...incrementOptions("sub_articles", opts) }, (file, ind) => {
200715
200761
  return validateString(file, incrementOptions(`sub_articles.${ind}`, opts));
200716
200762
  });
200717
200763
  }
200718
200764
  }
200719
- return output2;
200765
+ return validExport;
200720
200766
  }
200721
200767
 
200722
200768
  // ../myst-frontmatter/dist/funding/validators.js
@@ -240762,6 +240808,8 @@ function blockToFigureTransform(mdast2, opts) {
240762
240808
  function codeTransform(mdast2, file, opts) {
240763
240809
  const code7 = selectAll("code", mdast2);
240764
240810
  code7.forEach((node3) => {
240811
+ if (node3.lang === "")
240812
+ return;
240765
240813
  if (!node3.lang) {
240766
240814
  if (!(opts === null || opts === void 0 ? void 0 : opts.lang)) {
240767
240815
  fileWarn(file, "Language is not defined for code block", {
@@ -242235,12 +242283,15 @@ function getFrontmatter(file, tree, opts = { removeYaml: true, removeHeading: tr
242235
242283
  var selectors_exports = {};
242236
242284
  __export(selectors_exports, {
242237
242285
  selectAffiliation: () => selectAffiliation,
242286
+ selectAllDependencies: () => selectAllDependencies,
242238
242287
  selectCurrentProjectConfig: () => selectCurrentProjectConfig,
242239
242288
  selectCurrentProjectFile: () => selectCurrentProjectFile,
242240
242289
  selectCurrentProjectPath: () => selectCurrentProjectPath,
242241
242290
  selectCurrentSiteConfig: () => selectCurrentSiteConfig,
242242
242291
  selectCurrentSiteFile: () => selectCurrentSiteFile,
242243
242292
  selectCurrentSitePath: () => selectCurrentSitePath,
242293
+ selectDependentFiles: () => selectDependentFiles,
242294
+ selectFileDependencies: () => selectFileDependencies,
242244
242295
  selectFileInfo: () => selectFileInfo,
242245
242296
  selectFileWarnings: () => selectFileWarnings,
242246
242297
  selectFileWarningsByRule: () => selectFileWarningsByRule,
@@ -242329,6 +242380,26 @@ function selectFileInfo(state, path39) {
242329
242380
  dataUrl
242330
242381
  };
242331
242382
  }
242383
+ function selectFileDependencies(state, path39) {
242384
+ var _a6, _b;
242385
+ return (_b = (_a6 = state.local.watch.files[(0, import_node_path4.resolve)(path39)]) === null || _a6 === void 0 ? void 0 : _a6.localDependencies) !== null && _b !== void 0 ? _b : [];
242386
+ }
242387
+ function selectAllDependencies(state, projectPath) {
242388
+ return Object.entries(state.local.watch.files).filter(([file]) => !projectPath || file.startsWith((0, import_node_path4.resolve)(projectPath))).map(([, value]) => {
242389
+ var _a6;
242390
+ return (_a6 = value.localDependencies) !== null && _a6 !== void 0 ? _a6 : [];
242391
+ }).flat();
242392
+ }
242393
+ function selectDependentFiles(state, path39) {
242394
+ const dependentFiles = [];
242395
+ Object.entries(state.local.watch.files).forEach(([key2, value]) => {
242396
+ var _a6;
242397
+ if ((_a6 = value.localDependencies) === null || _a6 === void 0 ? void 0 : _a6.includes((0, import_node_path4.resolve)(path39))) {
242398
+ dependentFiles.push(key2);
242399
+ }
242400
+ });
242401
+ return dependentFiles;
242402
+ }
242332
242403
  function selectPageSlug(state, projectPath, path39) {
242333
242404
  const project = selectLocalProject(state, projectPath);
242334
242405
  if (!project)
@@ -242423,6 +242494,14 @@ var watch = (0, import_toolkit.createSlice)({
242423
242494
  const { path: path39, sha256 = null } = action.payload;
242424
242495
  state.files[(0, import_node_path5.resolve)(path39)] = { ...state.files[(0, import_node_path5.resolve)(path39)], sha256 };
242425
242496
  },
242497
+ addLocalDependency(state, action) {
242498
+ var _a6;
242499
+ const { path: path39, dependency } = action.payload;
242500
+ const existingDeps = [...(_a6 = state.files[(0, import_node_path5.resolve)(path39)].localDependencies) !== null && _a6 !== void 0 ? _a6 : []];
242501
+ if (!existingDeps.includes(dependency)) {
242502
+ state.files[(0, import_node_path5.resolve)(path39)].localDependencies = [...existingDeps, dependency];
242503
+ }
242504
+ },
242426
242505
  updateFileInfo(state, action) {
242427
242506
  const { path: path39, sha256, title, short_title, description, date, thumbnail, thumbnailOptimized, banner, bannerOptimized, tags, url, dataUrl } = action.payload;
242428
242507
  const resolvedPath = (0, import_node_path5.resolve)(path39);
@@ -282832,8 +282911,7 @@ var codeDirective = {
282832
282911
  var codeCellDirective = {
282833
282912
  name: "code-cell",
282834
282913
  arg: {
282835
- type: String,
282836
- required: true
282914
+ type: String
282837
282915
  },
282838
282916
  options: {
282839
282917
  tags: {
@@ -282844,25 +282922,25 @@ var codeCellDirective = {
282844
282922
  type: String
282845
282923
  },
282846
282924
  run(data, vfile2) {
282847
- var _a6, _b, _c, _d2;
282925
+ var _a6, _b, _c, _d2, _e;
282848
282926
  const code7 = {
282849
282927
  type: "code",
282850
282928
  lang: data.arg,
282851
282929
  executable: true,
282852
- value: data.body
282930
+ value: (_a6 = data.body) !== null && _a6 !== void 0 ? _a6 : ""
282853
282931
  };
282854
282932
  let tags;
282855
- if (typeof ((_a6 = data.options) === null || _a6 === void 0 ? void 0 : _a6.tags) === "string") {
282933
+ if (typeof ((_b = data.options) === null || _b === void 0 ? void 0 : _b.tags) === "string") {
282856
282934
  try {
282857
282935
  tags = js_yaml_default.load(data.options.tags);
282858
282936
  } catch (error) {
282859
282937
  fileError(vfile2, "Could not load tags for code-cell directive", {
282860
- node: (_b = select('mystDirectiveOption[name="tags"]', data.node)) !== null && _b !== void 0 ? _b : data.node,
282938
+ node: (_c = select('mystDirectiveOption[name="tags"]', data.node)) !== null && _c !== void 0 ? _c : data.node,
282861
282939
  source: "code-cell:tags",
282862
282940
  ruleId: RuleId.directiveOptionsCorrect
282863
282941
  });
282864
282942
  }
282865
- } else if (((_c = data.options) === null || _c === void 0 ? void 0 : _c.tags) && Array.isArray(data.options.tags)) {
282943
+ } else if (((_d2 = data.options) === null || _d2 === void 0 ? void 0 : _d2.tags) && Array.isArray(data.options.tags)) {
282866
282944
  tags = data.options.tags;
282867
282945
  }
282868
282946
  if (tags && Array.isArray(tags) && tags.every((t2) => typeof t2 === "string")) {
@@ -282871,12 +282949,25 @@ var codeCellDirective = {
282871
282949
  }
282872
282950
  } else if (tags) {
282873
282951
  fileWarn(vfile2, "tags in code-cell directive must be a list of strings", {
282874
- node: (_d2 = select('mystDirectiveOption[name="tags"]', data.node)) !== null && _d2 !== void 0 ? _d2 : data.node,
282952
+ node: (_e = select('mystDirectiveOption[name="tags"]', data.node)) !== null && _e !== void 0 ? _e : data.node,
282875
282953
  source: "code-cell:tags",
282876
282954
  ruleId: RuleId.directiveOptionsCorrect
282877
282955
  });
282878
282956
  }
282879
- return [code7];
282957
+ const output2 = {
282958
+ type: "output",
282959
+ id: nanoid(),
282960
+ data: []
282961
+ };
282962
+ const block5 = {
282963
+ type: "block",
282964
+ meta: void 0,
282965
+ children: [code7, output2],
282966
+ data: {
282967
+ type: "notebook-code"
282968
+ }
282969
+ };
282970
+ return [block5];
282880
282971
  }
282881
282972
  };
282882
282973
 
@@ -283394,7 +283485,7 @@ var tableDirective = {
283394
283485
  type: "myst",
283395
283486
  required: true
283396
283487
  },
283397
- run(data, vfile2) {
283488
+ run(data) {
283398
283489
  var _a6, _b;
283399
283490
  const children = [];
283400
283491
  if (data.arg) {
@@ -283403,13 +283494,6 @@ var tableDirective = {
283403
283494
  children: [{ type: "paragraph", children: data.arg }]
283404
283495
  });
283405
283496
  }
283406
- const body3 = data.body;
283407
- if (!select("table", { type: "root", children: body3 })) {
283408
- fileError(vfile2, "table directive does not include a markdown table in the body", {
283409
- node: data.node,
283410
- ruleId: RuleId.directiveBodyCorrect
283411
- });
283412
- }
283413
283497
  children.push(...data.body);
283414
283498
  const { label, identifier } = normalizeLabel((_a6 = data.options) === null || _a6 === void 0 ? void 0 : _a6.label) || {};
283415
283499
  const container4 = {
@@ -285736,7 +285820,7 @@ var import_node_path15 = __toESM(require("path"), 1);
285736
285820
  var import_nbtx = __toESM(require_cjs2(), 1);
285737
285821
 
285738
285822
  // ../myst-cli/dist/version.js
285739
- var version2 = "1.1.36";
285823
+ var version2 = "1.1.37";
285740
285824
  var version_default2 = version2;
285741
285825
 
285742
285826
  // ../myst-cli/dist/utils/headers.js
@@ -286276,6 +286360,8 @@ async function writeBase64(session, writeFolder, data, contentType) {
286276
286360
  const file = `${hash}${ext2}`;
286277
286361
  const filePath = import_node_path15.default.join(writeFolder, file);
286278
286362
  session.log.debug(`Writing binary output file ${justData.length} bytes to ${filePath}`);
286363
+ if (!import_node_fs10.default.existsSync(writeFolder))
286364
+ import_node_fs10.default.mkdirSync(writeFolder, { recursive: true });
286279
286365
  import_node_fs10.default.writeFileSync(filePath, justData, {
286280
286366
  encoding: "base64"
286281
286367
  });
@@ -286719,12 +286805,6 @@ async function transformDeleteBase64UrlSource(mdast2) {
286719
286805
  }
286720
286806
 
286721
286807
  // ../myst-cli/dist/process/notebook.js
286722
- function createOutputDirective() {
286723
- const id = nanoid();
286724
- return { myst: `\`\`\`{output}
286725
- :id: ${id}
286726
- \`\`\``, id };
286727
- }
286728
286808
  function blockParent(cell3, children) {
286729
286809
  const type2 = cell3.cell_type === import_nbtx2.CELL_TYPES.code ? NotebookCell.code : NotebookCell.content;
286730
286810
  return { type: "block", meta: JSON.stringify({ type: type2, ...cell3.metadata }), children };
@@ -286768,7 +286848,6 @@ async function processNotebook(session, file, content3, opts) {
286768
286848
  const language = (_b = (_a6 = metadata === null || metadata === void 0 ? void 0 : metadata.kernelspec) === null || _a6 === void 0 ? void 0 : _a6.language) !== null && _b !== void 0 ? _b : "python";
286769
286849
  log.debug(`Processing Notebook: "${file}"`);
286770
286850
  const cache = castSession(session);
286771
- const outputMap = {};
286772
286851
  let end = cells2.length;
286773
286852
  if (cells2 && cells2.length > 1 && (cells2 === null || cells2 === void 0 ? void 0 : cells2[cells2.length - 1].source.length) === 0) {
286774
286853
  end = -1;
@@ -286788,34 +286867,34 @@ async function processNotebook(session, file, content3, opts) {
286788
286867
  return acc.concat(blockParent(cell3, cellMdast.children));
286789
286868
  }
286790
286869
  if (cell3.cell_type === import_nbtx2.CELL_TYPES.raw) {
286791
- const cellContent = `\`\`\`
286792
- ${(0, import_nbtx2.ensureString)(cell3.source)}
286793
- \`\`\``;
286794
- const cellMdast = parseMyst(session, cellContent, file);
286795
- return acc.concat(blockParent(cell3, cellMdast.children));
286870
+ const raw2 = {
286871
+ type: "code",
286872
+ lang: "",
286873
+ value: (0, import_nbtx2.ensureString)(cell3.source)
286874
+ };
286875
+ return acc.concat(blockParent(cell3, [raw2]));
286796
286876
  }
286797
286877
  if (cell3.cell_type === import_nbtx2.CELL_TYPES.code) {
286798
- const cellCodeContent = `\`\`\`{code-cell} ${language}
286799
- ${(0, import_nbtx2.ensureString)(cell3.source)}
286800
- \`\`\``;
286801
- const cellCodeMdast = parseMyst(session, cellCodeContent, file);
286802
- const { myst: myst2, id } = createOutputDirective();
286878
+ const code7 = {
286879
+ type: "code",
286880
+ lang: language,
286881
+ executable: true,
286882
+ value: (0, import_nbtx2.ensureString)(cell3.source)
286883
+ };
286884
+ const output2 = {
286885
+ type: "output",
286886
+ id: nanoid(),
286887
+ data: []
286888
+ };
286803
286889
  if (cell3.outputs && cell3.outputs.length > 0) {
286804
286890
  const minified = await (0, import_nbtx2.minifyCellOutput)(cell3.outputs, cache.$outputs, { computeHash, maxCharacters: opts === null || opts === void 0 ? void 0 : opts.minifyMaxCharacters });
286805
- outputMap[id] = minified;
286806
- } else {
286807
- outputMap[id] = [];
286891
+ output2.data = minified;
286808
286892
  }
286809
- const cellOutputMdast = parseMyst(session, myst2, file);
286810
- return acc.concat(blockParent(cell3, [...cellCodeMdast.children, ...cellOutputMdast.children]));
286893
+ return acc.concat(blockParent(cell3, [code7, output2]));
286811
286894
  }
286812
286895
  return acc;
286813
286896
  }, Promise.resolve([])));
286814
- const mdast2 = { type: "root", children: items };
286815
- selectAll("output", mdast2).forEach((output2) => {
286816
- output2.data = outputMap[output2.id];
286817
- });
286818
- return mdast2;
286897
+ return { type: "root", children: items };
286819
286898
  }
286820
286899
 
286821
286900
  // ../myst-cli/dist/process/file.js
@@ -296120,6 +296199,30 @@ function propagateBlockDataToCode(session, vfile2, mdast2) {
296120
296199
  outputNode.visibility = "show";
296121
296200
  });
296122
296201
  }
296202
+ function transformLiftCodeBlocksInJupytext(mdast2) {
296203
+ const flattened = mdast2.children.reduce((acc, node3) => {
296204
+ var _a6, _b;
296205
+ if (node3.type !== "block" || !node3.children)
296206
+ return [...acc, node3];
296207
+ const buriedCodeCells = selectAll("block:has(block)", node3);
296208
+ if (buriedCodeCells.length === 0)
296209
+ return [...acc, node3];
296210
+ const newBlocks = [{ ...node3, children: [] }];
296211
+ (_a6 = node3.children) === null || _a6 === void 0 ? void 0 : _a6.forEach((child) => {
296212
+ var _a7, _b2, _c, _d2;
296213
+ if (child.type === "block" && ((_a7 = child.children) === null || _a7 === void 0 ? void 0 : _a7.length) === 2 && ((_b2 = child.children) === null || _b2 === void 0 ? void 0 : _b2[0].type) === "code" && ((_c = child.children) === null || _c === void 0 ? void 0 : _c[1].type) === "output") {
296214
+ newBlocks.push(child);
296215
+ newBlocks.push({ type: "block", children: [] });
296216
+ return;
296217
+ }
296218
+ (_d2 = newBlocks[newBlocks.length - 1].children) === null || _d2 === void 0 ? void 0 : _d2.push(child);
296219
+ });
296220
+ if (((_b = newBlocks[newBlocks.length - 1].children) === null || _b === void 0 ? void 0 : _b.length) === 0)
296221
+ newBlocks.pop();
296222
+ return [...acc, ...newBlocks];
296223
+ }, []);
296224
+ mdast2.children = flattened;
296225
+ }
296123
296226
 
296124
296227
  // ../myst-cli/dist/transforms/dois.js
296125
296228
  async function getDoiOrgBibtex(log, doiString) {
@@ -296273,7 +296376,7 @@ var filter2 = (
296273
296376
  );
296274
296377
 
296275
296378
  // ../myst-cli/dist/transforms/embed.js
296276
- function embedTransform(session, mdast2, dependencies, state) {
296379
+ function embedTransform(session, mdast2, file, dependencies, state) {
296277
296380
  const embedNodes = selectAll("embed", mdast2);
296278
296381
  embedNodes.forEach((node3) => {
296279
296382
  var _a6, _b, _c, _d2;
@@ -296311,12 +296414,16 @@ function embedTransform(session, mdast2, dependencies, state) {
296311
296414
  const multiState = state;
296312
296415
  if (!multiState.states)
296313
296416
  return;
296314
- const { url, file } = (_b = multiState.resolveStateProvider(normalized.identifier)) !== null && _b !== void 0 ? _b : {};
296417
+ const { url, file: depFile } = (_b = multiState.resolveStateProvider(normalized.identifier)) !== null && _b !== void 0 ? _b : {};
296315
296418
  if (!url)
296316
296419
  return;
296317
296420
  const source2 = { url, label: (_c = node3.source) === null || _c === void 0 ? void 0 : _c.label };
296318
- if (file) {
296319
- const { kind, slug, frontmatter, location: location4 } = (_d2 = selectFile(session, file)) !== null && _d2 !== void 0 ? _d2 : {};
296421
+ if (depFile) {
296422
+ session.store.dispatch(watch.actions.addLocalDependency({
296423
+ path: file,
296424
+ dependency: depFile
296425
+ }));
296426
+ const { kind, slug, frontmatter, location: location4 } = (_d2 = selectFile(session, depFile)) !== null && _d2 !== void 0 ? _d2 : {};
296320
296427
  if (kind)
296321
296428
  source2.kind = kind;
296322
296429
  if (slug)
@@ -296370,6 +296477,10 @@ async function includeFilesTransform(session, baseFile, tree, vfile2) {
296370
296477
  });
296371
296478
  return;
296372
296479
  }
296480
+ session.store.dispatch(watch.actions.addLocalDependency({
296481
+ path: baseFile,
296482
+ dependency: fullFile
296483
+ }));
296373
296484
  return import_node_fs23.default.readFileSync(fullFile).toString();
296374
296485
  };
296375
296486
  const parseContent = (filename, content3) => {
@@ -296766,13 +296877,28 @@ function renderExpression(node3, file) {
296766
296877
  const result = node3.result;
296767
296878
  if (!result)
296768
296879
  return [];
296880
+ let content3;
296769
296881
  if (result.status === "ok") {
296770
- if (result.data["text/latex"]) {
296771
- return [{ type: "inlineMath", value: processLatex(result.data["text/latex"]) }];
296772
- }
296773
- if (result.data["text/plain"]) {
296774
- return [{ type: "text", value: result.data["text/plain"] }];
296775
- }
296882
+ Object.entries(result.data).forEach(([mimeType, value]) => {
296883
+ if (content3) {
296884
+ return;
296885
+ } else if (mimeType.startsWith("image/")) {
296886
+ content3 = [
296887
+ {
296888
+ type: "image",
296889
+ url: `data:${mimeType}${BASE64_HEADER_SPLIT}${value}`
296890
+ }
296891
+ ];
296892
+ } else if (mimeType === "text/latex") {
296893
+ content3 = [{ type: "inlineMath", value: processLatex(value) }];
296894
+ } else if (mimeType === "text/html") {
296895
+ content3 = [{ type: "html", value }];
296896
+ } else if (mimeType === "text/plain") {
296897
+ content3 = [{ type: "text", value }];
296898
+ }
296899
+ });
296900
+ if (content3)
296901
+ return content3;
296776
296902
  fileWarn(file, "Unrecognized mime bundle for inline content", {
296777
296903
  node: node3,
296778
296904
  ruleId: RuleId.inlineExpressionRenders
@@ -296781,6 +296907,7 @@ function renderExpression(node3, file) {
296781
296907
  return [];
296782
296908
  }
296783
296909
  function transformInlineExpressions(mdast2, file) {
296910
+ blockMetadataTransform(mdast2, file);
296784
296911
  const blocks2 = selectAll("block", mdast2).filter((node3) => {
296785
296912
  var _a6, _b;
296786
296913
  return ((_a6 = node3.data) === null || _a6 === void 0 ? void 0 : _a6.type) === NotebookCell.content && ((_b = node3.data) === null || _b === void 0 ? void 0 : _b[metadataSection]);
@@ -296790,14 +296917,14 @@ function transformInlineExpressions(mdast2, file) {
296790
296917
  var _a6;
296791
296918
  const userExpressions = (_a6 = node3.data) === null || _a6 === void 0 ? void 0 : _a6[metadataSection];
296792
296919
  const inlineNodes = selectAll("inlineExpression", node3);
296793
- inlineNodes.forEach((inlineExpression2) => {
296794
- const data = findExpression(userExpressions, inlineExpression2.value);
296920
+ inlineNodes.forEach((inlineExpression3) => {
296921
+ const data = findExpression(userExpressions, inlineExpression3.value);
296795
296922
  if (!data)
296796
296923
  return;
296797
296924
  count2 += 1;
296798
- inlineExpression2.identifier = `eval-${count2}`;
296799
- inlineExpression2.result = data.result;
296800
- inlineExpression2.children = renderExpression(inlineExpression2, file);
296925
+ inlineExpression3.identifier = `eval-${count2}`;
296926
+ inlineExpression3.result = data.result;
296927
+ inlineExpression3.children = renderExpression(inlineExpression3, file);
296801
296928
  });
296802
296929
  });
296803
296930
  }
@@ -296870,9 +296997,9 @@ async function transformMdast(session, opts) {
296870
296997
  importMdastFromJson(session, file, mdast2);
296871
296998
  await includeFilesTransform(session, file, mdast2, vfile2);
296872
296999
  liftCodeMetadataToBlock(session, vfile2, mdast2);
296873
- const pipe = unified().use(reconstructHtmlPlugin).use(htmlPlugin, { htmlHandlers }).use(basicTransformationsPlugin, {
297000
+ const pipe = unified().use(reconstructHtmlPlugin).use(inlineExpressionsPlugin).use(htmlPlugin, { htmlHandlers }).use(basicTransformationsPlugin, {
296874
297001
  parser: (content3) => parseMyst(session, content3, file)
296875
- }).use(inlineExpressionsPlugin).use(inlineMathSimplificationPlugin).use(mathPlugin, { macros: frontmatter.math }).use(glossaryPlugin, { state }).use(abbreviationPlugin, { abbreviations: frontmatter.abbreviations }).use(enumerateTargetsPlugin, { state }).use(joinGatesPlugin);
297002
+ }).use(inlineMathSimplificationPlugin).use(mathPlugin, { macros: frontmatter.math }).use(glossaryPlugin, { state }).use(abbreviationPlugin, { abbreviations: frontmatter.abbreviations }).use(enumerateTargetsPlugin, { state }).use(joinGatesPlugin);
296876
297003
  (_c = session.plugins) === null || _c === void 0 ? void 0 : _c.transforms.forEach((t2) => {
296877
297004
  if (t2.stage !== "document")
296878
297005
  return;
@@ -296904,13 +297031,16 @@ async function transformMdast(session, opts) {
296904
297031
  await unified().use(codePlugin, { lang: (_d2 = frontmatter === null || frontmatter === void 0 ? void 0 : frontmatter.kernelspec) === null || _d2 === void 0 ? void 0 : _d2.language }).use(footnotesPlugin).run(mdast2, vfile2);
296905
297032
  transformImagesToEmbed(mdast2);
296906
297033
  transformImagesWithoutExt(session, mdast2, file, { imageExtensions });
297034
+ const isJupytext = frontmatter.kernelspec || frontmatter.jupytext;
297035
+ if (isJupytext)
297036
+ transformLiftCodeBlocksInJupytext(mdast2);
296907
297037
  const sha256 = selectors_exports.selectFileInfo(store.getState(), file).sha256;
296908
297038
  const useSlug = pageSlug !== index4;
296909
297039
  const url = projectSlug ? `/${projectSlug}/${useSlug ? pageSlug : ""}` : `/${useSlug ? pageSlug : ""}`;
296910
297040
  const dataUrl = projectSlug ? `/${projectSlug}/${pageSlug}.json` : `/${pageSlug}.json`;
296911
297041
  updateFileInfoFromFrontmatter(session, file, frontmatter, url, dataUrl);
296912
297042
  const data = {
296913
- kind: frontmatter.kernelspec || frontmatter.jupytext ? SourceFileKind.Notebook : kind,
297043
+ kind: isJupytext ? SourceFileKind.Notebook : kind,
296914
297044
  file,
296915
297045
  location: location4,
296916
297046
  sha256,
@@ -296955,7 +297085,7 @@ async function postProcessMdast(session, { file, checkLinks, pageReferenceStates
296955
297085
  selector: LINKS_SELECTOR
296956
297086
  });
296957
297087
  resolveReferencesTransform(mdast2, state.file, { state });
296958
- embedTransform(session, mdast2, dependencies, state);
297088
+ embedTransform(session, mdast2, file, dependencies, state);
296959
297089
  const pipe = unified();
296960
297090
  (_a6 = session.plugins) === null || _a6 === void 0 ? void 0 : _a6.transforms.forEach((t2) => {
296961
297091
  if (t2.stage !== "project")
@@ -297373,18 +297503,39 @@ async function fileProcessor(session, file, eventType, siteProject, serverReload
297373
297503
  session.log.warn(`\u26A0\uFE0F No local project path for file: ${file}`);
297374
297504
  return;
297375
297505
  }
297506
+ const projectPath = siteProject.path;
297376
297507
  const pageSlug = selectors_exports.selectPageSlug(session.store.getState(), siteProject.path, file);
297377
- if (!pageSlug) {
297508
+ const dependencies = selectors_exports.selectDependentFiles(session.store.getState(), file);
297509
+ if (!pageSlug && dependencies.length === 0) {
297378
297510
  session.log.warn(`\u26A0\uFE0F File is not in project: ${file}`);
297379
297511
  return;
297380
297512
  }
297381
- await fastProcessFile(session, {
297382
- file,
297383
- projectPath: siteProject.path,
297384
- projectSlug: siteProject.slug,
297385
- pageSlug,
297386
- ...opts
297387
- });
297513
+ if (pageSlug) {
297514
+ await fastProcessFile(session, {
297515
+ file,
297516
+ projectPath,
297517
+ projectSlug: siteProject.slug,
297518
+ pageSlug,
297519
+ ...opts
297520
+ });
297521
+ }
297522
+ if (dependencies.length) {
297523
+ session.log.info(`\u{1F504} Updating dependent pages`);
297524
+ await Promise.all([
297525
+ dependencies.map((dep) => {
297526
+ const depSlug = selectors_exports.selectPageSlug(session.store.getState(), projectPath, dep);
297527
+ if (!depSlug)
297528
+ return void 0;
297529
+ return fastProcessFile(session, {
297530
+ file: dep,
297531
+ projectPath,
297532
+ projectSlug: siteProject.slug,
297533
+ pageSlug: depSlug,
297534
+ ...opts
297535
+ });
297536
+ })
297537
+ ]);
297538
+ }
297388
297539
  serverReload();
297389
297540
  }
297390
297541
  function watchProcessor(operation, session, siteProject, serverReload, opts) {
@@ -297413,10 +297564,11 @@ function watchProcessor(operation, session, siteProject, serverReload, opts) {
297413
297564
  };
297414
297565
  }
297415
297566
  function watchContent(session, serverReload, opts) {
297416
- const siteConfig = selectors_exports.selectCurrentSiteConfig(session.store.getState());
297567
+ const state = session.store.getState();
297568
+ const siteConfig = selectors_exports.selectCurrentSiteConfig(state);
297417
297569
  if (!(siteConfig === null || siteConfig === void 0 ? void 0 : siteConfig.projects))
297418
297570
  return;
297419
- const siteConfigFile = selectors_exports.selectCurrentSiteFile(session.store.getState());
297571
+ const siteConfigFile = selectors_exports.selectCurrentSiteFile(state);
297420
297572
  const localProjects = siteConfig.projects.filter((proj) => {
297421
297573
  return Boolean(proj.path);
297422
297574
  });
@@ -297424,7 +297576,8 @@ function watchContent(session, serverReload, opts) {
297424
297576
  const ignored = proj.path === "." ? localProjects.filter(({ path: path39 }) => path39 !== ".").map(({ path: path39 }) => (0, import_node_path35.join)(path39, "*")) : [];
297425
297577
  if (siteConfigFile)
297426
297578
  ignored.push(siteConfigFile);
297427
- import_chokidar.default.watch(proj.path, {
297579
+ const dependencies = new Set(selectors_exports.selectAllDependencies(state, proj.path));
297580
+ import_chokidar.default.watch([proj.path, ...dependencies], {
297428
297581
  ignoreInitial: true,
297429
297582
  ignored: ["public", "**/_build/**", "**/.git/**", ...ignored],
297430
297583
  awaitWriteFinish: { stabilityThreshold: 100, pollInterval: 50 }
@@ -297650,6 +297803,7 @@ async function buildHtml(session, opts) {
297650
297803
 
297651
297804
  // ../myst-cli/dist/build/utils/localArticleExport.js
297652
297805
  var import_node_path51 = __toESM(require("path"), 1);
297806
+ var import_chokidar2 = __toESM(require_chokidar(), 1);
297653
297807
 
297654
297808
  // ../myst-cli/dist/build/utils/resolveAndLogErrors.js
297655
297809
  async function resolveAndLogErrors(session, promises, throwOnFailure) {
@@ -299011,6 +299165,16 @@ var handlers3 = {
299011
299165
  } else {
299012
299166
  state.write(`\\qty{${node3.number}}{${(_d2 = (_c = node3.units) === null || _c === void 0 ? void 0 : _c.map((u3) => `\\${u3}`).join("")) !== null && _d2 !== void 0 ? _d2 : ""}}`);
299013
299167
  }
299168
+ },
299169
+ inlineExpression(node3, state) {
299170
+ var _a6;
299171
+ if ((_a6 = node3.children) === null || _a6 === void 0 ? void 0 : _a6.length) {
299172
+ state.renderChildren(node3, true);
299173
+ } else {
299174
+ state.write("\\texttt{");
299175
+ state.text(node3.value, false);
299176
+ state.write("}");
299177
+ }
299014
299178
  }
299015
299179
  };
299016
299180
  var TexSerializer = class {
@@ -299395,14 +299559,14 @@ async function localArticleToTexTemplated(session, file, templateOptions, projec
299395
299559
  const state = session.store.getState();
299396
299560
  frontmatter = (_a6 = selectors_exports.selectLocalProjectConfig(state, projectPath !== null && projectPath !== void 0 ? projectPath : ".")) !== null && _a6 !== void 0 ? _a6 : {};
299397
299561
  const { dir, name: name2, ext: ext2 } = import_node_path43.default.parse(output2);
299398
- const includeFileBases = results.map((result, ind) => {
299562
+ const includeFilenames = results.map((result, ind) => {
299399
299563
  var _a7, _b;
299400
- const base5 = `${name2}-${(_b = (_a7 = content3[ind]) === null || _a7 === void 0 ? void 0 : _a7.slug) !== null && _b !== void 0 ? _b : ind}${ext2}`;
299401
- const includeFile = import_node_path43.default.format({ dir, ext: ext2, base: base5 });
299564
+ const includeFilename = `${name2}-${(_b = (_a7 = content3[ind]) === null || _a7 === void 0 ? void 0 : _a7.slug) !== null && _b !== void 0 ? _b : ind}`;
299565
+ const includeFile = import_node_path43.default.format({ dir, ext: ext2, base: `${includeFilename}${ext2}` });
299402
299566
  writeFileToFolder(includeFile, result.value);
299403
- return base5;
299567
+ return includeFilename;
299404
299568
  });
299405
- texContent = includeFileBases.map((base5) => `\\include{${base5}}`).join("\n");
299569
+ texContent = includeFilenames.map((base5) => `\\include{${base5}}`).join("\n");
299406
299570
  }
299407
299571
  session.log.info(toc(`\u{1F4D1} Exported TeX in %s, copying to ${output2}`));
299408
299572
  const { preamble, suffix } = generatePreamble(preambleData);
@@ -299468,26 +299632,52 @@ var containerHandler2 = (node3, state) => {
299468
299632
  state.ensureNewLine();
299469
299633
  const prevState = state.data.isInFigure;
299470
299634
  state.data.isInFigure = true;
299471
- const { label } = node3;
299472
- const caption3 = select("caption", node3);
299473
- const image6 = select("image", node3);
299474
- if (!image6) {
299475
- fileError(state.file, `Figure only supports image children at the moment!`, {
299635
+ const { label, kind } = node3;
299636
+ const captions = selectAll("caption,legend", node3);
299637
+ const imagesAndTables = selectAll("image,table", node3);
299638
+ if (label === "table10") {
299639
+ console.log(imagesAndTables);
299640
+ }
299641
+ if (imagesAndTables.length !== 1) {
299642
+ fileWarn(state.file, `Typst best supports figures with single image or table`, {
299476
299643
  node: node3,
299477
- source: "myst-to-typst"
299644
+ source: "myst-to-typst",
299645
+ note: `Figure "${label !== null && label !== void 0 ? label : "unlabeled"}" may not render correctly`
299478
299646
  });
299479
- return;
299480
299647
  }
299481
- state.write("#figure(\n ");
299482
- state.renderChildren({ children: [image6] }, true);
299483
- state.trimEnd();
299484
- state.write(",");
299485
- if (caption3) {
299648
+ if (imagesAndTables.length > 1) {
299649
+ state.write("#figure((\n ");
299650
+ imagesAndTables.forEach((item) => {
299651
+ state.renderChildren({ children: [item] });
299652
+ state.write(",");
299653
+ });
299654
+ state.trimEnd();
299655
+ state.write(").join(),");
299656
+ } else if (imagesAndTables.length === 1) {
299657
+ state.write("#figure(\n ");
299658
+ state.renderChildren({ children: [imagesAndTables[0]] });
299659
+ state.trimEnd();
299660
+ state.write(",");
299661
+ } else {
299662
+ state.write("#figure([\n ");
299663
+ state.renderChildren(node3, true);
299664
+ state.trimEnd();
299665
+ state.write("],");
299666
+ }
299667
+ if (captions.length) {
299486
299668
  state.write("\n caption: [");
299487
- state.renderChildren(caption3, true);
299669
+ state.renderChildren({
299670
+ children: captions.map((cap2) => cap2.children).filter(Boolean).flat()
299671
+ }, true);
299488
299672
  state.trimEnd();
299489
299673
  state.write("],");
299490
299674
  }
299675
+ if (kind) {
299676
+ state.write(`
299677
+ kind: "${kind}",`);
299678
+ state.write(`
299679
+ supplement: [${kind[0].toUpperCase() + kind.substring(1)}],`);
299680
+ }
299491
299681
  state.write("\n)");
299492
299682
  if (label)
299493
299683
  state.write(` <${label}>`);
@@ -299696,7 +299886,7 @@ function stringToLatexText2(text7) {
299696
299886
  return `${s5}$${next.text}$`;
299697
299887
  return s5 + next.text;
299698
299888
  }, "");
299699
- const final = replaced.replace(new RegExp(BACKSLASH_SPACE2, "g"), "\\\\ ").replace(new RegExp(BACKSLASH2, "g"), "\\\\").replace(new RegExp(COMMENT, "g"), "\\/\\/").replace(new RegExp(TILDE2, "g"), "#sym.tilde");
299889
+ const final = replaced.replace(new RegExp(BACKSLASH_SPACE2, "g"), "\\\\ ").replace(new RegExp(BACKSLASH2, "g"), "\\\\").replace(new RegExp(COMMENT, "g"), "\\/\\/").replace(new RegExp(TILDE2, "g"), "$tilde$");
299700
299890
  return cleanWhitespaceChars2(final, "~");
299701
299891
  }
299702
299892
  function stringToLatexMath2(text7) {
@@ -300014,6 +300204,62 @@ var inlineMath3 = (node3, state) => {
300014
300204
  var MATH_HANDLERS3 = { math: math5, inlineMath: inlineMath3 };
300015
300205
  var math_default2 = MATH_HANDLERS3;
300016
300206
 
300207
+ // ../myst-to-typst/dist/table.js
300208
+ function countColumns(table5) {
300209
+ var _a6, _b;
300210
+ const firstRow = (_a6 = table5.children) === null || _a6 === void 0 ? void 0 : _a6.find((child) => child.type === "tableRow");
300211
+ const columns = (_b = firstRow === null || firstRow === void 0 ? void 0 : firstRow.children) === null || _b === void 0 ? void 0 : _b.filter((cell3) => cell3.type === "tableCell").reduce((val, cell3) => {
300212
+ var _a7;
300213
+ return val + ((_a7 = cell3.colspan) !== null && _a7 !== void 0 ? _a7 : 1);
300214
+ }, 0);
300215
+ return columns;
300216
+ }
300217
+ function isHeaderRow(node3) {
300218
+ var _a6;
300219
+ if (node3.type !== "tableRow")
300220
+ return false;
300221
+ return (_a6 = node3.children) === null || _a6 === void 0 ? void 0 : _a6.filter((child) => child.type === "tableCell").every((child) => child.header);
300222
+ }
300223
+ function countHeaderRows(table5) {
300224
+ var _a6, _b;
300225
+ const headerRows = (_a6 = table5.children) === null || _a6 === void 0 ? void 0 : _a6.filter((child) => isHeaderRow(child));
300226
+ return (_b = headerRows === null || headerRows === void 0 ? void 0 : headerRows.length) !== null && _b !== void 0 ? _b : 0;
300227
+ }
300228
+ var tableHandler = (node3, state) => {
300229
+ const command = state.data.isInFigure ? "tablex" : "#tablex";
300230
+ const columns = countColumns(node3);
300231
+ if (!columns) {
300232
+ fileError(state.file, "Unable to count table columns", {
300233
+ node: node3,
300234
+ source: "myst-to-typst"
300235
+ });
300236
+ return;
300237
+ }
300238
+ state.useMacro('#import "@preview/tablex:0.0.7": tablex, cellx');
300239
+ state.write(`${command}(columns: ${columns}, header-rows: ${countHeaderRows(node3)},
300240
+ `);
300241
+ state.renderChildren(node3);
300242
+ state.write(")\n");
300243
+ };
300244
+ var tableRowHandler = (node3, state) => {
300245
+ state.renderChildren(node3);
300246
+ };
300247
+ var tableCellHandler = (node3, state) => {
300248
+ if (node3.rowspan || node3.colspan) {
300249
+ state.write("cellx(");
300250
+ if (node3.rowspan) {
300251
+ state.write(`rowspan: ${node3.rowspan}, `);
300252
+ }
300253
+ if (node3.colspan) {
300254
+ state.write(`colspan: ${node3.colspan}, `);
300255
+ }
300256
+ state.write(")");
300257
+ }
300258
+ state.write("[");
300259
+ state.renderChildren(node3);
300260
+ state.write("],");
300261
+ };
300262
+
300017
300263
  // ../myst-to-typst/dist/index.js
300018
300264
  var admonition2 = `#let admonition(body, heading: none, color: blue) = {
300019
300265
  let stroke = (left: 2pt + color.darken(20%))
@@ -300045,6 +300291,17 @@ var blockquote3 = `#let blockquote(node, color: gray) = {
300045
300291
  block(width: 100%, inset: 8pt, stroke: stroke)[#node]
300046
300292
  }`;
300047
300293
  var INDENT = " ";
300294
+ var linkHandler = (node3, state) => {
300295
+ const href = node3.url;
300296
+ state.write('#link("');
300297
+ state.write(hrefToLatexText2(href));
300298
+ state.write('")');
300299
+ if (node3.children.length && node3.children[0].value !== href) {
300300
+ state.write("[");
300301
+ state.renderChildren(node3, true);
300302
+ state.write("]");
300303
+ }
300304
+ };
300048
300305
  var handlers4 = {
300049
300306
  text(node3, state) {
300050
300307
  state.text(node3.value);
@@ -300113,10 +300370,10 @@ var handlers4 = {
300113
300370
  state.renderChildren(node3, true);
300114
300371
  state.write("\n");
300115
300372
  },
300116
- // thematicBreak(node, state) {
300117
- // state.write('\n\\bigskip\n\\centerline{\\rule{13cm}{0.4pt}}\n\\bigskip');
300118
- // state.closeBlock(node);
300119
- // },
300373
+ thematicBreak(node3, state) {
300374
+ state.write("#line(length: 100%, stroke: gray)");
300375
+ state.closeBlock(node3);
300376
+ },
300120
300377
  ...math_default2,
300121
300378
  mystRole(node3, state) {
300122
300379
  state.renderChildren(node3, true);
@@ -300181,18 +300438,7 @@ ${node3.value}
300181
300438
  abbreviation(node3, state) {
300182
300439
  state.renderChildren(node3, true);
300183
300440
  },
300184
- link(node3, state) {
300185
- var _a6;
300186
- const href = node3.url;
300187
- state.write('#link("');
300188
- state.write(hrefToLatexText2(href));
300189
- state.write('")');
300190
- if (((_a6 = node3.children[0]) === null || _a6 === void 0 ? void 0 : _a6.value) !== href) {
300191
- state.write("[");
300192
- state.renderChildren(node3, true);
300193
- state.write("]");
300194
- }
300195
- },
300441
+ link: linkHandler,
300196
300442
  admonition(node3, state) {
300197
300443
  state.useMacro(admonition2);
300198
300444
  state.ensureNewLine();
@@ -300221,7 +300467,9 @@ ${node3.value}
300221
300467
  admonitionTitle() {
300222
300468
  return;
300223
300469
  },
300224
- // table: renderNodeToLatex,
300470
+ table: tableHandler,
300471
+ tableRow: tableRowHandler,
300472
+ tableCell: tableCellHandler,
300225
300473
  image(node3, state) {
300226
300474
  const { width: nodeWidth, url: nodeSrc, align } = node3;
300227
300475
  const src = nodeSrc;
@@ -300232,6 +300480,7 @@ ${node3.value}
300232
300480
  },
300233
300481
  container: containerHandler2,
300234
300482
  caption: captionHandler2,
300483
+ legend: captionHandler2,
300235
300484
  captionNumber: () => void 0,
300236
300485
  crossReference(node3, state) {
300237
300486
  const id = node3.identifier;
@@ -300241,7 +300490,12 @@ ${node3.value}
300241
300490
  state.renderChildren(node3, true, " ");
300242
300491
  },
300243
300492
  cite(node3, state) {
300244
- state.write(`@${node3.label}`);
300493
+ var _a6;
300494
+ if (node3.protocol === "doi" || ((_a6 = node3.label) === null || _a6 === void 0 ? void 0 : _a6.startsWith("https://doi.org"))) {
300495
+ linkHandler(node3, state);
300496
+ } else {
300497
+ state.write(`@${node3.label}`);
300498
+ }
300245
300499
  },
300246
300500
  embed(node3, state) {
300247
300501
  state.renderChildren(node3, true);
@@ -300336,7 +300590,7 @@ var TypstSerializer = class {
300336
300590
  if (!inline)
300337
300591
  this.closeBlock(node3);
300338
300592
  }
300339
- renderEnvironment(node3, env5, opts) {
300593
+ renderEnvironment(node3, env5) {
300340
300594
  this.file.result += `#${env5}[
300341
300595
  `;
300342
300596
  this.renderChildren(node3, true);
@@ -301103,6 +301357,14 @@ var mystDirective2 = (state, node3) => {
301103
301357
  var mystRole2 = (state, node3) => {
301104
301358
  state.renderChildren(node3);
301105
301359
  };
301360
+ var inlineExpression = (state, node3, parent2) => {
301361
+ var _a6;
301362
+ if ((_a6 = node3.children) === null || _a6 === void 0 ? void 0 : _a6.length) {
301363
+ state.renderChildren(node3);
301364
+ } else {
301365
+ inlineCode3(state, { ...node3, type: "inlineCode" }, parent2);
301366
+ }
301367
+ };
301106
301368
  var defaultHandlers = {
301107
301369
  text: text5,
301108
301370
  paragraph: paragraph2,
@@ -301145,7 +301407,8 @@ var defaultHandlers = {
301145
301407
  cite,
301146
301408
  citeGroup,
301147
301409
  embed: embed2,
301148
- include: include2
301410
+ include: include2,
301411
+ inlineExpression
301149
301412
  };
301150
301413
 
301151
301414
  // ../myst-to-docx/dist/serializer.js
@@ -302631,8 +302894,8 @@ function tableTransform(mdast2) {
302631
302894
  const head2 = { type: "tableHead", children: [] };
302632
302895
  const body3 = { type: "tableBody", children: [] };
302633
302896
  table5.children.forEach((tr3) => {
302634
- const isHeaderRow = tr3.children.reduce((h4, v) => h4 && !!v.header, true);
302635
- if (isHeaderRow && body3.children.length === 0) {
302897
+ const isHeaderRow2 = tr3.children.reduce((h4, v) => h4 && !!v.header, true);
302898
+ if (isHeaderRow2 && body3.children.length === 0) {
302636
302899
  head2.children.push(tr3);
302637
302900
  } else {
302638
302901
  body3.children.push(tr3);
@@ -302938,7 +303201,7 @@ function affiliationIdTransform(frontmatters, idPrefix) {
302938
303201
  }
302939
303202
 
302940
303203
  // ../myst-to-jats/dist/inlineExpression.js
302941
- var inlineExpression = (node3, state) => {
303204
+ var inlineExpression2 = (node3, state) => {
302942
303205
  const { identifier, value } = node3;
302943
303206
  state.renderInline(node3, "xref", {
302944
303207
  "ref-type": "custom",
@@ -303500,7 +303763,7 @@ var handlers5 = {
303500
303763
  state.closeNode();
303501
303764
  state.closeNode();
303502
303765
  },
303503
- inlineExpression
303766
+ inlineExpression: inlineExpression2
303504
303767
  };
303505
303768
  function createText2(text7) {
303506
303769
  return { type: "text", text: escapeForXML2(text7) };
@@ -303824,7 +304087,7 @@ function writeJats(file, content3, opts) {
303824
304087
  }
303825
304088
 
303826
304089
  // ../myst-cli/dist/build/jats/single.js
303827
- async function runJatsExport(session, exportOptions, projectPath, clean3, extraLinkTransformers) {
304090
+ async function runJatsExport(session, sourceFile, exportOptions, projectPath, clean3, extraLinkTransformers) {
303828
304091
  const toc = tic();
303829
304092
  const { output: output2, articles, sub_articles } = exportOptions;
303830
304093
  const article = articles[0];
@@ -303878,6 +304141,7 @@ async function runJatsExport(session, exportOptions, projectPath, clean3, extraL
303878
304141
  logMessagesFromVFile(session, jats);
303879
304142
  session.log.info(toc(`\u{1F4D1} Exported JATS in %s, copying to ${output2}`));
303880
304143
  writeFileToFolder(output2, jats.result);
304144
+ return { tempFolders: [] };
303881
304145
  }
303882
304146
 
303883
304147
  // ../myst-cli/dist/build/pdf/single.js
@@ -304266,7 +304530,7 @@ function writeMecaManifest(manifestItems, mecaFolder) {
304266
304530
  const manifest = createManifestXml(manifestItems);
304267
304531
  import_node_fs34.default.writeFileSync(import_node_path49.default.join(mecaFolder, "manifest.xml"), manifest);
304268
304532
  }
304269
- async function runMecaExport(session, exportOptions, projectPath, clean3, extraLinkTransformers) {
304533
+ async function runMecaExport(session, sourceFile, exportOptions, projectPath, clean3, extraLinkTransformers) {
304270
304534
  const toc = tic();
304271
304535
  const { output: output2, articles } = exportOptions;
304272
304536
  const article = articles === null || articles === void 0 ? void 0 : articles[0];
@@ -304284,7 +304548,7 @@ async function runMecaExport(session, exportOptions, projectPath, clean3, extraL
304284
304548
  });
304285
304549
  if (jatsExports.length === 0 && article) {
304286
304550
  const jatsOutput = import_node_path49.default.join(mecaFolder, "article.xml");
304287
- await runJatsExport(session, { ...exportOptions, output: jatsOutput }, projectPath, clean3, extraLinkTransformers);
304551
+ await runJatsExport(session, sourceFile, { ...exportOptions, output: jatsOutput }, projectPath, clean3, extraLinkTransformers);
304288
304552
  addManifestItem(manifestItems, "article-metadata", mecaFolder, jatsOutput);
304289
304553
  const jatsFiles = import_node_path49.default.join(mecaFolder, "files");
304290
304554
  if (import_node_fs34.default.existsSync(jatsFiles)) {
@@ -304316,8 +304580,8 @@ To resolve this, run: myst build --all`, {
304316
304580
  const jatsFiles = import_node_path49.default.join(import_node_path49.default.dirname(jatsOutput), "files");
304317
304581
  if (import_node_fs34.default.existsSync(jatsFiles)) {
304318
304582
  import_node_fs34.default.readdirSync(jatsFiles).forEach((file) => {
304319
- const sourceFile = import_node_path49.default.join(jatsFiles, file);
304320
- const fileDest = copyFileToFolder(session, sourceFile, import_node_path49.default.join(mecaFolder, "files"), fileCopyErrorLogFn);
304583
+ const src = import_node_path49.default.join(jatsFiles, file);
304584
+ const fileDest = copyFileToFolder(session, src, import_node_path49.default.join(mecaFolder, "files"), fileCopyErrorLogFn);
304321
304585
  addManifestItem(manifestItems, "article-supporting-file", mecaFolder, fileDest);
304322
304586
  });
304323
304587
  }
@@ -304381,6 +304645,7 @@ To resolve this, run: myst build --all`, {
304381
304645
  zip2.writeZip(output2);
304382
304646
  logMessagesFromVFile(session, vfile2);
304383
304647
  session.log.info(toc(`\u{1F910} MECA output copied and zipped to ${output2} in %s`));
304648
+ return { tempFolders: [] };
304384
304649
  }
304385
304650
 
304386
304651
  // ../myst-cli/dist/build/md/index.js
@@ -308409,8 +308674,8 @@ function container3(node3, _, state, info) {
308409
308674
  const listNodes = selectAll("tableRow", tableNode).map((row2) => {
308410
308675
  const cells2 = selectAll("tableCell", row2);
308411
308676
  if (inHeader) {
308412
- const isHeaderRow = cells2.map((cell3) => cell3.header).reduce((val, allHeaders) => val ? allHeaders : false, true);
308413
- if (isHeaderRow) {
308677
+ const isHeaderRow2 = cells2.map((cell3) => cell3.header).reduce((val, allHeaders) => val ? allHeaders : false, true);
308678
+ if (isHeaderRow2) {
308414
308679
  headerRows += 1;
308415
308680
  } else {
308416
308681
  inHeader = false;
@@ -308756,7 +309021,7 @@ function writeMd(file, node3, frontmatter) {
308756
309021
  }
308757
309022
 
308758
309023
  // ../myst-cli/dist/build/md/index.js
308759
- async function runMdExport(session, exportOptions, projectPath, clean3, extraLinkTransformers) {
309024
+ async function runMdExport(session, sourceFile, exportOptions, projectPath, clean3, extraLinkTransformers) {
308760
309025
  const toc = tic();
308761
309026
  const { output: output2, articles } = exportOptions;
308762
309027
  const article = articles[0];
@@ -308782,47 +309047,82 @@ async function runMdExport(session, exportOptions, projectPath, clean3, extraLin
308782
309047
  logMessagesFromVFile(session, mdOut);
308783
309048
  session.log.info(toc(`\u{1F4D1} Exported MD in %s, copying to ${output2}`));
308784
309049
  writeFileToFolder(output2, mdOut.result);
309050
+ return { tempFolders: [] };
308785
309051
  }
308786
309052
 
308787
309053
  // ../myst-cli/dist/build/utils/localArticleExport.js
309054
+ async function runExportAndWatch(watch2, exportFn, session, $file, exportOptions, projectPath, clean3) {
309055
+ let results = await exportFn(session, $file, exportOptions, projectPath, clean3);
309056
+ if (watch2) {
309057
+ const watchedFiles = /* @__PURE__ */ new Set([
309058
+ $file,
309059
+ ...exportOptions.articles,
309060
+ ...exportOptions.articles.map((article) => {
309061
+ return selectors_exports.selectFileDependencies(session.store.getState(), article);
309062
+ }).flat()
309063
+ ]);
309064
+ import_chokidar2.default.watch([...watchedFiles], {
309065
+ awaitWriteFinish: { stabilityThreshold: 100, pollInterval: 50 }
309066
+ }).on("change", async (eventType, modifiedFile) => {
309067
+ const { reloading } = selectors_exports.selectReloadingState(session.store.getState());
309068
+ if (reloading) {
309069
+ session.store.dispatch(watch.actions.markReloadRequested(true));
309070
+ return;
309071
+ }
309072
+ session.store.dispatch(watch.actions.markReloading(true));
309073
+ session.log.debug(`File modified: "${modifiedFile}" (${eventType})`);
309074
+ while (selectors_exports.selectReloadingState(session.store.getState()).reloadRequested) {
309075
+ session.store.dispatch(watch.actions.markReloadRequested(false));
309076
+ results = await exportFn(session, $file, exportOptions, projectPath, clean3);
309077
+ }
309078
+ session.store.dispatch(watch.actions.markReloading(false));
309079
+ results = await exportFn(session, $file, exportOptions, projectPath, clean3);
309080
+ });
309081
+ }
309082
+ return results;
309083
+ }
308788
309084
  async function _localArticleExport(session, exportOptionsList, opts) {
308789
- const { clean: clean3, projectPath } = opts;
309085
+ const { clean: clean3, projectPath, watch: watch2 } = opts;
308790
309086
  const errors3 = await resolveAndLogErrors(session, exportOptionsList.map(async (exportOptionsWithFile) => {
308791
309087
  var _a6;
308792
309088
  const { $file, $project, ...exportOptions } = exportOptionsWithFile;
308793
309089
  const { format, output: output2 } = exportOptions;
308794
309090
  const sessionClone = session.clone();
308795
309091
  const fileProjectPath = (_a6 = projectPath !== null && projectPath !== void 0 ? projectPath : $project) !== null && _a6 !== void 0 ? _a6 : findCurrentProjectAndLoad(sessionClone, import_node_path51.default.dirname($file));
308796
- let exportResults;
308797
309092
  if (fileProjectPath) {
308798
309093
  await loadProjectFromDisk(sessionClone, fileProjectPath);
308799
309094
  }
309095
+ let exportFn;
308800
309096
  if (format === ExportFormats.tex) {
308801
309097
  if (import_node_path51.default.extname(output2) === ".zip") {
308802
- exportResults = await runTexZipExport(sessionClone, $file, exportOptions, fileProjectPath, clean3);
309098
+ exportFn = runTexZipExport;
308803
309099
  } else {
308804
- exportResults = await runTexExport(sessionClone, $file, exportOptions, fileProjectPath, clean3);
309100
+ exportFn = runTexExport;
308805
309101
  }
308806
309102
  } else if (format === ExportFormats.typst) {
308807
309103
  if (import_node_path51.default.extname(output2) === ".zip") {
308808
- exportResults = await runTypstZipExport(sessionClone, $file, exportOptions, fileProjectPath, clean3);
309104
+ exportFn = runTypstZipExport;
308809
309105
  } else {
308810
- exportResults = await runTypstExport(sessionClone, $file, exportOptions, fileProjectPath, clean3);
309106
+ exportFn = runTypstExport;
308811
309107
  }
308812
309108
  } else if (format === ExportFormats.docx) {
308813
- exportResults = await runWordExport(sessionClone, $file, exportOptions, fileProjectPath, clean3);
309109
+ exportFn = runWordExport;
308814
309110
  } else if (format === ExportFormats.xml) {
308815
- await runJatsExport(sessionClone, exportOptions, fileProjectPath, clean3);
309111
+ exportFn = runJatsExport;
308816
309112
  } else if (format === ExportFormats.md) {
308817
- await runMdExport(sessionClone, exportOptions, fileProjectPath, clean3);
309113
+ exportFn = runMdExport;
308818
309114
  } else if (format === ExportFormats.meca) {
308819
- await runMecaExport(sessionClone, exportOptions, fileProjectPath, clean3);
309115
+ exportFn = runMecaExport;
308820
309116
  } else {
308821
309117
  const keepTexAndLogs = format === ExportFormats.pdftex;
308822
- const texExportOptions = texExportOptionsFromPdf(sessionClone, exportOptions, keepTexAndLogs, clean3);
308823
- exportResults = await runTexExport(sessionClone, $file, texExportOptions, fileProjectPath, clean3);
308824
- await createPdfGivenTexExport(sessionClone, texExportOptions, output2, keepTexAndLogs, clean3, exportResults.hasGlossaries);
309118
+ exportFn = async (fnSession, fnFile, fnOpts, fnPath, fnClean) => {
309119
+ const texExportOptions = texExportOptionsFromPdf(fnSession, fnOpts, keepTexAndLogs, fnClean);
309120
+ const results = await runTexExport(fnSession, fnFile, texExportOptions, fnPath, fnClean);
309121
+ await createPdfGivenTexExport(fnSession, texExportOptions, output2, keepTexAndLogs, fnClean, results.hasGlossaries);
309122
+ return results;
309123
+ };
308825
309124
  }
309125
+ await runExportAndWatch(!!watch2, exportFn, sessionClone, $file, exportOptions, fileProjectPath, clean3);
308826
309126
  }), opts.throwOnFailure);
308827
309127
  return errors3;
308828
309128
  }
@@ -308925,7 +309225,7 @@ function extToKind(ext2) {
308925
309225
  return ext2;
308926
309226
  }
308927
309227
  async function build(session, files, opts) {
308928
- const { site, all: all10 } = opts;
309228
+ const { site, all: all10, watch: watch2 } = opts;
308929
309229
  const performSiteBuild = all10 || files.length === 0 && exportSite(session, opts);
308930
309230
  const exportOptionsList = await collectAllBuildExportOptions(session, files, opts);
308931
309231
  const exportLogList = exportOptionsList.map((exportOptions) => {
@@ -308949,7 +309249,7 @@ exports:
308949
309249
  } else {
308950
309250
  session.log.info(`\u{1F4EC} Performing exports:
308951
309251
  ${exportLogList.join("\n ")}`);
308952
- await localArticleExport(session, exportOptionsList, {});
309252
+ await localArticleExport(session, exportOptionsList, { watch: watch2 });
308953
309253
  }
308954
309254
  if (!performSiteBuild)
308955
309255
  return;
@@ -308959,6 +309259,9 @@ exports:
308959
309259
  session.log.debug(`To build a site, first run 'myst init --site'`);
308960
309260
  } else {
308961
309261
  session.log.info(`\u{1F30E} Building MyST site`);
309262
+ if (watch2) {
309263
+ session.log.warn(`Site content will not be watched and updated; use 'myst start' instead`);
309264
+ }
308962
309265
  if (opts.html) {
308963
309266
  await buildHtml(session, opts);
308964
309267
  } else {
@@ -316244,6 +316547,9 @@ function makeProjectOption(description) {
316244
316547
  function makeAllOption(description) {
316245
316548
  return new Option("-a, --all", description).default(false);
316246
316549
  }
316550
+ function makeWatchOption() {
316551
+ return new Option("--watch", "Watch modified files and re-build on change").default(false);
316552
+ }
316247
316553
  function makeNamedExportOption(description) {
316248
316554
  return new Option("-o, --output <output>", description);
316249
316555
  }
@@ -316304,7 +316610,7 @@ function makeYesOption() {
316304
316610
 
316305
316611
  // src/build.ts
316306
316612
  function makeBuildCLI(program3) {
316307
- const command = new Command("build").description("Build PDF, LaTeX, Word and website exports from MyST files").argument("[files...]", "list of files to export").addOption(makePdfOption("Build PDF output")).addOption(makeTexOption("Build LaTeX outputs")).addOption(makeTypstOption("Build Typst outputs")).addOption(makeDocxOption("Build Docx output")).addOption(makeMdOption("Build MD output")).addOption(makeJatsOption("Build JATS xml output")).addOption(makeMecaOptions("Build MECA zip output")).addOption(makeSiteOption("Build MyST site content")).addOption(makeHtmlOption("Build static HTML site content")).addOption(makeAllOption("Build all exports")).addOption(makeNamedExportOption("Output file for the export")).addOption(makeForceOption()).addOption(makeCheckLinksOption()).addOption(makeStrictOption()).action(clirun2(Session, build, program3));
316613
+ const command = new Command("build").description("Build PDF, LaTeX, Word and website exports from MyST files").argument("[files...]", "list of files to export").addOption(makePdfOption("Build PDF output")).addOption(makeTexOption("Build LaTeX outputs")).addOption(makeTypstOption("Build Typst outputs")).addOption(makeDocxOption("Build Docx output")).addOption(makeMdOption("Build MD output")).addOption(makeJatsOption("Build JATS xml output")).addOption(makeMecaOptions("Build MECA zip output")).addOption(makeSiteOption("Build MyST site content")).addOption(makeHtmlOption("Build static HTML site content")).addOption(makeAllOption("Build all exports")).addOption(makeWatchOption()).addOption(makeNamedExportOption("Output file for the export")).addOption(makeForceOption()).addOption(makeCheckLinksOption()).addOption(makeStrictOption()).action(clirun2(Session, build, program3));
316308
316614
  return command;
316309
316615
  }
316310
316616
 
@@ -1,9 +0,0 @@
1
- mystmd_py/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- mystmd_py/main.py,sha256=_dRwNvYQ3xult25BmsZgXMWe1asD_wuSW8JeWV-S3c0,1411
3
- mystmd_py/myst.cjs,sha256=_nuDWYu_fHscxMpCVzs1sS8v7B_27xuf0R_gNQgDE30,13207642
4
- mystmd-1.1.36.dist-info/LICENSE,sha256=vgXlcTOVbxYpGiMuE9NqgguIBXAH0hJAktlaxiyZ2wg,1088
5
- mystmd-1.1.36.dist-info/METADATA,sha256=oTtt-jXGgCj1AIiEXxHdeVK-CJiET0KGVUnZTt8Gxqw,2601
6
- mystmd-1.1.36.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
7
- mystmd-1.1.36.dist-info/entry_points.txt,sha256=eC2ol2gqS2q5E-ktkMrBSvV0tckGUcNGS-c4hEQ-_V4,45
8
- mystmd-1.1.36.dist-info/top_level.txt,sha256=__Xz3ZzAj4SsfBUP5OFexvriJM7gBwu8L2r3TL6UXKE,10
9
- mystmd-1.1.36.dist-info/RECORD,,