mystmd 1.3.9__tar.gz → 1.3.11__tar.gz

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.3
2
2
  Name: mystmd
3
- Version: 1.3.9
3
+ Version: 1.3.11
4
4
  Summary: Command line tools for MyST Markdown
5
5
  Project-URL: Homepage, https://github.com/jupyter-book/mystmd
6
6
  Project-URL: Bug Tracker, https://github.com/jupyter-book/mystmd/issues
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mystmd",
3
- "version": "1.3.9",
3
+ "version": "1.3.11",
4
4
  "description": "Command line tools for MyST Markdown",
5
5
  "author": "Rowan Cockett <rowan@curvenote.com>",
6
6
  "license": "MIT",
@@ -45,6 +45,6 @@
45
45
  "commander": "^10.0.1",
46
46
  "core-js": "^3.31.1",
47
47
  "js-yaml": "^4.1.0",
48
- "myst-cli": "^1.3.9"
48
+ "myst-cli": "^1.3.11"
49
49
  }
50
50
  }
@@ -193562,7 +193562,7 @@ var {
193562
193562
  } = import_index.default;
193563
193563
 
193564
193564
  // src/version.ts
193565
- var version = "1.3.9";
193565
+ var version = "1.3.11";
193566
193566
  var version_default = version;
193567
193567
 
193568
193568
  // ../myst-cli/dist/build/build.js
@@ -241281,7 +241281,17 @@ function logMessagesFromVFile(session, file) {
241281
241281
  file.messages = [];
241282
241282
  }
241283
241283
  function writeJsonLogs(session, name3, logData) {
241284
- writeFileToFolder((0, import_node_path6.join)(session.buildPath(), "logs", name3), JSON.stringify(logData, null, 2));
241284
+ const seen = /* @__PURE__ */ new WeakSet();
241285
+ const data = JSON.stringify(logData, function(_3, value) {
241286
+ if (typeof value === "object" && value !== null) {
241287
+ if (seen.has(value)) {
241288
+ return "[Circular]";
241289
+ }
241290
+ seen.add(value);
241291
+ }
241292
+ return value;
241293
+ }, 2);
241294
+ writeFileToFolder((0, import_node_path6.join)(session.buildPath(), "logs", name3), data);
241285
241295
  }
241286
241296
 
241287
241297
  // ../myst-cli/dist/session/cache.js
@@ -241881,11 +241891,12 @@ var InlineCite;
241881
241891
  InlineCite2["t"] = "t";
241882
241892
  })(InlineCite || (InlineCite = {}));
