jats-cli 1.1.0 → 1.1.2

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.
package/README.md CHANGED
@@ -94,6 +94,6 @@ As of v1.0.0 this package is [ESM only](https://gist.github.com/sindresorhus/a39
94
94
  <p style="text-align: center; color: #aaa; padding-top: 50px">
95
95
  Made with love by
96
96
  <a href="https://continuous.foundation" target="_blank" style="color: #aaa">
97
- Continuous Science Foundation <img src="https://continuous.foundation/images/logo-small.svg" style="height: 1em" />
97
+ Continuous Science Foundation <img src="https://cdn.curvenote.com/static/site/csf/icon.svg" style="height: 1em" />
98
98
  </a>
99
99
  </p>
package/dist/jats-test.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Command, Option } from 'commander';
2
2
  import { clirun, tic } from 'myst-cli-utils';
3
- import yaml from 'js-yaml';
3
+ import { load, dump } from 'js-yaml';
4
4
  import fs from 'fs';
5
5
  import { select, selectAll } from 'unist-util-select';
6
6
  import { is } from 'unist-util-is';
@@ -9,14 +9,12 @@ import { getSession } from 'jats-xml';
9
9
  import { parseJats } from './parse.js';
10
10
  const INDENT = ' ';
11
11
  function printNodes(expected, received) {
12
- return chalk.reset(`\n${INDENT}${chalk.greenBright('Expected node containing')}:\n${INDENT} ${yaml
13
- .dump(expected)
14
- .replace(/\n/g, `\n${INDENT} `)}\n${INDENT}${chalk.redBright('Received node')}:\n${INDENT} ${yaml.dump(received).replace(/\n/g, `\n${INDENT} `)}`);
12
+ return chalk.reset(`\n${INDENT}${chalk.greenBright('Expected node containing')}:\n${INDENT} ${dump(expected).replace(/\n/g, `\n${INDENT} `)}\n${INDENT}${chalk.redBright('Received node')}:\n${INDENT} ${dump(received).replace(/\n/g, `\n${INDENT} `)}`);
15
13
  }
