jats-convert 1.0.13 → 1.0.15

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.
Files changed (37) hide show
  1. package/README.md +5 -5
  2. package/dist/index.d.ts +7 -9
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +162 -79
  5. package/dist/myst/abbreviations.d.ts +11 -0
  6. package/dist/myst/abbreviations.d.ts.map +1 -0
  7. package/dist/myst/abbreviations.js +80 -0
  8. package/dist/myst/inlineCitations.d.ts.map +1 -1
  9. package/dist/myst/inlineCitations.js +40 -0
  10. package/dist/transforms/abbreviations.d.ts +5 -0
  11. package/dist/transforms/abbreviations.d.ts.map +1 -1
  12. package/dist/transforms/abbreviations.js +38 -0
  13. package/dist/transforms/footnotes.d.ts +9 -5
  14. package/dist/transforms/footnotes.d.ts.map +1 -1
  15. package/dist/transforms/footnotes.js +21 -14
  16. package/dist/transforms/index.d.ts +4 -5
  17. package/dist/transforms/index.d.ts.map +1 -1
  18. package/dist/transforms/index.js +9 -10
  19. package/dist/transforms/parts.d.ts +6 -0
  20. package/dist/transforms/parts.d.ts.map +1 -0
  21. package/dist/transforms/parts.js +18 -0
  22. package/dist/transforms/references.d.ts +11 -2
  23. package/dist/transforms/references.d.ts.map +1 -1
  24. package/dist/transforms/references.js +8 -10
  25. package/dist/transforms/sections.d.ts.map +1 -1
  26. package/dist/transforms/sections.js +13 -2
  27. package/dist/transforms/supplementary.d.ts +2 -2
  28. package/dist/transforms/supplementary.d.ts.map +1 -1
  29. package/dist/transforms/supplementary.js +7 -9
  30. package/dist/types.d.ts +4 -10
  31. package/dist/types.d.ts.map +1 -1
  32. package/dist/version.d.ts +1 -1
  33. package/dist/version.js +1 -1
  34. package/package.json +9 -9
  35. package/dist/transforms/citations.d.ts +0 -8
  36. package/dist/transforms/citations.d.ts.map +0 -1
  37. package/dist/transforms/citations.js +0 -11
package/README.md CHANGED
@@ -1,18 +1,18 @@
1
1
  # jats-convert
2
2
 
