jats-cli 1.0.10 → 1.0.11
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/convert.d.ts.map +1 -1
- package/dist/convert.js +4 -3
- package/dist/jats.cjs +112 -106
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -6
package/dist/convert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AA8B5C,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,QAE7C"}
|
package/dist/convert.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Command, Option } from 'commander';
|
|
2
2
|
import { jatsConvert } from 'jats-convert';
|
|
3
|
+
import { clirun, getSession } from 'myst-cli-utils';
|
|
3
4
|
function makeConvertCLI(program) {
|
|
4
5
|
const command = new Command('convert')
|
|
5
6
|
.description('Convert JATS file to MyST mdast json')
|
|
6
7
|
.argument('<input>', 'The JATS file')
|
|
7
8
|
.addOption(new Option('--frontmatter <frontmatter>', 'Treat JATS frontmatter fields as page or project, or ignore if not specified').choices(['page', 'project']))
|
|
8
|
-
.addOption(new Option('--no-
|
|
9
|
-
.addOption(new Option('--no-
|
|
10
|
-
.action(jatsConvert);
|
|
9
|
+
.addOption(new Option('--no-doi, --no-dois', 'By default, DOIs are used for references when available, to be later resolved against doi.org. This option disables that behavior and creates bibtex entries for citations with DOIs.'))
|
|
10
|
+
.addOption(new Option('--no-bib, --no-bibtex', 'By default, a bibtex file will be written with referenced citations. This option prevents writing that file'))
|
|
11
|
+
.action(clirun(jatsConvert, { program, getSession }));
|
|
11
12
|
return command;
|
|
12
13
|
}
|
|
13
14
|
export function addConvertCLI(program) {
|
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.11";
|
|
49003
49003
|
var version_default = version;
|
|
49004
49004
|
|
|
49005
49005
|
// src/parse.ts
|
|
@@ -57977,15 +57977,21 @@ async function downloadAndUnzipPMC(session, entry, outputDir, fetcher) {
|
|
|
57977
57977
|
throw new Error(`Unable to download ${entry.url}`);
|
|
57978
57978
|
}
|
|
57979
57979
|
session.log.info(`Extracting PMC data from ${dest} to ${outputDir}`);
|
|
57980
|
-
const unzip = makeExecutable(`tar -xf ${dest}`, session.log);
|
|
57980
|
+
const unzip = makeExecutable(`tar -xf ${dest} -C ${outputDir}`, session.log);
|
|
57981
57981
|
await unzip();
|
|
57982
|
-
const
|
|
57983
|
-
zipContent
|
|
57984
|
-
|
|
57982
|
+
const zipDir = import_node_path3.default.join(outputDir, import_node_path3.default.basename(dest).replace(/\.(tar\.gz|tgz)$/, ""));
|
|
57983
|
+
const zipContent = import_node_fs4.default.readdirSync(zipDir);
|
|
57984
|
+
zipContent.map((file) => {
|
|
57985
|
+
const oldPath = import_node_path3.default.join(zipDir, file);
|
|
57986
|
+
const newPath = import_node_path3.default.join(outputDir, file);
|
|
57987
|
+
import_node_fs4.default.renameSync(oldPath, newPath);
|
|
57988
|
+
return newPath;
|
|
57989
|
+
}).filter((file) => file.toLowerCase().endsWith(".gif")).forEach((gifFile) => {
|
|
57985
57990
|
const jpgFile = gifFile.replace(/.gif$/, ".jpg");
|
|
57986
57991
|
if (import_node_fs4.default.existsSync(jpgFile))
|
|
57987
57992
|
import_node_fs4.default.rmSync(gifFile);
|
|
57988
57993
|
});
|
|
57994
|
+
import_node_fs4.default.rmdirSync(zipDir);
|
|
57989
57995
|
}
|
|
57990
57996
|
async function getDataFromPMC(session, pmcid, outputDir, listing, fetcher) {
|
|
57991
57997
|
const listingFile = await getListingsFile(session, listing, fetcher);
|
|
@@ -58140,11 +58146,12 @@ async function jatsFetch(session, input, opts) {
|
|
|
58140
58146
|
return;
|
|
58141
58147
|
}
|
|
58142
58148
|
let output = (_b = opts.output) !== null && _b !== void 0 ? _b : opts.data ? `${input}` : ".";
|
|
58143
|
-
|
|
58144
|
-
|
|
58149
|
+
if (!import_node_path4.default.extname(output)) {
|
|
58150
|
+
const filename = input.startsWith("PMC") ? `${input}.xml` : "jats.xml";
|
|
58151
|
+
output = import_node_path4.default.join(output, filename);
|
|
58152
|
+
}
|
|
58145
58153
|
if (import_node_path4.default.extname(output) && ![".xml", ".jats"].includes(import_node_path4.default.extname(output).toLowerCase())) {
|
|
58146
|
-
|
|
58147
|
-
process.exit(1);
|
|
58154
|
+
throw new Error(`Output must be an XML file or a directory`);
|
|
58148
58155
|
}
|
|
58149
58156
|
let result;
|
|
58150
58157
|
try {
|
|
@@ -58158,8 +58165,7 @@ async function jatsFetch(session, input, opts) {
|
|
|
58158
58165
|
}
|
|
58159
58166
|
}
|
|
58160
58167
|
if (!(result === null || result === void 0 ? void 0 : result.data)) {
|
|
58161
|
-
|
|
58162
|
-
process.exit(1);
|
|
58168
|
+
throw new Error(`Unable to resolve JATS XML content from ${input}`);
|
|
58163
58169
|
}
|
|
58164
58170
|
if (!import_node_path4.default.extname(output)) {
|
|
58165
58171
|
import_node_fs5.default.mkdirSync(output, { recursive: true });
|
|
@@ -58573,11 +58579,14 @@ var Jats = class {
|
|
|
58573
58579
|
} else if (licenseString === null || licenseString === void 0 ? void 0 : licenseString.toLowerCase().startsWith("this is an open access article")) {
|
|
58574
58580
|
openAccess = true;
|
|
58575
58581
|
}
|
|
58582
|
+
const pmc = this.pmc;
|
|
58583
|
+
const identifiers = pmc ? { pmcid: `PMC${pmc}` } : void 0;
|
|
58576
58584
|
const frontmatter = validatePageFrontmatter({
|
|
58577
58585
|
title: title ? toText(title) : void 0,
|
|
58578
58586
|
subtitle: subtitle ? toText(subtitle) : void 0,
|
|
58579
58587
|
short_title: short_title ? toText(short_title) : void 0,
|
|
58580
58588
|
doi: (_h = this.doi) !== null && _h !== void 0 ? _h : void 0,
|
|
58589
|
+
identifiers,
|
|
58581
58590
|
date,
|
|
58582
58591
|
authors: authors.length ? authors : void 0,
|
|
58583
58592
|
// editors,
|
|
@@ -64778,6 +64787,35 @@ function toText2(node) {
|
|
|
64778
64787
|
function copyNode2(node) {
|
|
64779
64788
|
return copyNode(node);
|
|
64780
64789
|
}
|
|
64790
|
+
function logMessagesFromVFile(session, file) {
|
|
64791
|
+
if (!file)
|
|
64792
|
+
return;
|
|
64793
|
+
file.messages.forEach((message) => {
|
|
64794
|
+
const kind = message.fatal === null ? "info" : message.fatal === false ? "warn" : "error";
|
|
64795
|
+
const note = (message === null || message === void 0 ? void 0 : message.note) ? `
|
|
64796
|
+
Note: ${message.note}` : "";
|
|
64797
|
+
const url = (message === null || message === void 0 ? void 0 : message.url) ? `
|
|
64798
|
+
See also: ${message.url}
|
|
64799
|
+
` : "";
|
|
64800
|
+
const prefix = (message === null || message === void 0 ? void 0 : message.file) ? `${message === null || message === void 0 ? void 0 : message.file} ` : "";
|
|
64801
|
+
const formatted = `${message.reason}${note}${url}`;
|
|
64802
|
+
switch (kind) {
|
|
64803
|
+
case "info":
|
|
64804
|
+
session.log.info(`\u2139\uFE0F ${prefix}${formatted}`);
|
|
64805
|
+
break;
|
|
64806
|
+
case "error":
|
|
64807
|
+
session.log.error(`\u26D4\uFE0F ${prefix}${formatted}`);
|
|
64808
|
+
break;
|
|
64809
|
+
case "warn":
|
|
64810
|
+
session.log.warn(`\u26A0\uFE0F ${prefix}${formatted}`);
|
|
64811
|
+
break;
|
|
64812
|
+
default:
|
|
64813
|
+
session.log.debug(`${prefix}${formatted}`);
|
|
64814
|
+
break;
|
|
64815
|
+
}
|
|
64816
|
+
});
|
|
64817
|
+
file.messages = [];
|
|
64818
|
+
}
|
|
64781
64819
|
|
|
64782
64820
|
// ../jats-convert/dist/transforms/biorxiv.js
|
|
64783
64821
|
function isBioRxiv(tree) {
|
|
@@ -65058,7 +65096,7 @@ function backToBodyTransform(jats) {
|
|
|
65058
65096
|
});
|
|
65059
65097
|
if (!((_b = jats.body) === null || _b === void 0 ? void 0 : _b.children) || backNodes.length === 0)
|
|
65060
65098
|
return;
|
|
65061
|
-
jats.body.children.push({ type: "
|
|
65099
|
+
jats.body.children.push({ type: "hr" }, ...copyNode(backNodes));
|
|
65062
65100
|
backNodes.forEach((node) => {
|
|
65063
65101
|
node.type = "__delete__";
|
|
65064
65102
|
});
|
|
@@ -65424,7 +65462,7 @@ function journalTransforms(tree) {
|
|
|
65424
65462
|
}
|
|
65425
65463
|
|
|
65426
65464
|
// ../jats-convert/dist/version.js
|
|
65427
|
-
var version3 = "1.0.
|
|
65465
|
+
var version3 = "1.0.11";
|
|
65428
65466
|
var version_default3 = version3;
|
|
65429
65467
|
|
|
65430
65468
|
// ../jats-convert/dist/myst/inlineCitations.js
|
|
@@ -65580,6 +65618,25 @@ function inlineCitationsTransform(tree, referenceIds) {
|
|
|
65580
65618
|
}
|
|
65581
65619
|
}
|
|
65582
65620
|
|
|
65621
|
+
// ../jats-convert/dist/transforms/supplementary.js
|
|
65622
|
+
function floatToEndTransform(jats) {
|
|
65623
|
+
var _a;
|
|
65624
|
+
if (!jats.body)
|
|
65625
|
+
return;
|
|
65626
|
+
const floatSupplementaryMaterial = selectAll2("supplementary-material[position=float]", jats.body);
|
|
65627
|
+
if (floatSupplementaryMaterial.length === 0)
|
|
65628
|
+
return;
|
|
65629
|
+
(_a = jats.body.children) === null || _a === void 0 ? void 0 : _a.push({ type: "hr" });
|
|
65630
|
+
floatSupplementaryMaterial.forEach((node) => {
|
|
65631
|
+
var _a2, _b;
|
|
65632
|
+
const copy = copyNode2(node);
|
|
65633
|
+
delete copy.position;
|
|
65634
|
+
(_b = (_a2 = jats.body) === null || _a2 === void 0 ? void 0 : _a2.children) === null || _b === void 0 ? void 0 : _b.push(copy);
|
|
65635
|
+
node.type = "__delete__";
|
|
65636
|
+
});
|
|
65637
|
+
remove(jats.body, "__delete__");
|
|
65638
|
+
}
|
|
65639
|
+
|
|
65583
65640
|
// ../jats-convert/dist/index.js
|
|
65584
65641
|
function refTypeToReferenceKind(kind) {
|
|
65585
65642
|
switch (kind) {
|
|
@@ -65677,9 +65734,6 @@ var handlers = {
|
|
|
65677
65734
|
["list-item"](node, state2) {
|
|
65678
65735
|
state2.renderInline(node, "listItem");
|
|
65679
65736
|
},
|
|
65680
|
-
thematicBreak(node, state2) {
|
|
65681
|
-
state2.addLeaf("thematicBreak");
|
|
65682
|
-
},
|
|
65683
65737
|
["inline-formula"](node, state2) {
|
|
65684
65738
|
const texMath = texMathFromNode(node);
|
|
65685
65739
|
if (texMath) {
|
|
@@ -65877,81 +65931,21 @@ var handlers = {
|
|
|
65877
65931
|
return;
|
|
65878
65932
|
state2.addLeaf("thematicBreak");
|
|
65879
65933
|
},
|
|
65934
|
+
alternatives(node, state2) {
|
|
65935
|
+
var _a;
|
|
65936
|
+
const choice = (_a = node.children) === null || _a === void 0 ? void 0 : _a.find((child) => !!state2.handlers[child.type]);
|
|
65937
|
+
if (!choice) {
|
|
65938
|
+
state2.error(`No supported types in 'alternatives' node`);
|
|
65939
|
+
} else {
|
|
65940
|
+
state2.handlers[choice.type](choice, state2, node);
|
|
65941
|
+
}
|
|
65942
|
+
},
|
|
65880
65943
|
break(node, state2) {
|
|
65881
65944
|
state2.addLeaf("break");
|
|
65882
65945
|
},
|
|
65883
65946
|
["named-content"](node, state2) {
|
|
65884
65947
|
state2.renderChildren(node);
|
|
65885
65948
|
},
|
|
65886
|
-
// container(node, state) {
|
|
65887
|
-
// state.data.isInContainer = true;
|
|
65888
|
-
// switch (node.kind) {
|
|
65889
|
-
// case 'figure': {
|
|
65890
|
-
// state.renderInline(node, 'fig');
|
|
65891
|
-
// break;
|
|
65892
|
-
// }
|
|
65893
|
-
// case 'table': {
|
|
65894
|
-
// state.renderInline(node, 'table-wrap');
|
|
65895
|
-
// break;
|
|
65896
|
-
// }
|
|
65897
|
-
// case 'quote': {
|
|
65898
|
-
// // This is transformed in containers.ts
|
|
65899
|
-
// state.renderChildren(node);
|
|
65900
|
-
// break;
|
|
65901
|
-
// }
|
|
65902
|
-
// case 'code': {
|
|
65903
|
-
// // This is transformed in containers.ts
|
|
65904
|
-
// state.renderInline(node, 'boxed-text', { 'content-type': node.kind });
|
|
65905
|
-
// break;
|
|
65906
|
-
// }
|
|
65907
|
-
// default: {
|
|
65908
|
-
// state.error(`Unhandled container kind of ${node.kind}`, node, 'container');
|
|
65909
|
-
// state.renderChildren(node);
|
|
65910
|
-
// }
|
|
65911
|
-
// }
|
|
65912
|
-
// delete state.data.isInContainer;
|
|
65913
|
-
// },
|
|
65914
|
-
// caption(node, state) {
|
|
65915
|
-
// state.renderInline(node, 'caption');
|
|
65916
|
-
// },
|
|
65917
|
-
// captionNumber(node, state) {
|
|
65918
|
-
// state.renderInline(node, 'label');
|
|
65919
|
-
// },
|
|
65920
|
-
// crossReference(node, state) {
|
|
65921
|
-
// // Look up reference and add the text
|
|
65922
|
-
// const { identifier, kind } = node as CrossReference;
|
|
65923
|
-
// const attrs: Attributes = { 'ref-type': referenceKindToRefType(kind), rid: identifier };
|
|
65924
|
-
// if (attrs['ref-type'] === RefType.custom && kind) {
|
|
65925
|
-
// attrs['custom-type'] = kind;
|
|
65926
|
-
// }
|
|
65927
|
-
// state.renderInline(node, 'xref', attrs);
|
|
65928
|
-
// },
|
|
65929
|
-
// citeGroup(node, state) {
|
|
65930
|
-
// if (state.options.citestyle === 'numerical-only') {
|
|
65931
|
-
// state.write('\\cite{');
|
|
65932
|
-
// } else if (state.options.bibliography === 'biblatex') {
|
|
65933
|
-
// const command = node.kind === 'narrative' ? 'textcite' : 'parencite';
|
|
65934
|
-
// state.write(`\\${command}{`);
|
|
65935
|
-
// } else {
|
|
65936
|
-
// const tp = node.kind === 'narrative' ? 't' : 'p';
|
|
65937
|
-
// state.write(`\\cite${tp}{`);
|
|
65938
|
-
// }
|
|
65939
|
-
// state.renderChildren(node, true, ', ');
|
|
65940
|
-
// state.write('}');
|
|
65941
|
-
// },
|
|
65942
|
-
// cite(node, state, parent) {
|
|
65943
|
-
// if (!state.options.bibliography) {
|
|
65944
|
-
// state.usePackages('natbib');
|
|
65945
|
-
// // Don't include biblatex in the package list
|
|
65946
|
-
// }
|
|
65947
|
-
// if (parent.type === 'citeGroup') {
|
|
65948
|
-
// state.write(node.label);
|
|
65949
|
-
// } else if (state.options.bibliography === 'biblatex') {
|
|
65950
|
-
// state.write(`\\textcite{${node.label}}`);
|
|
65951
|
-
// } else {
|
|
65952
|
-
// state.write(`\\cite{${node.label}}`);
|
|
65953
|
-
// }
|
|
65954
|
-
// },
|
|
65955
65949
|
["fn-group"](node, state2) {
|
|
65956
65950
|
state2.renderChildren(node);
|
|
65957
65951
|
},
|
|
@@ -65975,6 +65969,7 @@ var handlers = {
|
|
|
65975
65969
|
kind: "narrative"
|
|
65976
65970
|
});
|
|
65977
65971
|
return;
|
|
65972
|
+
case RefType.supplementaryMaterial:
|
|
65978
65973
|
case RefType.sec:
|
|
65979
65974
|
case RefType.fig:
|
|
65980
65975
|
case RefType.dispFormula:
|
|
@@ -65990,17 +65985,28 @@ var handlers = {
|
|
|
65990
65985
|
}
|
|
65991
65986
|
default: {
|
|
65992
65987
|
state2.renderInline(node, "crossReference", { identifier: node.rid });
|
|
65993
|
-
state2.warn(`Unknown ref-type of ${refType}
|
|
65988
|
+
state2.warn(`Unknown ref-type of ${refType}`);
|
|
65994
65989
|
return;
|
|
65995
65990
|
}
|
|
65996
65991
|
}
|
|
65997
65992
|
},
|
|
65998
65993
|
["supplementary-material"](node, state2) {
|
|
65994
|
+
var _a;
|
|
65995
|
+
if (node.id) {
|
|
65996
|
+
const { label, identifier } = (_a = normalizeLabel(node.id)) !== null && _a !== void 0 ? _a : {};
|
|
65997
|
+
state2.openNode("div", { label, identifier });
|
|
65998
|
+
}
|
|
65999
65999
|
state2.renderChildren(node);
|
|
66000
|
+
if (node.id) {
|
|
66001
|
+
state2.closeNode();
|
|
66002
|
+
}
|
|
66000
66003
|
},
|
|
66001
66004
|
media(node, state2) {
|
|
66002
66005
|
state2.renderInline(node, "link", { url: node["xlink:href"] });
|
|
66003
66006
|
},
|
|
66007
|
+
["inline-supplementary-material"](node, state2) {
|
|
66008
|
+
state2.renderInline(node, "link", { url: node["xlink:href"] });
|
|
66009
|
+
},
|
|
66004
66010
|
caption(node, state2) {
|
|
66005
66011
|
state2.renderChildren(node);
|
|
66006
66012
|
},
|
|
@@ -66033,18 +66039,16 @@ var JatsParser = class {
|
|
|
66033
66039
|
top() {
|
|
66034
66040
|
return this.stack[this.stack.length - 1];
|
|
66035
66041
|
}
|
|
66036
|
-
warn(message,
|
|
66042
|
+
warn(message, source, opts) {
|
|
66037
66043
|
fileError(this.file, message, {
|
|
66038
66044
|
...opts,
|
|
66039
|
-
node,
|
|
66040
66045
|
source: source ? `jats-convert:${source}` : "jats-convert",
|
|
66041
66046
|
ruleId: RuleId.jatsParses
|
|
66042
66047
|
});
|
|
66043
66048
|
}
|
|
66044
|
-
error(message,
|
|
66049
|
+
error(message, source, opts) {
|
|
66045
66050
|
fileError(this.file, message, {
|
|
66046
66051
|
...opts,
|
|
66047
|
-
node,
|
|
66048
66052
|
source: source ? `jats-convert:${source}` : "jats-convert",
|
|
66049
66053
|
ruleId: RuleId.jatsParses
|
|
66050
66054
|
});
|
|
@@ -66079,10 +66083,7 @@ var JatsParser = class {
|
|
|
66079
66083
|
handler(child, this, node);
|
|
66080
66084
|
} else {
|
|
66081
66085
|
this.unhandled.push(child.type);
|
|
66082
|
-
|
|
66083
|
-
source: "jats-convert",
|
|
66084
|
-
ruleId: RuleId.jatsParses
|
|
66085
|
-
});
|
|
66086
|
+
this.error(`Unhandled JATS conversion for node of "${child.type}"`);
|
|
66086
66087
|
}
|
|
66087
66088
|
});
|
|
66088
66089
|
}
|
|
@@ -66177,7 +66178,7 @@ var jatsConvertPlugin = function(jats, opts) {
|
|
|
66177
66178
|
};
|
|
66178
66179
|
};
|
|
66179
66180
|
async function jatsConvertTransform(data, opts) {
|
|
66180
|
-
var _a, _b;
|
|
66181
|
+
var _a, _b, _c;
|
|
66181
66182
|
const jats = typeof data === "string" ? new Jats(data) : data;
|
|
66182
66183
|
if (opts === null || opts === void 0 ? void 0 : opts.logInfo) {
|
|
66183
66184
|
opts.logInfo.publisher = toText2(select3("publisher-name", jats.tree)) || null;
|
|
@@ -66200,13 +66201,14 @@ async function jatsConvertTransform(data, opts) {
|
|
|
66200
66201
|
opts.logInfo.license = licenseString;
|
|
66201
66202
|
}
|
|
66202
66203
|
const { frontmatter } = jats;
|
|
66203
|
-
const file = new VFile();
|
|
66204
|
+
const file = (_b = opts === null || opts === void 0 ? void 0 : opts.vfile) !== null && _b !== void 0 ? _b : new VFile();
|
|
66204
66205
|
const refLookup = await processJatsReferences(jats, opts);
|
|
66206
|
+
floatToEndTransform(jats);
|
|
66205
66207
|
backToBodyTransform(jats);
|
|
66206
66208
|
const pipe = unified().use(jatsConvertPlugin, jats, opts);
|
|
66207
|
-
|
|
66208
|
-
const references =
|
|
66209
|
-
const tree =
|
|
66209
|
+
pipe.stringify((_c = jats.body) !== null && _c !== void 0 ? _c : { type: "body", children: [] }, file);
|
|
66210
|
+
const references = file.result.references;
|
|
66211
|
+
const tree = file.result.tree;
|
|
66210
66212
|
resolveJatsCitations(tree, refLookup);
|
|
66211
66213
|
inlineCitationsTransform(tree, [...Object.keys(references.data)]);
|
|
66212
66214
|
abbreviationSectionTransform(tree, frontmatter);
|
|
@@ -66245,17 +66247,21 @@ async function jatsConvertTransform(data, opts) {
|
|
|
66245
66247
|
myst: selectAll2("footnoteDefinition", tree).length
|
|
66246
66248
|
};
|
|
66247
66249
|
}
|
|
66248
|
-
return { tree, jats,
|
|
66250
|
+
return { tree, jats, references, frontmatter };
|
|
66249
66251
|
}
|
|
66250
|
-
async function jatsConvert(input, opts) {
|
|
66252
|
+
async function jatsConvert(session, input, opts) {
|
|
66251
66253
|
const logInfo = { jatsVersion: version_default3 };
|
|
66252
66254
|
const dir = import_node_path6.default.dirname(input);
|
|
66255
|
+
const vfile2 = new VFile();
|
|
66256
|
+
vfile2.path = input;
|
|
66253
66257
|
const { tree, frontmatter } = await jatsConvertTransform(import_node_fs7.default.readFileSync(input).toString(), {
|
|
66258
|
+
vfile: vfile2,
|
|
66254
66259
|
dir,
|
|
66255
66260
|
logInfo,
|
|
66256
66261
|
dois: opts === null || opts === void 0 ? void 0 : opts.dois,
|
|
66257
66262
|
bibtex: opts === null || opts === void 0 ? void 0 : opts.bibtex
|
|
66258
66263
|
});
|
|
66264
|
+
logMessagesFromVFile(session, vfile2);
|
|
66259
66265
|
const basename = import_node_path6.default.basename(input, import_node_path6.default.extname(input));
|
|
66260
66266
|
const mystJson = import_node_path6.default.join(dir, `${basename}.myst.json`);
|
|
66261
66267
|
const mystYml = import_node_path6.default.join(dir, "myst.yml");
|
|
@@ -66272,9 +66278,9 @@ async function jatsConvert(input, opts) {
|
|
|
66272
66278
|
} else {
|
|
66273
66279
|
import_node_fs7.default.writeFileSync(mystYml, js_yaml_default.dump({ version: 1, project: frontmatter, site: {} }));
|
|
66274
66280
|
}
|
|
66275
|
-
import_node_fs7.default.writeFileSync(mystJson, JSON.stringify({ mdast: tree }, null, 2));
|
|
66281
|
+
import_node_fs7.default.writeFileSync(mystJson, JSON.stringify({ mdast: tree, frontmatter: { title: frontmatter.title } }, null, 2));
|
|
66276
66282
|
} else {
|
|
66277
|
-
import_node_fs7.default.writeFileSync(mystJson, JSON.stringify({ mdast: tree }, null, 2));
|
|
66283
|
+
import_node_fs7.default.writeFileSync(mystJson, JSON.stringify({ mdast: tree, frontmatter: { title: frontmatter.title } }, null, 2));
|
|
66278
66284
|
}
|
|
66279
66285
|
}
|
|
66280
66286
|
|
|
@@ -66287,15 +66293,15 @@ function makeConvertCLI(program3) {
|
|
|
66287
66293
|
).choices(["page", "project"])
|
|
66288
66294
|
).addOption(
|
|
66289
66295
|
new Option(
|
|
66290
|
-
"--no-
|
|
66296
|
+
"--no-doi, --no-dois",
|
|
66291
66297
|
"By default, DOIs are used for references when available, to be later resolved against doi.org. This option disables that behavior and creates bibtex entries for citations with DOIs."
|
|
66292
66298
|
)
|
|
66293
66299
|
).addOption(
|
|
66294
66300
|
new Option(
|
|
66295
|
-
"--no-
|
|
66301
|
+
"--no-bib, --no-bibtex",
|
|
66296
66302
|
"By default, a bibtex file will be written with referenced citations. This option prevents writing that file"
|
|
66297
66303
|
)
|
|
66298
|
-
).action(jatsConvert);
|
|
66304
|
+
).action(clirun(jatsConvert, { program: program3, getSession }));
|
|
66299
66305
|
return command;
|
|
66300
66306
|
}
|
|
66301
66307
|
function addConvertCLI(program3) {
|
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.11';
|
|
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.11",
|
|
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.
|
|
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.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",
|
|
53
53
|
"js-yaml": "^4.1.0",
|
|
54
54
|
"unist-util-is": "^5.2.1",
|
|
55
55
|
"unist-util-select": "^4.0.0"
|