mystmd 1.1.53__tar.gz → 1.1.54__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.1.53
3
+ Version: 1.1.54
4
4
  Summary: Command line tools for MyST Markdown
5
5
  Project-URL: Homepage, https://github.com/executablebooks/mystmd
6
6
  Project-URL: Bug Tracker, https://github.com/executablebooks/mystmd/issues
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mystmd",
3
- "version": "1.1.53",
3
+ "version": "1.1.54",
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.1.53"
48
+ "myst-cli": "^1.1.54"
49
49
  }
50
50
  }
@@ -193279,7 +193279,7 @@ var {
193279
193279
  } = import_index.default;
193280
193280
 
193281
193281
  // src/version.ts
193282
- var version = "1.1.53";
193282
+ var version = "1.1.54";
193283
193283
  var version_default = version;
193284
193284
 
193285
193285
  // ../myst-cli/dist/build/build.js
@@ -194861,6 +194861,8 @@ var FRONTMATTER_ALIASES = {
194861
194861
  part: "parts",
194862
194862
  ack: "acknowledgments",
194863
194863
  acknowledgements: "acknowledgments",
194864
+ acknowledgment: "acknowledgments",
194865
+ acknowledgement: "acknowledgments",
194864
194866
  availability: "data_availability",
194865
194867
  dataAvailability: "data_availability",
194866
194868
  "data-availability": "data_availability",
@@ -198266,7 +198268,7 @@ function validatePageFrontmatterKeys(value, opts) {
198266
198268
  const partsOptions = incrementOptions("parts", opts);
198267
198269
  let parts;
198268
198270
  if (defined(value.parts)) {
198269
- parts = validateObject(value.parts, partsOptions);
198271
+ parts = validateObjectKeys(value.parts, { optional: PAGE_KNOWN_PARTS, alias: FRONTMATTER_ALIASES }, { keepExtraKeys: true, suppressWarnings: true, ...partsOptions });
198270
198272
  }
198271
198273
  PAGE_KNOWN_PARTS.forEach((partKey) => {
198272
198274
  if (defined(value[partKey])) {
@@ -199958,7 +199960,21 @@ function coercePart(part) {
199958
199960
  if (!part) {
199959
199961
  return [];
199960
199962
  }
199961
- return typeof part === "string" ? [part.toLowerCase()] : part.map((s5) => s5.toLowerCase());
199963
+ if (typeof part === "string")
199964
+ return coercePart([part]);
199965
+ const parts = [];
199966
+ part.map((p5) => p5.toLowerCase()).forEach((p5) => {
199967
+ parts.push(p5);
199968
+ Object.entries(FRONTMATTER_ALIASES).forEach(([alias, value]) => {
199969
+ if (p5 === alias || p5 === value) {
199970
+ if (!parts.includes(value))
199971
+ parts.unshift(value);
199972
+ if (!parts.includes(alias))
199973
+ parts.push(alias);
199974
+ }
199975
+ });
199976
+ });
199977
+ return parts;
199962
199978
  }
199963
199979
  function selectBlockParts(tree, part) {
199964
199980
  const parts = coercePart(part);
@@ -202921,9 +202937,55 @@ var jsYaml = {
202921
202937
  };
202922
202938
  var js_yaml_default = jsYaml;
202923
202939
 
202940
+ // ../myst-config/dist/errorRules/validators.js
202941
+ var ERROR_RULE_KEY_OBJECT = {
202942
+ required: ["id"],
202943
+ optional: ["severity", "keys"],
202944
+ alias: {
202945
+ rule: "id",
202946
+ key: "keys"
202947
+ }
202948
+ };
202949
+ function validateErrorRule(input3, opts) {
202950
+ if (typeof input3 === "string") {
202951
+ input3 = { id: input3 };
202952
+ }
202953
+ const value = validateObjectKeys(input3, ERROR_RULE_KEY_OBJECT, {
202954
+ ...opts
202955
+ });
202956
+ if (value === void 0)
202957
+ return void 0;
202958
+ const id = validateString(value.id, incrementOptions("id", opts));
202959
+ const severity = validateChoice(value.severity || "ignore", {
202960
+ ...incrementOptions("severity", opts),
202961
+ choices: ["ignore", "warn", "error"]
202962
+ });
202963
+ if (!id || !severity)
202964
+ return void 0;
202965
+ const output2 = { id, severity };
202966
+ if (!defined(value.keys))
202967
+ return [output2];
202968
+ const keyList = validateList(value.keys, { ...incrementOptions("keys", opts), coerce: true }, (key2, ind) => {
202969
+ return validateString(key2, incrementOptions(`keys.${ind}`, opts));
202970
+ });
202971
+ if (!keyList)
202972
+ return void 0;
202973
+ return keyList.map((key2) => ({ ...output2, key: key2 }));
202974
+ }
202975
+ function validateErrorRuleList(input3, opts) {
202976
+ if (input3 === void 0)
202977
+ return void 0;
202978
+ const output2 = validateList(input3, { coerce: true, ...incrementOptions("error_rules", opts) }, (exp, ind) => {
202979
+ return validateErrorRule(exp, incrementOptions(`error_rules.${ind}`, opts));
202980
+ });
202981
+ if (!output2)
202982
+ return void 0;
202983
+ return output2.flat();
202984
+ }
202985
+
202924
202986
  // ../myst-config/dist/project/validators.js
202925
202987
  var PROJECT_CONFIG_KEYS = {
202926
- optional: ["remote", "index", "exclude", "plugins", ...PROJECT_FRONTMATTER_KEYS],
202988
+ optional: ["remote", "index", "exclude", "plugins", "error_rules", ...PROJECT_FRONTMATTER_KEYS],
202927
202989
  alias: FRONTMATTER_ALIASES
202928
202990
  };
202929
202991
  function validateProjectConfigKeys(value, opts) {
@@ -202944,6 +203006,11 @@ function validateProjectConfigKeys(value, opts) {
202944
203006
  return validateString(file, incrementOptions(`plugins.${index4}`, opts));
202945
203007
  });
202946
203008
  }
203009
+ if (defined(value.error_rules)) {
203010
+ const error_rules = validateErrorRuleList(value.error_rules, opts);
203011
+ if (error_rules)
203012
+ output2.error_rules = error_rules;
203013
+ }
202947
203014
  return output2;
202948
203015
  }
202949
203016
  function validateProjectConfig(input3, opts) {
@@ -236414,6 +236481,7 @@ var SUBFIGURE_TYPES = [
236414
236481
  "block",
236415
236482
  "container",
236416
236483
  "image",
236484
+ "mermaid",
236417
236485
  "iframe",
236418
236486
  "table",
236419
236487
  "code",
@@ -239600,8 +239668,8 @@ var rootReducer = combineReducers({
239600
239668
  });
239601
239669
 
239602
239670
  // ../myst-cli/dist/utils/addWarningForFile.js
239603
- function addWarningForFile(session, file, message, kind = "warn", opts) {
239604
- var _a6, _b, _c;
239671
+ function addWarningForFile(session, file, message, severity = "warn", opts) {
239672
+ var _a6, _b, _c, _d2, _e;
239605
239673
  const line2 = ((_a6 = opts === null || opts === void 0 ? void 0 : opts.position) === null || _a6 === void 0 ? void 0 : _a6.start.line) ? `:${opts === null || opts === void 0 ? void 0 : opts.position.start.line}` : "";
239606
239674
  const column = ((_b = opts === null || opts === void 0 ? void 0 : opts.position) === null || _b === void 0 ? void 0 : _b.start.column) && ((_c = opts === null || opts === void 0 ? void 0 : opts.position) === null || _c === void 0 ? void 0 : _c.start.column) > 1 ? `:${opts === null || opts === void 0 ? void 0 : opts.position.start.column}` : "";
239607
239675
  const note = (opts === null || opts === void 0 ? void 0 : opts.note) ? `
@@ -239611,7 +239679,23 @@ function addWarningForFile(session, file, message, kind = "warn", opts) {
239611
239679
  `) : "";
239612
239680
  const prefix2 = file ? `${file}${line2}${column} ` : "";
239613
239681
  const formatted = `${message}${note}${url}`;
239614
- switch (kind) {
239682
+ if (opts === null || opts === void 0 ? void 0 : opts.ruleId) {
239683
+ const config2 = selectCurrentProjectConfig(session.store.getState());
239684
+ const handler = (_d2 = config2 === null || config2 === void 0 ? void 0 : config2.error_rules) === null || _d2 === void 0 ? void 0 : _d2.find((rule) => {
239685
+ if (rule.key) {
239686
+ return rule.id === opts.ruleId && rule.key === opts.key;
239687
+ }
239688
+ return rule.id === opts.ruleId;
239689
+ });
239690
+ if (handler) {
239691
+ if (handler.severity === "ignore") {
239692
+ session.log.debug(`${prefix2}${formatted}`);
239693
+ return;
239694
+ }
239695
+ severity = (_e = handler.severity) !== null && _e !== void 0 ? _e : severity;
239696
+ }
239697
+ }
239698
+ switch (severity) {
239615
239699
  case "info":
239616
239700
  session.log.info(`\u2139\uFE0F ${prefix2}${formatted}`);
239617
239701
  break;
@@ -239623,11 +239707,14 @@ function addWarningForFile(session, file, message, kind = "warn", opts) {
239623
239707
  session.log.warn(`\u26A0\uFE0F ${prefix2}${formatted}`);
239624
239708
  break;
239625
239709
  }
239710
+ if (opts === null || opts === void 0 ? void 0 : opts.ruleId) {
239711
+ session.log.debug(`To suppress this message, add rule: "${opts.ruleId}"${opts.key ? ` with key: "${opts.key}"` : ""} to "error_rules" in your project config`);
239712
+ }
239626
239713
  if (file) {
239627
239714
  session.store.dispatch(warnings.actions.addWarning({
239628
239715
  file,
239629
239716
  message,
239630
- kind,
239717
+ kind: severity,
239631
239718
  url: opts === null || opts === void 0 ? void 0 : opts.url,
239632
239719
  note: opts === null || opts === void 0 ? void 0 : opts.note,
239633
239720
  position: opts === null || opts === void 0 ? void 0 : opts.position,
@@ -282591,7 +282678,8 @@ var defaultMdast = {
282591
282678
  args: (_a6 = t2.meta) === null || _a6 === void 0 ? void 0 : _a6.arg,
282592
282679
  options: (_b = t2.meta) === null || _b === void 0 ? void 0 : _b.options,
282593
282680
  value: t2.content || void 0,
282594
- tight: ((_c = t2.meta) === null || _c === void 0 ? void 0 : _c.tight) || void 0
282681
+ tight: ((_c = t2.meta) === null || _c === void 0 ? void 0 : _c.tight) || void 0,
282682
+ processed: false
282595
282683
  };
282596
282684
  }
282597
282685
  },
@@ -282629,7 +282717,8 @@ var defaultMdast = {
282629
282717
  getAttrs(t2) {
282630
282718
  return {
282631
282719
  name: t2.info,
282632
- value: t2.content
282720
+ value: t2.content,
282721
+ processed: false
282633
282722
  };
282634
282723
  }
282635
282724
  },
@@ -282852,8 +282941,9 @@ function applyRoles(tree, specs, vfile2) {
282852
282941
  }
282853
282942
  });
282854
282943
  });
282855
- const nodes = selectAll("mystRole", tree);
282944
+ const nodes = selectAll("mystRole[processed=false]", tree);
282856
282945
  nodes.forEach((node3) => {
282946
+ delete node3.processed;
282857
282947
  const { name: name3 } = node3;
282858
282948
  const spec = specLookup[name3];
282859
282949
  if (!spec) {
@@ -282896,7 +282986,7 @@ function applyRoles(tree, specs, vfile2) {
282896
282986
  }
282897
282987
 
282898
282988
  // ../myst-parser/dist/directives.js
282899
- function applyDirectives(tree, specs, vfile2) {
282989
+ function applyDirectives(tree, specs, vfile2, ctx) {
282900
282990
  const specLookup = {};
282901
282991
  specs.forEach((spec) => {
282902
282992
  const names = [spec.name];
@@ -282913,9 +283003,10 @@ function applyDirectives(tree, specs, vfile2) {
282913
283003
  }
282914
283004
  });
282915
283005
  });
282916
- const nodes = selectAll("mystDirective", tree);
283006
+ const nodes = selectAll("mystDirective[processed=false]", tree);
282917
283007
  nodes.forEach((node3) => {
282918
283008
  var _a6, _b, _c, _d2;
283009
+ delete node3.processed;
282919
283010
  const { name: name3 } = node3;
282920
283011
  const spec = specLookup[name3];
282921
283012
  if (!spec) {
@@ -283042,7 +283133,10 @@ ${node3.value}` : "";
283042
283133
  if (validate5) {
283043
283134
  data = validate5(data, vfile2);
283044
283135
  }
283045
- node3.children = run(data, vfile2);
283136
+ node3.children = run(data, vfile2, {
283137
+ // Implement a parseMyst function that accepts _relative_ line numbers
283138
+ parseMyst: (source2, offset = 0) => ctx.parseMyst(source2, offset + node3.position.start.line)
283139
+ });
283046
283140
  });
283047
283141
  }
283048
283142
 
@@ -283120,7 +283214,18 @@ function mystParse(content3, opts) {
283120
283214
  const parsedOpts = parseOptions(opts);
283121
283215
  const tokenizer = createTokenizer(parsedOpts);
283122
283216
  const tree = tokensToMyst(content3, tokenizer.parse(content3, { vfile: vfile2 }), parsedOpts.mdast);
283123
- applyDirectives(tree, parsedOpts.directives, parsedOpts.vfile);
283217
+ applyDirectives(tree, parsedOpts.directives, parsedOpts.vfile, {
283218
+ parseMyst: (source2, offset = 0) => {
283219
+ const mdast2 = mystParse(source2, opts);
283220
+ visit(mdast2, (node3) => {
283221
+ if (node3.position) {
283222
+ node3.position.start.line += offset;
283223
+ node3.position.end.line += offset;
283224
+ }
283225
+ });
283226
+ return mdast2;
283227
+ }
283228
+ });
283124
283229
  applyRoles(tree, parsedOpts.roles, parsedOpts.vfile);
283125
283230
  return tree;
283126
283231
  }
@@ -283668,7 +283773,7 @@ var import_node_path17 = __toESM(require("path"), 1);
283668
283773
  var import_nbtx = __toESM(require_cjs2(), 1);
283669
283774
 
283670
283775
  // ../myst-cli/dist/version.js
283671
- var version2 = "1.1.53";
283776
+ var version2 = "1.1.54";
283672
283777
  var version_default2 = version2;
283673
283778
 
283674
283779
  // ../myst-cli/dist/utils/headers.js
@@ -295803,7 +295908,8 @@ async function checkLinksTransform(session, file, mdast2) {
295803
295908
  const status = check2.status ? ` (${check2.status}, ${check2.statusText})` : "";
295804
295909
  addWarningForFile(session, file, `Link for "${url}" did not resolve.${status}`, "error", {
295805
295910
  position: position6,
295806
- ruleId: RuleId.linkResolves
295911
+ ruleId: RuleId.linkResolves,
295912
+ key: url
295807
295913
  });
295808
295914
  return url;
295809
295915
  })));
@@ -296247,7 +296353,7 @@ async function kernelExecutionTransform(tree, vfile2, opts) {
296247
296353
  } else {
296248
296354
  let sessionConnection;
296249
296355
  const sessionOpts = {
296250
- path: vfile2.path,
296356
+ path: import_node_path36.default.relative(opts.basePath, vfile2.path),
296251
296357
  type: "notebook",
296252
296358
  name: import_node_path36.default.basename(vfile2.path),
296253
296359
  kernel: {
@@ -296812,12 +296918,16 @@ async function launchJupyterServer(contentPath, log) {
296812
296918
  const pythonPath = import_which3.default.sync("python");
296813
296919
  const proc2 = (0, import_node_child_process.spawn)(pythonPath, ["-m", "jupyter_server", "--ServerApp.root_dir", contentPath]);
296814
296920
  const reader = proc2.stderr;
296921
+ let timerID;
296815
296922
  const settings = await new Promise((resolve7, reject) => {
296816
- const id = setTimeout(() => {
296817
- log.error(`\u{1FA90} ${source_default3.redBright("Jupyter server did not respond")}
296818
- ${source_default3.dim(url)}`);
296923
+ timerID = setTimeout(() => {
296924
+ log.error(`\u{1FA90} ${source_default3.redBright("Jupyter server did not respond")}`);
296819
296925
  reject();
296820
296926
  }, 2e4);
296927
+ proc2.on("exit", () => {
296928
+ log.error(`\u{1FA90} ${source_default3.redBright("Jupyter server did not start")}`);
296929
+ reject();
296930
+ });
296821
296931
  reader.on("data", (buf) => {
296822
296932
  const data = buf.toString();
296823
296933
  const match3 = data.match(/([^\s]*?)\?token=([^\s]*)/);
@@ -296825,7 +296935,6 @@ async function launchJupyterServer(contentPath, log) {
296825
296935
  return;
296826
296936
  }
296827
296937
  const [, addr, token] = match3;
296828
- clearTimeout(id);
296829
296938
  resolve7({
296830
296939
  baseUrl: addr,
296831
296940
  token
@@ -296833,7 +296942,13 @@ async function launchJupyterServer(contentPath, log) {
296833
296942
  });
296834
296943
  }).finally(
296835
296944
  // Don't keep listening to messages
296836
- () => reader.removeAllListeners("data")
296945
+ () => {
296946
+ reader.removeAllListeners("data");
296947
+ proc2.removeAllListeners("exit");
296948
+ if (timerID !== void 0) {
296949
+ clearTimeout(timerID);
296950
+ }
296951
+ }
296837
296952
  );
296838
296953
  const url = `${settings.baseUrl}?token=${settings.token}`;
296839
296954
  log.info(`\u{1FA90} ${source_default3.greenBright("Jupyter server started")}
@@ -296969,6 +297084,7 @@ async function transformMdast(session, opts) {
296969
297084
  if (execute) {
296970
297085
  const cachePath = import_node_path38.default.join(session.buildPath(), "execute");
296971
297086
  await kernelExecutionTransform(mdast2, vfile2, {
297087
+ basePath: session.sourcePath(),
296972
297088
  cache: new LocalDiskCache(cachePath),
296973
297089
  sessionFactory: () => session.jupyterSessionManager(),
296974
297090
  frontmatter,
@@ -297380,7 +297496,8 @@ ${page.file}
297380
297496
  if (hasWarnings[0] > 0) {
297381
297497
  const pluralE = hasWarnings[0] > 1 ? "s" : "";
297382
297498
  const pluralW = hasWarnings[1] > 1 ? "s" : "";
297383
- throw new Error(`Site has ${hasWarnings[0]} error${pluralE} and ${hasWarnings[1]} warning${pluralW}, stopping build.`);
297499
+ session.log.error(`Site has ${hasWarnings[0]} error${pluralE} and ${hasWarnings[1]} warning${pluralW}, stopping build.`);
297500
+ process.exit(1);
297384
297501
  }
297385
297502
  }
297386
297503
  if ((_b = opts === null || opts === void 0 ? void 0 : opts.writeFiles) !== null && _b !== void 0 ? _b : true) {
@@ -297714,7 +297831,7 @@ async function currentSiteRoutes(session, host, baseurl, opts) {
297714
297831
  };
297715
297832
  }),
297716
297833
  // Download other assets
297717
- ...["robots.txt", "sitemap.xml", "sitemap_style.xsl"].map((asset) => ({
297834
+ ...["favicon.ico", "robots.txt"].map((asset) => ({
297718
297835
  url: `${host}/${asset}`,
297719
297836
  path: asset
297720
297837
  }))
@@ -312418,6 +312535,7 @@ var SITE_CONFIG = `site:
312418
312535
  template: book-theme
312419
312536
  # title:
312420
312537
  # options:
312538
+ # favicon: favicon.ico
312421
312539
  # logo: site_logo.png
312422
312540
  nav: []
312423
312541
  actions:
File without changes
File without changes
File without changes
File without changes
File without changes