3
3
  [![jats-convert on npm](https://img.shields.io/npm/v/jats-convert.svg)](https://www.npmjs.com/package/jats-convert)
4
- [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/curvenote/jats/blob/main/LICENSE)
5
- [![CI](https://github.com/curvenote/jats/workflows/CI/badge.svg)](https://github.com/curvenote/jats-cli/actions)
4
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/continuous-foundation/jats/blob/main/LICENSE)
5
+ [![CI](https://github.com/continuous-foundation/jats/workflows/CI/badge.svg)](https://github.com/continuous-foundation/jats-cli/actions)
6
6
 
7
7
  Convert a JATS XML document to a MyST AST.
8
8
 
9
- Portions of this package were created for `jats-to-myst` and [committed](https://github.com/jupyter-book/mystmd/commits/mystmd%401.3.12/packages/jats-to-myst/src) to project Jupyter's `mystmd` project by Curvenote team members. The work is licensed MIT in both places, `jats-convert` has additional functionality and nuance depending on the publisher.
9
+ Portions of this package were created for `jats-to-myst` and [committed](https://github.com/jupyter-book/mystmd/commits/mystmd%401.3.12/packages/jats-to-myst/src) to project Jupyter's `mystmd` project. The work is licensed MIT in both places, `jats-convert` has additional functionality and nuance depending on the publisher.
10
10
 
11
11
  ---
12
12
 
13
13
  <p style="text-align: center; color: #aaa; padding-top: 50px">
14
14
  Made with love by
15
- <a href="https://curvenote.com" target="_blank" style="color: #aaa">
16
- <img src="https://cdn.curvenote.com/brand/logo-blue-icon.png" style="height: 1em" /> Curvenote
15
+ <a href="https://continuous.foundation" target="_blank" style="color: #aaa">
16
+ Continuous Science Foundation <img src="https://continuous.foundation/images/logo-small.svg" style="height: 1em" />
17
17
  </a>
18
18
  </p>
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { Root } from 'myst-spec';
2
1
  import type { Plugin } from 'unified';
3
2
  import { VFile } from 'vfile';
4
- import type { MessageInfo, GenericNode } from 'myst-common';
3
+ import type { MessageInfo, GenericNode, GenericParent } from 'myst-common';
4
+ import type { Body } from 'jats-tags';
5
5
  import type { ISession } from 'jats-xml';
6
6
  import { Jats } from 'jats-xml';
7
7
  import type { Handler, IJatsParser, Options, StateData } from './types.js';
@@ -30,14 +30,12 @@ export declare class JatsParser implements IJatsParser {
30
30
  openNode(name: string, attributes?: Attributes, isLeaf?: boolean): void;
31
31
  closeNode(): GenericNode | undefined;
32
32
  }
33
- export declare const jatsConvertPlugin: Plugin<[Jats, Options?], Root, Root>;
34
- export declare function jatsConvertTransform(data: string | Jats, opts?: Options): Promise<{
35
- tree: Root;
36
- jats: Jats;
37
- references: any;
33
+ export declare const jatsConvertPlugin: Plugin<[Jats, Options?], Body, Body>;
34
+ export declare function jatsConvertTransform(jats: Jats, opts?: Options): {
35
+ tree: GenericParent;
38
36
  frontmatter: ProjectFrontmatter;
39
- }>;
40
- export declare function jatsConvert(session: ISession, input: string, opts?: {
37
+ };
38
+ export declare function jatsConvert(session: ISession, input?: string, opts?: {
41
39
  frontmatter?: 'page' | 'project';
42
40
  dois?: boolean;
43
41
  bibtex?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAiB,MAAM,aAAa,CAAC;AAM3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAc,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAMvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAyD3D,KAAK,UAAU,GAAG,MAAM,CAAC,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E"}
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { unified } from 'unified';
4
- import { doi } from 'doi-utils';
5
4
  import { VFile } from 'vfile';
6
5
  import yaml from 'js-yaml';
7
6
  import { copyNode, fileError, RuleId, normalizeLabel } from 'myst-common';
@@ -11,15 +10,31 @@ import { RefType } from 'jats-tags';
11
10
  import { Jats } from 'jats-xml';
12
11
  import { MathMLToLaTeX } from 'mathml-to-latex';
13
12
  import { js2xml } from 'xml-js';
14
- import { basicTransformations, citationToMixedCitation, journalTransforms, } from './transforms/index.js';
13
+ import { basicTransformations, journalTransforms } from './transforms/index.js';
15
14
  import { abstractTransform, descriptionFromAbstract } from './transforms/abstract.js';
16
- import { processJatsReferences, resolveJatsCitations } from './transforms/references.js';
17
- import { backToBodyTransform } from './transforms/footnotes.js';
15
+ import { getPMIDLookup, processJatsReferences, resolveJatsCitations, } from './transforms/references.js';
16
+ import { backToBodyTransform, tableFootnotesToLegend } from './transforms/footnotes.js';
18
17
  import version from './version.js';
19
18
  import { logMessagesFromVFile, toText } from './utils.js';
20
19
  import { inlineCitationsTransform } from './myst/inlineCitations.js';
21
- import { abbreviationSectionTransform } from './transforms/abbreviations.js';
20
+ import { abbreviationFootnoteTransform, abbreviationSectionTransform, } from './transforms/abbreviations.js';
22
21
  import { floatToEndTransform } from './transforms/supplementary.js';
22
+ import { dataAvailabilityTransform } from './transforms/parts.js';
23
+ import { abbreviationsFromTree } from './myst/abbreviations.js';
24
+ const MEDIA_FIGURE_EXTENSIONS = [
25
+ '.png',
26
+ '.jpg',
27
+ '.jpeg',
28
+ '.svg',
29
+ '.gif',
30
+ '.tiff',
31
+ '.tif',
32
+ '.eps',
33
+ '.webp',
34
+ '.mp4',
35
+ '.mov',
36
+ '.avi',
37
+ ];
23
38
  function refTypeToReferenceKind(kind) {
24
39
  switch (kind) {
25
40
  case RefType.sec:
@@ -79,10 +94,12 @@ const handlers = {
79
94
  state.renderInline(node, 'paragraph');
80
95
  },
81
96
  heading(node, state) {
97
+ var _a;
98
+ const { label, identifier } = (_a = normalizeLabel(node.id)) !== null && _a !== void 0 ? _a : {};
82
99
  state.renderInline(node, 'heading', {
83
100
  enumerated: true,
84
- label: node.id,
85
- identifier: node.id,
101
+ label,
102
+ identifier,
86
103
  depth: node.depth,
87
104
  });
88
105
  },
@@ -119,12 +136,14 @@ const handlers = {
119
136
  state.renderInline(node, 'listItem');
120
137
  },
121
138
  ['inline-formula'](node, state) {
139
+ var _a;
122
140
  const texMath = texMathFromNode(node);
123
141
  if (texMath) {
142
+ const { label, identifier } = (_a = normalizeLabel(node.id)) !== null && _a !== void 0 ? _a : {};
124
143
  state.addLeaf('inlineMath', {
125
144
  value: texMath,
126
- label: node.id,
127
- identifier: node.id,
145
+ label,
146
+ identifier,
128
147
  });
129
148
  }
130
149
  else {
@@ -132,16 +151,26 @@ const handlers = {
132
151
  }
133
152
  },
134
153
  ['disp-formula'](node, state) {
154
+ var _a;
135
155
  const texMath = texMathFromNode(node);
156
+ const { label, identifier } = (_a = normalizeLabel(node.id)) !== null && _a !== void 0 ? _a : {};
136
157
  if (texMath) {
137
158
  state.addLeaf('math', {
138
159
  value: texMath,
139
- label: node.id,
140
- identifier: node.id,
160
+ label,
161
+ identifier,
141
162
  });
142
163
  }
143
164
  else {
165
+ if (node.id) {
166
+ state.openNode('div', { label, identifier });
167
+ }
168
+ state.openNode('paragraph');
144
169
  state.renderChildren(node);
170
+ state.closeNode();
171
+ if (node.id) {
172
+ state.closeNode();
173
+ }
145
174
  }
146
175
  },
147
176
  bold(node, state) {
@@ -184,7 +213,15 @@ const handlers = {
184
213
  state.renderInline(node, 'link', { url: node['xlink:href'] });
185
214
  },
186
215
  ['boxed-text'](node, state) {
216
+ var _a;
217
+ if (node.id) {
218
+ const { label, identifier } = (_a = normalizeLabel(node.id)) !== null && _a !== void 0 ? _a : {};
219
+ state.openNode('div', { label, identifier });
220
+ }
187
221
  state.renderInline(node, 'admonition', { kind: 'info' });
222
+ if (node.id) {
223
+ state.closeNode();
224
+ }
188
225
  },
189
226
  admonitionTitle(node, state) {
190
227
  // This is created in a transform!
@@ -359,6 +396,9 @@ const handlers = {
359
396
  kind: 'narrative',
360
397
  });
361
398
  return;
399
+ case RefType.app:
400
+ case RefType.boxedText:
401
+ case RefType.media:
362
402
  case RefType.supplementaryMaterial:
363
403
  case RefType.sec:
364
404
  case RefType.fig:
@@ -381,6 +421,59 @@ const handlers = {
381
421
  }
382
422
  },
383
423
  ['supplementary-material'](node, state) {
424
+ var _a, _b, _c, _d, _e;
425
+ const { label, identifier } = (_a = normalizeLabel(node.id)) !== null && _a !== void 0 ? _a : {};
426
+ let maybeCaption;
427
+ let media;
428
+ if (((_b = node.children) === null || _b === void 0 ? void 0 : _b.length) === 1 && node.children[0].type === 'media') {
429
+ media = node.children[0];
430
+ }
431
+ else if (((_c = node.children) === null || _c === void 0 ? void 0 : _c.length) === 2 &&
432
+ node.children[0].type === 'label' &&
433
+ node.children[1].type === 'media') {
434
+ maybeCaption = node.children[0];
435
+ media = node.children[1];
436
+ }
437
+ const url = media === null || media === void 0 ? void 0 : media['xlink:href'];
438
+ let caption = ((_d = select('caption', media)) !== null && _d !== void 0 ? _d : maybeCaption);
439
+ if (((_e = caption === null || caption === void 0 ? void 0 : caption.children) === null || _e === void 0 ? void 0 : _e.length) === 1 && caption.children[0].type === 'p') {
440
+ caption = caption.children[0];
441
+ }
442
+ if (url && MEDIA_FIGURE_EXTENSIONS.find((ext) => url.endsWith(ext))) {
443
+ const title = select('title', media);
444
+ state.openNode('container', { label, identifier, kind: 'figure' });
445
+ const wasInContainer = state.data.isInContainer;
446
+ state.data.isInContainer = true;
447
+ state.addLeaf('image', { url });
448
+ state.openNode('caption');
449
+ state.openNode('link', { url });
450
+ if (title) {
451
+ state.openNode('strong');
452
+ state.renderChildren(title);
453
+ state.closeNode();
454
+ }
455
+ if (caption) {
456
+ state.renderChildren(caption);
457
+ }
458
+ state.closeNode();
459
+ state.closeNode();
460
+ state.closeNode();
461
+ state.data.isInContainer = wasInContainer;
462
+ }
463
+ else {
464
+ if (node.id) {
465
+ state.openNode('div', { label, identifier });
466
+ }
467
+ state.renderChildren(node);
468
+ if (node.id) {
469
+ state.closeNode();
470
+ }
471
+ }
472
+ },
473
+ ['app-group'](node, state) {
474
+ state.renderChildren(node);
475
+ },
476
+ app(node, state) {
384
477
  var _a;
385
478
  if (node.id) {
386
479
  const { label, identifier } = (_a = normalizeLabel(node.id)) !== null && _a !== void 0 ? _a : {};
@@ -400,6 +493,9 @@ const handlers = {
400
493
  caption(node, state) {
401
494
  state.renderChildren(node);
402
495
  },
496
+ email(node, state) {
497
+ state.renderInline(node, 'link', { url: `mailto:${toText(node)}` });
498
+ },
403
499
  // These nodes can be safely ignored
404
500
  label() { },
405
501
  comment() { },
@@ -503,68 +599,57 @@ export class JatsParser {
503
599
  }
504
600
  }
505
601
  export const jatsConvertPlugin = function (jats, opts) {
506
- this.Compiler = (node, file) => {
507
- if (jats.abstract)
602
+ this.Compiler = (body, file) => {
603
+ if (jats.abstract) {
508
604
  abstractTransform(jats.abstract);
509
- const tree = jats.abstract
510
- ? {
511
- type: 'root',
512
- children: [
513
- u('block', { part: 'abstract' }, copyNode(jats.abstract).children),
514
- ...copyNode(node).children,
515
- ],
516
- }
517
- : copyNode(node);
605
+ body.children = [
606
+ u('block', { part: 'abstract' }, copyNode(jats.abstract).children),
607
+ ...body.children,
608
+ ];
609
+ }
518
610
  // Can do better than this in the future, but for now, just put them at the end!
519
611
  const floatsGroup = selectAll('floats-group', jats.tree);
520
612
  if (floatsGroup.length > 0) {
521
613
  floatsGroup.forEach((g) => {
522
- tree.children.push(...g.children);
614
+ body.children.push(...g.children);
523
615
  });
524
616
  }
525
- basicTransformations(tree, file);
526
- citationToMixedCitation(tree);
527
- journalTransforms(tree);
528
- const state = new JatsParser(file, jats, opts !== null && opts !== void 0 ? opts : { handlers });
529
- state.renderChildren(tree);
617
+ floatToEndTransform(body);
618
+ backToBodyTransform(body, jats.back);
619
+ dataAvailabilityTransform(body);
620
+ const refLookup = processJatsReferences(body, jats.references, opts);
621
+ basicTransformations(body, file);
622
+ journalTransforms(body);
623
+ const state = new JatsParser(file, jats, opts);
624
+ state.renderChildren(body);
530
625
  while (state.stack.length > 1)
531
626
  state.closeNode();
627
+ const tree = state.stack[0];
532
628
  if (state.unhandled.length && (opts === null || opts === void 0 ? void 0 : opts.logInfo)) {
533
629
  opts.logInfo.unhandled = [...new Set(state.unhandled)];
534
630
  }
535
- const referenceData = Object.fromEntries(jats.references.map((bibr) => {
536
- const id = bibr.id;
537
- const names = selectAll('name,string-name', bibr)
538
- .map((n) => `${toText(select('surname', n))}, ${toText(select('given-names', n))}`)
539
- .join(', ');
540
- const year = toText(select('year', bibr));
541
- const title = toText(select('article-title', bibr));
542
- const source = toText(select('source', bibr));
543
- const volume = toText(select('volume', bibr));
544
- const fpage = toText(select('fpage', bibr));
545
- const lpage = toText(select('lpage', bibr));
546
- const doiElement = selectAll('ext-link,[pub-id-type=doi]', bibr).find((e) => doi.validate(toText(e)));
547
- const doiString = doiElement ? toText(doiElement) : undefined;
548
- const doiLink = doiString ? ` <a href=${doi.buildUrl(doiString)}>${doiString}</a>` : '';
549
- return [
550
- id,
551
- {
552
- html: `${names}. (${year}). ${title}. <i>${source}</i>, <i>${volume}</i>, ${fpage}-${lpage}.${doiLink}`,
553
- doi: doiString,
554
- },
555
- ];
556
- }));
557
- const referenceOrder = [];
558
- const xrefs = selectAll('xref[ref-type=bibr]', jats.body);
559
- xrefs.forEach((xref) => {
560
- const rid = xref.rid;
561
- if (!referenceOrder.includes(rid)) {
562
- referenceOrder.push(rid);
563
- }
631
+ resolveJatsCitations(tree, refLookup);
632
+ inlineCitationsTransform(tree, jats.references
633
+ .map(({ id }) => {
634
+ var _a;
635
+ const { identifier } = (_a = normalizeLabel(id)) !== null && _a !== void 0 ? _a : {};
636
+ return identifier;
637
+ })
638
+ .filter((id) => !!id));
639
+ const { frontmatter } = jats;
640
+ abbreviationSectionTransform(tree, frontmatter);
641
+ abbreviationFootnoteTransform(tree, frontmatter);
642
+ abbreviationsFromTree(tree, frontmatter);
643
+ tableFootnotesToLegend(tree);
644
+ const abstract = selectAll('block', tree).find((block) => {
645
+ return block.data && block.data.part === 'abstract';
564
646
  });
647
+ if (abstract) {
648
+ frontmatter.description = descriptionFromAbstract(toText(abstract));
649
+ }
565
650
  const result = {
566
- references: { order: referenceOrder, data: referenceData },
567
- tree: state.stack[0],
651
+ tree,
652
+ frontmatter,
568
653
  };
569
654
  file.result = result;
570
655
  return file;
@@ -573,9 +658,8 @@ export const jatsConvertPlugin = function (jats, opts) {
573
658
  return node;
574
659
  };
575
660
  };
576
- export async function jatsConvertTransform(data, opts) {
661
+ export function jatsConvertTransform(jats, opts) {
577
662
  var _a, _b, _c;
578
- const jats = typeof data === 'string' ? new Jats(data) : data;
579
663
  if (opts === null || opts === void 0 ? void 0 : opts.logInfo) {
580
664
  opts.logInfo.publisher = toText(select('publisher-name', jats.tree)) || null;
581
665
  opts.logInfo.journal = toText(select('journal-title', jats.tree)) || null;
@@ -599,24 +683,10 @@ export async function jatsConvertTransform(data, opts) {
599
683
  }
600
684
  opts.logInfo.license = licenseString;
601
685
  }
602
- const { frontmatter } = jats;
603
686
  const file = (_b = opts === null || opts === void 0 ? void 0 : opts.vfile) !== null && _b !== void 0 ? _b : new VFile();
604
- const refLookup = await processJatsReferences(jats, opts);
605
- floatToEndTransform(jats);
606
- backToBodyTransform(jats);
607
687
  const pipe = unified().use(jatsConvertPlugin, jats, opts);
608
- pipe.stringify(((_c = jats.body) !== null && _c !== void 0 ? _c : { type: 'body', children: [] }), file);
609
- const references = file.result.references;
610
- const tree = file.result.tree;
611
- resolveJatsCitations(tree, refLookup);
612
- inlineCitationsTransform(tree, [...Object.keys(references.data)]);
613
- abbreviationSectionTransform(tree, frontmatter);
614
- const abstract = selectAll('block', tree).find((node) => {
615
- return node.data && node.data.part === 'abstract';
616
- });
617
- if (abstract) {
618
- frontmatter.description = descriptionFromAbstract(toText(abstract));
619
- }
688
+ pipe.stringify(copyNode((_c = jats.body) !== null && _c !== void 0 ? _c : { type: 'body', children: [] }), file);
689
+ const { tree, frontmatter } = file.result;
620
690
  if (opts === null || opts === void 0 ? void 0 : opts.logInfo) {
621
691
  opts.logInfo.figures = {
622
692
  body: selectAll('fig', jats.body).length,
@@ -646,17 +716,30 @@ export async function jatsConvertTransform(data, opts) {
646
716
  myst: selectAll('footnoteDefinition', tree).length,
647
717
  };
648
718
  }
649
- return { tree, jats, references, frontmatter }; //, kind };
719
+ return { tree, frontmatter };
650
720
  }
651
721
  export async function jatsConvert(session, input, opts) {
652
722
  const logInfo = { jatsVersion: version };
723
+ if (!input) {
724
+ const xmls = fs.readdirSync('.').filter((file) => path.extname(file) === '.xml');
725
+ if (xmls.length === 0) {
726
+ throw new Error('No JATS xml file found in current directory; please specify input');
727
+ }
728
+ if (xmls.length > 1) {
729
+ throw new Error('Multiple XML files found in current directory; please specify input');
730
+ }
731
+ input = xmls[0];
732
+ }
653
733
  const dir = path.dirname(input);
654
734
  const vfile = new VFile();
655
735
  vfile.path = input;
656
- const { tree, frontmatter } = await jatsConvertTransform(fs.readFileSync(input).toString(), {
736
+ const jats = new Jats(fs.readFileSync(input).toString());
737
+ const pmidCache = await getPMIDLookup(jats.references, dir);
738
+ const { tree, frontmatter } = jatsConvertTransform(jats, {
657
739
  vfile,
658
740
  dir,
659
741
  logInfo,
742
+ pmidCache,
660
743
  dois: opts === null || opts === void 0 ? void 0 : opts.dois,
661
744
  bibtex: opts === null || opts === void 0 ? void 0 : opts.bibtex,
662
745
  });
@@ -0,0 +1,11 @@
1
+ import type { GenericParent } from 'myst-common';
2
+ import type { ProjectFrontmatter } from 'myst-frontmatter';
3
+ /**
4
+ * Attempt to pull abbreviations out of tree
5
+ *
6
+ * This looks for parenthesized letters and tries to match them to the
7
+ * previous words.
8
+ */
9
+ export declare function abbreviationsFromTree(tree: GenericParent, frontmatter: Pick<ProjectFrontmatter, 'abbreviations'>): void;
10
+ export declare function abbreviationsFromText(text: string): Record<string, string>;
11
+ //# sourceMappingURL=abbreviations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abbreviations.d.ts","sourceRoot":"","sources":["../../src/myst/abbreviations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,QAYvD;AAgCD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA+B1E"}
@@ -0,0 +1,80 @@
1
+ import { selectAll } from 'unist-util-select';
2
+ import { toText } from '../utils.js';
3
+ /**
4
+ * Attempt to pull abbreviations out of tree
5
+ *
6
+ * This looks for parenthesized letters and tries to match them to the
7
+ * previous words.
8
+ */
9
+ export function abbreviationsFromTree(tree, frontmatter) {
10
+ let abbreviations = {};
11
+ const paragraphs = selectAll('paragraph', tree);
12
+ paragraphs.forEach((paragraph) => {
13
+ const text = toText(paragraph);
14
+ abbreviations = {
15
+ ...abbreviations,
16
+ ...abbreviationsFromText(text),
17
+ };
18
+ });
19
+ frontmatter.abbreviations = { ...frontmatter.abbreviations, ...abbreviations };
20
+ }
21
+ function maybeStopWord(word) {
22
+ return word.length < 5;
23
+ }
24
+ function exploreAbbrPossibilities(letter, possibilities) {
25
+ const newPossibilities = [];
26
+ possibilities.forEach(({ prev, next }) => {
27
+ if (prev === null || prev === void 0 ? void 0 : prev.includes(letter)) {
28
+ newPossibilities.push({
29
+ prev: prev.slice(prev.indexOf(letter) + 1),
30
+ next,
31
+ });
32
+ }
33
+ for (const [i, n] of next.entries()) {
34
+ if (n.startsWith(letter)) {
35
+ newPossibilities.push({
36
+ prev: next[i].slice(1),
37
+ next: next.slice(i + 1),
38
+ });
39
+ }
40
+ if (!prev || !maybeStopWord(n)) {
41
+ break;
42
+ }
43
+ }
44
+ });
45
+ return newPossibilities;
46
+ }
47
+ export function abbreviationsFromText(text) {
48
+ const abbreviations = {};
49
+ const textList = text.split(' ');
50
+ textList.forEach((word, index) => {
51
+ var _a;
52
+ const abbr = (_a = word.match(/^\(([^\s]{2,})\).{0,1}/)) === null || _a === void 0 ? void 0 : _a[1];
53
+ if (!abbr)
54
+ return;
55
+ const possibleWords = [];
56
+ let wordIndex = index - 1;
57
+ while (textList[wordIndex] && possibleWords.filter((w) => w.length > 4).length < abbr.length) {
58
+ possibleWords.unshift(textList[wordIndex]);
59
+ wordIndex--;
60
+ }
61
+ for (const i of Array(possibleWords.length).keys()) {
62
+ let possibilities = [
63
+ {
64
+ next: possibleWords.slice(i).map((w) => w.toLowerCase()),
65
+ },
66
+ ];
67
+ abbr
68
+ .split('')
69
+ .filter((letter) => letter.match(/^[a-zA-Z]$/))
70
+ .forEach((letter) => {
71
+ possibilities = exploreAbbrPossibilities(letter.toLowerCase(), possibilities);
72
+ });
73
+ if (possibilities.filter(({ next }) => next.length === 0).length) {
74
+ abbreviations[abbr] = possibleWords.slice(i).join(' ');
75
+ break;
76
+ }
77
+ }
78
+ });
79
+ return abbreviations;
80
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"inlineCitations.d.ts","sourceRoot":"","sources":["../../src/myst/inlineCitations.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAuKzF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,QAenF"}
1
+ {"version":3,"file":"inlineCitations.d.ts","sourceRoot":"","sources":["../../src/myst/inlineCitations.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAwMzF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,QAiBnF"}
@@ -174,6 +174,44 @@ function expandHyphenatedCites(tree, referenceList) {
174
174
  });
175
175
  remove(tree, '__delete__');
176
176
  }
177
+ /**
178
+ * Remove superscript around citations
179
+ */
180
+ function removeCiteSuperscript(tree) {
181
+ const citeGroupParents = selectAll(':has(> citeGroup)', tree);
182
+ citeGroupParents.forEach((parent) => {
183
+ if (parent.type !== 'superscript')
184
+ return;
185
+ if (parent.children.length !== 1)
186
+ return;
187
+ parent.type = '__lift__';
188
+ });
189
+ liftChildren(tree, '__lift__');
190
+ }
191
+ /**
192
+ * Ensure there are spaces before citations
193
+ *
194
+ * This is a problem, for example, when citations are removed from superscript and there
195
+ * was no space before the citation.
196
+ */
197
+ function ensureSpaceBeforeCite(tree) {
198
+ const citeGroupParents = selectAll(':has(> text + citeGroup)', tree);
199
+ citeGroupParents.forEach((parent) => {
200
+ parent.children.forEach((child, index) => {
201
+ var _a, _b;
202
+ if (child.type !== 'text')
203
+ return;
204
+ const citeChild = parent.children[index + 1];
205
+ if ((citeChild === null || citeChild === void 0 ? void 0 : citeChild.type) !== 'citeGroup')
206
+ return;
207
+ if ((_a = child.value) === null || _a === void 0 ? void 0 : _a.match(/\s+$/))
208
+ return;
209
+ if ((_b = child.value) === null || _b === void 0 ? void 0 : _b.match(/[[(]$/))
210
+ return;
211
+ child.value = `${child.value} `;
212
+ });
213
+ });
214
+ }
177
215
  export function inlineCitationsTransform(tree, referenceIds) {
178
216
  let before = '';
179
217
  let current = JSON.stringify(tree);
@@ -187,6 +225,8 @@ export function inlineCitationsTransform(tree, referenceIds) {
187
225
  removeCiteSeparators(tree);
188
226
  expandHyphenatedCites(tree, referenceIds);
189
227
  removeCiteParentheses(tree);
228
+ removeCiteSuperscript(tree);
229
+ ensureSpaceBeforeCite(tree);
190
230
  current = JSON.stringify(tree);
191
231
  }
192
232
  }
@@ -14,4 +14,9 @@ import type { ProjectFrontmatter } from 'myst-frontmatter';
14
14
  * CER, ceramides; FASN, fatty acid synthase; FDR, false discovery rate.
15
15
  */
16
16
  export declare function abbreviationSectionTransform(tree: GenericParent, frontmatter: Pick<ProjectFrontmatter, 'abbreviations'>): void;
17
+ /**
18
+ * If there is a footnote that starts with "abbreviations:" try to move abbreviatons to frontmatter
19
+ *
20
+ */
21
+ export declare function abbreviationFootnoteTransform(tree: GenericParent, frontmatter: Pick<ProjectFrontmatter, 'abbreviations'>): void;
17
22
  //# sourceMappingURL=abbreviations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"abbreviations.d.ts","sourceRoot":"","sources":["../../src/transforms/abbreviations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAK3D;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,QAuBvD"}
1
+ {"version":3,"file":"abbreviations.d.ts","sourceRoot":"","sources":["../../src/transforms/abbreviations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAK3D;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,QAuBvD;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,QA4BvD"}
@@ -45,3 +45,41 @@ export function abbreviationSectionTransform(tree, frontmatter) {
45
45
  });
46
46
  remove(tree, '__delete__');
47
47
  }
48
+ /**
49
+ * If there is a footnote that starts with "abbreviations:" try to move abbreviatons to frontmatter
50
+ *
51
+ */
52
+ export function abbreviationFootnoteTransform(tree, frontmatter) {
53
+ const fnDefs = selectAll('footnoteDefinition', tree);
54
+ const fnRefs = selectAll('footnoteReference', tree).map(({ identifier }) => identifier);
55
+ fnDefs.forEach((fnDef) => {
56
+ var _a;
57
+ if (fnDef.identifier && fnRefs.includes(fnDef.identifier))
58
+ return;
59
+ if (((_a = fnDef.children) === null || _a === void 0 ? void 0 : _a.length) !== 1)
60
+ return;
61
+ if (fnDef.children[0].type !== 'paragraph')
62
+ return;
63
+ const fnText = toText(fnDef.children[0]);
64
+ const abbrPrefix = 'abbreviations: ';
65
+ if (!fnText.toLowerCase().startsWith(abbrPrefix))
66
+ return;
67
+ const abbreviations = fnText.slice(abbrPrefix.length).replace(/\.$/, '').split(/;\s*/g);
68
+ const entries = abbreviations.map((abbr) => {
69
+ const parts = abbr.split(/[,:]\s*/g);
70
+ if (parts.length !== 2)
71
+ return undefined;
72
+ // Spaces in abbreviation value are not allowed
73
+ if (parts[0].match(/\s/))
74
+ return undefined;
75
+ return [parts[0], parts[1]];
76
+ });
77
+ // There cannot be a single invalid abbreviation
78
+ if (entries.findIndex((entry) => !entry) !== -1)
79
+ return;
80
+ const newAbbreviations = Object.fromEntries(entries);
81
+ frontmatter.abbreviations = { ...frontmatter.abbreviations, ...newAbbreviations };
82
+ fnDef.type = '__delete__';
83
+ });
84
+ remove(tree, '__delete__');
85
+ }
@@ -1,9 +1,13 @@
1
- import type { Jats } from 'jats-xml';
1
+ import type { GenericParent } from 'myst-common';
2
+ import type { Back, Body } from 'jats-tags';
2
3
  /**
3
- * Move footnotes and sections from back to body
4
+ * Copy footnotes and sections from back into body tree
4
5
  *
5
- * Currently we only pass body to JATS convert plugin, so we move parts of
6
- * the backmatter that need parsing to body.
6
+ * Back is not modified.
7
7
  */
8
- export declare function backToBodyTransform(jats: Jats): void;
8
+ export declare function backToBodyTransform(body: Body, back?: Back): void;
9
+ /**
10
+ * Leave table footnotes in legend if they are not referenced anywhere
11
+ */
12
+ export declare function tableFootnotesToLegend(tree: GenericParent): void;
9
13
  //# sourceMappingURL=footnotes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"footnotes.d.ts","sourceRoot":"","sources":["../../src/transforms/footnotes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,QAW7C"}
1
+ {"version":3,"file":"footnotes.d.ts","sourceRoot":"","sources":["../../src/transforms/footnotes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAG5C;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,QAO1D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,aAAa,QASzD"}
@@ -1,23 +1,30 @@
1
1
  import { copyNode } from 'myst-common';
2
- import { remove } from 'unist-util-remove';
2
+ import { selectAll } from 'unist-util-select';
3
3
  /**
4
- * Move footnotes and sections from back to body
4
+ * Copy footnotes and sections from back into body tree
5
5
  *
6
- * Currently we only pass body to JATS convert plugin, so we move parts of
7
- * the backmatter that need parsing to body.
6
+ * Back is not modified.
8
7
  */
9
- export function backToBodyTransform(jats) {
10
- var _a, _b;
11
- if (!jats.back)
8
+ export function backToBodyTransform(body, back) {
9
+ var _a;
10
+ if (!back)
12
11
  return;
13
- const backNodes = (_a = jats.back.children) === null || _a === void 0 ? void 0 : _a.filter((node) => {
14
- return ['fn-group', 'sec', 'ack'].includes(node.type);
12
+ const backNodes = (_a = back.children) === null || _a === void 0 ? void 0 : _a.filter((node) => {
13
+ return ['fn-group', 'sec', 'ack', 'app-group'].includes(node.type);
15
14
  });
16
- if (!((_b = jats.body) === null || _b === void 0 ? void 0 : _b.children) || backNodes.length === 0)
15
+ if (!(body === null || body === void 0 ? void 0 : body.children) || backNodes.length === 0)
17
16
  return;
18
- jats.body.children.push({ type: 'hr' }, ...copyNode(backNodes));
19
- backNodes.forEach((node) => {
20
- node.type = '__delete__';
17
+ body.children.push({ type: 'hr' }, ...copyNode(backNodes));
18
+ }
19
+ /**
20
+ * Leave table footnotes in legend if they are not referenced anywhere
21
+ */
22
+ export function tableFootnotesToLegend(tree) {
23
+ const tableFns = selectAll('legend > footnoteDefinition', tree);
24
+ const fnRefs = selectAll('footnoteReference', tree).map(({ identifier }) => identifier);
25
+ tableFns.forEach((tableFn) => {
26
+ if (tableFn.identifier && fnRefs.includes(tableFn.identifier))
27
+ return;
28
+ tableFn.type = 'paragraph';
21
29
  });
22
- remove(jats.back, '__delete__');
23
30
  }
@@ -1,17 +1,16 @@
1
- import type { GenericParent, GenericNode } from 'myst-common';
2
1
  import type { Plugin } from 'unified';
3
2
  import type { VFile } from 'vfile';
3
+ import type { Body } from 'jats-tags';
4
4
  export * from './abbreviations.js';
5
5
  export * from './abstract.js';
6
6
  export * from './admonitions.js';
7
7
  export * from './biorxiv.js';
8
- export * from './citations.js';
9
8
  export * from './figureCaptions.js';
10
9
  export * from './footnotes.js';
11
10
  export * from './references.js';
12
11
  export * from './sections.js';
13
12
  export * from './typography.js';
14
- export declare function basicTransformations(tree: GenericParent, file: VFile): void;
15
- export declare const basicTransformationsPlugin: Plugin<[], GenericParent, GenericParent>;
16
- export declare function journalTransforms(tree?: GenericNode): void;
13
+ export declare function basicTransformations(body: Body, file: VFile): void;
14
+ export declare const basicTransformationsPlugin: Plugin<[], Body, Body>;
15
+ export declare function journalTransforms(body: Body): void;
17
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAQnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAEhC,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,KAAK,QAKpE;AAED,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,CAG7E,CAAC;AAEJ,wBAAgB,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,QAEnD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAEhC,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,QAK3D;AAED,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAE7D,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,QAE3C"}
@@ -7,21 +7,20 @@ export * from './abbreviations.js';
7
7
  export * from './abstract.js';
8
8
  export * from './admonitions.js';
9
9
  export * from './biorxiv.js';
10
- export * from './citations.js';
11
10
  export * from './figureCaptions.js';
12
11
  export * from './footnotes.js';
13
12
  export * from './references.js';
14
13
  export * from './sections.js';
15
14
  export * from './typography.js';
16
- export function basicTransformations(tree, file) {
17
- sectionTransform(tree);
18
- typographyTransform(tree);
19
- admonitionTransform(tree, file);
20
- figCaptionTitleTransform(tree);
15
+ export function basicTransformations(body, file) {
16
+ sectionTransform(body);
17
+ typographyTransform(body);
18
+ admonitionTransform(body, file);
19
+ figCaptionTitleTransform(body);
21
20
  }
22
- export const basicTransformationsPlugin = () => (tree, file) => {
23
- basicTransformations(tree, file);
21
+ export const basicTransformationsPlugin = () => (body, file) => {
22
+ basicTransformations(body, file);
24
23
  };
25
- export function journalTransforms(tree) {
26
- graphicToBioRxivUrl(tree);
24
+ export function journalTransforms(body) {
25
+ graphicToBioRxivUrl(body);
27
26
  }
@@ -0,0 +1,6 @@
1
+ import type { GenericParent } from 'myst-common';
2
+ /**
3
+ * Remove duplicate Data Availability title from data-availability part
4
+ */
5
+ export declare function dataAvailabilityTransform(tree: GenericParent): void;
6
+ //# sourceMappingURL=parts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../../src/transforms/parts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,aAAa,CAAC;AAK9D;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,aAAa,QAW5D"}
@@ -0,0 +1,18 @@
1
+ import { toText } from 'myst-common';
2
+ import { remove } from 'unist-util-remove';
3
+ import { selectAll } from 'unist-util-select';
4
+ /**
5
+ * Remove duplicate Data Availability title from data-availability part
6
+ */
7
+ export function dataAvailabilityTransform(tree) {
8
+ const dataAvailability = selectAll('sec[sec-type=data-availability]', tree);
9
+ dataAvailability.forEach((node) => {
10
+ const titles = selectAll('title', node);
11
+ titles.forEach((title) => {
12
+ if (toText(title).toLowerCase() === 'data availability') {
13
+ title.type = '__delete__';
14
+ }
15
+ });
16
+ });
17
+ remove(tree, '__delete__');
18
+ }
@@ -1,6 +1,6 @@
1
1
  import 'dotenv/config.js';
2
+ import type { Body, Reference } from 'jats-tags';
2
3
  import type { GenericParent } from 'myst-common';
3
- import type { Jats } from 'jats-xml';
4
4
  import type { Options } from '../types.js';
5
5
  type ProcessedReference = {
6
6
  cite?: string;
@@ -18,7 +18,16 @@ type ProcessedReference = {
18
18
  * This function also writes a bibtex file if necessary and appends footnotes
19
19
  * to the jats tree.
20
20
  */
21
- export declare function processJatsReferences(jats: Jats, opts?: Options): Promise<Record<string, ProcessedReference[]>>;
21
+ export declare function processJatsReferences(body: Body, references: Reference[], opts?: Options): Record<string, ProcessedReference[]>;
22
+ /**
23
+ * Generate a DOI lookup dictionary for a list of References with PubMed IDs
24
+ *
25
+ * This will load lookup dictionary cached on path, if available,
26
+ * then query (and cache) NIH APIs for other PMIDs
27
+ *
28
+ * Returns PMID -> DOI lookup dictionary
29
+ */
30
+ export declare function getPMIDLookup(refs: Reference[], dir: string): Promise<Record<string, string | null>>;
22
31
  /**
23
32
  * Resolve cite nodes using reference lookup
24
33
  *
@@ -1 +1 @@
1
- {"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../src/transforms/references.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAM1B,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,aAAa,CAAC;AAI9D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAW3C,KAAK,kBAAkB,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AA6RF;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,OAAO,iDA2DrE;AAsCD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,aAAa,EACnB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,iBAqChD"}
1
+ {"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../src/transforms/references.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,aAAa,CAAC;AAI9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAW3C,KAAK,kBAAkB,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AA6RF;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,IAAI,CAAC,EAAE,OAAO,wCA0DxF;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,MAAM,0CAejE;AAaD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,aAAa,EACnB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,iBAqChD"}
@@ -1,7 +1,6 @@
1
1
  import 'dotenv/config.js';
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
- // import OpenAI from 'openai';
5
4
  import { convertPMIDs2DOIs, normalizePMID } from 'jats-fetch';
6
5
  import { copyNode, liftChildren, normalizeLabel } from 'myst-common';
7
6
  import { select, selectAll } from 'unist-util-select';
@@ -183,7 +182,7 @@ function bibtexFromCite(key, cite, counts, doi) {
183
182
  }
184
183
  if (bibtexLines.length === 1) {
185
184
  counts.unprocessed += 1;
186
- // console.log(`This needs addressing: ${key}`);
185
+ bibtexLines.push(` note = {${toText(cite)}}`);
187
186
  }
188
187
  else {
189
188
  counts.bibtex += 1;
@@ -266,7 +265,7 @@ function processRef(ref, pmidCache, fnCount, counts, dois) {
266
265
  const footnotes = [];
267
266
  const bibtexEntries = [];
268
267
  (_b = ref.children) === null || _b === void 0 ? void 0 : _b.forEach((child) => {
269
- if (['element-citation', 'mixed-citation'].includes(child.type)) {
268
+ if (['element-citation', 'mixed-citation', 'citation'].includes(child.type)) {
270
269
  if (!toText(child))
271
270
  return;
272
271
  const cite = processRefCite(child, identifier, pmidCache, counts, dois);
@@ -307,15 +306,14 @@ function processRef(ref, pmidCache, fnCount, counts, dois) {
307
306
  * This function also writes a bibtex file if necessary and appends footnotes
308
307
  * to the jats tree.
309
308
  */
310
- export async function processJatsReferences(jats, opts) {
309
+ export function processJatsReferences(body, references, opts) {
311
310
  var _a, _b;
312
311
  const dir = (_a = opts === null || opts === void 0 ? void 0 : opts.dir) !== null && _a !== void 0 ? _a : '.';
313
312
  const bibfile = path.join(dir, 'main.bib');
314
- const refs = jats.references;
313
+ const pmidCache = (_b = opts === null || opts === void 0 ? void 0 : opts.pmidCache) !== null && _b !== void 0 ? _b : {};
315
314
  let refLookup = {};
316
315
  const footnotes = [];
317
316
  const bibtexEntries = [];
318
- const pmidCache = await getPMIDLookup(refs, dir);
319
317
  const counts = {
320
318
  dois: 0,
321
319
  bibtex: 0,
@@ -323,7 +321,7 @@ export async function processJatsReferences(jats, opts) {
323
321
  lostRefs: [],
324
322
  lostRefItems: [],
325
323
  };
326
- refs.forEach((ref) => {
324
+ references.forEach((ref) => {
327
325
  const { refLookup: newRefLookup, footnotes: newFootnotes, bibtexEntries: newBibtexEntries, } = processRef(ref, pmidCache, footnotes.length + 1, counts, opts === null || opts === void 0 ? void 0 : opts.dois);
328
326
  refLookup = { ...refLookup, ...newRefLookup };
329
327
  bibtexEntries.push(...newBibtexEntries);
@@ -331,7 +329,7 @@ export async function processJatsReferences(jats, opts) {
331
329
  });
332
330
  if (opts === null || opts === void 0 ? void 0 : opts.logInfo) {
333
331
  opts.logInfo.references = {
334
- total: refs.length,
332
+ total: references.length,
335
333
  dois: counts.dois,
336
334
  bibtex: counts.bibtex,
337
335
  footnotes: footnotes.length,
@@ -362,7 +360,7 @@ export async function processJatsReferences(jats, opts) {
362
360
  fs.writeFileSync(bibfile, bibtexEntries.join('\n\n'));
363
361
  }
364
362
  if (footnotes.length) {
365
- (_b = jats.body) === null || _b === void 0 ? void 0 : _b.children.push({ type: 'fn-group', children: footnotes });
363
+ body.children.push({ type: 'fn-group', children: footnotes });
366
364
  }
367
365
  return refLookup;
368
366
  }
@@ -374,7 +372,7 @@ export async function processJatsReferences(jats, opts) {
374
372
  *
375
373
  * Returns PMID -> DOI lookup dictionary
376
374
  */
377
- async function getPMIDLookup(refs, dir) {
375
+ export async function getPMIDLookup(refs, dir) {
378
376
  const pmids = refs
379
377
  .map((ref) => {
380
378
  const pmidElement = select('ext-link,[pub-id-type=pmid]', ref);
@@ -1 +1 @@
1
- {"version":3,"file":"sections.d.ts","sourceRoot":"","sources":["../../src/transforms/sections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,aAAa,CAAC;AAqC9D;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,QASrF;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,CAElE,CAAC"}
1
+ {"version":3,"file":"sections.d.ts","sourceRoot":"","sources":["../../src/transforms/sections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,aAAa,CAAC;AAgD9D;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,QAUrF;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,CAElE,CAAC"}
@@ -1,9 +1,16 @@
1
1
  import { liftChildren, toText } from 'myst-common';
2
2
  import { blockNestingTransform } from 'myst-transforms';
3
- import { select } from 'unist-util-select';
3
+ import { select, selectAll } from 'unist-util-select';
4
4
  import { remove } from 'unist-util-remove';
5
+ const SECTION_TYPES = ['sec', 'ack', 'app'];
5
6
  function isSection(node) {
6
- return node.type === 'sec' || node.type === 'ack';
7
+ return SECTION_TYPES.includes(node.type);
8
+ }
9
+ function liftApps(tree) {
10
+ selectAll('app-group', tree).forEach((group) => {
11
+ group.type = '__lift__';
12
+ });
13
+ liftChildren(tree, '__lift__');
7
14
  }
8
15
  function recurseSections(tree, depth = 1, titleType) {
9
16
  var _a;
@@ -34,6 +41,9 @@ function recurseSections(tree, depth = 1, titleType) {
34
41
  }
35
42
  if (sec.type === 'ack')
36
43
  sec.part = 'acknowledgments';
44
+ if (sec.type === 'app')
45
+ sec.part = 'appendix';
46
+ sec.type = 'sec';
37
47
  recurseSections(sec, depth + 1, titleType);
38
48
  });
39
49
  }
@@ -47,6 +57,7 @@ function recurseSections(tree, depth = 1, titleType) {
47
57
  */
48
58
  export function sectionTransform(tree, titleType) {
49
59
  var _a;
60
+ liftApps(tree);
50
61
  recurseSections(tree, 1, titleType);
51
62
  remove(tree, '__delete__');
52
63
  const topSections = (_a = tree.children) === null || _a === void 0 ? void 0 : _a.filter((n) => isSection(n));
@@ -1,6 +1,6 @@
1
- import type { Jats } from 'jats-xml';
1
+ import type { Body } from 'jats-tags';
2
2
  /**
3
3
  * Move any supplementary-material marked as position=float to end of document
4
4
  */
5
- export declare function floatToEndTransform(jats: Jats): void;
5
+ export declare function floatToEndTransform(body: Body): void;
6
6
  //# sourceMappingURL=supplementary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"supplementary.d.ts","sourceRoot":"","sources":["../../src/transforms/supplementary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKrC;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,QAY7C"}
1
+ {"version":3,"file":"supplementary.d.ts","sourceRoot":"","sources":["../../src/transforms/supplementary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAKtC;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,QAW7C"}
@@ -1,23 +1,21 @@
1
1
  import { selectAll } from 'unist-util-select';
2
- import { copyNode } from '../utils.js';
3
2
  import { remove } from 'unist-util-remove';
3
+ import { copyNode } from '../utils.js';
4
4
  /**
5
5
  * Move any supplementary-material marked as position=float to end of document
6
6
  */
7
- export function floatToEndTransform(jats) {
7
+ export function floatToEndTransform(body) {
8
8
  var _a;
9
- if (!jats.body)
10
- return;
11
- const floatSupplementaryMaterial = selectAll('supplementary-material[position=float]', jats.body);
9
+ const floatSupplementaryMaterial = selectAll('supplementary-material[position=float]', body);
12
10
  if (floatSupplementaryMaterial.length === 0)
13
11
  return;
14
- (_a = jats.body.children) === null || _a === void 0 ? void 0 : _a.push({ type: 'hr' });
12
+ (_a = body.children) === null || _a === void 0 ? void 0 : _a.push({ type: 'hr' });
15
13
  floatSupplementaryMaterial.forEach((node) => {
16
- var _a, _b;
14
+ var _a;
17
15
  const copy = copyNode(node);
18
16
  delete copy.position;
19
- (_b = (_a = jats.body) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.push(copy);
17
+ (_a = body === null || body === void 0 ? void 0 : body.children) === null || _a === void 0 ? void 0 : _a.push(copy);
20
18
  node.type = '__delete__';
21
19
  });
22
- remove(jats.body, '__delete__');
20
+ remove(body, '__delete__');
23
21
  }
package/dist/types.d.ts CHANGED
@@ -1,18 +1,11 @@
1
1
  import type { PageFrontmatter } from 'myst-frontmatter';
2
- import type { GenericNode, MessageInfo } from 'myst-common';
2
+ import type { GenericNode, GenericParent, MessageInfo } from 'myst-common';
3
3
  import type { Jats } from 'jats-xml';
4
- import type { Root } from 'myst-spec';
5
4
  import type { VFile } from 'vfile';
6
5
  export type Handler = (node: GenericNode, state: IJatsParser, parent: any) => void;
7
6
  export type JatsResult = {
8
- references: {
9
- order: string[];
10
- data: Record<string, {
11
- html: string;
12
- doi: string;
13
- }>;
14
- };
15
- tree: Root;
7
+ tree: GenericParent;
8
+ frontmatter: PageFrontmatter;
16
9
  };
17
10
  export type MathPlugins = Required<PageFrontmatter>['math'];
18
11
  export type Options = {
@@ -20,6 +13,7 @@ export type Options = {
20
13
  handlers?: Record<string, Handler>;
21
14
  dir?: string;
22
15
  logInfo?: Record<string, any>;
16
+ pmidCache?: Record<string, string | null>;
23
17
  dois?: boolean;
24
18
  bibtex?: boolean;
25
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAA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,KAAK,IAAI,CAAC;IAC1F,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAClE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACnE,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;IACrE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;CACvE"}
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const version = "1.0.13";
1
+ declare const version = "1.0.15";
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.13';
1
+ const version = '1.0.15';
2
2
  export default version;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "jats-convert",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Read JATS and convert to MyST-spec frontmatter and AST",
5
- "author": "Rowan Cockett <rowan@curvenote.com>",
6
- "homepage": "https://github.com/curvenote/jats/tree/main/packages/jats-convert",
5
+ "author": "Rowan Cockett <rowan@continuous.foundation>",
6
+ "homepage": "https://github.com/continuous-foundation/jats/tree/main/packages/jats-convert",
7
7
  "license": "MIT",
8
8
  "type": "module",
9
9
  "exports": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
23
- "url": "git+https://github.com/curvenote/jats.git"
23
+ "url": "git+https://github.com/continuous-foundation/jats.git"
24
24
  },
25
25
  "scripts": {
26
26
  "copy:version": "echo \"const version = '\"$npm_package_version\"';\nexport default version;\" > src/version.ts",
@@ -33,14 +33,14 @@
33
33
  "build": "npm-run-all -l clean copy:version -p build:esm"
34
34
  },
35
35
  "bugs": {
36
- "url": "https://github.com/curvenote/jats/issues"
36
+ "url": "https://github.com/continuous-foundation/jats/issues"
37
37
  },
38
38
  "dependencies": {
39
39
  "doi-utils": "^2.0.3",
40
40
  "dotenv": "^16.4.5",
41
- "jats-fetch": "^1.0.13",
42
- "jats-tags": "^1.0.13",
43
- "jats-xml": "^1.0.13",
41
+ "jats-fetch": "^1.0.15",
42
+ "jats-tags": "^1.0.15",
43
+ "jats-xml": "^1.0.15",
44
44
  "js-yaml": "^4.1.0",
45
45
  "mathml-to-latex": "^1.3.0",
46
46
  "myst-cli-utils": "^2.0.11",
@@ -48,7 +48,7 @@
48
48
  "myst-frontmatter": "^1.7.5",
49
49
  "myst-spec": "^0.0.5",
50
50
  "myst-spec-ext": "^1.7.5",
51
- "myst-transforms": "^1.3.27",
51
+ "myst-transforms": "^1.3.28",
52
52
  "unified": "^10.0.0",
53
53
  "unist-builder": "^3.0.0",
54
54
  "unist-util-select": "^5.1.0",
@@ -1,8 +0,0 @@
1
- import type { GenericNode } from 'myst-common';
2
- /**
3
- * Replace invalid 'citation' element with 'mixed-citation'
4
- *
5
- * This occurs in JATS from multiple publishers
6
- */
7
- export declare function citationToMixedCitation(tree?: GenericNode): void;
8
- //# sourceMappingURL=citations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"citations.d.ts","sourceRoot":"","sources":["../../src/transforms/citations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,CAAC,EAAE,WAAW,QAIzD"}
@@ -1,11 +0,0 @@
1
- import { selectAll } from 'unist-util-select';
2
- /**
3
- * Replace invalid 'citation' element with 'mixed-citation'
4
- *
5
- * This occurs in JATS from multiple publishers
6
- */
7
- export function citationToMixedCitation(tree) {
8
- selectAll('citation', tree).forEach((node) => {
9
- node.type = 'mixed-citation';
10
- });
11
- }