jats-cli 1.0.11 → 1.0.12

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/dist/jats.cjs CHANGED
@@ -48999,7 +48999,7 @@ var {
48999
48999
  } = import_index.default;
49000
49000
 
49001
49001
  // src/version.ts
49002
- var version = "1.0.11";
49002
+ var version = "1.0.12";
49003
49003
  var version_default = version;
49004
49004
 
49005
49005
  // src/parse.ts
@@ -57911,6 +57911,7 @@ async function getPubMedJatsFromS3(session, pmcid) {
57911
57911
  session.log.debug(`Not available from open-access S3 bucket: ${pmcid}`);
57912
57912
  return { success: false, source: pmcid };
57913
57913
  } else {
57914
+ session.log.debug(`Fetching PMC JATS from S3 bucket: ${pmcid}`);
57914
57915
  const result = await downloadFileFromS3(client, found.path, OA_CONFIG);
57915
57916
  return result;
57916
57917
  }
@@ -58071,6 +58072,9 @@ async function downloadFromUrl(session, jatsUrl, opts) {
58071
58072
  session.log.warn(`Expected content-type "application/xml" instead we got "${contentType}" for ${jatsUrl}`);
58072
58073
  }
58073
58074
  const data = await resp.text();
58075
+ if (!data.match(/<article/)) {
58076
+ throw new Error(`XML downloaded from ${jatsUrl} does not look like a JATS article`);
58077
+ }
58074
58078
  session.log.debug(toc(`Fetched document with content-type "${contentType}" in %s`));
58075
58079
  return data;
58076
58080
  }
@@ -58126,17 +58130,23 @@ async function downloadJatsFromUrl(session, urlOrDoi, opts = {}) {
58126
58130
  }
58127
58131
  return { success: false, source: expectedUrls[0] };
58128
58132
  }
58129
- if (doi.validate(urlOrDoi)) {
58130
- const jatsUrl = await customResolveJatsUrlFromDoi(session, urlOrDoi, opts);
58131
- const data = await downloadFromUrl(session, jatsUrl, opts);
58132
- return { success: true, source: jatsUrl, data };
58133
- }
58134
- if (isUrl(urlOrDoi)) {
58135
- session.log.debug("No resolver matched, and the URL doesn't look like a DOI. We will attempt to download it directly.");
58136
- const data = await downloadFromUrl(session, urlOrDoi, opts);
58137
- return { success: true, source: urlOrDoi, data };
58133
+ try {
58134
+ if (doi.validate(urlOrDoi)) {
58135
+ const jatsUrl = await customResolveJatsUrlFromDoi(session, urlOrDoi, opts);
58136
+ const data = await downloadFromUrl(session, jatsUrl, opts);
58137
+ return { success: true, source: jatsUrl, data };
58138
+ }
58139
+ if (isUrl(urlOrDoi)) {
58140
+ session.log.debug("No resolver matched, and the URL doesn't look like a DOI. We will attempt to download it directly.");
58141
+ const data = await downloadFromUrl(session, urlOrDoi, opts);
58142
+ return { success: true, source: urlOrDoi, data };
58143
+ }
58144
+ } catch (error) {
58145
+ session.log.debug(error.message);
58146
+ return { success: false, source: urlOrDoi };
58138
58147
  }
58139
- throw new Error(`Could not find ${urlOrDoi} locally, and it doesn't look like a URL or DOI`);
58148
+ session.log.debug(`Could not find ${urlOrDoi} locally, and it doesn't look like a URL or DOI`);
58149
+ return { success: false, source: urlOrDoi };
58140
58150
  }
