jats-cli 1.0.15 → 1.0.16
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 +60 -22
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -6
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.
|
|
49002
|
+
var version = "1.0.16";
|
|
49003
49003
|
var version_default = version;
|
|
49004
49004
|
|
|
49005
49005
|
// src/parse.ts
|
|
@@ -56426,6 +56426,7 @@ var RefType;
|
|
|
56426
56426
|
RefType2["tableFn"] = "table-fn";
|
|
56427
56427
|
RefType2["ref"] = "ref";
|
|
56428
56428
|
RefType2["media"] = "media";
|
|
56429
|
+
RefType2["video"] = "video";
|
|
56429
56430
|
})(RefType || (RefType = {}));
|
|
56430
56431
|
|
|
56431
56432
|
// ../jats-fetch/dist/download.js
|
|
@@ -57848,6 +57849,10 @@ async function convertPMID2PMCID(session, pmid, opts) {
|
|
|
57848
57849
|
const pmcid = await convertId(session, pmid, "pmid", "pmcid", opts);
|
|
57849
57850
|
return pmcid;
|
|
57850
57851
|
}
|
|
57852
|
+
async function convertDOI2PMCID(session, input, opts) {
|
|
57853
|
+
const pmDoi = await convertId(session, input, "doi", "pmcid", opts);
|
|
57854
|
+
return pmDoi;
|
|
57855
|
+
}
|
|
57851
57856
|
async function convertPMIDs2DOIs(session, pmids, opts) {
|
|
57852
57857
|
var _a, _b, _c;
|
|
57853
57858
|
pmids = [...new Set(pmids.map((pmid) => normalizePMID(session, pmid)))];
|
|
@@ -58088,8 +58093,21 @@ var joss = {
|
|
|
58088
58093
|
return `https://raw.githubusercontent.com/openjournals/joss-papers/master/joss.${id}/${org}.${jossId}.jats`;
|
|
58089
58094
|
}
|
|
58090
58095
|
};
|
|
58091
|
-
var
|
|
58092
|
-
|
|
58096
|
+
var biorxiv2 = {
|
|
58097
|
+
test(url) {
|
|
58098
|
+
return new URL(url).hostname === "www.biorxiv.org";
|
|
58099
|
+
},
|
|
58100
|
+
async jatsUrl(url, fetcher) {
|
|
58101
|
+
const resp = await (fetcher !== null && fetcher !== void 0 ? fetcher : fetch2)(url);
|
|
58102
|
+
const xmlUrl = (await resp.text()).match(/https:\/\/www\.biorxiv\.org\/content\/biorxiv\/[^\s]+\.full\.pdf/);
|
|
58103
|
+
if (!xmlUrl) {
|
|
58104
|
+
throw new Error(`Could not resolve JATS for biorxiv URL: ${url}`);
|
|
58105
|
+
}
|
|
58106
|
+
return xmlUrl[0].replace(".full.pdf", ".source.xml");
|
|
58107
|
+
}
|
|
58108
|
+
};
|
|
58109
|
+
var DEFAULT_RESOLVERS2 = [biorxiv2, elife2, plos, joss];
|
|
58110
|
+
async function customResolveJatsUrlFromDoi(session, doiString, opts) {
|
|
58093
58111
|
var _a, _b;
|
|
58094
58112
|
if (!doi.validate(doiString))
|
|
58095
58113
|
throw new Error(`The doi ${doiString} is not valid`);
|
|
@@ -58098,10 +58116,11 @@ async function customResolveJatsUrlFromDoi(session, doiString, opts = { resolver
|
|
|
58098
58116
|
const resp = await ((_a = opts === null || opts === void 0 ? void 0 : opts.fetcher) !== null && _a !== void 0 ? _a : fetch2)(doiUrl);
|
|
58099
58117
|
const articleUrl = resp.url;
|
|
58100
58118
|
session.log.debug(`Found resolved URL for DOI at ${articleUrl}`);
|
|
58101
|
-
const
|
|
58119
|
+
const resolvers = (_b = opts === null || opts === void 0 ? void 0 : opts.resolvers) !== null && _b !== void 0 ? _b : DEFAULT_RESOLVERS2;
|
|
58120
|
+
const resolver = resolvers === null || resolvers === void 0 ? void 0 : resolvers.find((r2) => r2.test(articleUrl));
|
|
58102
58121
|
if (!resolver)
|
|
58103
58122
|
throw new Error(`Could not resolve JATS for ${articleUrl}, no resolver matched`);
|
|
58104
|
-
const jatsUrl = resolver.jatsUrl(articleUrl);
|
|
58123
|
+
const jatsUrl = await resolver.jatsUrl(articleUrl, opts === null || opts === void 0 ? void 0 : opts.fetcher);
|
|
58105
58124
|
return jatsUrl;
|
|
58106
58125
|
}
|
|
58107
58126
|
|
|
@@ -58217,6 +58236,20 @@ async function jatsFetch(session, input, opts) {
|
|
|
58217
58236
|
output = foldername;
|
|
58218
58237
|
}
|
|
58219
58238
|
}
|
|
58239
|
+
if (input.match(/^[0-9]+$/)) {
|
|
58240
|
+
const pmcid = await convertPMID2PMCID(session, input);
|
|
58241
|
+
if (pmcid) {
|
|
58242
|
+
session.log.debug(`Resolved input ${input} to PMC ID: ${pmcid}`);
|
|
58243
|
+
input = pmcid;
|
|
58244
|
+
}
|
|
58245
|
+
}
|
|
58246
|
+
if (doi.validate(input)) {
|
|
58247
|
+
const pmcid = await convertDOI2PMCID(session, input);
|
|
58248
|
+
if (pmcid) {
|
|
58249
|
+
session.log.debug(`Resolved input ${input} to PMC ID: ${pmcid}`);
|
|
58250
|
+
input = pmcid;
|
|
58251
|
+
}
|
|
58252
|
+
}
|
|
58220
58253
|
if (!output)
|
|
58221
58254
|
output = opts.data ? `${input}` : ".";
|
|
58222
58255
|
if (!import_node_path4.default.extname(output)) {
|
|
@@ -58590,15 +58623,16 @@ var Jats = class {
|
|
|
58590
58623
|
}
|
|
58591
58624
|
const { declaration, elements } = this.raw;
|
|
58592
58625
|
this.declaration = declaration === null || declaration === void 0 ? void 0 : declaration.attributes;
|
|
58593
|
-
|
|
58626
|
+
const filteredElements = elements === null || elements === void 0 ? void 0 : elements.filter((elem) => elem.type !== "comment");
|
|
58627
|
+
if ((filteredElements === null || filteredElements === void 0 ? void 0 : filteredElements.length) && filteredElements[0].type !== "doctype") {
|
|
58594
58628
|
(_a = this.log) === null || _a === void 0 ? void 0 : _a.warn("JATS is missing DOCTYPE declaration");
|
|
58595
|
-
|
|
58629
|
+
filteredElements.unshift({ type: "doctype" });
|
|
58596
58630
|
}
|
|
58597
|
-
if (!((
|
|
58631
|
+
if (!((filteredElements === null || filteredElements === void 0 ? void 0 : filteredElements.length) === 2 && filteredElements[0].type === "doctype" && hasSingleArticle(filteredElements[1]))) {
|
|
58598
58632
|
throw new Error("JATS must be structured as <!DOCTYPE><article>...</article>");
|
|
58599
58633
|
}
|
|
58600
|
-
this.doctype =
|
|
58601
|
-
const converted = convertToUnist(
|
|
58634
|
+
this.doctype = filteredElements[0].doctype;
|
|
58635
|
+
const converted = convertToUnist(filteredElements[1]);
|
|
58602
58636
|
this.tree = select2("article", converted);
|
|
58603
58637
|
(_b = this.log) === null || _b === void 0 ? void 0 : _b.debug(toc("Parsed and converted JATS to unist tree in %s"));
|
|
58604
58638
|
}
|
|
@@ -64835,7 +64869,10 @@ function admonitionTransform(tree, file) {
|
|
|
64835
64869
|
captions.forEach((caption) => {
|
|
64836
64870
|
const title = select3(Tags.title, caption);
|
|
64837
64871
|
if (!title) {
|
|
64838
|
-
fileWarn(file, "
|
|
64872
|
+
fileWarn(file, "Encountered boxed-text without title", {
|
|
64873
|
+
node: caption,
|
|
64874
|
+
ruleId: RuleId.jatsParses
|
|
64875
|
+
});
|
|
64839
64876
|
return;
|
|
64840
64877
|
}
|
|
64841
64878
|
caption.type = "admonitionTitle";
|
|
@@ -64890,19 +64927,19 @@ function isBioRxiv(tree) {
|
|
|
64890
64927
|
const journalId = select3("journal-id[journal-id-type=hwp]", tree);
|
|
64891
64928
|
return toText2(journalId) === "biorxiv";
|
|
64892
64929
|
}
|
|
64893
|
-
function graphicToBioRxivUrl(
|
|
64894
|
-
if (!isBioRxiv(
|
|
64930
|
+
function graphicToBioRxivUrl(fullTree, body) {
|
|
64931
|
+
if (!isBioRxiv(fullTree))
|
|
64895
64932
|
return;
|
|
64896
64933
|
console.log("inside graphics transform");
|
|
64897
|
-
const accepted = select3("date[date-type=accepted]",
|
|
64934
|
+
const accepted = select3("date[date-type=accepted]", fullTree);
|
|
64898
64935
|
if (!accepted)
|
|
64899
64936
|
return;
|
|
64900
64937
|
const year = toText2(select3("year", accepted));
|
|
64901
64938
|
const month = toText2(select3("month", accepted)).padStart(2, "0");
|
|
64902
64939
|
const day = toText2(select3("day", accepted)).padStart(2, "0");
|
|
64903
|
-
const slug = toText2(select3("article-id[pub-id-type=doi]",
|
|
64940
|
+
const slug = toText2(select3("article-id[pub-id-type=doi]", fullTree)).split("/").slice(1).join("/");
|
|
64904
64941
|
const urlBase = `https://www.biorxiv.org/content/biorxiv/early/${year}/${month}/${day}/${slug}`;
|
|
64905
|
-
selectAll2("fig,table-wrap",
|
|
64942
|
+
selectAll2("fig,table-wrap", body).forEach((node) => {
|
|
64906
64943
|
const figId = node["hwp:id"];
|
|
64907
64944
|
if (!figId)
|
|
64908
64945
|
return;
|
|
@@ -65568,12 +65605,12 @@ function basicTransformations(body, file) {
|
|
|
65568
65605
|
admonitionTransform(body, file);
|
|
65569
65606
|
figCaptionTitleTransform(body);
|
|
65570
65607
|
}
|
|
65571
|
-
function journalTransforms(body) {
|
|
65572
|
-
graphicToBioRxivUrl(body);
|
|
65608
|
+
function journalTransforms(fullTree, body) {
|
|
65609
|
+
graphicToBioRxivUrl(fullTree, body);
|
|
65573
65610
|
}
|
|
65574
65611
|
|
|
65575
65612
|
// ../jats-convert/dist/version.js
|
|
65576
|
-
var version3 = "1.0.
|
|
65613
|
+
var version3 = "1.0.16";
|
|
65577
65614
|
var version_default3 = version3;
|
|
65578
65615
|
|
|
65579
65616
|
// ../jats-convert/dist/myst/inlineCitations.js
|
|
@@ -66056,7 +66093,7 @@ var handlers = {
|
|
|
66056
66093
|
const { label, identifier } = (_a = normalizeLabel(node.id)) !== null && _a !== void 0 ? _a : {};
|
|
66057
66094
|
state2.openNode("div", { label, identifier });
|
|
66058
66095
|
}
|
|
66059
|
-
state2.renderInline(node, "admonition", { kind: "
|
|
66096
|
+
state2.renderInline(node, "admonition", { kind: "note" });
|
|
66060
66097
|
if (node.id) {
|
|
66061
66098
|
state2.closeNode();
|
|
66062
66099
|
}
|
|
@@ -66100,7 +66137,7 @@ var handlers = {
|
|
|
66100
66137
|
fig(node, state2) {
|
|
66101
66138
|
var _a;
|
|
66102
66139
|
const caption = select3("caption", node);
|
|
66103
|
-
const graphic = select3("graphic", node);
|
|
66140
|
+
const graphic = select3("graphic,media", node);
|
|
66104
66141
|
const title = select3("title", node);
|
|
66105
66142
|
const { label, identifier } = (_a = normalizeLabel(node.id)) !== null && _a !== void 0 ? _a : {};
|
|
66106
66143
|
state2.openNode("container", { label, identifier, kind: "figure" });
|
|
@@ -66230,6 +66267,7 @@ var handlers = {
|
|
|
66230
66267
|
kind: "narrative"
|
|
66231
66268
|
});
|
|
66232
66269
|
return;
|
|
66270
|
+
case RefType.video:
|
|
66233
66271
|
case RefType.app:
|
|
66234
66272
|
case RefType.boxedText:
|
|
66235
66273
|
case RefType.media:
|
|
@@ -66447,7 +66485,7 @@ var jatsConvertPlugin = function(jats, opts) {
|
|
|
66447
66485
|
dataAvailabilityTransform(body);
|
|
66448
66486
|
const refLookup = processJatsReferences(body, jats.references, opts);
|
|
66449
66487
|
basicTransformations(body, file);
|
|
66450
|
-
journalTransforms(body);
|
|
66488
|
+
journalTransforms(jats.tree, body);
|
|
66451
66489
|
const state2 = new JatsParser(file, jats, opts);
|
|
66452
66490
|
state2.renderChildren(body);
|
|
66453
66491
|
while (state2.stack.length > 1)
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = '1.0.
|
|
1
|
+
const version = '1.0.16';
|
|
2
2
|
export default version;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jats-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "Typescript CLI for with JATS",
|
|
5
5
|
"author": "Rowan Cockett <rowan@continuous.foundation>",
|
|
6
6
|
"homepage": "https://github.com/continuous-foundation/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.
|
|
49
|
-
"jats-fetch": "^1.0.
|
|
50
|
-
"jats-tags": "^1.0.
|
|
51
|
-
"jats-utils": "^1.0.
|
|
52
|
-
"jats-xml": "^1.0.
|
|
48
|
+
"jats-convert": "^1.0.16",
|
|
49
|
+
"jats-fetch": "^1.0.16",
|
|
50
|
+
"jats-tags": "^1.0.16",
|
|
51
|
+
"jats-utils": "^1.0.16",
|
|
52
|
+
"jats-xml": "^1.0.16",
|
|
53
53
|
"js-yaml": "^4.1.0",
|
|
54
54
|
"unist-util-is": "^5.2.1",
|
|
55
55
|
"unist-util-select": "^4.0.0"
|