16
14
  export async function testJatsFile(session, file, opts) {
17
15
  const toc = tic();
18
16
  const jats = await parseJats(session, file);
19
- const tests = yaml.load(fs.readFileSync(opts.cases).toString());
17
+ const tests = load(fs.readFileSync(opts.cases).toString());
20
18
  const results = tests.cases.map((testCase, index) => {
21
19
  if (!testCase.title) {
22
20
  return [`Test Case ${index}`, null, 'Test must include a title'];
package/dist/jats.cjs CHANGED
@@ -33957,7 +33957,7 @@ var require_dist_cjs71 = __commonJS({
33957
33957
  Tier: () => Tier,
33958
33958
  TransitionDefaultMinimumObjectSize: () => TransitionDefaultMinimumObjectSize,
33959
33959
  TransitionStorageClass: () => TransitionStorageClass,
33960
- Type: () => Type2,
33960
+ Type: () => Type,
33961
33961
  UploadPartCommand: () => UploadPartCommand,
33962
33962
  UploadPartCopyCommand: () => UploadPartCopyCommand,
33963
33963
  UploadPartCopyOutputFilterSensitiveLog: () => UploadPartCopyOutputFilterSensitiveLog,
@@ -34060,7 +34060,7 @@ var require_dist_cjs71 = __commonJS({
34060
34060
  Enabled: "Enabled",
34061
34061
  Suspended: "Suspended"
34062
34062
  };
34063
- var Type2 = {
34063
+ var Type = {
34064
34064
  AmazonCustomerByEmail: "AmazonCustomerByEmail",
34065
34065
  CanonicalUser: "CanonicalUser",
34066
34066
  Group: "Group"
@@ -48999,7 +48999,7 @@ var {
48999
48999
  } = import_index.default;
49000
49000
 
49001
49001
  // src/version.ts
49002
- var version = "1.1.0";
49002
+ var version = "1.1.2";
49003
49003
  var version_default = version;
49004
49004
 
49005
49005
  // src/parse.ts
@@ -55916,11 +55916,14 @@ var RuleId;
55916
55916
  })(RuleId || (RuleId = {}));
55917
55917
 
55918
55918
  // ../jats-utils/dist/utils.js
55919
- function convertToUnist(node) {
55919
+ function convertToUnist(node, ctx) {
55920
+ var _a;
55921
+ const insidePreformat = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.insidePreformat) !== null && _a !== void 0 ? _a : false;
55920
55922
  switch (node.type) {
55921
55923
  case "element": {
55922
55924
  const { name: name2, attributes, elements } = node;
55923
- const children = elements === null || elements === void 0 ? void 0 : elements.map(convertToUnist).filter((n) => !!n);
55925
+ const nextInside = insidePreformat || name2 === "preformat";
55926
+ const children = elements === null || elements === void 0 ? void 0 : elements.map((el) => convertToUnist(el, { insidePreformat: nextInside })).filter((n) => !!n);
55924
55927
  const { type: type2, ...attrs } = attributes !== null && attributes !== void 0 ? attributes : {};
55925
55928
  if (type2 !== void 0)
55926
55929
  attrs._type = type2;
@@ -55933,18 +55936,24 @@ function convertToUnist(node) {
55933
55936
  }
55934
55937
  case "text": {
55935
55938
  const { attributes, text } = node;
55939
+ const raw = String(text);
55940
+ if (!insidePreformat && !raw.trim()) {
55941
+ return void 0;
55942
+ }
55943
+ const value = insidePreformat ? raw : raw.replace(/\n(\s+)$/, "");
55936
55944
  return {
55937
55945
  type: "text",
55938
55946
  ...attributes,
55939
- value: String(text).replace(/\n(\s+)$/, "")
55947
+ value
55940
55948
  };
55941
55949
  }
55942
55950
  case "cdata": {
55943
55951
  const { attributes, cdata } = node;
55952
+ const str2 = String(cdata);
55944
55953
  return {
55945
55954
  type: "cdata",
55946
55955
  ...attributes,
55947
- cdata: String(cdata).trim()
55956
+ cdata: insidePreformat ? str2 : str2.trim()
55948
55957
  };
55949
55958
  }
55950
55959
  case "comment": {
@@ -58720,10 +58729,29 @@ var tableWrapOrder = order([
58720
58729
 
58721
58730
  // ../jats-xml/dist/jats.js
58722
58731
  function select2(selector, node) {
58723
- var _a;
58724
- return (_a = select(selector, node)) !== null && _a !== void 0 ? _a : void 0;
58732
+ var _a, _b;
58733
+ try {
58734
+ return (_a = select(selector, node)) !== null && _a !== void 0 ? _a : void 0;
58735
+ } catch (error) {
58736
+ const nodeType = (_b = node === null || node === void 0 ? void 0 : node.type) !== null && _b !== void 0 ? _b : "(undefined)";
58737
+ const msg = error instanceof Error ? error.message : String(error);
58738
+ throw new Error(`[jats-xml/select] selector="${selector}" nodeType="${nodeType}" failed: ${msg}`);
58739
+ }
58725
58740
  }
58726
58741
  var DEFAULT_DOCTYPE = 'article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with MathML3 v1.3 20210610//EN" "http://jats.nlm.nih.gov/publishing/1.3/JATS-archivearticle1-3-mathml3.dtd"';
58742
+ function significantChildElements(elements) {
58743
+ return elements === null || elements === void 0 ? void 0 : elements.filter((elem) => {
58744
+ var _a;
58745
+ if (elem.type === "comment")
58746
+ return false;
58747
+ if (elem.type === "text") {
58748
+ const t2 = String((_a = elem.text) !== null && _a !== void 0 ? _a : "");
58749
+ if (!t2.trim())
58750
+ return false;
58751
+ }
58752
+ return true;
58753
+ });
58754
+ }
58727
58755
  var Jats = class {
58728
58756
  constructor(data, opts) {
58729
58757
  var _a, _b;
@@ -58732,13 +58760,18 @@ var Jats = class {
58732
58760
  if (opts === null || opts === void 0 ? void 0 : opts.source)
58733
58761
  this.source = opts.source;
58734
58762
  try {
58735
- this.raw = (0, import_xml_js3.xml2js)(data, { compact: false });
58763
+ this.raw = (0, import_xml_js3.xml2js)(data, {
58764
+ compact: false,
58765
+ // Preserve whitespace-only text nodes between elements. This is usually unnecessary except inside <preformat>.
58766
+ // convertToUnist drops these outside preformat so other content is processed independent of arbitrary xml whitespace.
58767
+ captureSpacesBetweenElements: true
58768
+ });
58736
58769
  } catch (error) {
58737
58770
  throw new Error("Problem parsing the JATS document, please ensure it is XML");
58738
58771
  }
58739
58772
  const { declaration, elements } = this.raw;
58740
58773
  this.declaration = declaration === null || declaration === void 0 ? void 0 : declaration.attributes;
58741
- const filteredElements = elements === null || elements === void 0 ? void 0 : elements.filter((elem) => elem.type !== "comment");
58774
+ const filteredElements = significantChildElements(elements);
58742
58775
  if ((filteredElements === null || filteredElements === void 0 ? void 0 : filteredElements.length) && filteredElements[0].type !== "doctype") {
58743
58776
  (_a = this.log) === null || _a === void 0 ? void 0 : _a.warn("JATS is missing DOCTYPE declaration");
58744
58777
  filteredElements.unshift({ type: "doctype" });
@@ -58752,42 +58785,45 @@ var Jats = class {
58752
58785
  (_b = this.log) === null || _b === void 0 ? void 0 : _b.debug(toc("Parsed and converted JATS to unist tree in %s"));
58753
58786
  }
58754
58787
  get frontmatter() {
58755
- var _a, _b, _c, _d, _e, _f, _g, _h;
58788
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
58756
58789
  const title = this.articleTitle;
58757
58790
  const subtitle = this.articleSubtitle;
58758
58791
  const short_title = this.articleAltTitle;
58759
58792
  let date;
58760
- if (this.publicationDate) {
58761
- const pubDate = toDate(this.publicationDate);
58762
- if (pubDate) {
58763
- const year = pubDate.getFullYear();
58764
- const month = (pubDate.getMonth() + 1).toString().padStart(2, "0");
58765
- const day = pubDate.getDate().toString().padStart(2, "0");
58793
+ const preferredDateNode = (_c = (_b = (_a = this.publicationDate) !== null && _a !== void 0 ? _a : this.pubHistoryPubDate) !== null && _b !== void 0 ? _b : this.pubHistoryAcceptedDate) !== null && _c !== void 0 ? _c : this.historyAcceptedDate;
58794
+ if (preferredDateNode) {
58795
+ const d = toDate(preferredDateNode);
58796
+ if (d) {
58797
+ const year = d.getUTCFullYear();
58798
+ const month = (d.getUTCMonth() + 1).toString().padStart(2, "0");
58799
+ const day = d.getUTCDate().toString().padStart(2, "0");
58766
58800
  date = `${year}-${month}-${day}`;
58767
58801
  }
58768
58802
  }
58769
- const authors = (_a = this.articleAuthors) === null || _a === void 0 ? void 0 : _a.map((auth) => {
58803
+ const authors = (_d = this.articleAuthors) === null || _d === void 0 ? void 0 : _d.map((auth) => {
58770
58804
  return processContributor(auth);
58771
58805
  });
58772
- const affiliations = (_b = this.articleAffiliations) === null || _b === void 0 ? void 0 : _b.map((aff) => {
58806
+ const affiliations = (_e = this.articleAffiliations) === null || _e === void 0 ? void 0 : _e.map((aff) => {
58773
58807
  return processAffiliation(aff);
58774
58808
  });
58775
- const keywords = (_d = (_c = this.keywords) === null || _c === void 0 ? void 0 : _c.map((k) => toText(k))) !== null && _d !== void 0 ? _d : [];
58776
- const firstSubject = select2(Tags.subject, (_e = this.articleCategories) !== null && _e !== void 0 ? _e : this.front);
58809
+ const keywords = (_g = (_f = this.keywords) === null || _f === void 0 ? void 0 : _f.map((k) => toText(k))) !== null && _g !== void 0 ? _g : [];
58810
+ const subjectScope = (_h = this.articleCategories) !== null && _h !== void 0 ? _h : this.front;
58811
+ const journalCollSubject = select2(`${Tags.subjGroup}[subj-group-type="hwp-journal-coll"] ${Tags.subject}`, subjectScope);
58812
+ const articleSubject = journalCollSubject !== null && journalCollSubject !== void 0 ? journalCollSubject : select2(Tags.subject, subjectScope);
58777
58813
  const journalTitle = select2(Tags.journalTitle, this.front);
58778
58814
  const license = this.license;
58779
58815
  let licenseString = null;
58780
58816
  if (license === null || license === void 0 ? void 0 : license["xlink:href"]) {
58781
58817
  licenseString = license["xlink:href"];
58782
- } else if (select2("[type=ali:license_ref]", license)) {
58783
- licenseString = toText(select2("[type=ali:license_ref]", license));
58818
+ } else if (license && select2("[type=ali\\:license_ref]", license)) {
58819
+ licenseString = toText(select2("[type=ali\\:license_ref]", license));
58784
58820
  } else if (selectAll("ext-link", license).length === 1) {
58785
- licenseString = (_f = select2("ext-link", license)["xlink:href"]) !== null && _f !== void 0 ? _f : null;
58821
+ licenseString = (_j = select2("ext-link", license)["xlink:href"]) !== null && _j !== void 0 ? _j : null;
58786
58822
  } else if (license) {
58787
58823
  licenseString = toText(license);
58788
58824
  }
58789
58825
  let openAccess;
58790
- const licenseType = (_g = license === null || license === void 0 ? void 0 : license["license-type"]) === null || _g === void 0 ? void 0 : _g.toLowerCase();
58826
+ const licenseType = (_k = license === null || license === void 0 ? void 0 : license["license-type"]) === null || _k === void 0 ? void 0 : _k.toLowerCase();
58791
58827
  if (licenseType && ["openaccess", "open-access"].includes(licenseType)) {
58792
58828
  openAccess = true;
58793
58829
  } else if (licenseString === null || licenseString === void 0 ? void 0 : licenseString.match(/^\s*Open Access\s*This/)) {
@@ -58802,7 +58838,7 @@ var Jats = class {
58802
58838
  title: title ? toText(title) : void 0,
58803
58839
  subtitle: subtitle ? toText(subtitle) : void 0,
58804
58840
  short_title: short_title ? toText(short_title) : void 0,
58805
- doi: (_h = this.doi) !== null && _h !== void 0 ? _h : void 0,
58841
+ doi: (_l = this.doi) !== null && _l !== void 0 ? _l : void 0,
58806
58842
  identifiers,
58807
58843
  date,
58808
58844
  authors: authors.length ? authors : void 0,
@@ -58810,7 +58846,7 @@ var Jats = class {
58810
58846
  affiliations: affiliations.length ? affiliations : void 0,
58811
58847
  keywords: keywords.length ? keywords : void 0,
58812
58848
  venue: journalTitle ? { title: toText(journalTitle) } : void 0,
58813
- subject: firstSubject ? toText(firstSubject) : void 0,
58849
+ subject: articleSubject ? toText(articleSubject) : void 0,
58814
58850
  license: licenseString !== null && licenseString !== void 0 ? licenseString : void 0,
58815
58851
  open_access: openAccess
58816
58852
  }, { property: "frontmatter", messages: {} });
@@ -58842,6 +58878,49 @@ var Jats = class {
58842
58878
  get publicationDate() {
58843
58879
  return this.publicationDates.find((d) => !!select2(Tags.day, d));
58844
58880
  }
58881
+ /**
58882
+ * JATS `<history>` can include multiple `<date date-type="...">` nodes,
58883
+ * often including an "accepted" date that is a better default for project/page `date`.
58884
+ */
58885
+ get historyDates() {
58886
+ var _a;
58887
+ return selectAll("history date", (_a = this.articleMeta) !== null && _a !== void 0 ? _a : this.front);
58888
+ }
58889
+ get historyAcceptedDate() {
58890
+ const accepted = this.historyDates.find((d) => {
58891
+ var _a;
58892
+ const dt = String((_a = d["date-type"]) !== null && _a !== void 0 ? _a : "").toLowerCase();
58893
+ return dt === "accepted" || dt === "accept";
58894
+ });
58895
+ if (accepted && select2(Tags.day, accepted))
58896
+ return accepted;
58897
+ return void 0;
58898
+ }
58899
+ /**
58900
+ * Some sources store important dates under:
58901
+ * `<article-meta><pub-history><event><date date-type="...">...</date></event></pub-history>`.
58902
+ */
58903
+ get pubHistoryDates() {
58904
+ var _a;
58905
+ return selectAll("pub-history event date", (_a = this.articleMeta) !== null && _a !== void 0 ? _a : this.front);
58906
+ }
58907
+ findPubHistoryDateByType(types3) {
58908
+ const wanted = new Set(types3.map((t2) => t2.toLowerCase()));
58909
+ const found = this.pubHistoryDates.find((d) => {
58910
+ var _a;
58911
+ const dt = String((_a = d["date-type"]) !== null && _a !== void 0 ? _a : "").toLowerCase();
58912
+ return wanted.has(dt);
58913
+ });
58914
+ if (found && select2(Tags.day, found))
58915
+ return found;
58916
+ return void 0;
58917
+ }
58918
+ get pubHistoryPubDate() {
58919
+ return this.findPubHistoryDateByType(["pub", "published", "publication"]);
58920
+ }
58921
+ get pubHistoryAcceptedDate() {
58922
+ return this.findPubHistoryDateByType(["accepted", "accept"]);
58923
+ }
58845
58924
  get license() {
58846
58925
  return select2(Tags.license, this.permissions);
58847
58926
  }
@@ -58905,11 +58984,19 @@ var Jats = class {
58905
58984
  get subArticles() {
58906
58985
  return selectAll(Tags.subArticle, this.tree);
58907
58986
  }
58987
+ /** First `ref-list` in back matter. */
58908
58988
  get refList() {
58909
- return select2(Tags.refList, this.back);
58989
+ return this.refLists[0];
58910
58990
  }
58991
+ /** All `ref-list` elements under `back`, in document order. */
58992
+ get refLists() {
58993
+ if (!this.back)
58994
+ return [];
58995
+ return selectAll(Tags.refList, this.back);
58996
+ }
58997
+ /** Every `ref` from every `ref-list` under `back`, in document order. */
58911
58998
  get references() {
58912
- return selectAll(Tags.ref, this.refList);
58999
+ return this.refLists.flatMap((list) => selectAll(Tags.ref, list));
58913
59000
  }
58914
59001
  sort() {
58915
59002
  var _a;
@@ -58943,12 +59030,12 @@ var Jats = class {
58943
59030
  }
58944
59031
  };
58945
59032
  function hasSingleArticle(element) {
58946
- var _a;
58947
59033
  if (element.name === "article") {
58948
59034
  return true;
58949
59035
  }
58950
- if (element.name === "pmc-articleset" && ((_a = element.elements) === null || _a === void 0 ? void 0 : _a.length) === 1 && element.elements[0].name === "article") {
58951
- return true;
59036
+ if (element.name === "pmc-articleset") {
59037
+ const children = significantChildElements(element.elements);
59038
+ return (children === null || children === void 0 ? void 0 : children.length) === 1 && children[0].name === "article";
58952
59039
  }
58953
59040
  return false;
58954
59041
  }
@@ -62513,51 +62600,12 @@ function renamed(from, to) {
62513
62600
  throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
62514
62601
  };
62515
62602
  }
62516
- var Type = type;
62517
- var Schema = schema;
62518
- var FAILSAFE_SCHEMA = failsafe;
62519
- var JSON_SCHEMA = json;
62520
- var CORE_SCHEMA = core;
62521
- var DEFAULT_SCHEMA = _default;
62522
62603
  var load = loader.load;
62523
62604
  var loadAll = loader.loadAll;
62524
62605
  var dump = dumper.dump;
62525
- var YAMLException = exception;
62526
- var types3 = {
62527
- binary,
62528
- float,
62529
- map,
62530
- null: _null,
62531
- pairs,
62532
- set,
62533
- timestamp,
62534
- bool,
62535
- int,
62536
- merge,
62537
- omap,
62538
- seq,
62539
- str
62540
- };
62541
62606
  var safeLoad = renamed("safeLoad", "load");
62542
62607
  var safeLoadAll = renamed("safeLoadAll", "loadAll");
62543
62608
  var safeDump = renamed("safeDump", "dump");
62544
- var jsYaml = {
62545
- Type,
62546
- Schema,
62547
- FAILSAFE_SCHEMA,
62548
- JSON_SCHEMA,
62549
- CORE_SCHEMA,
62550
- DEFAULT_SCHEMA,
62551
- load,
62552
- loadAll,
62553
- dump,
62554
- YAMLException,
62555
- types: types3,
62556
- safeLoad,
62557
- safeLoadAll,
62558
- safeDump
62559
- };
62560
- var js_yaml_default = jsYaml;
62561
62609
 
62562
62610
  // src/jats-test.ts
62563
62611
  var import_fs3 = __toESM(require("fs"), 1);
@@ -62566,19 +62614,21 @@ function printNodes(expected, received) {
62566
62614
  return source_default2.reset(
62567
62615
  `
62568
62616
  ${INDENT}${source_default2.greenBright("Expected node containing")}:
62569
- ${INDENT} ${js_yaml_default.dump(expected).replace(/\n/g, `
62617
+ ${INDENT} ${dump(
62618
+ expected
62619
+ ).replace(/\n/g, `
62570
62620
  ${INDENT} `)}
62571
62621
  ${INDENT}${source_default2.redBright(
62572
62622
  "Received node"
62573
62623
  )}:
62574
- ${INDENT} ${js_yaml_default.dump(received).replace(/\n/g, `
62624
+ ${INDENT} ${dump(received).replace(/\n/g, `
62575
62625
  ${INDENT} `)}`
62576
62626
  );
62577
62627
  }
62578
62628
  async function testJatsFile(session, file, opts) {
62579
62629
  const toc = tic();
62580
62630
  const jats = await parseJats(session, file);
62581
- const tests = js_yaml_default.load(import_fs3.default.readFileSync(opts.cases).toString());
62631
+ const tests = load(import_fs3.default.readFileSync(opts.cases).toString());
62582
62632
  const results = tests.cases.map((testCase, index2) => {
62583
62633
  if (!testCase.title) {
62584
62634
  return [`Test Case ${index2}`, null, "Test must include a title"];
@@ -63537,7 +63587,7 @@ var defaultPseudoSignature = {
63537
63587
  type: "String",
63538
63588
  optional: true
63539
63589
  };
63540
- function calculatePseudoSignature(types4) {
63590
+ function calculatePseudoSignature(types3) {
63541
63591
  var result = {
63542
63592
  type: "NoArgument",
63543
63593
  optional: false
@@ -63548,7 +63598,7 @@ function calculatePseudoSignature(types4) {
63548
63598
  }
63549
63599
  result.type = type3;
63550
63600
  }
63551
- for (var _i = 0, types_1 = types4; _i < types_1.length; _i++) {
63601
+ for (var _i = 0, types_1 = types3; _i < types_1.length; _i++) {
63552
63602
  var type2 = types_1[_i];
63553
63603
  if (type2 === "NoArgument") {
63554
63604
  result.optional = true;
@@ -64980,18 +65030,20 @@ var import_xml_js4 = __toESM(require_lib2(), 1);
64980
65030
 
64981
65031
  // ../jats-convert/dist/transforms/admonitions.js
64982
65032
  function admonitionTransform(tree, file) {
64983
- const captions = selectAll2(`${Tags.boxedText} > ${Tags.caption}`, tree);
64984
- captions.forEach((caption) => {
64985
- const title = select3(Tags.title, caption);
65033
+ const boxedTexts = selectAll2(Tags.boxedText, tree);
65034
+ boxedTexts.forEach((boxedText) => {
65035
+ const caption = select3(`${Tags.caption}`, boxedText);
65036
+ const title = caption ? select3(Tags.title, caption) : select3(Tags.title, boxedText);
64986
65037
  if (!title) {
64987
65038
  fileWarn(file, "Encountered boxed-text without title", {
64988
- node: caption,
65039
+ node: boxedText,
64989
65040
  ruleId: RuleId.jatsParses
64990
65041
  });
64991
- return;
65042
+ } else {
65043
+ const nodeToReplace = caption !== null && caption !== void 0 ? caption : title;
65044
+ nodeToReplace.type = "admonitionTitle";
65045
+ nodeToReplace.children = title.children;
64992
65046
  }
64993
- caption.type = "admonitionTitle";
64994
- caption.children = title.children;
64995
65047
  });
64996
65048
  const noCaptions = selectAll2(`${Tags.boxedText} > ${Tags.caption}`, tree);
64997
65049
  noCaptions.forEach((caption) => {
@@ -65004,6 +65056,20 @@ function admonitionTransform(tree, file) {
65004
65056
  function toText2(node) {
65005
65057
  return toText(node);
65006
65058
  }
65059
+ function toTextPreserveWhitespace(node) {
65060
+ if (!node)
65061
+ return "";
65062
+ if (typeof node === "string")
65063
+ return node;
65064
+ if (typeof node.value === "string")
65065
+ return node.value;
65066
+ if (typeof node.cdata === "string")
65067
+ return node.cdata;
65068
+ const children = node.children;
65069
+ if (!children || children.length === 0)
65070
+ return "";
65071
+ return children.map((child) => toTextPreserveWhitespace(child)).join("");
65072
+ }
65007
65073
  function copyNode2(node) {
65008
65074
  return copyNode(node);
65009
65075
  }
@@ -65725,7 +65791,7 @@ function journalTransforms(fullTree, body) {
65725
65791
  }
65726
65792
 
65727
65793
  // ../jats-convert/dist/version.js
65728
- var version3 = "1.1.0";
65794
+ var version3 = "1.1.2";
65729
65795
  var version_default3 = version3;
65730
65796
 
65731
65797
  // ../jats-convert/dist/myst/inlineCitations.js
@@ -65959,6 +66025,14 @@ function abbreviationsFromTree(tree, frontmatter) {
65959
66025
  function maybeStopWord(word) {
65960
66026
  return word.length < 5;
65961
66027
  }
66028
+ function isQuotedParentheticalLabel(abbr) {
66029
+ var _a, _b;
66030
+ const t2 = abbr.trim();
66031
+ if (!t2)
66032
+ return false;
66033
+ const mark = /\p{Quotation_Mark}/u;
66034
+ return mark.test((_a = t2[0]) !== null && _a !== void 0 ? _a : "") || mark.test((_b = t2[t2.length - 1]) !== null && _b !== void 0 ? _b : "");
66035
+ }
65962
66036
  function exploreAbbrPossibilities(letter, possibilities) {
65963
66037
  const newPossibilities = [];
65964
66038
  possibilities.forEach(({ prev, next }) => {
@@ -65988,7 +66062,7 @@ function abbreviationsFromText(text) {
65988
66062
  textList.forEach((word, index2) => {
65989
66063
  var _a;
65990
66064
  const abbr = (_a = word.match(/^\(([^\s]{2,})\).{0,1}/)) === null || _a === void 0 ? void 0 : _a[1];
65991
- if (!abbr)
66065
+ if (!abbr || isQuotedParentheticalLabel(abbr) || doi.validate(abbr.trim()) || isUrl(abbr.trim()))
65992
66066
  return;
65993
66067
  const possibleWords = [];
65994
66068
  let wordIndex = index2 - 1;
@@ -66117,8 +66191,11 @@ var handlers = {
66117
66191
  // },
66118
66192
  // code(node, state) {
66119
66193
  // const { lang } = node as Code;
66120
- // state.renderInline(node, 'code', { language: lang });
66194
+ // state.renderInline(node, 'code', { lang });
66121
66195
  // },
66196
+ preformat(node, state2) {
66197
+ state2.addLeaf("code", { value: toTextPreserveWhitespace(node), lang: "text" });
66198
+ },
66122
66199
  list(node, state2) {
66123
66200
  state2.renderInline(node, "list", {
66124
66201
  ordered: node["list-type"] === "ordered"
@@ -66249,6 +66326,10 @@ var handlers = {
66249
66326
  const link = node === null || node === void 0 ? void 0 : node["xlink:href"];
66250
66327
  state2.addLeaf("image", { url: link });
66251
66328
  },
66329
+ ["inline-graphic"](node, state2) {
66330
+ const link = node === null || node === void 0 ? void 0 : node["xlink:href"];
66331
+ state2.addLeaf("image", { url: link });
66332
+ },
66252
66333
  fig(node, state2) {
66253
66334
  var _a;
66254
66335
  const caption = select3("caption", node);
@@ -66726,15 +66807,15 @@ async function jatsConvert(session, input, opts) {
66726
66807
  const logJson = import_node_path10.default.join(dir, `${basename}.log.json`);
66727
66808
  const logYml = import_node_path10.default.join(dir, `${basename}.log.yml`);
66728
66809
  import_node_fs11.default.writeFileSync(logJson, JSON.stringify(logInfo, null, 2));
66729
- import_node_fs11.default.writeFileSync(logYml, js_yaml_default.dump(logInfo));
66810
+ import_node_fs11.default.writeFileSync(logYml, dump(logInfo));
66730
66811
  if ((opts === null || opts === void 0 ? void 0 : opts.frontmatter) === "page") {
66731
66812
  import_node_fs11.default.writeFileSync(mystJson, JSON.stringify({ mdast: tree, frontmatter }, null, 2));
66732
66813
  } else if ((opts === null || opts === void 0 ? void 0 : opts.frontmatter) === "project") {
66733
66814
  if (import_node_fs11.default.existsSync(mystYml)) {
66734
- const previous = js_yaml_default.load(import_node_fs11.default.readFileSync(mystYml).toString());
66735
- import_node_fs11.default.writeFileSync(mystYml, js_yaml_default.dump({ ...previous, project: { ...previous.project, ...frontmatter } }));
66815
+ const previous = load(import_node_fs11.default.readFileSync(mystYml).toString());
66816
+ import_node_fs11.default.writeFileSync(mystYml, dump({ ...previous, project: { ...previous.project, ...frontmatter } }));
66736
66817
  } else {
66737
- import_node_fs11.default.writeFileSync(mystYml, js_yaml_default.dump({ version: 1, project: frontmatter, site: {} }));
66818
+ import_node_fs11.default.writeFileSync(mystYml, dump({ version: 1, project: frontmatter, site: {} }));
66738
66819
  }
66739
66820
  import_node_fs11.default.writeFileSync(mystJson, JSON.stringify({ mdast: tree, frontmatter: { title: frontmatter.title } }, null, 2));
66740
66821
  } else {
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const version = "1.1.0";
1
+ declare const version = "1.1.2";
2
2
  export default version;
3
3
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- const version = '1.1.0';
1
+ const version = '1.1.2';
2
2
  export default version;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "jats-cli",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Typescript CLI for with JATS",
5
- "author": "Rowan Cockett <rowan@continuous.foundation>",
5
+ "author": "Rowan Cockett <rowan@continuousfoundation.org>",
6
6
  "homepage": "https://github.com/continuous-foundation/jats",
7
7
  "license": "MIT",
8
8
  "sideEffects": false,
@@ -45,11 +45,11 @@
45
45
  "dependencies": {
46
46
  "doi-utils": "^2.0.6",
47
47
  "fair-principles": "^2.0.0",
48
- "jats-convert": "^1.1.0",
49
- "jats-fetch": "^1.1.0",
50
- "jats-tags": "^1.1.0",
51
- "jats-utils": "^1.1.0",
52
- "jats-xml": "^1.1.0",
48
+ "jats-convert": "^1.1.2",
49
+ "jats-fetch": "^1.1.2",
50
+ "jats-tags": "^1.1.2",
51
+ "jats-utils": "^1.1.2",
52
+ "jats-xml": "^1.1.2",
53
53
  "js-yaml": "^4.1.0",
54
54
  "unist-util-is": "^5.2.1",
55
55
  "unist-util-select": "^4.0.0"