jats-cli 1.0.10 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AA6B5C,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,QAE7C"}
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-dois, --no-doi', '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.'))
9
- .addOption(new Option('--no-bibtex, --no-bib', 'By default, a bibtex file will be written with referenced citations. This option prevents writing that file'))
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.10";
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
  }
@@ -57977,15 +57978,21 @@ async function downloadAndUnzipPMC(session, entry, outputDir, fetcher) {
57977
57978
  throw new Error(`Unable to download ${entry.url}`);
57978
57979
  }
57979
57980
  session.log.info(`Extracting PMC data from ${dest} to ${outputDir}`);
57980
- const unzip = makeExecutable(`tar -xf ${dest}`, session.log);
57981
+ const unzip = makeExecutable(`tar -xf ${dest} -C ${outputDir}`, session.log);
57981
57982
  await unzip();
57982
- const zipContent = import_node_fs4.default.readdirSync(outputDir);
57983
- zipContent.filter((file) => file.toLowerCase().endsWith(".gif")).forEach((file) => {
57984
- const gifFile = import_node_path3.default.join(outputDir, file);
57983
+ const zipDir = import_node_path3.default.join(outputDir, import_node_path3.default.basename(dest).replace(/\.(tar\.gz|tgz)$/, ""));
57984
+ const zipContent = import_node_fs4.default.readdirSync(zipDir);
57985
+ zipContent.map((file) => {
57986
+ const oldPath = import_node_path3.default.join(zipDir, file);
57987
+ const newPath = import_node_path3.default.join(outputDir, file);
57988
+ import_node_fs4.default.renameSync(oldPath, newPath);
57989
+ return newPath;
57990
+ }).filter((file) => file.toLowerCase().endsWith(".gif")).forEach((gifFile) => {
57985
57991
  const jpgFile = gifFile.replace(/.gif$/, ".jpg");
57986
57992
  if (import_node_fs4.default.existsSync(jpgFile))
57987
57993
  import_node_fs4.default.rmSync(gifFile);
57988
57994
  });
57995
+ import_node_fs4.default.rmdirSync(zipDir);
57989
57996
  }
57990
57997
  async function getDataFromPMC(session, pmcid, outputDir, listing, fetcher) {
57991
57998
  const listingFile = await getListingsFile(session, listing, fetcher);
@@ -58065,6 +58072,9 @@ async function downloadFromUrl(session, jatsUrl, opts) {
58065
58072
  session.log.warn(`Expected content-type "application/xml" instead we got "${contentType}" for ${jatsUrl}`);
58066
58073
  }
58067
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
+ }
58068
58078
  session.log.debug(toc(`Fetched document with content-type "${contentType}" in %s`));
58069
58079
  return data;
58070
58080
  }
@@ -58120,17 +58130,23 @@ async function downloadJatsFromUrl(session, urlOrDoi, opts = {}) {
58120
58130
  }
58121
58131
  return { success: false, source: expectedUrls[0] };
58122
58132
  }
58123
- if (doi.validate(urlOrDoi)) {
58124
- const jatsUrl = await customResolveJatsUrlFromDoi(session, urlOrDoi, opts);
58125
- const data = await downloadFromUrl(session, jatsUrl, opts);
58126
- return { success: true, source: jatsUrl, data };
58127
- }
58128
- if (isUrl(urlOrDoi)) {
58129
- session.log.debug("No resolver matched, and the URL doesn't look like a DOI. We will attempt to download it directly.");
58130
- const data = await downloadFromUrl(session, urlOrDoi, opts);
58131
- 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 };
58132
58147
  }
58133
- 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 };
58134
58150
  }
