@manuscripts/transform 2.3.38-LEAN-3911.0 → 2.6.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.
- package/dist/cjs/__tests__/data/project-dump.json +825 -0
- package/dist/cjs/index.js +6 -6
- package/dist/cjs/jats/importer/index.js +22 -0
- package/dist/cjs/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +34 -273
- package/dist/cjs/jats/importer/jats-body-transformations.js +22 -74
- package/dist/cjs/jats/importer/jats-comments.js +104 -27
- package/dist/cjs/jats/importer/jats-front-parser.js +321 -0
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +1 -8
- package/dist/cjs/jats/importer/jats-parser-utils.js +5 -43
- package/dist/cjs/jats/importer/jats-reference-parser.js +23 -16
- package/dist/cjs/jats/importer/jats-references.js +18 -18
- package/dist/cjs/jats/importer/parse-jats-article.js +79 -40
- package/dist/cjs/jats/index.js +7 -7
- package/dist/cjs/jats/{exporter/jats-exporter.js → jats-exporter.js} +398 -264
- package/dist/cjs/jats/{exporter/jats-versions.js → jats-versions.js} +3 -1
- package/dist/cjs/lib/utils.js +1 -12
- package/dist/cjs/transformer/__tests__/__helpers__/doc.js +37 -0
- package/dist/cjs/transformer/builders.js +219 -0
- package/dist/cjs/transformer/decode.js +898 -0
- package/dist/cjs/transformer/document-object-types.js +31 -0
- package/dist/cjs/transformer/encode.js +674 -0
- package/dist/cjs/{jats/importer/create-article-node.js → transformer/filename.js} +9 -10
- package/dist/cjs/transformer/footnote-category.js +20 -0
- package/dist/cjs/transformer/footnotes-order.js +60 -0
- package/dist/cjs/transformer/highlight-markers.js +138 -0
- package/dist/cjs/transformer/html.js +400 -0
- package/dist/cjs/transformer/id.js +5 -10
- package/dist/cjs/transformer/index.js +18 -0
- package/dist/cjs/{jats/exporter → transformer}/labels.js +5 -4
- package/dist/cjs/transformer/manuscript-dependencies.js +21 -0
- package/dist/cjs/transformer/model-map.js +26 -0
- package/dist/cjs/{lib/deafults.js → transformer/models.js} +1 -3
- package/dist/cjs/transformer/node-names.js +1 -0
- package/dist/cjs/transformer/object-types.js +57 -0
- package/dist/cjs/transformer/project-bundle.js +94 -0
- package/dist/cjs/transformer/serializer.js +23 -0
- package/dist/cjs/transformer/timestamp.js +20 -0
- package/dist/cjs/transformer/update-identifiers.js +93 -0
- package/dist/cjs/version.js +1 -1
- package/dist/es/__tests__/data/project-dump.json +825 -0
- package/dist/es/index.js +5 -5
- package/dist/{types/jats/importer/create-article-node.d.ts → es/jats/importer/index.js} +2 -3
- package/dist/es/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +35 -274
- package/dist/es/jats/importer/jats-body-transformations.js +22 -74
- package/dist/es/jats/importer/jats-comments.js +101 -26
- package/dist/es/jats/importer/jats-front-parser.js +315 -0
- package/dist/es/jats/importer/jats-journal-meta-parser.js +0 -6
- package/dist/es/jats/importer/jats-parser-utils.js +6 -44
- package/dist/es/jats/importer/jats-reference-parser.js +23 -16
- package/dist/es/jats/importer/jats-references.js +18 -18
- package/dist/es/jats/importer/parse-jats-article.js +78 -41
- package/dist/es/jats/index.js +3 -5
- package/dist/es/jats/{exporter/jats-exporter.js → jats-exporter.js} +392 -258
- package/dist/es/jats/{exporter/jats-versions.js → jats-versions.js} +1 -0
- package/dist/es/lib/utils.js +0 -9
- package/dist/es/transformer/__tests__/__helpers__/doc.js +29 -0
- package/dist/es/transformer/builders.js +186 -0
- package/dist/es/transformer/decode.js +888 -0
- package/dist/es/transformer/document-object-types.js +28 -0
- package/dist/es/transformer/encode.js +664 -0
- package/dist/es/transformer/filename.js +23 -0
- package/dist/es/transformer/footnote-category.js +16 -0
- package/dist/es/transformer/footnotes-order.js +55 -0
- package/dist/es/transformer/highlight-markers.js +132 -0
- package/dist/es/transformer/html.js +393 -0
- package/dist/es/transformer/id.js +3 -8
- package/dist/es/transformer/index.js +16 -0
- package/dist/es/{jats/exporter → transformer}/labels.js +5 -4
- package/dist/es/transformer/manuscript-dependencies.js +17 -0
- package/dist/es/transformer/model-map.js +22 -0
- package/dist/es/{lib/deafults.js → transformer/models.js} +2 -2
- package/dist/es/transformer/node-names.js +1 -0
- package/dist/es/transformer/object-types.js +52 -0
- package/dist/es/transformer/project-bundle.js +85 -0
- package/dist/es/transformer/serializer.js +17 -0
- package/dist/es/transformer/timestamp.js +16 -0
- package/dist/es/transformer/update-identifiers.js +87 -0
- package/dist/es/version.js +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/jats/importer/index.d.ts +16 -0
- package/dist/types/jats/importer/{jats-dom-parser.d.ts → jats-body-dom-parser.d.ts} +1 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -5
- package/dist/types/jats/importer/jats-comments.d.ts +10 -4
- package/dist/types/jats/importer/jats-front-parser.d.ts +84 -0
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +0 -10
- package/dist/types/jats/importer/jats-references.d.ts +8 -19
- package/dist/types/jats/importer/parse-jats-article.d.ts +5 -12
- package/dist/types/jats/index.d.ts +3 -5
- package/dist/types/jats/{exporter/jats-exporter.d.ts → jats-exporter.d.ts} +29 -15
- package/dist/types/jats/{exporter/jats-versions.d.ts → jats-versions.d.ts} +1 -0
- package/dist/types/lib/utils.d.ts +0 -2
- package/dist/types/schema/nodes/bibliography_item.d.ts +3 -3
- package/dist/types/schema/nodes/contributor.d.ts +0 -10
- package/dist/types/schema/nodes/keyword_group.d.ts +0 -1
- package/dist/types/schema/nodes/manuscript.d.ts +7 -8
- package/dist/types/schema/nodes/title.d.ts +3 -0
- package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +18 -0
- package/dist/types/transformer/builders.d.ts +61 -0
- package/dist/types/transformer/decode.d.ts +52 -0
- package/dist/types/transformer/document-object-types.d.ts +17 -0
- package/dist/types/transformer/encode.d.ts +29 -0
- package/dist/types/transformer/filename.d.ts +16 -0
- package/dist/types/transformer/footnote-category.d.ts +17 -0
- package/dist/{es/jats/importer/create-article-node.js → types/transformer/footnotes-order.d.ts} +8 -10
- package/dist/types/transformer/highlight-markers.d.ts +31 -0
- package/dist/types/transformer/html.d.ts +36 -0
- package/dist/types/transformer/id.d.ts +2 -5
- package/dist/types/transformer/index.d.ts +16 -0
- package/dist/types/{jats/exporter → transformer}/labels.d.ts +2 -2
- package/dist/types/transformer/manuscript-dependencies.d.ts +4 -0
- package/dist/types/transformer/model-map.d.ts +19 -0
- package/dist/types/transformer/models.d.ts +48 -0
- package/dist/types/transformer/object-types.d.ts +30 -0
- package/dist/types/transformer/project-bundle.d.ts +30 -0
- package/dist/types/transformer/serializer.d.ts +19 -0
- package/dist/types/{lib/deafults.d.ts → transformer/timestamp.d.ts} +2 -2
- package/dist/types/transformer/update-identifiers.d.ts +23 -0
- package/dist/types/types.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -2
- package/dist/cjs/jats/importer/jats-front-transformations.js +0 -79
- package/dist/es/jats/importer/jats-front-transformations.js +0 -76
- package/dist/types/jats/importer/jats-front-transformations.d.ts +0 -22
- package/dist/types/jats/types.d.ts +0 -1
- /package/dist/cjs/{jats/types.js → types.js} +0 -0
- /package/dist/es/{jats/types.js → types.js} +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -15,17 +15,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.isSectionLabelNode = exports.migrateFor = exports.getVersion = void 0;
|
|
18
|
-
__exportStar(require("./errors"), exports);
|
|
19
|
-
var getVersion_1 = require("./getVersion");
|
|
20
|
-
Object.defineProperty(exports, "getVersion", { enumerable: true, get: function () { return getVersion_1.getVersion; } });
|
|
21
|
-
__exportStar(require("./jats"), exports);
|
|
22
|
-
__exportStar(require("./jats/types"), exports);
|
|
23
18
|
__exportStar(require("./lib/section-group-type"), exports);
|
|
24
19
|
__exportStar(require("./lib/table-cell-styles"), exports);
|
|
25
20
|
__exportStar(require("./lib/utils"), exports);
|
|
26
21
|
__exportStar(require("./schema"), exports);
|
|
22
|
+
__exportStar(require("./transformer"), exports);
|
|
23
|
+
__exportStar(require("./jats"), exports);
|
|
24
|
+
__exportStar(require("./types"), exports);
|
|
25
|
+
__exportStar(require("./errors"), exports);
|
|
26
|
+
var getVersion_1 = require("./getVersion");
|
|
27
|
+
Object.defineProperty(exports, "getVersion", { enumerable: true, get: function () { return getVersion_1.getVersion; } });
|
|
27
28
|
var migrate_1 = require("./schema/migration/migrate");
|
|
28
29
|
Object.defineProperty(exports, "migrateFor", { enumerable: true, get: function () { return migrate_1.migrateFor; } });
|
|
29
30
|
var section_label_1 = require("./schema/nodes/section_label");
|
|
30
31
|
Object.defineProperty(exports, "isSectionLabelNode", { enumerable: true, get: function () { return section_label_1.isSectionLabelNode; } });
|
|
31
|
-
__exportStar(require("./transformer"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2020 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.parseJATSArticle = exports.parseJATSBody = exports.parseJATSFront = void 0;
|
|
19
|
+
var parse_jats_article_1 = require("./parse-jats-article");
|
|
20
|
+
Object.defineProperty(exports, "parseJATSFront", { enumerable: true, get: function () { return parse_jats_article_1.parseJATSFront; } });
|
|
21
|
+
Object.defineProperty(exports, "parseJATSBody", { enumerable: true, get: function () { return parse_jats_article_1.parseJATSBody; } });
|
|
22
|
+
Object.defineProperty(exports, "parseJATSArticle", { enumerable: true, get: function () { return parse_jats_article_1.parseJATSArticle; } });
|
|
@@ -18,14 +18,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.
|
|
22
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
21
|
+
exports.jatsBodyDOMParser = void 0;
|
|
23
22
|
const mime_1 = __importDefault(require("mime"));
|
|
24
23
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
25
|
-
const utils_1 = require("../../lib/utils");
|
|
26
24
|
const schema_1 = require("../../schema");
|
|
27
25
|
const transformer_1 = require("../../transformer");
|
|
28
|
-
const jats_comments_1 = require("./jats-comments");
|
|
29
26
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
30
27
|
const chooseContentType = (graphicNode) => {
|
|
31
28
|
if (graphicNode) {
|
|
@@ -40,12 +37,6 @@ const chooseContentType = (graphicNode) => {
|
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
39
|
};
|
|
43
|
-
const parsePriority = (priority) => {
|
|
44
|
-
if (!priority) {
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
return parseInt(priority);
|
|
48
|
-
};
|
|
49
40
|
const getEquationContent = (p) => {
|
|
50
41
|
var _a;
|
|
51
42
|
const element = p;
|
|
@@ -110,224 +101,6 @@ const marks = [
|
|
|
110
101
|
},
|
|
111
102
|
];
|
|
112
103
|
const nodes = [
|
|
113
|
-
{
|
|
114
|
-
tag: 'article',
|
|
115
|
-
node: 'manuscript',
|
|
116
|
-
getAttrs: (node) => {
|
|
117
|
-
var _a, _b, _c, _d;
|
|
118
|
-
const element = node;
|
|
119
|
-
return {
|
|
120
|
-
doi: (_a = element.getAttribute('DOI')) !== null && _a !== void 0 ? _a : '',
|
|
121
|
-
articleType: (_b = element.getAttribute('article-type')) !== null && _b !== void 0 ? _b : '',
|
|
122
|
-
prototype: (_c = element.getAttribute('prototype')) !== null && _c !== void 0 ? _c : '',
|
|
123
|
-
primaryLanguageCode: (_d = element.getAttribute('primary-language-code')) !== null && _d !== void 0 ? _d : '',
|
|
124
|
-
};
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
tag: 'article-title',
|
|
129
|
-
node: 'title',
|
|
130
|
-
getAttrs: (node) => {
|
|
131
|
-
const element = node;
|
|
132
|
-
return {
|
|
133
|
-
id: element.getAttribute('id'),
|
|
134
|
-
};
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
tag: 'highlight-marker',
|
|
139
|
-
node: 'highlight_marker',
|
|
140
|
-
getAttrs: (node) => {
|
|
141
|
-
var _a;
|
|
142
|
-
const element = node;
|
|
143
|
-
const id = element.getAttribute('id');
|
|
144
|
-
return {
|
|
145
|
-
id: id,
|
|
146
|
-
position: (_a = element.getAttribute('position')) !== null && _a !== void 0 ? _a : '',
|
|
147
|
-
};
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
tag: 'comment-annotation',
|
|
152
|
-
node: 'comment',
|
|
153
|
-
getAttrs: (node) => {
|
|
154
|
-
const element = node;
|
|
155
|
-
return {
|
|
156
|
-
id: element.getAttribute('id'),
|
|
157
|
-
contents: element.textContent,
|
|
158
|
-
contributions: [
|
|
159
|
-
{
|
|
160
|
-
_id: (0, transformer_1.generateID)(json_schema_1.ObjectTypes.Contribution),
|
|
161
|
-
objecType: json_schema_1.ObjectTypes.Contribution,
|
|
162
|
-
profileID: jats_comments_1.DEFAULT_PROFILE_ID,
|
|
163
|
-
timestamp: (0, utils_1.timestamp)(),
|
|
164
|
-
},
|
|
165
|
-
],
|
|
166
|
-
};
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
tag: 'author-notes',
|
|
171
|
-
node: 'author_notes',
|
|
172
|
-
getAttrs: (node) => {
|
|
173
|
-
const element = node;
|
|
174
|
-
return {
|
|
175
|
-
id: element.getAttribute('id'),
|
|
176
|
-
};
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
tag: 'fn:not([fn-type])',
|
|
181
|
-
node: 'footnote',
|
|
182
|
-
context: 'author_notes/',
|
|
183
|
-
getAttrs: (node) => {
|
|
184
|
-
const element = node;
|
|
185
|
-
return {
|
|
186
|
-
id: element.getAttribute('id'),
|
|
187
|
-
kind: 'footnote',
|
|
188
|
-
};
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
tag: 'corresp',
|
|
193
|
-
node: 'corresp',
|
|
194
|
-
getAttrs: (node) => {
|
|
195
|
-
var _a;
|
|
196
|
-
const element = node;
|
|
197
|
-
const label = element.querySelector('label');
|
|
198
|
-
if (label) {
|
|
199
|
-
label.remove();
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
id: element.getAttribute('id'),
|
|
203
|
-
label: (_a = label === null || label === void 0 ? void 0 : label.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
|
|
204
|
-
};
|
|
205
|
-
},
|
|
206
|
-
getContent: (node) => {
|
|
207
|
-
var _a;
|
|
208
|
-
const element = node;
|
|
209
|
-
return prosemirror_model_1.Fragment.from(schema_1.schema.text(((_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || ''));
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
tag: 'contrib[contrib-type="author"]',
|
|
214
|
-
node: 'contributor',
|
|
215
|
-
getAttrs: (node) => {
|
|
216
|
-
var _a, _b;
|
|
217
|
-
const element = node;
|
|
218
|
-
const footnote = [];
|
|
219
|
-
const affiliations = [];
|
|
220
|
-
const corresp = [];
|
|
221
|
-
const xrefs = element.querySelectorAll('xref');
|
|
222
|
-
for (const xref of xrefs) {
|
|
223
|
-
const rid = xref.getAttribute('rid');
|
|
224
|
-
const type = xref.getAttribute('ref-type');
|
|
225
|
-
if (!rid) {
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
switch (type) {
|
|
229
|
-
case 'fn':
|
|
230
|
-
footnote.push({
|
|
231
|
-
noteID: rid,
|
|
232
|
-
noteLabel: ((_a = xref.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '',
|
|
233
|
-
});
|
|
234
|
-
break;
|
|
235
|
-
case 'corresp':
|
|
236
|
-
corresp.push({
|
|
237
|
-
correspID: rid,
|
|
238
|
-
correspLabel: ((_b = xref.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '',
|
|
239
|
-
});
|
|
240
|
-
break;
|
|
241
|
-
case 'aff':
|
|
242
|
-
affiliations.push(rid);
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return {
|
|
247
|
-
id: element.getAttribute('id'),
|
|
248
|
-
role: 'author',
|
|
249
|
-
affiliations,
|
|
250
|
-
corresp,
|
|
251
|
-
footnote,
|
|
252
|
-
isCorresponding: element.getAttribute('corresp')
|
|
253
|
-
? element.getAttribute('corresp') === 'yes'
|
|
254
|
-
: undefined,
|
|
255
|
-
bibliographicName: {
|
|
256
|
-
given: (0, utils_1.getTrimmedTextContent)(element, 'name > given-names'),
|
|
257
|
-
family: (0, utils_1.getTrimmedTextContent)(element, 'name > surname'),
|
|
258
|
-
ObjectType: json_schema_1.ObjectTypes.BibliographicName,
|
|
259
|
-
_id: (0, transformer_1.generateID)(json_schema_1.ObjectTypes.BibliographicName),
|
|
260
|
-
},
|
|
261
|
-
ORCIDIdentifier: (0, utils_1.getTrimmedTextContent)(element, 'contrib-id[contrib-id-type="orcid"]'),
|
|
262
|
-
priority: parsePriority(element.getAttribute('priority')),
|
|
263
|
-
};
|
|
264
|
-
},
|
|
265
|
-
getContent: () => {
|
|
266
|
-
return prosemirror_model_1.Fragment.from(schema_1.schema.text('_'));
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
tag: 'affiliations',
|
|
271
|
-
node: 'affiliations',
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
tag: 'aff',
|
|
275
|
-
node: 'affiliation',
|
|
276
|
-
context: 'affiliations/',
|
|
277
|
-
getAttrs: (node) => {
|
|
278
|
-
var _a, _b;
|
|
279
|
-
const element = node;
|
|
280
|
-
const getEmail = (element) => {
|
|
281
|
-
var _a, _b, _c;
|
|
282
|
-
const email = element.querySelector('email');
|
|
283
|
-
if (email) {
|
|
284
|
-
return {
|
|
285
|
-
href: (_a = email.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _a !== void 0 ? _a : '',
|
|
286
|
-
text: (_c = (_b = email.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '',
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
const getInstitutionDetails = (element) => {
|
|
291
|
-
var _a;
|
|
292
|
-
let department = '';
|
|
293
|
-
let institution = '';
|
|
294
|
-
for (const node of element.querySelectorAll('institution')) {
|
|
295
|
-
const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
296
|
-
if (!content) {
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
const type = node.getAttribute('content-type');
|
|
300
|
-
if (type === 'dept') {
|
|
301
|
-
department = content;
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
institution = content;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return { department, institution };
|
|
308
|
-
};
|
|
309
|
-
const getAddressLine = (element, index) => {
|
|
310
|
-
return ((0, utils_1.getTrimmedTextContent)(element, `addr-line:nth-of-type(${index})`) ||
|
|
311
|
-
'');
|
|
312
|
-
};
|
|
313
|
-
const { department, institution } = getInstitutionDetails(element);
|
|
314
|
-
return {
|
|
315
|
-
id: element.getAttribute('id'),
|
|
316
|
-
institution: institution !== null && institution !== void 0 ? institution : '',
|
|
317
|
-
department: department !== null && department !== void 0 ? department : '',
|
|
318
|
-
addressLine1: getAddressLine(element, 1),
|
|
319
|
-
addressLine2: getAddressLine(element, 2),
|
|
320
|
-
addressLine3: getAddressLine(element, 3),
|
|
321
|
-
postCode: (_a = (0, utils_1.getTrimmedTextContent)(element, 'postal-code')) !== null && _a !== void 0 ? _a : '',
|
|
322
|
-
country: (_b = (0, utils_1.getTrimmedTextContent)(element, 'country')) !== null && _b !== void 0 ? _b : '',
|
|
323
|
-
email: getEmail(element),
|
|
324
|
-
priority: parsePriority(element.getAttribute('priority')),
|
|
325
|
-
};
|
|
326
|
-
},
|
|
327
|
-
getContent: () => {
|
|
328
|
-
return prosemirror_model_1.Fragment.from(schema_1.schema.text('_'));
|
|
329
|
-
},
|
|
330
|
-
},
|
|
331
104
|
{
|
|
332
105
|
tag: 'attrib',
|
|
333
106
|
node: 'attribution',
|
|
@@ -336,6 +109,10 @@ const nodes = [
|
|
|
336
109
|
tag: 'back',
|
|
337
110
|
ignore: true,
|
|
338
111
|
},
|
|
112
|
+
{
|
|
113
|
+
tag: 'body',
|
|
114
|
+
node: 'manuscript',
|
|
115
|
+
},
|
|
339
116
|
{
|
|
340
117
|
tag: 'break',
|
|
341
118
|
node: 'hard_break',
|
|
@@ -355,13 +132,13 @@ const nodes = [
|
|
|
355
132
|
const title = element.querySelector('title');
|
|
356
133
|
if (title) {
|
|
357
134
|
const captionTitle = schema.nodes.caption_title.create();
|
|
358
|
-
content.push(exports.
|
|
135
|
+
content.push(exports.jatsBodyDOMParser.parse(title, { topNode: captionTitle }));
|
|
359
136
|
}
|
|
360
137
|
const paragraphs = element.querySelectorAll('p');
|
|
361
138
|
if (paragraphs.length) {
|
|
362
139
|
const figcaption = schema.nodes.caption.create();
|
|
363
140
|
for (const paragraph of paragraphs) {
|
|
364
|
-
content.push(exports.
|
|
141
|
+
content.push(exports.jatsBodyDOMParser.parse(paragraph, { topNode: figcaption }));
|
|
365
142
|
}
|
|
366
143
|
}
|
|
367
144
|
return prosemirror_model_1.Fragment.from(content);
|
|
@@ -372,6 +149,17 @@ const nodes = [
|
|
|
372
149
|
node: 'figcaption',
|
|
373
150
|
context: 'table_element/',
|
|
374
151
|
},
|
|
152
|
+
{
|
|
153
|
+
tag: 'caption',
|
|
154
|
+
node: 'figcaption',
|
|
155
|
+
context: 'box_element/',
|
|
156
|
+
getAttrs: (node) => {
|
|
157
|
+
const element = node;
|
|
158
|
+
return {
|
|
159
|
+
id: element.getAttribute('id'),
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
},
|
|
375
163
|
{
|
|
376
164
|
tag: 'code',
|
|
377
165
|
node: 'listing',
|
|
@@ -552,7 +340,7 @@ const nodes = [
|
|
|
552
340
|
const paragraphs = [];
|
|
553
341
|
node.childNodes.forEach((p) => {
|
|
554
342
|
const paragraph = schema_1.schema.nodes.paragraph.create();
|
|
555
|
-
const content = exports.
|
|
343
|
+
const content = exports.jatsBodyDOMParser.parse(p, {
|
|
556
344
|
topNode: paragraph,
|
|
557
345
|
});
|
|
558
346
|
paragraphs.push(content);
|
|
@@ -652,50 +440,14 @@ const nodes = [
|
|
|
652
440
|
node: 'backmatter',
|
|
653
441
|
},
|
|
654
442
|
{
|
|
655
|
-
tag: '
|
|
656
|
-
node: '
|
|
657
|
-
getAttrs: (node) => {
|
|
658
|
-
const element = node;
|
|
659
|
-
return {
|
|
660
|
-
id: element.getAttribute('id'),
|
|
661
|
-
};
|
|
662
|
-
},
|
|
663
|
-
},
|
|
664
|
-
{
|
|
665
|
-
tag: 'bibliography-item',
|
|
666
|
-
node: 'bibliography_item',
|
|
443
|
+
tag: 'sec[sec-type="box-element"]',
|
|
444
|
+
node: 'box_element',
|
|
667
445
|
getAttrs: (node) => {
|
|
446
|
+
var _a;
|
|
668
447
|
const element = node;
|
|
669
|
-
const authors = [];
|
|
670
|
-
element.querySelectorAll('author').forEach((author) => {
|
|
671
|
-
authors.push({
|
|
672
|
-
_id: author.getAttribute('id') || '',
|
|
673
|
-
given: author.getAttribute('given') || '',
|
|
674
|
-
family: author.getAttribute('family') || '',
|
|
675
|
-
objectType: 'MPBibliographicName',
|
|
676
|
-
});
|
|
677
|
-
});
|
|
678
|
-
const issuedEl = element.querySelector('issued');
|
|
679
|
-
const issued = issuedEl
|
|
680
|
-
? {
|
|
681
|
-
objectType: 'MPBibliographicDate',
|
|
682
|
-
_id: issuedEl.getAttribute('id'),
|
|
683
|
-
'date-parts': [[issuedEl.getAttribute('year')]],
|
|
684
|
-
}
|
|
685
|
-
: undefined;
|
|
686
448
|
return {
|
|
687
449
|
id: element.getAttribute('id'),
|
|
688
|
-
|
|
689
|
-
containerTitle: element.getAttribute('container-title'),
|
|
690
|
-
volume: element.getAttribute('volume'),
|
|
691
|
-
issue: element.getAttribute('issue'),
|
|
692
|
-
supplement: element.getAttribute('supplement'),
|
|
693
|
-
page: element.getAttribute('page'),
|
|
694
|
-
title: element.getAttribute('title'),
|
|
695
|
-
literal: element.getAttribute('literal'),
|
|
696
|
-
author: authors,
|
|
697
|
-
issued,
|
|
698
|
-
DOI: element.getAttribute('DOI'),
|
|
450
|
+
label: (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent,
|
|
699
451
|
};
|
|
700
452
|
},
|
|
701
453
|
},
|
|
@@ -731,6 +483,15 @@ const nodes = [
|
|
|
731
483
|
context: 'keyword_group//',
|
|
732
484
|
node: 'keyword',
|
|
733
485
|
},
|
|
486
|
+
{
|
|
487
|
+
tag: 'label',
|
|
488
|
+
context: 'box_element/',
|
|
489
|
+
ignore: true,
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
tag: 'boxed-text',
|
|
493
|
+
ignore: true,
|
|
494
|
+
},
|
|
734
495
|
{
|
|
735
496
|
tag: 'label',
|
|
736
497
|
context: 'section/',
|
|
@@ -769,7 +530,7 @@ const nodes = [
|
|
|
769
530
|
{
|
|
770
531
|
tag: 'title',
|
|
771
532
|
node: 'section_title',
|
|
772
|
-
context: 'section/|footnotes_section/|bibliography_section/|keywords/|supplements
|
|
533
|
+
context: 'section/|footnotes_section/|bibliography_section/|keywords/|supplements/',
|
|
773
534
|
},
|
|
774
535
|
{
|
|
775
536
|
tag: 'title',
|
|
@@ -851,4 +612,4 @@ const nodes = [
|
|
|
851
612
|
},
|
|
852
613
|
},
|
|
853
614
|
];
|
|
854
|
-
exports.
|
|
615
|
+
exports.jatsBodyDOMParser = new prosemirror_model_1.DOMParser(schema_1.schema, [...marks, ...nodes]);
|
|
@@ -156,6 +156,25 @@ exports.jatsBodyTransformations = {
|
|
|
156
156
|
group.appendChild(sec);
|
|
157
157
|
}
|
|
158
158
|
},
|
|
159
|
+
createBoxedElementSection(doc, body, createElement) {
|
|
160
|
+
const boxedTexts = body.querySelectorAll('boxed-text');
|
|
161
|
+
for (const boxedText of boxedTexts) {
|
|
162
|
+
const boxElementSec = createElement('sec');
|
|
163
|
+
boxElementSec.setAttribute('sec-type', 'box-element');
|
|
164
|
+
const title = createElement('title');
|
|
165
|
+
title.textContent = 'BoxElement';
|
|
166
|
+
boxElementSec.append(title);
|
|
167
|
+
for (const element of [...boxedText.children]) {
|
|
168
|
+
if ((element === null || element === void 0 ? void 0 : element.tagName) === 'label' || (element === null || element === void 0 ? void 0 : element.tagName) === 'caption') {
|
|
169
|
+
boxElementSec.append(element);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const containerSection = createElement('sec');
|
|
173
|
+
containerSection.append(...boxedText.children);
|
|
174
|
+
boxElementSec.append(containerSection);
|
|
175
|
+
boxedText.replaceWith(boxElementSec);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
159
178
|
createBody(doc, body, createElement) {
|
|
160
179
|
const group = createSectionGroup(section_group_type_1.bodyType, createElement);
|
|
161
180
|
this.wrapBodySections(doc, group);
|
|
@@ -221,7 +240,9 @@ exports.jatsBodyTransformations = {
|
|
|
221
240
|
moveCaptionsToEnd(body) {
|
|
222
241
|
const captions = body.querySelectorAll('caption');
|
|
223
242
|
for (const caption of captions) {
|
|
224
|
-
if (caption.parentNode &&
|
|
243
|
+
if (caption.parentNode &&
|
|
244
|
+
caption.parentNode.nodeName !== 'table-wrap' &&
|
|
245
|
+
caption.parentNode.nodeName !== 'boxed-text') {
|
|
225
246
|
caption.parentNode.appendChild(caption);
|
|
226
247
|
}
|
|
227
248
|
}
|
|
@@ -302,77 +323,4 @@ exports.jatsBodyTransformations = {
|
|
|
302
323
|
body.prepend(section);
|
|
303
324
|
}
|
|
304
325
|
},
|
|
305
|
-
moveReferencesToBackmatter(body, references, createElement) {
|
|
306
|
-
const backmatter = body.querySelector('sec[sec-type="backmatter"]');
|
|
307
|
-
if (!references || !references.items.size || !backmatter) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
const bibliographySection = this.createBibliographySection(createElement);
|
|
311
|
-
const bibliographyElement = createElement('bibliography-element');
|
|
312
|
-
references.getBibliographyItems().forEach((item) => {
|
|
313
|
-
const bibliographyItem = this.createBibliographyItem(item, createElement);
|
|
314
|
-
bibliographyElement.appendChild(bibliographyItem);
|
|
315
|
-
});
|
|
316
|
-
bibliographySection.appendChild(bibliographyElement);
|
|
317
|
-
backmatter.appendChild(bibliographySection);
|
|
318
|
-
},
|
|
319
|
-
createBibliographySection(createElement) {
|
|
320
|
-
const section = createElement('sec');
|
|
321
|
-
section.setAttribute('sec-type', 'bibliography_section');
|
|
322
|
-
const title = createElement('title');
|
|
323
|
-
title.textContent = 'References';
|
|
324
|
-
section.appendChild(title);
|
|
325
|
-
return section;
|
|
326
|
-
},
|
|
327
|
-
createBibliographyItem(item, createElement) {
|
|
328
|
-
var _a, _b, _c;
|
|
329
|
-
const bibliographyItem = createElement('bibliography-item');
|
|
330
|
-
bibliographyItem.setAttribute('id', item.id);
|
|
331
|
-
bibliographyItem.setAttribute('type', item.type);
|
|
332
|
-
(_a = item.author) === null || _a === void 0 ? void 0 : _a.forEach((author) => {
|
|
333
|
-
const authorElement = createElement('author');
|
|
334
|
-
authorElement.setAttribute('id', author._id);
|
|
335
|
-
authorElement.setAttribute('family', author.family || '');
|
|
336
|
-
authorElement.setAttribute('given', author.given || '');
|
|
337
|
-
bibliographyItem.appendChild(authorElement);
|
|
338
|
-
});
|
|
339
|
-
if (item.issued) {
|
|
340
|
-
const issuedEl = createElement('issued');
|
|
341
|
-
issuedEl.setAttribute('id', ((_b = item.issued) === null || _b === void 0 ? void 0 : _b._id) || '');
|
|
342
|
-
const dateParts = item.issued['date-parts'];
|
|
343
|
-
const year = (_c = dateParts === null || dateParts === void 0 ? void 0 : dateParts[0]) === null || _c === void 0 ? void 0 : _c[0];
|
|
344
|
-
if (year) {
|
|
345
|
-
issuedEl.setAttribute('year', year.toString());
|
|
346
|
-
}
|
|
347
|
-
bibliographyItem.appendChild(issuedEl);
|
|
348
|
-
}
|
|
349
|
-
if (item.containerTitle) {
|
|
350
|
-
bibliographyItem.setAttribute('containerTitle', item.containerTitle);
|
|
351
|
-
}
|
|
352
|
-
if (item.volume) {
|
|
353
|
-
bibliographyItem.setAttribute('volume', item.volume.toString());
|
|
354
|
-
}
|
|
355
|
-
if (item.issue) {
|
|
356
|
-
bibliographyItem.setAttribute('issue', item.issue.toString());
|
|
357
|
-
}
|
|
358
|
-
if (item.supplement) {
|
|
359
|
-
bibliographyItem.setAttribute('supplement', item.supplement);
|
|
360
|
-
}
|
|
361
|
-
if (item.page) {
|
|
362
|
-
bibliographyItem.setAttribute('page', item.page.toString());
|
|
363
|
-
}
|
|
364
|
-
if (item.title) {
|
|
365
|
-
bibliographyItem.setAttribute('title', item.title);
|
|
366
|
-
}
|
|
367
|
-
if (item.literal) {
|
|
368
|
-
bibliographyItem.setAttribute('literal', item.literal);
|
|
369
|
-
}
|
|
370
|
-
if (item.doi) {
|
|
371
|
-
bibliographyItem.setAttribute('DOI', item.doi);
|
|
372
|
-
}
|
|
373
|
-
if (item.literal) {
|
|
374
|
-
bibliographyItem.setAttribute('literal', item.literal);
|
|
375
|
-
}
|
|
376
|
-
return bibliographyItem;
|
|
377
|
-
},
|
|
378
326
|
};
|