jats-xml 0.0.17 → 0.1.0

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/dist/cjs/cli/parse.js +12 -12
  2. package/dist/cjs/jats.js +25 -25
  3. package/dist/cjs/utils.js +4 -4
  4. package/dist/cjs/version.js +1 -1
  5. package/dist/esm/cli/parse.js +1 -1
  6. package/dist/esm/jats.js +1 -1
  7. package/dist/esm/utils.js +2 -2
  8. package/dist/esm/version.js +1 -1
  9. package/dist/jats.js +902 -514
  10. package/dist/types/jats.d.ts +1 -1
  11. package/dist/types/jats.d.ts.map +1 -1
  12. package/dist/types/{types/session.d.ts → types.d.ts} +1 -1
  13. package/dist/types/types.d.ts.map +1 -0
  14. package/dist/types/utils.d.ts.map +1 -1
  15. package/dist/types/version.d.ts +1 -1
  16. package/dist/types/version.d.ts.map +1 -1
  17. package/package.json +3 -8
  18. package/LICENSE +0 -21
  19. package/dist/cjs/types/elementTags.js +0 -1301
  20. package/dist/cjs/types/index.js +0 -20
  21. package/dist/cjs/types/refType.js +0 -57
  22. package/dist/cjs/types/session.js +0 -2
  23. package/dist/esm/types/elementTags.js +0 -1298
  24. package/dist/esm/types/index.js +0 -4
  25. package/dist/esm/types/refType.js +0 -54
  26. package/dist/esm/types/session.js +0 -1
  27. package/dist/types/types/elementTags.d.ts +0 -1298
  28. package/dist/types/types/elementTags.d.ts.map +0 -1
  29. package/dist/types/types/elements.d.ts +0 -93
  30. package/dist/types/types/elements.d.ts.map +0 -1
  31. package/dist/types/types/index.d.ts +0 -5
  32. package/dist/types/types/index.d.ts.map +0 -1
  33. package/dist/types/types/refType.d.ts +0 -54
  34. package/dist/types/types/refType.d.ts.map +0 -1
  35. package/dist/types/types/session.d.ts.map +0 -1
  36. /package/dist/cjs/{types/elements.js → types.js} +0 -0
  37. /package/dist/esm/{types/elements.js → types.js} +0 -0
@@ -21,7 +21,7 @@ const doi_utils_1 = __importDefault(require("doi-utils"));
21
21
  const chalk_1 = __importDefault(require("chalk"));
22
22
  const fair_principles_1 = require("fair-principles");
23
23
  const session_1 = require("../session");
24
- const types_1 = require("../types");
24
+ const jats_tags_1 = require("jats-tags");
25
25
  const jats_1 = require("../jats");
26
26
  const myst_common_1 = require("myst-common");
27
27
  const unist_util_select_1 = require("unist-util-select");
@@ -122,7 +122,7 @@ function jatsSummaryCLI(session, file) {
122
122
  Title: (_a = (0, myst_common_1.toText)(jats.articleTitle)) === null || _a === void 0 ? void 0 : _a.replace(/\n/g, ' '),
123
123
  Date: (0, utils_1.formatDate)((0, utils_1.toDate)(jats.publicationDate)),
124
124
  Authors: jats.articleAuthors
125
- .map((a) => `${(0, myst_common_1.toText)((0, unist_util_select_1.select)(types_1.Tags.givenNames, a))} ${(0, myst_common_1.toText)((0, unist_util_select_1.select)(types_1.Tags.surname, a))}`)
125
+ .map((a) => `${(0, myst_common_1.toText)((0, unist_util_select_1.select)(jats_tags_1.Tags.givenNames, a))} ${(0, myst_common_1.toText)((0, unist_util_select_1.select)(jats_tags_1.Tags.surname, a))}`)
126
126
  .join(', '),
127
127
  Abstract: (_b = (0, myst_common_1.toText)(jats.abstract)) === null || _b === void 0 ? void 0 : _b.replace(/\n/g, ' '),
128
128
  Keywords: jats.keywords.map((k) => (0, myst_common_1.toText)(k)).join(', '),
@@ -131,32 +131,32 @@ function jatsSummaryCLI(session, file) {
131
131
  if (jats.body) {
132
132
  summary.Figures = {
133
133
  label: chalk_1.default.blue.bold,
134
- value: String((0, unist_util_select_1.selectAll)(types_1.Tags.fig, jats.body).length),
134
+ value: String((0, unist_util_select_1.selectAll)(jats_tags_1.Tags.fig, jats.body).length),
135
135
  };
136
136
  summary.Equations = {
137
137
  label: chalk_1.default.blue.bold,
138
- value: String((0, unist_util_select_1.selectAll)(types_1.Tags.dispFormula, jats.body).length),
138
+ value: String((0, unist_util_select_1.selectAll)(jats_tags_1.Tags.dispFormula, jats.body).length),
139
139
  };
140
140
  summary.Tables = {
141
141
  label: chalk_1.default.blue.bold,
142
- value: String((0, unist_util_select_1.selectAll)(types_1.Tags.table, jats.body).length),
142
+ value: String((0, unist_util_select_1.selectAll)(jats_tags_1.Tags.table, jats.body).length),
143
143
  };
144
144
  summary.Code = {
145
145
  label: chalk_1.default.blue.bold,
146
- value: String((0, unist_util_select_1.selectAll)(types_1.Tags.code, jats.body).length),
146
+ value: String((0, unist_util_select_1.selectAll)(jats_tags_1.Tags.code, jats.body).length),
147
147
  };
148
148
  summary.Sections = {
149
149
  label: chalk_1.default.blue.bold,
150
- value: String((0, unist_util_select_1.selectAll)(types_1.Tags.sec, jats.body).length),
150
+ value: String((0, unist_util_select_1.selectAll)(jats_tags_1.Tags.sec, jats.body).length),
151
151
  };
152
152
  summary.Paragraphs = {
153
153
  label: chalk_1.default.blue.bold,
154
- value: String((0, unist_util_select_1.selectAll)(types_1.Tags.p, jats.body).length),
154
+ value: String((0, unist_util_select_1.selectAll)(jats_tags_1.Tags.p, jats.body).length),
155
155
  };
156
156
  summary.Citations = { label: chalk_1.default.blue.bold, value: String(jats.references.length) };
157
157
  summary['Cross-References'] = {
158
158
  label: chalk_1.default.blue.bold,
159
- value: String((0, unist_util_select_1.selectAll)(types_1.Tags.xref, jats.body).length),
159
+ value: String((0, unist_util_select_1.selectAll)(jats_tags_1.Tags.xref, jats.body).length),
160
160
  };
161
161
  summary['Sub Articles'] = { label: chalk_1.default.blue.bold, value: String(jats.subArticles.length) };
162
162
  }
@@ -172,9 +172,9 @@ function jatsReferencesCLI(session, file) {
172
172
  const sorted = jats.references
173
173
  .map((ref) => {
174
174
  const doiString = (0, utils_1.findArticleId)(ref, 'doi');
175
- const title = (0, myst_common_1.toText)((0, unist_util_select_1.select)(types_1.Tags.articleTitle, ref));
176
- const year = (0, myst_common_1.toText)((0, unist_util_select_1.select)(types_1.Tags.year, ref));
177
- const surnames = (0, unist_util_select_1.selectAll)(types_1.Tags.surname, ref);
175
+ const title = (0, myst_common_1.toText)((0, unist_util_select_1.select)(jats_tags_1.Tags.articleTitle, ref));
176
+ const year = (0, myst_common_1.toText)((0, unist_util_select_1.select)(jats_tags_1.Tags.year, ref));
177
+ const surnames = (0, unist_util_select_1.selectAll)(jats_tags_1.Tags.surname, ref);
178
178
  const short = surnames.length > 2
179
179
  ? (0, myst_common_1.toText)(surnames[0]) + ' et al.'
180
180
  : surnames.length === 2
package/dist/cjs/jats.js CHANGED
@@ -9,7 +9,7 @@ const xml_js_1 = require("xml-js");
9
9
  const doi_utils_1 = __importDefault(require("doi-utils"));
10
10
  const utils_1 = require("./utils");
11
11
  const unist_util_select_1 = require("unist-util-select");
12
- const types_1 = require("./types");
12
+ const jats_tags_1 = require("jats-tags");
13
13
  const myst_cli_utils_1 = require("myst-cli-utils");
14
14
  function select(selector, node) {
15
15
  var _a;
@@ -44,8 +44,8 @@ class Jats {
44
44
  const subtitle = this.articleSubtitle;
45
45
  const date = this.publicationDate;
46
46
  const authors = this.articleAuthors;
47
- const firstSubject = select(types_1.Tags.subject, (_a = this.articleCategories) !== null && _a !== void 0 ? _a : this.front);
48
- const journalTitle = select(types_1.Tags.journalTitle, this.front);
47
+ const firstSubject = select(jats_tags_1.Tags.subject, (_a = this.articleCategories) !== null && _a !== void 0 ? _a : this.front);
48
+ const journalTitle = select(jats_tags_1.Tags.journalTitle, this.front);
49
49
  return {
50
50
  title: title ? (0, myst_common_1.toText)(title) : undefined,
51
51
  subtitle: subtitle ? (0, myst_common_1.toText)(subtitle) : undefined,
@@ -58,10 +58,10 @@ class Jats {
58
58
  };
59
59
  }
60
60
  get front() {
61
- return select(types_1.Tags.front, this.tree);
61
+ return select(jats_tags_1.Tags.front, this.tree);
62
62
  }
63
63
  get premissions() {
64
- return select(types_1.Tags.permissions, this.front);
64
+ return select(jats_tags_1.Tags.permissions, this.front);
65
65
  }
66
66
  get doi() {
67
67
  var _a;
@@ -75,65 +75,65 @@ class Jats {
75
75
  return (0, utils_1.findArticleId)(this.front, 'pmid');
76
76
  }
77
77
  get publicationDates() {
78
- return (0, unist_util_select_1.selectAll)(types_1.Tags.pubDate, this.front);
78
+ return (0, unist_util_select_1.selectAll)(jats_tags_1.Tags.pubDate, this.front);
79
79
  }
80
80
  get publicationDate() {
81
- return this.publicationDates.find((d) => !!select(types_1.Tags.day, d));
81
+ return this.publicationDates.find((d) => !!select(jats_tags_1.Tags.day, d));
82
82
  }
83
83
  get license() {
84
- return select(types_1.Tags.license, this.premissions);
84
+ return select(jats_tags_1.Tags.license, this.premissions);
85
85
  }
86
86
  get keywordGroup() {
87
- return select(types_1.Tags.kwdGroup, this.front);
87
+ return select(jats_tags_1.Tags.kwdGroup, this.front);
88
88
  }
89
89
  /** The first keywords */
90
90
  get keywords() {
91
- return (0, unist_util_select_1.selectAll)(types_1.Tags.kwd, this.keywordGroup);
91
+ return (0, unist_util_select_1.selectAll)(jats_tags_1.Tags.kwd, this.keywordGroup);
92
92
  }
93
93
  get keywordGroups() {
94
- return (0, unist_util_select_1.selectAll)(types_1.Tags.kwdGroup, this.front);
94
+ return (0, unist_util_select_1.selectAll)(jats_tags_1.Tags.kwdGroup, this.front);
95
95
  }
96
96
  get articleCategories() {
97
- return select(types_1.Tags.articleCategories, this.front);
97
+ return select(jats_tags_1.Tags.articleCategories, this.front);
98
98
  }
99
99
  get titleGroup() {
100
- return select(types_1.Tags.titleGroup, this.front);
100
+ return select(jats_tags_1.Tags.titleGroup, this.front);
101
101
  }
102
102
  get articleTitle() {
103
- return select(types_1.Tags.articleTitle, this.titleGroup);
103
+ return select(jats_tags_1.Tags.articleTitle, this.titleGroup);
104
104
  }
105
105
  get articleSubtitle() {
106
- return select(types_1.Tags.subtitle, this.titleGroup);
106
+ return select(jats_tags_1.Tags.subtitle, this.titleGroup);
107
107
  }
108
108
  get abstract() {
109
- return select(types_1.Tags.abstract, this.front);
109
+ return select(jats_tags_1.Tags.abstract, this.front);
110
110
  }
111
111
  get abstracts() {
112
- return (0, unist_util_select_1.selectAll)(types_1.Tags.abstract, this.front);
112
+ return (0, unist_util_select_1.selectAll)(jats_tags_1.Tags.abstract, this.front);
113
113
  }
114
114
  get contribGroup() {
115
- return select(types_1.Tags.contribGroup, this.front);
115
+ return select(jats_tags_1.Tags.contribGroup, this.front);
116
116
  }
117
117
  get contribGroups() {
118
- return (0, unist_util_select_1.selectAll)(types_1.Tags.contribGroup, this.front);
118
+ return (0, unist_util_select_1.selectAll)(jats_tags_1.Tags.contribGroup, this.front);
119
119
  }
120
120
  get articleAuthors() {
121
- return (0, unist_util_select_1.selectAll)(types_1.Tags.contrib, this.contribGroup);
121
+ return (0, unist_util_select_1.selectAll)(jats_tags_1.Tags.contrib, this.contribGroup);
122
122
  }
123
123
  get body() {
124
- return select(types_1.Tags.body, this.tree);
124
+ return select(jats_tags_1.Tags.body, this.tree);
125
125
  }
126
126
  get back() {
127
- return select(types_1.Tags.back, this.tree);
127
+ return select(jats_tags_1.Tags.back, this.tree);
128
128
  }
129
129
  get subArticles() {
130
- return (0, unist_util_select_1.selectAll)(types_1.Tags.subArticle, this.tree);
130
+ return (0, unist_util_select_1.selectAll)(jats_tags_1.Tags.subArticle, this.tree);
131
131
  }
132
132
  get refList() {
133
- return select(types_1.Tags.refList, this.back);
133
+ return select(jats_tags_1.Tags.refList, this.back);
134
134
  }
135
135
  get references() {
136
- return (0, unist_util_select_1.selectAll)(types_1.Tags.ref, this.refList);
136
+ return (0, unist_util_select_1.selectAll)(jats_tags_1.Tags.ref, this.refList);
137
137
  }
138
138
  }
139
139
  exports.Jats = Jats;
package/dist/cjs/utils.js CHANGED
@@ -7,7 +7,7 @@ exports.authorAndAffiliation = exports.findArticleId = exports.formatDate = expo
7
7
  const myst_common_1 = require("myst-common");
8
8
  const doi_utils_1 = __importDefault(require("doi-utils"));
9
9
  const unist_util_select_1 = require("unist-util-select");
10
- const types_1 = require("./types");
10
+ const jats_tags_1 = require("jats-tags");
11
11
  function convertToUnist(node) {
12
12
  switch (node.type) {
13
13
  case 'element': {
@@ -29,7 +29,7 @@ function convertToUnist(node) {
29
29
  }
30
30
  case 'cdata': {
31
31
  const { attributes, cdata } = node;
32
- return Object.assign(Object.assign({ type: 'cdata' }, attributes), { cdata });
32
+ return Object.assign(Object.assign({ type: 'cdata' }, attributes), { cdata: String(cdata).trim() });
33
33
  }
34
34
  case 'comment': {
35
35
  const { comment } = node;
@@ -105,13 +105,13 @@ function findArticleId(node, pubIdType = 'doi') {
105
105
  const id = (0, unist_util_select_1.select)(`[pub-id-type=${pubIdType}]`, node);
106
106
  if (id && (0, myst_common_1.toText)(id))
107
107
  return (0, myst_common_1.toText)(id);
108
- const doiTag = (0, unist_util_select_1.selectAll)(`${types_1.Tags.articleId},${types_1.Tags.pubId}`, node).find((t) => doi_utils_1.default.validate((0, myst_common_1.toText)(t)));
108
+ const doiTag = (0, unist_util_select_1.selectAll)(`${jats_tags_1.Tags.articleId},${jats_tags_1.Tags.pubId}`, node).find((t) => doi_utils_1.default.validate((0, myst_common_1.toText)(t)));
109
109
  return (0, myst_common_1.toText)(doiTag) || undefined;
110
110
  }
111
111
  exports.findArticleId = findArticleId;
112
112
  function authorAndAffiliation(node, article) {
113
113
  const author = {
114
- name: `${(0, myst_common_1.toText)((0, unist_util_select_1.select)(types_1.Tags.givenNames, node))} ${(0, myst_common_1.toText)((0, unist_util_select_1.select)(types_1.Tags.surname, node))}`,
114
+ name: `${(0, myst_common_1.toText)((0, unist_util_select_1.select)(jats_tags_1.Tags.givenNames, node))} ${(0, myst_common_1.toText)((0, unist_util_select_1.select)(jats_tags_1.Tags.surname, node))}`,
115
115
  };
116
116
  const orcid = (0, unist_util_select_1.select)('[contrib-id-type=orcid]', node);
117
117
  if (orcid) {
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const version = '0.0.17';
3
+ const version = '0.1.0';
4
4
  exports.default = version;
@@ -15,7 +15,7 @@ import doi from 'doi-utils';
15
15
  import chalk from 'chalk';
16
16
  import { formatPrinciples, highlightFAIR } from 'fair-principles';
17
17
  import { getSession } from '../session';
18
- import { Tags } from '../types';
18
+ import { Tags } from 'jats-tags';
19
19
  import { Jats } from '../jats';
20
20
  import { toText } from 'myst-common';
21
21
  import { select, selectAll } from 'unist-util-select';
package/dist/esm/jats.js CHANGED
@@ -3,7 +3,7 @@ import { xml2js } from 'xml-js';
3
3
  import doi from 'doi-utils';
4
4
  import { authorAndAffiliation, convertToUnist, findArticleId, toDate } from './utils';
5
5
  import { select as unistSelect, selectAll } from 'unist-util-select';
6
- import { Tags } from './types';
6
+ import { Tags } from 'jats-tags';
7
7
  import { tic } from 'myst-cli-utils';
8
8
  function select(selector, node) {
9
9
  var _a;
package/dist/esm/utils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { toText } from 'myst-common';
2
2
  import doi from 'doi-utils';
3
3
  import { select, selectAll } from 'unist-util-select';
4
- import { Tags } from './types';
4
+ import { Tags } from 'jats-tags';
5
5
  export function convertToUnist(node) {
6
6
  switch (node.type) {
7
7
  case 'element': {
@@ -23,7 +23,7 @@ export function convertToUnist(node) {
23
23
  }
24
24
  case 'cdata': {
25
25
  const { attributes, cdata } = node;
26
- return Object.assign(Object.assign({ type: 'cdata' }, attributes), { cdata });
26
+ return Object.assign(Object.assign({ type: 'cdata' }, attributes), { cdata: String(cdata).trim() });
27
27
  }
28
28
  case 'comment': {
29
29
  const { comment } = node;
@@ -1,2 +1,2 @@
1
- const version = '0.0.17';
1
+ const version = '0.1.0';
2
2
  export default version;