58141
58151
  async function jatsFetch(session, input, opts) {
58142
58152
  var _a, _b;
@@ -58154,15 +58164,14 @@ async function jatsFetch(session, input, opts) {
58154
58164
  throw new Error(`Output must be an XML file or a directory`);
58155
58165
  }
58156
58166
  let result;
58157
- try {
58167
+ if (input.startsWith("PMC")) {
58168
+ result = await getPubMedJatsFromS3(session, input);
58169
+ }
58170
+ if (!(result === null || result === void 0 ? void 0 : result.data)) {
58158
58171
  result = await downloadJatsFromUrl(session, input);
58159
- } catch {
58160
58172
  }
58161
58173
  if (!(result === null || result === void 0 ? void 0 : result.data) && input.startsWith("PMC")) {
58162
- result = await getPubMedJatsFromS3(session, input);
58163
- if (!(result === null || result === void 0 ? void 0 : result.data)) {
58164
- result = await getPubMedJatsFromData(session, input, import_node_path4.default.dirname(output), opts.listing);
58165
- }
58174
+ result = await getPubMedJatsFromData(session, input, import_node_path4.default.dirname(output), opts.listing);
58166
58175
  }
58167
58176
  if (!(result === null || result === void 0 ? void 0 : result.data)) {
58168
58177
  throw new Error(`Unable to resolve JATS XML content from ${input}`);
@@ -64977,7 +64986,9 @@ function recurseSections(tree, depth = 1, titleType) {
64977
64986
  firstChild3 = (_b = sec.children) === null || _b === void 0 ? void 0 : _b[1];
64978
64987
  }
64979
64988
  if ((firstChild3 === null || firstChild3 === void 0 ? void 0 : firstChild3.type) === "title") {
64980
- if (titleType === "strong") {
64989
+ if (sec.type === "ack" && toText(firstChild3).toLowerCase().startsWith("ack")) {
64990
+ firstChild3.type = "__delete__";
64991
+ } else if (titleType === "strong") {
64981
64992
  firstChild3.type = "p";
64982
64993
  firstChild3.children = [{ type: "bold", children: firstChild3.children }];
64983
64994
  } else {
@@ -64986,6 +64997,8 @@ function recurseSections(tree, depth = 1, titleType) {
64986
64997
  firstChild3.depth = depth;
64987
64998
  }
64988
64999
  }
65000
+ if (sec.type === "ack")
65001
+ sec.part = "acknowledgments";
64989
65002
  recurseSections(sec, depth + 1, titleType);
64990
65003
  });
64991
65004
  }
@@ -64995,8 +65008,6 @@ function sectionTransform(tree, titleType) {
64995
65008
  remove(tree, "__delete__");
64996
65009
  const topSections = (_a = tree.children) === null || _a === void 0 ? void 0 : _a.filter((n) => isSection(n));
64997
65010
  topSections.forEach((sec) => {
64998
- if (sec.type === "ack")
64999
- sec.part = "acknowledgments";
65000
65011
  sec.type = "block";
65001
65012
  });
65002
65013
  while (select3("sec", tree))
@@ -65462,7 +65473,7 @@ function journalTransforms(tree) {
65462
65473
  }
65463
65474
 
65464
65475
  // ../jats-convert/dist/version.js
65465
- var version3 = "1.0.11";
65476
+ var version3 = "1.0.12";
65466
65477
  var version_default3 = version3;
65467
65478
 
65468
65479
  // ../jats-convert/dist/myst/inlineCitations.js
@@ -65980,7 +65991,7 @@ var handlers = {
65980
65991
  }
65981
65992
  case RefType.fn:
65982
65993
  case RefType.tableFn: {
65983
- state2.renderInline(node, "footnoteReference", { label, identifier });
65994
+ state2.addLeaf("footnoteReference", { label, identifier });
65984
65995
  return;
65985
65996
  }
65986
65997
  default: {
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const version = "1.0.11";
1
+ declare const version = "1.0.12";
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.0.11';
1
+ const version = '1.0.12';
2
2
  export default version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jats-cli",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Typescript CLI for with JATS",
5
5
  "author": "Rowan Cockett <rowan@curvenote.com>",
6
6
  "homepage": "https://github.com/curvenote/jats",
@@ -45,11 +45,11 @@
45
45
  "dependencies": {
46
46
  "doi-utils": "^2.0.0",
47
47
  "fair-principles": "^2.0.0",
48
- "jats-convert": "^1.0.11",
49
- "jats-fetch": "^1.0.11",
50
- "jats-tags": "^1.0.11",
51
- "jats-utils": "^1.0.11",
52
- "jats-xml": "^1.0.11",
48
+ "jats-convert": "^1.0.12",
49
+ "jats-fetch": "^1.0.12",
50
+ "jats-tags": "^1.0.12",
51
+ "jats-utils": "^1.0.12",
52
+ "jats-xml": "^1.0.12",
53
53
  "js-yaml": "^4.1.0",
54
54
  "unist-util-is": "^5.2.1",
55
55
  "unist-util-select": "^4.0.0"