58135
58151
  async function jatsFetch(session, input, opts) {
58136
58152
  var _a, _b;
@@ -58140,26 +58156,25 @@ async function jatsFetch(session, input, opts) {
58140
58156
  return;
58141
58157
  }
58142
58158
  let output = (_b = opts.output) !== null && _b !== void 0 ? _b : opts.data ? `${input}` : ".";
58143
- const filename = input.startsWith("PMC") ? `${input}.xml` : "jats.xml";
58144
- output = import_node_path4.default.join(output, filename);
58159
+ if (!import_node_path4.default.extname(output)) {
58160
+ const filename = input.startsWith("PMC") ? `${input}.xml` : "jats.xml";
58161
+ output = import_node_path4.default.join(output, filename);
58162
+ }
58145
58163
  if (import_node_path4.default.extname(output) && ![".xml", ".jats"].includes(import_node_path4.default.extname(output).toLowerCase())) {
58146
- session.log.error(`Output must be an XML file or a directory`);
58147
- process.exit(1);
58164
+ throw new Error(`Output must be an XML file or a directory`);
58148
58165
  }
58149
58166
  let result;
58150
- try {
58167
+ if (input.startsWith("PMC")) {
58168
+ result = await getPubMedJatsFromS3(session, input);
58169
+ }
58170
+ if (!(result === null || result === void 0 ? void 0 : result.data)) {
58151
58171
  result = await downloadJatsFromUrl(session, input);
58152
- } catch {
58153
58172
  }
58154
58173
  if (!(result === null || result === void 0 ? void 0 : result.data) && input.startsWith("PMC")) {
58155
- result = await getPubMedJatsFromS3(session, input);
58156
- if (!(result === null || result === void 0 ? void 0 : result.data)) {
58157
- result = await getPubMedJatsFromData(session, input, import_node_path4.default.dirname(output), opts.listing);
58158
- }
58174
+ result = await getPubMedJatsFromData(session, input, import_node_path4.default.dirname(output), opts.listing);
58159
58175
  }
58160
58176
  if (!(result === null || result === void 0 ? void 0 : result.data)) {
58161
- session.log.error(`Unable to resolve JATS XML content from ${input}`);
58162
- process.exit(1);
58177
+ throw new Error(`Unable to resolve JATS XML content from ${input}`);
58163
58178
  }
58164
58179
  if (!import_node_path4.default.extname(output)) {
58165
58180
  import_node_fs5.default.mkdirSync(output, { recursive: true });
@@ -58573,11 +58588,14 @@ var Jats = class {
58573
58588
  } else if (licenseString === null || licenseString === void 0 ? void 0 : licenseString.toLowerCase().startsWith("this is an open access article")) {
58574
58589
  openAccess = true;
58575
58590
  }
58591
+ const pmc = this.pmc;
58592
+ const identifiers = pmc ? { pmcid: `PMC${pmc}` } : void 0;
58576
58593
  const frontmatter = validatePageFrontmatter({
58577
58594
  title: title ? toText(title) : void 0,
58578
58595
  subtitle: subtitle ? toText(subtitle) : void 0,
58579
58596
  short_title: short_title ? toText(short_title) : void 0,
58580
58597
  doi: (_h = this.doi) !== null && _h !== void 0 ? _h : void 0,
58598
+ identifiers,
58581
58599
  date,
58582
58600
  authors: authors.length ? authors : void 0,
58583
58601
  // editors,
@@ -64778,6 +64796,35 @@ function toText2(node) {
64778
64796
  function copyNode2(node) {
64779
64797
  return copyNode(node);
64780
64798
  }
64799
+ function logMessagesFromVFile(session, file) {
64800
+ if (!file)
64801
+ return;
64802
+ file.messages.forEach((message) => {
64803
+ const kind = message.fatal === null ? "info" : message.fatal === false ? "warn" : "error";
64804
+ const note = (message === null || message === void 0 ? void 0 : message.note) ? `
64805
+ Note: ${message.note}` : "";
64806
+ const url = (message === null || message === void 0 ? void 0 : message.url) ? `
64807
+ See also: ${message.url}
64808
+ ` : "";
64809
+ const prefix = (message === null || message === void 0 ? void 0 : message.file) ? `${message === null || message === void 0 ? void 0 : message.file} ` : "";
64810
+ const formatted = `${message.reason}${note}${url}`;
64811
+ switch (kind) {
64812
+ case "info":
64813
+ session.log.info(`\u2139\uFE0F ${prefix}${formatted}`);
64814
+ break;
64815
+ case "error":
64816
+ session.log.error(`\u26D4\uFE0F ${prefix}${formatted}`);
64817
+ break;
64818
+ case "warn":
64819
+ session.log.warn(`\u26A0\uFE0F ${prefix}${formatted}`);
64820
+ break;
64821
+ default:
64822
+ session.log.debug(`${prefix}${formatted}`);
64823
+ break;
64824
+ }
64825
+ });
64826
+ file.messages = [];
64827
+ }
64781
64828
 
64782
64829
  // ../jats-convert/dist/transforms/biorxiv.js
64783
64830
  function isBioRxiv(tree) {
@@ -64939,7 +64986,9 @@ function recurseSections(tree, depth = 1, titleType) {
64939
64986
  firstChild3 = (_b = sec.children) === null || _b === void 0 ? void 0 : _b[1];
64940
64987
  }
64941
64988
  if ((firstChild3 === null || firstChild3 === void 0 ? void 0 : firstChild3.type) === "title") {
64942
- if (titleType === "strong") {
64989
+ if (sec.type === "ack" && toText(firstChild3).toLowerCase().startsWith("ack")) {
64990
+ firstChild3.type = "__delete__";
64991
+ } else if (titleType === "strong") {
64943
64992
  firstChild3.type = "p";
64944
64993
  firstChild3.children = [{ type: "bold", children: firstChild3.children }];
64945
64994
  } else {
@@ -64948,6 +64997,8 @@ function recurseSections(tree, depth = 1, titleType) {
64948
64997
  firstChild3.depth = depth;
64949
64998
  }
64950
64999
  }
65000
+ if (sec.type === "ack")
65001
+ sec.part = "acknowledgments";
64951
65002
  recurseSections(sec, depth + 1, titleType);
64952
65003
  });
64953
65004
  }
@@ -64957,8 +65008,6 @@ function sectionTransform(tree, titleType) {
64957
65008
  remove(tree, "__delete__");
64958
65009
  const topSections = (_a = tree.children) === null || _a === void 0 ? void 0 : _a.filter((n) => isSection(n));
64959
65010
  topSections.forEach((sec) => {
64960
- if (sec.type === "ack")
64961
- sec.part = "acknowledgments";
64962
65011
  sec.type = "block";
64963
65012
  });
64964
65013
  while (select3("sec", tree))
@@ -65058,7 +65107,7 @@ function backToBodyTransform(jats) {
65058
65107
  });
65059
65108
  if (!((_b = jats.body) === null || _b === void 0 ? void 0 : _b.children) || backNodes.length === 0)
65060
65109
  return;
65061
- jats.body.children.push({ type: "thematicBreak" }, ...copyNode(backNodes));
65110
+ jats.body.children.push({ type: "hr" }, ...copyNode(backNodes));
65062
65111
  backNodes.forEach((node) => {
65063
65112
  node.type = "__delete__";
65064
65113
  });
@@ -65424,7 +65473,7 @@ function journalTransforms(tree) {
65424
65473
  }
65425
65474
 
65426
65475
  // ../jats-convert/dist/version.js
65427
- var version3 = "1.0.10";
65476
+ var version3 = "1.0.12";
65428
65477
  var version_default3 = version3;
65429
65478
 
65430
65479
  // ../jats-convert/dist/myst/inlineCitations.js
@@ -65580,6 +65629,25 @@ function inlineCitationsTransform(tree, referenceIds) {
65580
65629
  }
65581
65630
  }
65582
65631
 
65632
+ // ../jats-convert/dist/transforms/supplementary.js
65633
+ function floatToEndTransform(jats) {
65634
+ var _a;
65635
+ if (!jats.body)
65636
+ return;
65637
+ const floatSupplementaryMaterial = selectAll2("supplementary-material[position=float]", jats.body);
65638
+ if (floatSupplementaryMaterial.length === 0)
65639
+ return;
65640
+ (_a = jats.body.children) === null || _a === void 0 ? void 0 : _a.push({ type: "hr" });
65641
+ floatSupplementaryMaterial.forEach((node) => {
65642
+ var _a2, _b;
65643
+ const copy = copyNode2(node);
65644
+ delete copy.position;
65645
+ (_b = (_a2 = jats.body) === null || _a2 === void 0 ? void 0 : _a2.children) === null || _b === void 0 ? void 0 : _b.push(copy);
65646
+ node.type = "__delete__";
65647
+ });
65648
+ remove(jats.body, "__delete__");
65649
+ }
65650
+
65583
65651
  // ../jats-convert/dist/index.js
65584
65652
  function refTypeToReferenceKind(kind) {
65585
65653
  switch (kind) {
@@ -65677,9 +65745,6 @@ var handlers = {
65677
65745
  ["list-item"](node, state2) {
65678
65746
  state2.renderInline(node, "listItem");
65679
65747
  },
65680
- thematicBreak(node, state2) {
65681
- state2.addLeaf("thematicBreak");
65682
- },
65683
65748
  ["inline-formula"](node, state2) {
65684
65749
  const texMath = texMathFromNode(node);
65685
65750
  if (texMath) {
@@ -65877,81 +65942,21 @@ var handlers = {
65877
65942
  return;
65878
65943
  state2.addLeaf("thematicBreak");
65879
65944
  },
65945
+ alternatives(node, state2) {
65946
+ var _a;
65947
+ const choice = (_a = node.children) === null || _a === void 0 ? void 0 : _a.find((child) => !!state2.handlers[child.type]);
65948
+ if (!choice) {
65949
+ state2.error(`No supported types in 'alternatives' node`);
65950
+ } else {
65951
+ state2.handlers[choice.type](choice, state2, node);
65952
+ }
65953
+ },
65880
65954
  break(node, state2) {
65881
65955
  state2.addLeaf("break");
65882
65956
  },
65883
65957
  ["named-content"](node, state2) {
65884
65958
  state2.renderChildren(node);
65885
65959
  },
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
65960
  ["fn-group"](node, state2) {
65956
65961
  state2.renderChildren(node);
65957
65962
  },
@@ -65975,6 +65980,7 @@ var handlers = {
65975
65980
  kind: "narrative"
65976
65981
  });
65977
65982
  return;
65983
+ case RefType.supplementaryMaterial:
65978
65984
  case RefType.sec:
65979
65985
  case RefType.fig:
65980
65986
  case RefType.dispFormula:
@@ -65985,22 +65991,33 @@ var handlers = {
65985
65991
  }
65986
65992
  case RefType.fn:
65987
65993
  case RefType.tableFn: {
65988
- state2.renderInline(node, "footnoteReference", { label, identifier });
65994
+ state2.addLeaf("footnoteReference", { label, identifier });
65989
65995
  return;
65990
65996
  }
65991
65997
  default: {
65992
65998
  state2.renderInline(node, "crossReference", { identifier: node.rid });
65993
- state2.warn(`Unknown ref-type of ${refType}`, node);
65999
+ state2.warn(`Unknown ref-type of ${refType}`);
65994
66000
  return;
65995
66001
  }
65996
66002
  }
65997
66003
  },
65998
66004
  ["supplementary-material"](node, state2) {
66005
+ var _a;
66006
+ if (node.id) {
66007
+ const { label, identifier } = (_a = normalizeLabel(node.id)) !== null && _a !== void 0 ? _a : {};
66008
+ state2.openNode("div", { label, identifier });
66009
+ }
65999
66010
  state2.renderChildren(node);
66011
+ if (node.id) {
66012
+ state2.closeNode();
66013
+ }
66000
66014
  },
66001
66015
  media(node, state2) {
66002
66016
  state2.renderInline(node, "link", { url: node["xlink:href"] });
66003
66017
  },
66018
+ ["inline-supplementary-material"](node, state2) {
66019
+ state2.renderInline(node, "link", { url: node["xlink:href"] });
66020
+ },
66004
66021
  caption(node, state2) {
66005
66022
  state2.renderChildren(node);
66006
66023
  },
@@ -66033,18 +66050,16 @@ var JatsParser = class {
66033
66050
  top() {
66034
66051
  return this.stack[this.stack.length - 1];
66035
66052
  }
66036
- warn(message, node, source, opts) {
66053
+ warn(message, source, opts) {
66037
66054
  fileError(this.file, message, {
66038
66055
  ...opts,
66039
- node,
66040
66056
  source: source ? `jats-convert:${source}` : "jats-convert",
66041
66057
  ruleId: RuleId.jatsParses
66042
66058
  });
66043
66059
  }
66044
- error(message, node, source, opts) {
66060
+ error(message, source, opts) {
66045
66061
  fileError(this.file, message, {
66046
66062
  ...opts,
66047
- node,
66048
66063
  source: source ? `jats-convert:${source}` : "jats-convert",
66049
66064
  ruleId: RuleId.jatsParses
66050
66065
  });
@@ -66079,10 +66094,7 @@ var JatsParser = class {
66079
66094
  handler(child, this, node);
66080
66095
  } else {
66081
66096
  this.unhandled.push(child.type);
66082
- fileError(this.file, `Unhandled JATS conversion for node of "${child.type}"`, {
66083
- source: "jats-convert",
66084
- ruleId: RuleId.jatsParses
66085
- });
66097
+ this.error(`Unhandled JATS conversion for node of "${child.type}"`);
66086
66098
  }
66087
66099
  });
66088
66100
  }
@@ -66177,7 +66189,7 @@ var jatsConvertPlugin = function(jats, opts) {
66177
66189
  };
66178
66190
  };
66179
66191
  async function jatsConvertTransform(data, opts) {
66180
- var _a, _b;
66192
+ var _a, _b, _c;
66181
66193
  const jats = typeof data === "string" ? new Jats(data) : data;
66182
66194
  if (opts === null || opts === void 0 ? void 0 : opts.logInfo) {
66183
66195
  opts.logInfo.publisher = toText2(select3("publisher-name", jats.tree)) || null;
@@ -66200,13 +66212,14 @@ async function jatsConvertTransform(data, opts) {
66200
66212
  opts.logInfo.license = licenseString;
66201
66213
  }
66202
66214
  const { frontmatter } = jats;
66203
- const file = new VFile();
66215
+ const file = (_b = opts === null || opts === void 0 ? void 0 : opts.vfile) !== null && _b !== void 0 ? _b : new VFile();
66204
66216
  const refLookup = await processJatsReferences(jats, opts);
66217
+ floatToEndTransform(jats);
66205
66218
  backToBodyTransform(jats);
66206
66219
  const pipe = unified().use(jatsConvertPlugin, jats, opts);
66207
- const vfile2 = pipe.stringify((_b = jats.body) !== null && _b !== void 0 ? _b : { type: "body", children: [] }, file);
66208
- const references = vfile2.result.references;
66209
- const tree = vfile2.result.tree;
66220
+ pipe.stringify((_c = jats.body) !== null && _c !== void 0 ? _c : { type: "body", children: [] }, file);
66221
+ const references = file.result.references;
66222
+ const tree = file.result.tree;
66210
66223
  resolveJatsCitations(tree, refLookup);
66211
66224
  inlineCitationsTransform(tree, [...Object.keys(references.data)]);
66212
66225
  abbreviationSectionTransform(tree, frontmatter);
@@ -66245,17 +66258,21 @@ async function jatsConvertTransform(data, opts) {
66245
66258
  myst: selectAll2("footnoteDefinition", tree).length
66246
66259
  };
66247
66260
  }
66248
- return { tree, jats, file, references, frontmatter };
66261
+ return { tree, jats, references, frontmatter };
66249
66262
  }
66250
- async function jatsConvert(input, opts) {
66263
+ async function jatsConvert(session, input, opts) {
66251
66264
  const logInfo = { jatsVersion: version_default3 };
66252
66265
  const dir = import_node_path6.default.dirname(input);
66266
+ const vfile2 = new VFile();
66267
+ vfile2.path = input;
66253
66268
  const { tree, frontmatter } = await jatsConvertTransform(import_node_fs7.default.readFileSync(input).toString(), {
66269
+ vfile: vfile2,
66254
66270
  dir,
66255
66271
  logInfo,
66256
66272
  dois: opts === null || opts === void 0 ? void 0 : opts.dois,
66257
66273
  bibtex: opts === null || opts === void 0 ? void 0 : opts.bibtex
66258
66274
  });
66275
+ logMessagesFromVFile(session, vfile2);
66259
66276
  const basename = import_node_path6.default.basename(input, import_node_path6.default.extname(input));
66260
66277
  const mystJson = import_node_path6.default.join(dir, `${basename}.myst.json`);
66261
66278
  const mystYml = import_node_path6.default.join(dir, "myst.yml");
@@ -66272,9 +66289,9 @@ async function jatsConvert(input, opts) {
66272
66289
  } else {
66273
66290
  import_node_fs7.default.writeFileSync(mystYml, js_yaml_default.dump({ version: 1, project: frontmatter, site: {} }));
66274
66291
  }
66275
- import_node_fs7.default.writeFileSync(mystJson, JSON.stringify({ mdast: tree }, null, 2));
66292
+ import_node_fs7.default.writeFileSync(mystJson, JSON.stringify({ mdast: tree, frontmatter: { title: frontmatter.title } }, null, 2));
66276
66293
  } else {
66277
- import_node_fs7.default.writeFileSync(mystJson, JSON.stringify({ mdast: tree }, null, 2));
66294
+ import_node_fs7.default.writeFileSync(mystJson, JSON.stringify({ mdast: tree, frontmatter: { title: frontmatter.title } }, null, 2));
66278
66295
  }
66279
66296
  }
66280
66297
 
@@ -66287,15 +66304,15 @@ function makeConvertCLI(program3) {
66287
66304
  ).choices(["page", "project"])
66288
66305
  ).addOption(
66289
66306
  new Option(
66290
- "--no-dois, --no-doi",
66307
+ "--no-doi, --no-dois",
66291
66308
  "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
66309
  )
66293
66310
  ).addOption(
66294
66311
  new Option(
66295
- "--no-bibtex, --no-bib",
66312
+ "--no-bib, --no-bibtex",
66296
66313
  "By default, a bibtex file will be written with referenced citations. This option prevents writing that file"
66297
66314
  )
66298
- ).action(jatsConvert);
66315
+ ).action(clirun(jatsConvert, { program: program3, getSession }));
66299
66316
  return command;
66300
66317
  }
66301
66318
  function addConvertCLI(program3) {
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const version = "1.0.10";
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.10';
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.10",
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.10",
49
- "jats-fetch": "^1.0.10",
50
- "jats-tags": "^1.0.10",
51
- "jats-utils": "^1.0.10",
52
- "jats-xml": "^1.0.10",
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"