241883
241893
  function yearFromCitation(data) {
241884
- var _a6, _b, _c, _d2, _e, _f;
241885
- let year = (_c = (_b = (_a6 = data.issued) === null || _a6 === void 0 ? void 0 : _a6["date-parts"]) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c[0];
241894
+ var _a6, _b, _c, _d2, _e;
241895
+ const date = (_a6 = data.issued) !== null && _a6 !== void 0 ? _a6 : data.accessed;
241896
+ let year = (_c = (_b = date === null || date === void 0 ? void 0 : date["date-parts"]) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c[0];
241886
241897
  if (year)
241887
241898
  return year;
241888
- year = (_f = (_e = (_d2 = data.issued) === null || _d2 === void 0 ? void 0 : _d2["literal"]) === null || _e === void 0 ? void 0 : _e.match(/\b[12][0-9]{3}\b/)) === null || _f === void 0 ? void 0 : _f[0];
241899
+ year = (_e = (_d2 = date === null || date === void 0 ? void 0 : date["literal"]) === null || _d2 === void 0 ? void 0 : _d2.match(/\b[12][0-9]{3}\b/)) === null || _e === void 0 ? void 0 : _e[0];
241889
241900
  if (year)
241890
241901
  return year;
241891
241902
  return "n.d.";
@@ -289101,7 +289112,7 @@ var import_node_path15 = __toESM(require("path"), 1);
289101
289112
  var import_nbtx = __toESM(require_cjs2(), 1);
289102
289113
 
289103
289114
  // ../myst-cli/dist/version.js
289104
- var version2 = "1.3.9";
289115
+ var version2 = "1.3.11";
289105
289116
  var version_default2 = version2;
289106
289117
 
289107
289118
  // ../myst-cli/dist/utils/headers.js
@@ -290199,7 +290210,7 @@ function replaceAttachmentsTransform(session, mdast2, attachments, file) {
290199
290210
  logMessagesFromVFile(session, vfile2);
290200
290211
  }
290201
290212
  async function processNotebookFull(session, file, content3) {
290202
- var _a6, _b;
290213
+ var _a6, _b, _c;
290203
290214
  const { log } = session;
290204
290215
  const { metadata, cells: cells2 } = JSON.parse(content3);
290205
290216
  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";
@@ -290212,6 +290223,7 @@ async function processNotebookFull(session, file, content3) {
290212
290223
  ...Object.entries(FRONTMATTER_ALIASES).filter(([_3, value]) => PAGE_FRONTMATTER_KEYS.includes(value)).map(([key2, _3]) => key2)
290213
290224
  ]);
290214
290225
  const frontmatter = validatePageFrontmatter(filteredMetadata !== null && filteredMetadata !== void 0 ? filteredMetadata : {}, frontmatterValidationOpts(vfile2));
290226
+ const widgets = (_c = metadata === null || metadata === void 0 ? void 0 : metadata.widgets) !== null && _c !== void 0 ? _c : {};
290215
290227
  let end = cells2.length;
290216
290228
  if (cells2 && cells2.length > 1 && (cells2 === null || cells2 === void 0 ? void 0 : cells2[cells2.length - 1].source.length) === 0) {
290217
290229
  end = -1;
@@ -290269,7 +290281,7 @@ async function processNotebookFull(session, file, content3) {
290269
290281
  }, Promise.resolve([])));
290270
290282
  logMessagesFromVFile(session, vfile2);
290271
290283
  const mdast2 = { type: "root", children: items };
290272
- return { mdast: mdast2, frontmatter };
290284
+ return { mdast: mdast2, frontmatter, widgets };
290273
290285
  }
290274
290286
 
290275
290287
  // ../myst-cli/dist/process/file.js
@@ -290290,10 +290302,10 @@ function loadMdFile(session, content3, file, opts) {
290290
290302
  async function loadNotebookFile(session, content3, file, opts) {
290291
290303
  const vfile2 = new VFile();
290292
290304
  vfile2.path = file;
290293
- const { mdast: mdast2, frontmatter: nbFrontmatter } = await processNotebookFull(session, file, content3);
290305
+ const { mdast: mdast2, frontmatter: nbFrontmatter, widgets } = await processNotebookFull(session, file, content3);
290294
290306
  const { frontmatter: cellFrontmatter, identifiers } = getPageFrontmatter(session, mdast2, vfile2, opts === null || opts === void 0 ? void 0 : opts.preFrontmatter, opts === null || opts === void 0 ? void 0 : opts.keepTitleNode);
290295
290307
  const frontmatter = fillProjectFrontmatter(cellFrontmatter, nbFrontmatter, frontmatterValidationOpts(vfile2));
290296
- return { kind: SourceFileKind.Notebook, mdast: mdast2, frontmatter, identifiers };
290308
+ return { kind: SourceFileKind.Notebook, mdast: mdast2, frontmatter, identifiers, widgets };
290297
290309
  }
290298
290310
  function loadTexFile(session, content3, file, opts) {
290299
290311
  var _a6;
@@ -303080,7 +303092,7 @@ async function transformMdast(session, opts) {
303080
303092
  const cache = castSession(session);
303081
303093
  if (!cache.$getMdast(file))
303082
303094
  return;
303083
- const { mdast: mdastPre, kind, frontmatter: preFrontmatter, location: location4, identifiers } = (_b = (_a6 = cache.$getMdast(file)) === null || _a6 === void 0 ? void 0 : _a6.pre) !== null && _b !== void 0 ? _b : {};
303095
+ const { mdast: mdastPre, kind, frontmatter: preFrontmatter, location: location4, identifiers, widgets } = (_b = (_a6 = cache.$getMdast(file)) === null || _a6 === void 0 ? void 0 : _a6.pre) !== null && _b !== void 0 ? _b : {};
303084
303096
  if (!mdastPre || !kind || !location4)
303085
303097
  throw new Error(`Expected mdast to be parsed for ${file}`);
303086
303098
  log.debug(`Processing "${file}"`);
@@ -303164,7 +303176,8 @@ async function transformMdast(session, opts) {
303164
303176
  dependencies: [],
303165
303177
  frontmatter,
303166
303178
  mdast: mdast2,
303167
- references
303179
+ references,
303180
+ widgets
303168
303181
  };
303169
303182
  const cachedMdast = cache.$getMdast(file);
303170
303183
  if (cachedMdast)
@@ -303230,7 +303243,7 @@ async function postProcessMdast(session, { file, checkLinks, pageReferenceStates
303230
303243
  await checkLinksTransform(session, file, mdast2);
303231
303244
  }
303232
303245
  async function finalizeMdast(session, mdast2, frontmatter, file, { imageWriteFolder, useExistingImages, imageAltOutputFolder, imageExtensions, optimizeWebp, simplifyFigures, processThumbnail, maxSizeWebp }) {
303233
- var _a6;
303246
+ var _a6, _b;
303234
303247
  const vfile2 = new VFile();
303235
303248
  vfile2.path = file;
303236
303249
  if (simplifyFigures) {
@@ -303276,11 +303289,108 @@ async function finalizeMdast(session, mdast2, frontmatter, file, { imageWriteFol
303276
303289
  if (postData) {
303277
303290
  postData.frontmatter = frontmatter;
303278
303291
  postData.mdast = mdast2;
303292
+ postData.widgets = (_b = cache.$getMdast(file)) === null || _b === void 0 ? void 0 : _b.pre.widgets;
303279
303293
  updateFileInfoFromFrontmatter(session, file, frontmatter);
303280
303294
  }
303281
303295
  logMessagesFromVFile(session, vfile2);
303282
303296
  }
303283
303297
 
303298
+ // ../myst-cli/dist/process/search.js
303299
+ var IGNORED_TYPES = ["myst", "heading"];
303300
+ var INLINE_BLOCK_TYPES = [
303301
+ "strong",
303302
+ "emphasis",
303303
+ "delete",
303304
+ "superscript",
303305
+ "underline",
303306
+ "subscript",
303307
+ "abbreviation",
303308
+ "smallcaps",
303309
+ "keyboard"
303310
+ ];
303311
+ function toSectionedParts(content3) {
303312
+ const sections = [];
303313
+ const newSection = (heading6) => {
303314
+ var _a6;
303315
+ const info = heading6 ? {
303316
+ text: toText(heading6),
303317
+ depth: heading6.depth,
303318
+ html_id: (_a6 = heading6.html_id) !== null && _a6 !== void 0 ? _a6 : heading6.identifier
303319
+ } : void 0;
303320
+ sections.push({ heading: info, parts: [] });
303321
+ };
303322
+ newSection();
303323
+ visit(content3, (node3, index4, parent2) => {
303324
+ if (node3.type === "heading") {
303325
+ newSection(node3);
303326
+ }
303327
+ if (IGNORED_TYPES.includes(node3.type)) {
303328
+ return SKIP;
303329
+ }
303330
+ const section = sections[sections.length - 1];
303331
+ if ("value" in node3 && node3.value) {
303332
+ section.parts.push(node3.value);
303333
+ }
303334
+ if (index4 != null && parent2 != null && // Skip literal nodes
303335
+ "children" in node3 && // Skip inline-block nodes
303336
+ !INLINE_BLOCK_TYPES.includes(node3.type)) {
303337
+ let previousNode;
303338
+ for (let i2 = index4 - 1; i2 >= 0; i2--) {
303339
+ const maybePreviousNode = parent2.children[i2];
303340
+ if (maybePreviousNode.type === "heading") {
303341
+ break;
303342
+ }
303343
+ if (!IGNORED_TYPES.includes(maybePreviousNode.type)) {
303344
+ previousNode = maybePreviousNode;
303345
+ break;
303346
+ }
303347
+ }
303348
+ if (previousNode !== void 0) {
303349
+ section.parts.push("\n\n");
303350
+ }
303351
+ }
303352
+ });
303353
+ return sections;
303354
+ }
303355
+ function sectionToHeadingLevel(heading6) {
303356
+ if (!heading6) {
303357
+ return "lvl1";
303358
+ }
303359
+ switch (heading6.depth) {
303360
+ case 1:
303361
+ return "lvl1";
303362
+ case 2:
303363
+ return "lvl2";
303364
+ case 3:
303365
+ return "lvl3";
303366
+ case 4:
303367
+ return "lvl4";
303368
+ case 5:
303369
+ return "lvl5";
303370
+ case 6:
303371
+ return "lvl6";
303372
+ default:
303373
+ throw new Error(`unknown heading depth: ${heading6.depth}`);
303374
+ }
303375
+ }
303376
+ function buildHierarchy(title, sections, index4) {
303377
+ const result = { lvl1: title };
303378
+ let currentDepth = 100;
303379
+ for (let i2 = index4; i2 > 0; i2--) {
303380
+ const { heading: heading6 } = sections[i2];
303381
+ if (heading6 === void 0) {
303382
+ throw new Error();
303383
+ }
303384
+ if (heading6.depth >= currentDepth) {
303385
+ continue;
303386
+ }
303387
+ const lvl = sectionToHeadingLevel(heading6);
303388
+ result[lvl] = heading6.text;
303389
+ currentDepth = heading6.depth;
303390
+ }
303391
+ return result;
303392
+ }
303393
+
303284
303394
  // ../myst-cli/dist/process/site.js
303285
303395
  var WEB_IMAGE_EXTENSIONS = [
303286
303396
  ImageExtensions.mp4,
@@ -303344,6 +303454,53 @@ async function writeMystXRefJson(session, states) {
303344
303454
  session.log.debug(`Writing myst.xref.json file: ${filename}`);
303345
303455
  writeFileToFolder(filename, JSON.stringify(mystXRefs));
303346
303456
  }
303457
+ async function writeMystSearchJson(session, pages) {
303458
+ const records = [...pages].sort((left2, right2) => {
303459
+ if (left2.file < right2.file) {
303460
+ return -1;
303461
+ } else if (left2.file > right2.file) {
303462
+ return 1;
303463
+ } else {
303464
+ return 0;
303465
+ }
303466
+ }).map((page) => selectFile(session, page.file)).map((file) => {
303467
+ var _a6;
303468
+ const { mdast: mdast2, slug, frontmatter } = file !== null && file !== void 0 ? file : {};
303469
+ if (!mdast2 || !frontmatter) {
303470
+ return [];
303471
+ }
303472
+ const title = (_a6 = frontmatter.title) !== null && _a6 !== void 0 ? _a6 : "";
303473
+ const sections = toSectionedParts(mdast2);
303474
+ const pageURL = slug && DEFAULT_INDEX_FILENAMES.includes(slug) ? "/" : `/${slug}`;
303475
+ return sections.map((section, index4) => {
303476
+ var _a7;
303477
+ const hierarchy = buildHierarchy(title, sections, index4);
303478
+ const recordURL = ((_a7 = section.heading) === null || _a7 === void 0 ? void 0 : _a7.html_id) ? `${pageURL}#${section.heading.html_id}` : pageURL;
303479
+ return [
303480
+ {
303481
+ hierarchy,
303482
+ type: sectionToHeadingLevel(section.heading),
303483
+ url: recordURL,
303484
+ position: 2 * index4
303485
+ },
303486
+ {
303487
+ hierarchy,
303488
+ content: section.parts.join(""),
303489
+ type: "content",
303490
+ url: recordURL,
303491
+ position: 2 * index4 + 1
303492
+ }
303493
+ ];
303494
+ }).flat();
303495
+ }).flat();
303496
+ const data = {
303497
+ version: "1",
303498
+ records
303499
+ };
303500
+ const filename = (0, import_node_path37.join)(session.sitePath(), "myst.search.json");
303501
+ session.log.debug(`Writing myst.search.json file: ${filename}`);
303502
+ writeFileToFolder(filename, JSON.stringify(data));
303503
+ }
303347
303504
  async function writeObjectsInv(session, states, siteConfig) {
303348
303505
  const inv = new Inventory({
303349
303506
  project: siteConfig === null || siteConfig === void 0 ? void 0 : siteConfig.title,
@@ -303447,7 +303604,7 @@ async function writeFile(session, { file, pageSlug, projectSlug, projectPath })
303447
303604
  const selectedFile = selectFile(session, file);
303448
303605
  if (!selectedFile)
303449
303606
  return;
303450
- const { frontmatter, mdast: mdast2, kind, sha256, slug, references, dependencies, location: location4 } = selectedFile;
303607
+ const { frontmatter, mdast: mdast2, kind, sha256, slug, references, dependencies, location: location4, widgets } = selectedFile;
303451
303608
  const exports2 = await Promise.all([
303452
303609
  resolvePageSource(session, file),
303453
303610
  ...await resolvePageExports(session, file)
@@ -303465,6 +303622,7 @@ async function writeFile(session, { file, pageSlug, projectSlug, projectPath })
303465
303622
  location: location4,
303466
303623
  dependencies,
303467
303624
  frontmatter: frontmatterWithExports,
303625
+ widgets,
303468
303626
  mdast: mdast2,
303469
303627
  references
303470
303628
  }));
@@ -303638,16 +303796,19 @@ ${page.file}
303638
303796
  if ((_b = opts === null || opts === void 0 ? void 0 : opts.writeFiles) !== null && _b !== void 0 ? _b : true) {
303639
303797
  await writeSiteManifest(session, opts);
303640
303798
  const states = [];
303799
+ const allPages = [];
303641
303800
  await Promise.all(siteConfig.projects.map(async (project) => {
303642
303801
  if (!project.path)
303643
303802
  return;
303644
303803
  const { pages } = await loadProject(session, project.path);
303804
+ allPages.push(...pages);
303645
303805
  states.push(...selectPageReferenceStates(session, pages, {
303646
303806
  suppressWarnings: true
303647
303807
  }));
303648
303808
  }));
303649
303809
  await writeObjectsInv(session, states, siteConfig);
303650
303810
  await writeMystXRefJson(session, states);
303811
+ await writeMystSearchJson(session, allPages);
303651
303812
  }
303652
303813
  return true;
303653
303814
  }
@@ -306450,8 +306611,9 @@ var tableHandler = (node3, state) => {
306450
306611
  });
306451
306612
  return;
306452
306613
  }
306453
- state.useMacro('#import "@preview/tablex:0.0.7": tablex, cellx');
306454
- state.write(`${command}(columns: ${columns}, header-rows: ${countHeaderRows(node3)}, repeat-header: true,
306614
+ state.useMacro('#import "@preview/tablex:0.0.8": tablex, cellx, hlinex, vlinex');
306615
+ state.useMacro("#let tableStyle = (:)");
306616
+ state.write(`${command}(columns: ${columns}, header-rows: ${countHeaderRows(node3)}, repeat-header: true, ..tableStyle,
306455
306617
  `);
306456
306618
  state.renderChildren(node3, 1);
306457
306619
  state.write(")\n");
@@ -316122,6 +316284,7 @@ async function startContentServer(session, opts) {
316122
316284
  app.use("/config.json", import_express.default.static((0, import_node_path53.join)(session.sitePath(), "config.json")));
316123
316285
  app.use("/objects.inv", import_express.default.static((0, import_node_path53.join)(session.sitePath(), "objects.inv")));
316124
316286
  app.use("/myst.xref.json", import_express.default.static((0, import_node_path53.join)(session.sitePath(), "myst.xref.json")));
316287
+ app.use("/myst.search.json", import_express.default.static((0, import_node_path53.join)(session.sitePath(), "myst.search.json")));
316125
316288
  const server = app.listen(port, () => {
316126
316289
  session.log.debug(`Content server listening on port ${port}`);
316127
316290
  });
@@ -316347,6 +316510,7 @@ async function buildHtml(session, opts) {
316347
316510
  ref.data = (_a7 = ref.data) === null || _a7 === void 0 ? void 0 : _a7.replace(/^\/content/, "");
316348
316511
  });
316349
316512
  import_fs_extra.default.writeFileSync(import_node_path54.default.join(htmlDir, "myst.xref.json"), JSON.stringify(xrefs));
316513
+ import_fs_extra.default.copySync(import_node_path54.default.join(session.sitePath(), "myst.search.json"), import_node_path54.default.join(htmlDir, "myst.search.json"));
316350
316514
  rewriteAssetsFolder(htmlDir, baseurl);
316351
316515
  process.exit(0);
316352
316516
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes