@manuscripts/transform 2.3.34-LEAN-3911.2 → 2.3.35

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 (116) hide show
  1. package/dist/cjs/__tests__/data/project-dump.json +825 -0
  2. package/dist/cjs/jats/importer/index.js +3 -3
  3. package/dist/cjs/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +9 -229
  4. package/dist/cjs/jats/importer/jats-body-transformations.js +0 -70
  5. package/dist/cjs/jats/importer/jats-comments.js +104 -27
  6. package/dist/cjs/jats/importer/jats-front-parser.js +321 -0
  7. package/dist/cjs/jats/importer/jats-journal-meta-parser.js +1 -8
  8. package/dist/cjs/jats/importer/jats-parser-utils.js +5 -39
  9. package/dist/cjs/jats/importer/jats-reference-parser.js +27 -16
  10. package/dist/cjs/jats/importer/jats-references.js +18 -18
  11. package/dist/cjs/jats/importer/parse-jats-article.js +78 -42
  12. package/dist/cjs/jats/index.js +3 -4
  13. package/dist/cjs/jats/jats-exporter.js +354 -251
  14. package/dist/cjs/lib/utils.js +1 -9
  15. package/dist/cjs/schema/nodes/inline_footnote.js +1 -0
  16. package/dist/cjs/transformer/__tests__/__helpers__/doc.js +37 -0
  17. package/dist/cjs/transformer/builders.js +219 -0
  18. package/dist/cjs/transformer/decode.js +874 -0
  19. package/dist/cjs/transformer/document-object-types.js +31 -0
  20. package/dist/cjs/transformer/encode.js +664 -0
  21. package/dist/cjs/transformer/footnote-category.js +20 -0
  22. package/dist/cjs/transformer/footnotes-order.js +60 -0
  23. package/dist/cjs/transformer/highlight-markers.js +138 -0
  24. package/dist/cjs/transformer/html.js +400 -0
  25. package/dist/cjs/transformer/id.js +6 -6
  26. package/dist/cjs/transformer/index.js +18 -0
  27. package/dist/cjs/{jats → transformer}/labels.js +3 -3
  28. package/dist/cjs/transformer/manuscript-dependencies.js +21 -0
  29. package/dist/cjs/transformer/model-map.js +26 -0
  30. package/dist/cjs/transformer/models.js +17 -0
  31. package/dist/cjs/transformer/object-types.js +57 -0
  32. package/dist/cjs/transformer/project-bundle.js +94 -0
  33. package/dist/cjs/transformer/serializer.js +23 -0
  34. package/dist/cjs/transformer/update-identifiers.js +93 -0
  35. package/dist/cjs/version.js +1 -1
  36. package/dist/es/__tests__/data/project-dump.json +825 -0
  37. package/dist/es/jats/importer/index.js +1 -2
  38. package/dist/es/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +10 -230
  39. package/dist/es/jats/importer/jats-body-transformations.js +0 -70
  40. package/dist/es/jats/importer/jats-comments.js +101 -26
  41. package/dist/es/jats/importer/jats-front-parser.js +315 -0
  42. package/dist/es/jats/importer/jats-journal-meta-parser.js +0 -6
  43. package/dist/es/jats/importer/jats-parser-utils.js +6 -40
  44. package/dist/es/jats/importer/jats-reference-parser.js +27 -16
  45. package/dist/es/jats/importer/jats-references.js +18 -18
  46. package/dist/es/jats/importer/parse-jats-article.js +77 -43
  47. package/dist/es/jats/index.js +1 -3
  48. package/dist/es/jats/jats-exporter.js +356 -253
  49. package/dist/es/lib/utils.js +0 -7
  50. package/dist/es/schema/nodes/inline_footnote.js +1 -0
  51. package/dist/es/transformer/__tests__/__helpers__/doc.js +29 -0
  52. package/dist/es/transformer/builders.js +186 -0
  53. package/dist/es/transformer/decode.js +864 -0
  54. package/dist/es/transformer/document-object-types.js +28 -0
  55. package/dist/es/transformer/encode.js +654 -0
  56. package/dist/{types/jats/importer/create-article-node.d.ts → es/transformer/footnote-category.js} +2 -3
  57. package/dist/es/transformer/footnotes-order.js +55 -0
  58. package/dist/es/transformer/highlight-markers.js +132 -0
  59. package/dist/es/transformer/html.js +393 -0
  60. package/dist/es/transformer/id.js +4 -5
  61. package/dist/es/transformer/index.js +16 -0
  62. package/dist/es/{jats → transformer}/labels.js +3 -3
  63. package/dist/es/transformer/manuscript-dependencies.js +17 -0
  64. package/dist/es/transformer/model-map.js +22 -0
  65. package/dist/es/transformer/models.js +16 -0
  66. package/dist/es/transformer/object-types.js +52 -0
  67. package/dist/es/transformer/project-bundle.js +85 -0
  68. package/dist/es/transformer/serializer.js +17 -0
  69. package/dist/es/transformer/update-identifiers.js +87 -0
  70. package/dist/es/version.js +1 -1
  71. package/dist/types/jats/importer/index.d.ts +1 -2
  72. package/dist/types/jats/importer/{jats-dom-parser.d.ts → jats-body-dom-parser.d.ts} +1 -1
  73. package/dist/types/jats/importer/jats-body-transformations.d.ts +0 -5
  74. package/dist/types/jats/importer/jats-comments.d.ts +10 -4
  75. package/dist/types/jats/importer/jats-front-parser.d.ts +84 -0
  76. package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +0 -10
  77. package/dist/types/jats/importer/jats-references.d.ts +8 -19
  78. package/dist/types/jats/importer/parse-jats-article.d.ts +5 -12
  79. package/dist/types/jats/index.d.ts +1 -3
  80. package/dist/types/jats/jats-exporter.d.ts +29 -10
  81. package/dist/types/lib/utils.d.ts +0 -3
  82. package/dist/types/schema/nodes/bibliography_item.d.ts +6 -16
  83. package/dist/types/schema/nodes/contributor.d.ts +0 -10
  84. package/dist/types/schema/nodes/keyword_group.d.ts +0 -1
  85. package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +18 -0
  86. package/dist/types/transformer/builders.d.ts +61 -0
  87. package/dist/types/transformer/decode.d.ts +51 -0
  88. package/dist/types/transformer/document-object-types.d.ts +17 -0
  89. package/dist/types/transformer/encode.d.ts +29 -0
  90. package/dist/types/transformer/footnote-category.d.ts +17 -0
  91. package/dist/types/transformer/footnotes-order.d.ts +22 -0
  92. package/dist/types/transformer/highlight-markers.d.ts +31 -0
  93. package/dist/types/transformer/html.d.ts +36 -0
  94. package/dist/types/transformer/id.d.ts +3 -4
  95. package/dist/types/transformer/index.d.ts +16 -0
  96. package/dist/types/{jats → transformer}/labels.d.ts +1 -2
  97. package/dist/types/transformer/manuscript-dependencies.d.ts +4 -0
  98. package/dist/types/transformer/model-map.d.ts +19 -0
  99. package/dist/types/transformer/models.d.ts +48 -0
  100. package/dist/types/transformer/object-types.d.ts +30 -0
  101. package/dist/types/transformer/project-bundle.d.ts +30 -0
  102. package/dist/types/transformer/serializer.d.ts +19 -0
  103. package/dist/types/transformer/update-identifiers.d.ts +23 -0
  104. package/dist/types/version.d.ts +1 -1
  105. package/package.json +1 -2
  106. package/dist/cjs/jats/importer/create-article-node.js +0 -31
  107. package/dist/cjs/jats/importer/jats-front-transformations.js +0 -262
  108. package/dist/es/jats/importer/create-article-node.js +0 -27
  109. package/dist/es/jats/importer/jats-front-transformations.js +0 -259
  110. package/dist/types/jats/importer/jats-front-transformations.d.ts +0 -38
  111. /package/dist/cjs/{jats → transformer}/filename.js +0 -0
  112. /package/dist/cjs/{jats → transformer}/timestamp.js +0 -0
  113. /package/dist/es/{jats → transformer}/filename.js +0 -0
  114. /package/dist/es/{jats → transformer}/timestamp.js +0 -0
  115. /package/dist/types/{jats → transformer}/filename.d.ts +0 -0
  116. /package/dist/types/{jats → transformer}/timestamp.d.ts +0 -0
@@ -1,262 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2024 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.jatsFrontTransformations = exports.defaultTitle = void 0;
19
- const json_schema_1 = require("@manuscripts/json-schema");
20
- const utils_1 = require("../../lib/utils");
21
- const transformer_1 = require("../../transformer");
22
- const jats_parser_utils_1 = require("./jats-parser-utils");
23
- exports.defaultTitle = 'Untitled Manuscript';
24
- exports.jatsFrontTransformations = {
25
- setArticleAttrs(doc, template) {
26
- var _a;
27
- const doi = (_a = doc.querySelector('article-meta > article-id[pub-id-type="doi"]')) === null || _a === void 0 ? void 0 : _a.textContent;
28
- const Attrs = {
29
- DOI: doi !== null && doi !== void 0 ? doi : '',
30
- prototype: template !== null && template !== void 0 ? template : '',
31
- id: (0, transformer_1.generateID)(json_schema_1.ObjectTypes.Manuscript),
32
- };
33
- Object.entries(Attrs).forEach(([key, value]) => {
34
- var _a;
35
- if (value) {
36
- (_a = doc.querySelector('article')) === null || _a === void 0 ? void 0 : _a.setAttribute(key, value);
37
- }
38
- });
39
- },
40
- createTitle(front, createElement) {
41
- var _a;
42
- let title = front.querySelector('article-meta > title-group > article-title');
43
- if (title) {
44
- title.innerHTML = (_a = (0, jats_parser_utils_1.htmlFromJatsNode)(title, createElement)) !== null && _a !== void 0 ? _a : exports.defaultTitle;
45
- }
46
- else {
47
- title = createElement('article-title');
48
- title.textContent = exports.defaultTitle;
49
- }
50
- return title;
51
- },
52
- createAuthorNotes(document, createElement) {
53
- const authornotes = document.querySelector('article-meta > author-notes');
54
- if (!authornotes) {
55
- return;
56
- }
57
- const authorNotesEl = createElement('author-notes');
58
- authornotes
59
- .querySelectorAll('fn:not([fn-type]), :scope > p, corresp')
60
- .forEach((node) => {
61
- switch (node.nodeName) {
62
- case 'fn': {
63
- this.appendFootnote(node, authorNotesEl, createElement);
64
- break;
65
- }
66
- case 'p': {
67
- this.appendParagraph(document, node, authorNotesEl);
68
- break;
69
- }
70
- case 'corresp': {
71
- this.appendCorresp(node, authorNotesEl, createElement);
72
- break;
73
- }
74
- }
75
- });
76
- return authorNotesEl;
77
- },
78
- appendFootnote(node, element, createElement) {
79
- const fnEl = createElement('fn-author');
80
- fnEl.innerHTML = node.innerHTML;
81
- fnEl.setAttribute('kind', 'footnote');
82
- const id = node.getAttribute('id');
83
- if (id) {
84
- fnEl.setAttribute('id', id);
85
- }
86
- element.append(fnEl);
87
- },
88
- appendParagraph(document, node, element) {
89
- const pEl = document.createElementNS(null, 'p');
90
- pEl.innerHTML = node.innerHTML;
91
- element.append(pEl);
92
- },
93
- appendCorresp(node, element, createElement) {
94
- var _a, _b;
95
- const correspEl = createElement('corresp');
96
- const label = node.querySelector('label');
97
- if (label) {
98
- label.remove();
99
- }
100
- correspEl.textContent = ((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '';
101
- correspEl.setAttribute('label', ((_b = label === null || label === void 0 ? void 0 : label.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '');
102
- const id = node.getAttribute('id');
103
- if (id) {
104
- correspEl.setAttribute('id', id);
105
- }
106
- element.append(correspEl);
107
- },
108
- createContributors(front, createElement) {
109
- const contribs = front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]');
110
- const contributors = createElement('contributors');
111
- contribs.forEach((element, priority) => {
112
- const contributor = this.createContributorElement(priority, createElement);
113
- this.setNameAttrs(element, contributor);
114
- this.setOrcidAttribute(element, contributor);
115
- this.setIsCorrespondingAttribute(element, contributor);
116
- this.setContributorReferences(element, contributor, createElement);
117
- contributors.append(contributor);
118
- });
119
- return contributors;
120
- },
121
- createContributorElement(priority, createElement) {
122
- const contributor = createElement('contributor');
123
- contributor.setAttribute('priority', priority.toString());
124
- contributor.setAttribute('role', 'author');
125
- return contributor;
126
- },
127
- setNameAttrs(node, element) {
128
- const given = (0, utils_1.getTrimmedTextContent)(node, 'name > given-names');
129
- if (given) {
130
- element.setAttribute('given', given);
131
- }
132
- const surname = (0, utils_1.getTrimmedTextContent)(node, 'name > surname');
133
- if (surname) {
134
- element.setAttribute('family', surname);
135
- }
136
- },
137
- setOrcidAttribute(node, element) {
138
- const orcid = (0, utils_1.getTrimmedTextContent)(node, 'contrib-id[contrib-id-type="orcid"]');
139
- if (orcid) {
140
- element.setAttribute('ORCIDIdentifier', orcid);
141
- }
142
- },
143
- setIsCorrespondingAttribute(node, element) {
144
- const isCorresponding = node.getAttribute('corresp') === 'yes';
145
- if (isCorresponding) {
146
- element.setAttribute('isCorresponding', isCorresponding.toString());
147
- }
148
- },
149
- setContributorReferences(node, element, createElement) {
150
- const xrefs = node.querySelectorAll('xref');
151
- const footnotes = createElement('fns');
152
- const corresps = createElement('corresps');
153
- const affs = createElement('affs');
154
- xrefs.forEach((xref) => {
155
- const rid = xref.getAttribute('rid');
156
- const type = xref.getAttribute('ref-type');
157
- if (rid) {
158
- switch (type) {
159
- case 'fn':
160
- this.appendFootnoteID(xref, footnotes, rid, createElement);
161
- break;
162
- case 'corresp':
163
- this.appendCorrespID(xref, corresps, rid, createElement);
164
- break;
165
- case 'aff':
166
- this.appendAffiliationID(affs, rid, createElement);
167
- break;
168
- }
169
- }
170
- });
171
- element.append(footnotes, corresps, affs);
172
- },
173
- appendFootnoteID(xref, footnotes, rid, createElement) {
174
- var _a;
175
- const fn = createElement('fn');
176
- fn.setAttribute('noteID', rid);
177
- fn.setAttribute('noteLabel', ((_a = xref.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '');
178
- footnotes.append(fn);
179
- },
180
- appendCorrespID(xref, corresps, rid, createElement) {
181
- var _a;
182
- const corresp = createElement('corresp');
183
- corresp.setAttribute('correspID', rid);
184
- corresp.setAttribute('correspLabel', ((_a = xref.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '');
185
- corresps.append(corresp);
186
- },
187
- appendAffiliationID(affs, rid, createElement) {
188
- const rids = rid.split(/\s+/).filter(Boolean);
189
- if (rids.length) {
190
- rids.forEach((affID) => {
191
- const aff = createElement('aff');
192
- aff.setAttribute('affiliationID', affID);
193
- affs.append(aff);
194
- });
195
- }
196
- },
197
- createAffiliations(front, createElement) {
198
- const affiliations = front.querySelectorAll('article-meta > contrib-group > aff');
199
- const affiliationGroup = createElement('affiliations');
200
- affiliations.forEach((element, priority) => {
201
- const affiliation = this.createAffiliationElement(element, priority, createElement);
202
- this.setInstitutionAttrs(element, affiliation);
203
- this.setAddressAttrs(element, affiliation);
204
- this.appendEmail(element, affiliation);
205
- affiliationGroup.append(affiliation);
206
- });
207
- return affiliationGroup;
208
- },
209
- createAffiliationElement(element, priority, createElement) {
210
- const affiliation = createElement('affiliation');
211
- affiliation.setAttribute('priority', priority.toString());
212
- const id = element.getAttribute('id');
213
- if (id) {
214
- affiliation.setAttribute('id', id);
215
- }
216
- return affiliation;
217
- },
218
- appendEmail(element, affiliation) {
219
- const emailEl = element.querySelector('email');
220
- if (emailEl) {
221
- affiliation.appendChild(emailEl);
222
- }
223
- },
224
- setInstitutionAttrs(element, affiliation) {
225
- var _a;
226
- for (const node of element.querySelectorAll('institution')) {
227
- const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
228
- if (!content) {
229
- continue;
230
- }
231
- const type = node.getAttribute('content-type');
232
- if (type === 'dept') {
233
- affiliation.setAttribute('department', content);
234
- }
235
- else {
236
- affiliation.setAttribute('institution', content);
237
- }
238
- }
239
- },
240
- setAddressAttrs(element, affiliation) {
241
- const addressLine1 = (0, utils_1.getTrimmedTextContent)(element, 'addr-line:nth-of-type(1)');
242
- const addressLine2 = (0, utils_1.getTrimmedTextContent)(element, 'addr-line:nth-of-type(2)');
243
- const addressLine3 = (0, utils_1.getTrimmedTextContent)(element, 'addr-line:nth-of-type(3)');
244
- const postCode = (0, utils_1.getTrimmedTextContent)(element, 'postal-code');
245
- const country = (0, utils_1.getTrimmedTextContent)(element, 'country');
246
- if (addressLine1) {
247
- affiliation.setAttribute('addressLine1', addressLine1);
248
- }
249
- if (addressLine2) {
250
- affiliation.setAttribute('addressLine2', addressLine2);
251
- }
252
- if (addressLine3) {
253
- affiliation.setAttribute('addressLine3', addressLine3);
254
- }
255
- if (postCode) {
256
- affiliation.setAttribute('postCode', postCode);
257
- }
258
- if (country) {
259
- affiliation.setAttribute('country', country);
260
- }
261
- },
262
- };
@@ -1,27 +0,0 @@
1
- /*!
2
- * © 2024 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { schema } from '../../schema';
17
- import { defaultTitle } from './jats-front-transformations';
18
- export const createArticleNode = (manuscript) => {
19
- const title = schema.nodes.title.createChecked({}, schema.text(defaultTitle));
20
- return schema.nodes.manuscript.createAndFill({
21
- id: manuscript._id,
22
- doi: manuscript.DOI,
23
- articleType: manuscript.articleType,
24
- prototype: manuscript.prototype,
25
- primaryLanguageCode: manuscript.primaryLanguageCode,
26
- }, title);
27
- };
@@ -1,259 +0,0 @@
1
- /*!
2
- * © 2024 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { ObjectTypes } from '@manuscripts/json-schema';
17
- import { getTrimmedTextContent } from '../../lib/utils';
18
- import { generateID } from '../../transformer';
19
- import { htmlFromJatsNode } from './jats-parser-utils';
20
- export const defaultTitle = 'Untitled Manuscript';
21
- export const jatsFrontTransformations = {
22
- setArticleAttrs(doc, template) {
23
- var _a;
24
- const doi = (_a = doc.querySelector('article-meta > article-id[pub-id-type="doi"]')) === null || _a === void 0 ? void 0 : _a.textContent;
25
- const Attrs = {
26
- DOI: doi !== null && doi !== void 0 ? doi : '',
27
- prototype: template !== null && template !== void 0 ? template : '',
28
- id: generateID(ObjectTypes.Manuscript),
29
- };
30
- Object.entries(Attrs).forEach(([key, value]) => {
31
- var _a;
32
- if (value) {
33
- (_a = doc.querySelector('article')) === null || _a === void 0 ? void 0 : _a.setAttribute(key, value);
34
- }
35
- });
36
- },
37
- createTitle(front, createElement) {
38
- var _a;
39
- let title = front.querySelector('article-meta > title-group > article-title');
40
- if (title) {
41
- title.innerHTML = (_a = htmlFromJatsNode(title, createElement)) !== null && _a !== void 0 ? _a : defaultTitle;
42
- }
43
- else {
44
- title = createElement('article-title');
45
- title.textContent = defaultTitle;
46
- }
47
- return title;
48
- },
49
- createAuthorNotes(document, createElement) {
50
- const authornotes = document.querySelector('article-meta > author-notes');
51
- if (!authornotes) {
52
- return;
53
- }
54
- const authorNotesEl = createElement('author-notes');
55
- authornotes
56
- .querySelectorAll('fn:not([fn-type]), :scope > p, corresp')
57
- .forEach((node) => {
58
- switch (node.nodeName) {
59
- case 'fn': {
60
- this.appendFootnote(node, authorNotesEl, createElement);
61
- break;
62
- }
63
- case 'p': {
64
- this.appendParagraph(document, node, authorNotesEl);
65
- break;
66
- }
67
- case 'corresp': {
68
- this.appendCorresp(node, authorNotesEl, createElement);
69
- break;
70
- }
71
- }
72
- });
73
- return authorNotesEl;
74
- },
75
- appendFootnote(node, element, createElement) {
76
- const fnEl = createElement('fn-author');
77
- fnEl.innerHTML = node.innerHTML;
78
- fnEl.setAttribute('kind', 'footnote');
79
- const id = node.getAttribute('id');
80
- if (id) {
81
- fnEl.setAttribute('id', id);
82
- }
83
- element.append(fnEl);
84
- },
85
- appendParagraph(document, node, element) {
86
- const pEl = document.createElementNS(null, 'p');
87
- pEl.innerHTML = node.innerHTML;
88
- element.append(pEl);
89
- },
90
- appendCorresp(node, element, createElement) {
91
- var _a, _b;
92
- const correspEl = createElement('corresp');
93
- const label = node.querySelector('label');
94
- if (label) {
95
- label.remove();
96
- }
97
- correspEl.textContent = ((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '';
98
- correspEl.setAttribute('label', ((_b = label === null || label === void 0 ? void 0 : label.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '');
99
- const id = node.getAttribute('id');
100
- if (id) {
101
- correspEl.setAttribute('id', id);
102
- }
103
- element.append(correspEl);
104
- },
105
- createContributors(front, createElement) {
106
- const contribs = front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]');
107
- const contributors = createElement('contributors');
108
- contribs.forEach((element, priority) => {
109
- const contributor = this.createContributorElement(priority, createElement);
110
- this.setNameAttrs(element, contributor);
111
- this.setOrcidAttribute(element, contributor);
112
- this.setIsCorrespondingAttribute(element, contributor);
113
- this.setContributorReferences(element, contributor, createElement);
114
- contributors.append(contributor);
115
- });
116
- return contributors;
117
- },
118
- createContributorElement(priority, createElement) {
119
- const contributor = createElement('contributor');
120
- contributor.setAttribute('priority', priority.toString());
121
- contributor.setAttribute('role', 'author');
122
- return contributor;
123
- },
124
- setNameAttrs(node, element) {
125
- const given = getTrimmedTextContent(node, 'name > given-names');
126
- if (given) {
127
- element.setAttribute('given', given);
128
- }
129
- const surname = getTrimmedTextContent(node, 'name > surname');
130
- if (surname) {
131
- element.setAttribute('family', surname);
132
- }
133
- },
134
- setOrcidAttribute(node, element) {
135
- const orcid = getTrimmedTextContent(node, 'contrib-id[contrib-id-type="orcid"]');
136
- if (orcid) {
137
- element.setAttribute('ORCIDIdentifier', orcid);
138
- }
139
- },
140
- setIsCorrespondingAttribute(node, element) {
141
- const isCorresponding = node.getAttribute('corresp') === 'yes';
142
- if (isCorresponding) {
143
- element.setAttribute('isCorresponding', isCorresponding.toString());
144
- }
145
- },
146
- setContributorReferences(node, element, createElement) {
147
- const xrefs = node.querySelectorAll('xref');
148
- const footnotes = createElement('fns');
149
- const corresps = createElement('corresps');
150
- const affs = createElement('affs');
151
- xrefs.forEach((xref) => {
152
- const rid = xref.getAttribute('rid');
153
- const type = xref.getAttribute('ref-type');
154
- if (rid) {
155
- switch (type) {
156
- case 'fn':
157
- this.appendFootnoteID(xref, footnotes, rid, createElement);
158
- break;
159
- case 'corresp':
160
- this.appendCorrespID(xref, corresps, rid, createElement);
161
- break;
162
- case 'aff':
163
- this.appendAffiliationID(affs, rid, createElement);
164
- break;
165
- }
166
- }
167
- });
168
- element.append(footnotes, corresps, affs);
169
- },
170
- appendFootnoteID(xref, footnotes, rid, createElement) {
171
- var _a;
172
- const fn = createElement('fn');
173
- fn.setAttribute('noteID', rid);
174
- fn.setAttribute('noteLabel', ((_a = xref.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '');
175
- footnotes.append(fn);
176
- },
177
- appendCorrespID(xref, corresps, rid, createElement) {
178
- var _a;
179
- const corresp = createElement('corresp');
180
- corresp.setAttribute('correspID', rid);
181
- corresp.setAttribute('correspLabel', ((_a = xref.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '');
182
- corresps.append(corresp);
183
- },
184
- appendAffiliationID(affs, rid, createElement) {
185
- const rids = rid.split(/\s+/).filter(Boolean);
186
- if (rids.length) {
187
- rids.forEach((affID) => {
188
- const aff = createElement('aff');
189
- aff.setAttribute('affiliationID', affID);
190
- affs.append(aff);
191
- });
192
- }
193
- },
194
- createAffiliations(front, createElement) {
195
- const affiliations = front.querySelectorAll('article-meta > contrib-group > aff');
196
- const affiliationGroup = createElement('affiliations');
197
- affiliations.forEach((element, priority) => {
198
- const affiliation = this.createAffiliationElement(element, priority, createElement);
199
- this.setInstitutionAttrs(element, affiliation);
200
- this.setAddressAttrs(element, affiliation);
201
- this.appendEmail(element, affiliation);
202
- affiliationGroup.append(affiliation);
203
- });
204
- return affiliationGroup;
205
- },
206
- createAffiliationElement(element, priority, createElement) {
207
- const affiliation = createElement('affiliation');
208
- affiliation.setAttribute('priority', priority.toString());
209
- const id = element.getAttribute('id');
210
- if (id) {
211
- affiliation.setAttribute('id', id);
212
- }
213
- return affiliation;
214
- },
215
- appendEmail(element, affiliation) {
216
- const emailEl = element.querySelector('email');
217
- if (emailEl) {
218
- affiliation.appendChild(emailEl);
219
- }
220
- },
221
- setInstitutionAttrs(element, affiliation) {
222
- var _a;
223
- for (const node of element.querySelectorAll('institution')) {
224
- const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
225
- if (!content) {
226
- continue;
227
- }
228
- const type = node.getAttribute('content-type');
229
- if (type === 'dept') {
230
- affiliation.setAttribute('department', content);
231
- }
232
- else {
233
- affiliation.setAttribute('institution', content);
234
- }
235
- }
236
- },
237
- setAddressAttrs(element, affiliation) {
238
- const addressLine1 = getTrimmedTextContent(element, 'addr-line:nth-of-type(1)');
239
- const addressLine2 = getTrimmedTextContent(element, 'addr-line:nth-of-type(2)');
240
- const addressLine3 = getTrimmedTextContent(element, 'addr-line:nth-of-type(3)');
241
- const postCode = getTrimmedTextContent(element, 'postal-code');
242
- const country = getTrimmedTextContent(element, 'country');
243
- if (addressLine1) {
244
- affiliation.setAttribute('addressLine1', addressLine1);
245
- }
246
- if (addressLine2) {
247
- affiliation.setAttribute('addressLine2', addressLine2);
248
- }
249
- if (addressLine3) {
250
- affiliation.setAttribute('addressLine3', addressLine3);
251
- }
252
- if (postCode) {
253
- affiliation.setAttribute('postCode', postCode);
254
- }
255
- if (country) {
256
- affiliation.setAttribute('country', country);
257
- }
258
- },
259
- };
@@ -1,38 +0,0 @@
1
- /*!
2
- * © 2024 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- export declare const defaultTitle = "Untitled Manuscript";
17
- export declare const jatsFrontTransformations: {
18
- setArticleAttrs(doc: Document, template?: string): void;
19
- createTitle(front: Element, createElement: (tagName: string) => HTMLElement): Element;
20
- createAuthorNotes(document: Document, createElement: (tagName: string) => HTMLElement): HTMLElement | undefined;
21
- appendFootnote(node: Element, element: Element, createElement: (tagName: string) => HTMLElement): void;
22
- appendParagraph(document: Document, node: Element, element: Element): void;
23
- appendCorresp(node: Element, element: Element, createElement: (tagName: string) => HTMLElement): void;
24
- createContributors(front: Element, createElement: (tagName: string) => HTMLElement): HTMLElement;
25
- createContributorElement(priority: number, createElement: (tagName: string) => HTMLElement): HTMLElement;
26
- setNameAttrs(node: Element, element: Element): void;
27
- setOrcidAttribute(node: Element, element: Element): void;
28
- setIsCorrespondingAttribute(node: Element, element: Element): void;
29
- setContributorReferences(node: Element, element: Element, createElement: (tagName: string) => HTMLElement): void;
30
- appendFootnoteID(xref: Element, footnotes: Element, rid: string, createElement: (tagName: string) => HTMLElement): void;
31
- appendCorrespID(xref: Element, corresps: Element, rid: string, createElement: (tagName: string) => HTMLElement): void;
32
- appendAffiliationID(affs: Element, rid: string, createElement: (tagName: string) => HTMLElement): void;
33
- createAffiliations(front: Element, createElement: (tagName: string) => HTMLElement): HTMLElement;
34
- createAffiliationElement(element: Element, priority: number, createElement: (tagName: string) => HTMLElement): HTMLElement;
35
- appendEmail(element: Element, affiliation: Element): void;
36
- setInstitutionAttrs(element: Element, affiliation: Element): void;
37
- setAddressAttrs(element: Element, affiliation: Element): void;
38
- };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes