@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.
- package/dist/cjs/__tests__/data/project-dump.json +825 -0
- package/dist/cjs/jats/importer/index.js +3 -3
- package/dist/cjs/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +9 -229
- package/dist/cjs/jats/importer/jats-body-transformations.js +0 -70
- 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 -39
- package/dist/cjs/jats/importer/jats-reference-parser.js +27 -16
- package/dist/cjs/jats/importer/jats-references.js +18 -18
- package/dist/cjs/jats/importer/parse-jats-article.js +78 -42
- package/dist/cjs/jats/index.js +3 -4
- package/dist/cjs/jats/jats-exporter.js +354 -251
- package/dist/cjs/lib/utils.js +1 -9
- package/dist/cjs/schema/nodes/inline_footnote.js +1 -0
- package/dist/cjs/transformer/__tests__/__helpers__/doc.js +37 -0
- package/dist/cjs/transformer/builders.js +219 -0
- package/dist/cjs/transformer/decode.js +874 -0
- package/dist/cjs/transformer/document-object-types.js +31 -0
- package/dist/cjs/transformer/encode.js +664 -0
- 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 +6 -6
- package/dist/cjs/transformer/index.js +18 -0
- package/dist/cjs/{jats → transformer}/labels.js +3 -3
- package/dist/cjs/transformer/manuscript-dependencies.js +21 -0
- package/dist/cjs/transformer/model-map.js +26 -0
- package/dist/cjs/transformer/models.js +17 -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/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/jats/importer/index.js +1 -2
- package/dist/es/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +10 -230
- package/dist/es/jats/importer/jats-body-transformations.js +0 -70
- 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 -40
- package/dist/es/jats/importer/jats-reference-parser.js +27 -16
- package/dist/es/jats/importer/jats-references.js +18 -18
- package/dist/es/jats/importer/parse-jats-article.js +77 -43
- package/dist/es/jats/index.js +1 -3
- package/dist/es/jats/jats-exporter.js +356 -253
- package/dist/es/lib/utils.js +0 -7
- package/dist/es/schema/nodes/inline_footnote.js +1 -0
- package/dist/es/transformer/__tests__/__helpers__/doc.js +29 -0
- package/dist/es/transformer/builders.js +186 -0
- package/dist/es/transformer/decode.js +864 -0
- package/dist/es/transformer/document-object-types.js +28 -0
- package/dist/es/transformer/encode.js +654 -0
- package/dist/{types/jats/importer/create-article-node.d.ts → es/transformer/footnote-category.js} +2 -3
- 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 +4 -5
- package/dist/es/transformer/index.js +16 -0
- package/dist/es/{jats → transformer}/labels.js +3 -3
- package/dist/es/transformer/manuscript-dependencies.js +17 -0
- package/dist/es/transformer/model-map.js +22 -0
- package/dist/es/transformer/models.js +16 -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/update-identifiers.js +87 -0
- package/dist/es/version.js +1 -1
- package/dist/types/jats/importer/index.d.ts +1 -2
- 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 +0 -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 +1 -3
- package/dist/types/jats/jats-exporter.d.ts +29 -10
- package/dist/types/lib/utils.d.ts +0 -3
- package/dist/types/schema/nodes/bibliography_item.d.ts +6 -16
- package/dist/types/schema/nodes/contributor.d.ts +0 -10
- package/dist/types/schema/nodes/keyword_group.d.ts +0 -1
- 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 +51 -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/footnote-category.d.ts +17 -0
- package/dist/types/transformer/footnotes-order.d.ts +22 -0
- 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 +3 -4
- package/dist/types/transformer/index.d.ts +16 -0
- package/dist/types/{jats → transformer}/labels.d.ts +1 -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/transformer/update-identifiers.d.ts +23 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -2
- package/dist/cjs/jats/importer/create-article-node.js +0 -31
- package/dist/cjs/jats/importer/jats-front-transformations.js +0 -262
- package/dist/es/jats/importer/create-article-node.js +0 -27
- package/dist/es/jats/importer/jats-front-transformations.js +0 -259
- package/dist/types/jats/importer/jats-front-transformations.d.ts +0 -38
- /package/dist/cjs/{jats → transformer}/filename.js +0 -0
- /package/dist/cjs/{jats → transformer}/timestamp.js +0 -0
- /package/dist/es/{jats → transformer}/filename.js +0 -0
- /package/dist/es/{jats → transformer}/timestamp.js +0 -0
- /package/dist/types/{jats → transformer}/filename.d.ts +0 -0
- /package/dist/types/{jats → transformer}/timestamp.d.ts +0 -0
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.parseJATSArticle = exports.
|
|
19
|
-
var create_article_node_1 = require("./create-article-node");
|
|
20
|
-
Object.defineProperty(exports, "createArticleNode", { enumerable: true, get: function () { return create_article_node_1.createArticleNode; } });
|
|
18
|
+
exports.parseJATSArticle = exports.parseJATSBody = exports.parseJATSFront = void 0;
|
|
21
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
22
|
Object.defineProperty(exports, "parseJATSArticle", { enumerable: true, get: function () { return parse_jats_article_1.parseJATSArticle; } });
|
|
@@ -18,13 +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
24
|
const schema_1 = require("../../schema");
|
|
26
25
|
const transformer_1 = require("../../transformer");
|
|
27
|
-
const jats_comments_1 = require("./jats-comments");
|
|
28
26
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
29
27
|
const chooseContentType = (graphicNode) => {
|
|
30
28
|
if (graphicNode) {
|
|
@@ -39,12 +37,6 @@ const chooseContentType = (graphicNode) => {
|
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
};
|
|
42
|
-
const parsePriority = (priority) => {
|
|
43
|
-
if (!priority) {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
return parseInt(priority);
|
|
47
|
-
};
|
|
48
40
|
const getEquationContent = (p) => {
|
|
49
41
|
var _a;
|
|
50
42
|
const element = p;
|
|
@@ -109,174 +101,6 @@ const marks = [
|
|
|
109
101
|
},
|
|
110
102
|
];
|
|
111
103
|
const nodes = [
|
|
112
|
-
{
|
|
113
|
-
tag: 'article',
|
|
114
|
-
node: 'manuscript',
|
|
115
|
-
getAttrs: (node) => {
|
|
116
|
-
const element = node;
|
|
117
|
-
return {
|
|
118
|
-
doi: element.getAttribute('DOI'),
|
|
119
|
-
articleType: element.getAttribute('article-type') || '',
|
|
120
|
-
prototype: element.getAttribute('prototype') || '',
|
|
121
|
-
primaryLanguageCode: element.getAttribute('primary-language-code') || '',
|
|
122
|
-
};
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
tag: 'article-title',
|
|
127
|
-
node: 'title',
|
|
128
|
-
getAttrs: (node) => {
|
|
129
|
-
const element = node;
|
|
130
|
-
return {
|
|
131
|
-
id: element.getAttribute('id'),
|
|
132
|
-
};
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
tag: 'highlight-marker',
|
|
137
|
-
node: 'highlight_marker',
|
|
138
|
-
getAttrs: (node) => {
|
|
139
|
-
var _a;
|
|
140
|
-
const element = node;
|
|
141
|
-
const id = element.getAttribute('id');
|
|
142
|
-
return {
|
|
143
|
-
id: id,
|
|
144
|
-
position: (_a = element.getAttribute('position')) !== null && _a !== void 0 ? _a : '',
|
|
145
|
-
};
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
tag: 'comment-annotation',
|
|
150
|
-
node: 'comment',
|
|
151
|
-
getAttrs: (node) => {
|
|
152
|
-
const element = node;
|
|
153
|
-
return {
|
|
154
|
-
id: element.getAttribute('id'),
|
|
155
|
-
contents: element.textContent,
|
|
156
|
-
contributions: [
|
|
157
|
-
{
|
|
158
|
-
_id: (0, transformer_1.generateID)(json_schema_1.ObjectTypes.Contribution),
|
|
159
|
-
objecType: json_schema_1.ObjectTypes.Contribution,
|
|
160
|
-
profileID: jats_comments_1.DEFAULT_PROFILE_ID,
|
|
161
|
-
timestamp: (0, json_schema_1.timestamp)(),
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
};
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
tag: 'author-notes',
|
|
169
|
-
node: 'author_notes',
|
|
170
|
-
getAttrs: (node) => {
|
|
171
|
-
const element = node;
|
|
172
|
-
return {
|
|
173
|
-
id: element.getAttribute('id'),
|
|
174
|
-
};
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
tag: 'fn-author',
|
|
179
|
-
node: 'footnote',
|
|
180
|
-
getAttrs: (node) => {
|
|
181
|
-
const element = node;
|
|
182
|
-
return {
|
|
183
|
-
id: element.getAttribute('id'),
|
|
184
|
-
kind: 'footnote',
|
|
185
|
-
};
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
tag: 'corresp',
|
|
190
|
-
node: 'corresp',
|
|
191
|
-
getAttrs: (node) => {
|
|
192
|
-
const element = node;
|
|
193
|
-
return {
|
|
194
|
-
id: element.getAttribute('id'),
|
|
195
|
-
label: element.getAttribute('label'),
|
|
196
|
-
};
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
tag: 'contributor',
|
|
201
|
-
node: 'contributor',
|
|
202
|
-
getAttrs: (node) => {
|
|
203
|
-
const element = node;
|
|
204
|
-
const footnote = [];
|
|
205
|
-
const affiliations = [];
|
|
206
|
-
const corresp = [];
|
|
207
|
-
element.querySelectorAll('fn').forEach((fn) => {
|
|
208
|
-
const noteID = fn.getAttribute('noteID');
|
|
209
|
-
const noteLabel = fn.getAttribute('noteLabel');
|
|
210
|
-
if (noteID && noteLabel) {
|
|
211
|
-
footnote.push({ noteID, noteLabel });
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
element.querySelectorAll('corresp').forEach((correspondence) => {
|
|
215
|
-
const correspLabel = correspondence.getAttribute('correspLabel');
|
|
216
|
-
const correspID = correspondence.getAttribute('correspID');
|
|
217
|
-
if (correspID && correspLabel) {
|
|
218
|
-
corresp.push({ correspID, correspLabel });
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
element.querySelectorAll('aff').forEach((aff) => {
|
|
222
|
-
const affID = aff.getAttribute('affiliationID');
|
|
223
|
-
if (affID) {
|
|
224
|
-
affiliations.push(affID);
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
const isCorrespondingEl = element.getAttribute('isCorresponding');
|
|
228
|
-
return {
|
|
229
|
-
id: element.getAttribute('id'),
|
|
230
|
-
role: 'author',
|
|
231
|
-
isCorresponding: isCorrespondingEl
|
|
232
|
-
? isCorrespondingEl === 'true'
|
|
233
|
-
: undefined,
|
|
234
|
-
bibliographicName: {
|
|
235
|
-
given: element.getAttribute('given'),
|
|
236
|
-
family: element.getAttribute('family'),
|
|
237
|
-
ObjectType: 'MPBibliographicName',
|
|
238
|
-
_id: (0, transformer_1.generateID)(json_schema_1.ObjectTypes.BibliographicName),
|
|
239
|
-
},
|
|
240
|
-
affiliations,
|
|
241
|
-
corresp: corresp.length ? corresp : undefined,
|
|
242
|
-
footnote: footnote.length ? footnote : undefined,
|
|
243
|
-
ORCIDIdentifier: element.getAttribute('ORCIDIdentifier'),
|
|
244
|
-
priority: parsePriority(element.getAttribute('priority')),
|
|
245
|
-
};
|
|
246
|
-
},
|
|
247
|
-
getContent: () => {
|
|
248
|
-
return prosemirror_model_1.Fragment.from(schema_1.schema.text('_'));
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
tag: 'affiliation',
|
|
253
|
-
node: 'affiliation',
|
|
254
|
-
getAttrs: (node) => {
|
|
255
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
256
|
-
const element = node;
|
|
257
|
-
const emailEl = element.querySelector('email');
|
|
258
|
-
return {
|
|
259
|
-
id: element.getAttribute('id'),
|
|
260
|
-
institution: (_a = element.getAttribute('institution')) !== null && _a !== void 0 ? _a : '',
|
|
261
|
-
department: (_b = element.getAttribute('department')) !== null && _b !== void 0 ? _b : '',
|
|
262
|
-
addressLine1: (_c = element.getAttribute('addressLine1')) !== null && _c !== void 0 ? _c : '',
|
|
263
|
-
addressLine2: (_d = element.getAttribute('addressLine2')) !== null && _d !== void 0 ? _d : '',
|
|
264
|
-
addressLine3: (_e = element.getAttribute('addressLine3')) !== null && _e !== void 0 ? _e : '',
|
|
265
|
-
postCode: (_f = element.getAttribute('postCode')) !== null && _f !== void 0 ? _f : '',
|
|
266
|
-
country: (_g = element.getAttribute('country')) !== null && _g !== void 0 ? _g : '',
|
|
267
|
-
email: emailEl
|
|
268
|
-
? {
|
|
269
|
-
href: (_h = emailEl.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _h !== void 0 ? _h : '',
|
|
270
|
-
text: (_k = (_j = emailEl.textContent) === null || _j === void 0 ? void 0 : _j.trim()) !== null && _k !== void 0 ? _k : '',
|
|
271
|
-
}
|
|
272
|
-
: undefined,
|
|
273
|
-
priority: parsePriority(element.getAttribute('priority')),
|
|
274
|
-
};
|
|
275
|
-
},
|
|
276
|
-
getContent: () => {
|
|
277
|
-
return prosemirror_model_1.Fragment.from(schema_1.schema.text('_'));
|
|
278
|
-
},
|
|
279
|
-
},
|
|
280
104
|
{
|
|
281
105
|
tag: 'attrib',
|
|
282
106
|
node: 'attribution',
|
|
@@ -285,6 +109,10 @@ const nodes = [
|
|
|
285
109
|
tag: 'back',
|
|
286
110
|
ignore: true,
|
|
287
111
|
},
|
|
112
|
+
{
|
|
113
|
+
tag: 'body',
|
|
114
|
+
node: 'manuscript',
|
|
115
|
+
},
|
|
288
116
|
{
|
|
289
117
|
tag: 'break',
|
|
290
118
|
node: 'hard_break',
|
|
@@ -304,13 +132,13 @@ const nodes = [
|
|
|
304
132
|
const title = element.querySelector('title');
|
|
305
133
|
if (title) {
|
|
306
134
|
const captionTitle = schema.nodes.caption_title.create();
|
|
307
|
-
content.push(exports.
|
|
135
|
+
content.push(exports.jatsBodyDOMParser.parse(title, { topNode: captionTitle }));
|
|
308
136
|
}
|
|
309
137
|
const paragraphs = element.querySelectorAll('p');
|
|
310
138
|
if (paragraphs.length) {
|
|
311
139
|
const figcaption = schema.nodes.caption.create();
|
|
312
140
|
for (const paragraph of paragraphs) {
|
|
313
|
-
content.push(exports.
|
|
141
|
+
content.push(exports.jatsBodyDOMParser.parse(paragraph, { topNode: figcaption }));
|
|
314
142
|
}
|
|
315
143
|
}
|
|
316
144
|
return prosemirror_model_1.Fragment.from(content);
|
|
@@ -501,7 +329,7 @@ const nodes = [
|
|
|
501
329
|
const paragraphs = [];
|
|
502
330
|
node.childNodes.forEach((p) => {
|
|
503
331
|
const paragraph = schema_1.schema.nodes.paragraph.create();
|
|
504
|
-
const content = exports.
|
|
332
|
+
const content = exports.jatsBodyDOMParser.parse(p, {
|
|
505
333
|
topNode: paragraph,
|
|
506
334
|
});
|
|
507
335
|
paragraphs.push(content);
|
|
@@ -600,54 +428,6 @@ const nodes = [
|
|
|
600
428
|
tag: 'sec[sec-type="backmatter"]',
|
|
601
429
|
node: 'backmatter',
|
|
602
430
|
},
|
|
603
|
-
{
|
|
604
|
-
tag: 'bibliography-element',
|
|
605
|
-
node: 'bibliography_element',
|
|
606
|
-
getAttrs: (node) => {
|
|
607
|
-
const element = node;
|
|
608
|
-
return {
|
|
609
|
-
id: element.getAttribute('id'),
|
|
610
|
-
};
|
|
611
|
-
},
|
|
612
|
-
},
|
|
613
|
-
{
|
|
614
|
-
tag: 'bibliography-item',
|
|
615
|
-
node: 'bibliography_item',
|
|
616
|
-
getAttrs: (node) => {
|
|
617
|
-
const element = node;
|
|
618
|
-
const authors = [];
|
|
619
|
-
element.querySelectorAll('author').forEach((author) => {
|
|
620
|
-
authors.push({
|
|
621
|
-
_id: author.getAttribute('id') || '',
|
|
622
|
-
given: author.getAttribute('given') || '',
|
|
623
|
-
family: author.getAttribute('family') || '',
|
|
624
|
-
objectType: 'MPBibliographicName',
|
|
625
|
-
});
|
|
626
|
-
});
|
|
627
|
-
const issuedEl = element.querySelector('issued');
|
|
628
|
-
const issued = issuedEl
|
|
629
|
-
? {
|
|
630
|
-
objectType: 'MPBibliographicDate',
|
|
631
|
-
_id: issuedEl.getAttribute('id'),
|
|
632
|
-
'date-parts': [[issuedEl.getAttribute('year')]],
|
|
633
|
-
}
|
|
634
|
-
: undefined;
|
|
635
|
-
return {
|
|
636
|
-
id: element.getAttribute('id'),
|
|
637
|
-
type: element.getAttribute('type'),
|
|
638
|
-
containerTitle: element.getAttribute('container-title'),
|
|
639
|
-
volume: element.getAttribute('volume'),
|
|
640
|
-
issue: element.getAttribute('issue'),
|
|
641
|
-
supplement: element.getAttribute('supplement'),
|
|
642
|
-
page: element.getAttribute('page'),
|
|
643
|
-
title: element.getAttribute('title'),
|
|
644
|
-
literal: element.getAttribute('literal'),
|
|
645
|
-
author: authors,
|
|
646
|
-
issued,
|
|
647
|
-
DOI: element.getAttribute('DOI'),
|
|
648
|
-
};
|
|
649
|
-
},
|
|
650
|
-
},
|
|
651
431
|
{
|
|
652
432
|
tag: 'sec',
|
|
653
433
|
node: 'section',
|
|
@@ -800,4 +580,4 @@ const nodes = [
|
|
|
800
580
|
},
|
|
801
581
|
},
|
|
802
582
|
];
|
|
803
|
-
exports.
|
|
583
|
+
exports.jatsBodyDOMParser = new prosemirror_model_1.DOMParser(schema_1.schema, [...marks, ...nodes]);
|
|
@@ -302,74 +302,4 @@ exports.jatsBodyTransformations = {
|
|
|
302
302
|
body.prepend(section);
|
|
303
303
|
}
|
|
304
304
|
},
|
|
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
|
-
return bibliographyItem;
|
|
374
|
-
},
|
|
375
305
|
};
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
const
|
|
18
|
+
exports.createReferenceComments = exports.createComments = exports.markComments = exports.parseJATSComment = exports.isJATSComment = void 0;
|
|
19
|
+
const uuid_1 = require("uuid");
|
|
20
20
|
const transformer_1 = require("../../transformer");
|
|
21
|
-
|
|
21
|
+
const DEFAULT_PROFILE_ID = 'MPUserProfile:0000000000000000000000000000000000000001';
|
|
22
22
|
const isJATSComment = (node) => {
|
|
23
23
|
return (node.nodeType === node.PROCESSING_INSTRUCTION_NODE &&
|
|
24
24
|
node.nodeName === 'AuthorQuery');
|
|
@@ -27,34 +27,35 @@ exports.isJATSComment = isJATSComment;
|
|
|
27
27
|
const parseJATSComment = (node) => {
|
|
28
28
|
const text = node.textContent;
|
|
29
29
|
if (text) {
|
|
30
|
+
const id = /id="(.+)"/.exec(text);
|
|
30
31
|
const queryText = /queryText="(.+)"/.exec(text);
|
|
31
|
-
if (queryText) {
|
|
32
|
-
const parentNode = node.parentNode;
|
|
33
|
-
const index = parentNode.outerHTML.indexOf(queryText[1]);
|
|
32
|
+
if (id && queryText) {
|
|
34
33
|
return {
|
|
35
|
-
id:
|
|
34
|
+
id: id[1],
|
|
36
35
|
text: queryText[1],
|
|
37
|
-
index,
|
|
38
36
|
};
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
};
|
|
42
40
|
exports.parseJATSComment = parseJATSComment;
|
|
43
41
|
const markComments = (doc) => {
|
|
44
|
-
|
|
42
|
+
const marks = [];
|
|
45
43
|
const root = doc.getRootNode();
|
|
46
44
|
const queue = [root];
|
|
47
|
-
const commentsElement = doc.createElement('comments-annotations');
|
|
48
45
|
while (queue.length !== 0) {
|
|
49
46
|
const node = queue.shift();
|
|
50
47
|
if (node) {
|
|
51
48
|
if ((0, exports.isJATSComment)(node)) {
|
|
52
49
|
const comment = (0, exports.parseJATSComment)(node);
|
|
53
50
|
if (comment) {
|
|
54
|
-
const
|
|
55
|
-
(
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
const token = addMark(doc, node);
|
|
52
|
+
if (token) {
|
|
53
|
+
const mark = {
|
|
54
|
+
token,
|
|
55
|
+
comment,
|
|
56
|
+
};
|
|
57
|
+
marks.push(mark);
|
|
58
|
+
}
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
node.childNodes.forEach((child) => {
|
|
@@ -62,20 +63,96 @@ const markComments = (doc) => {
|
|
|
62
63
|
});
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
-
doc.documentElement.appendChild(commentsElement);
|
|
67
|
-
}
|
|
66
|
+
return marks;
|
|
68
67
|
};
|
|
69
68
|
exports.markComments = markComments;
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
const addMark = (doc, node) => {
|
|
70
|
+
const parent = node.parentElement;
|
|
71
|
+
if (parent) {
|
|
72
|
+
const token = (0, uuid_1.v4)();
|
|
73
|
+
const tokenNode = doc.createTextNode(token);
|
|
74
|
+
parent.insertBefore(tokenNode, node);
|
|
75
|
+
return token;
|
|
76
|
+
}
|
|
75
77
|
};
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
const createComments = (models, marks) => {
|
|
79
|
+
const comments = [];
|
|
80
|
+
for (const model of models) {
|
|
81
|
+
if ((0, transformer_1.isHighlightableModel)(model)) {
|
|
82
|
+
comments.push(...processModel(model, marks));
|
|
83
|
+
}
|
|
84
|
+
else if ((0, transformer_1.isKeyword)(model)) {
|
|
85
|
+
comments.push(...processKeyword(model, marks));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return comments;
|
|
89
|
+
};
|
|
90
|
+
exports.createComments = createComments;
|
|
91
|
+
const getFieldMarks = (content, marks) => {
|
|
92
|
+
return marks
|
|
93
|
+
.filter((m) => content.indexOf(m.token) >= 0)
|
|
94
|
+
.sort((a, b) => content.indexOf(a.token) - content.indexOf(b.token));
|
|
95
|
+
};
|
|
96
|
+
const processModel = (model, marks) => {
|
|
97
|
+
const comments = [];
|
|
98
|
+
for (const field of transformer_1.highlightableFields) {
|
|
99
|
+
const content = model[field];
|
|
100
|
+
if (!content) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const results = processContent(model, content, getFieldMarks(content, marks));
|
|
104
|
+
model[field] = results.content;
|
|
105
|
+
comments.push(...results.comments);
|
|
106
|
+
}
|
|
107
|
+
return comments;
|
|
108
|
+
};
|
|
109
|
+
const processKeyword = (model, marks) => {
|
|
110
|
+
const comments = [];
|
|
111
|
+
const name = model.name;
|
|
112
|
+
let content = name;
|
|
113
|
+
for (const mark of getFieldMarks(name, marks)) {
|
|
114
|
+
content = name.replace(mark.token, '');
|
|
115
|
+
const target = model.containedGroup;
|
|
116
|
+
if (!target) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const contributions = [(0, transformer_1.buildContribution)(DEFAULT_PROFILE_ID)];
|
|
120
|
+
const comment = (0, transformer_1.buildComment)(target, mark.comment.text, undefined, contributions);
|
|
121
|
+
model.name = content;
|
|
122
|
+
comments.push(comment);
|
|
123
|
+
}
|
|
124
|
+
return comments;
|
|
125
|
+
};
|
|
126
|
+
const processContent = (model, content, marks) => {
|
|
127
|
+
const comments = [];
|
|
128
|
+
let result = content;
|
|
129
|
+
for (const mark of marks) {
|
|
130
|
+
const token = mark.token;
|
|
131
|
+
const index = result.indexOf(token);
|
|
132
|
+
result = result.replace(token, '');
|
|
133
|
+
const contributions = [(0, transformer_1.buildContribution)(DEFAULT_PROFILE_ID)];
|
|
134
|
+
const selector = {
|
|
135
|
+
from: index,
|
|
136
|
+
to: index,
|
|
137
|
+
};
|
|
138
|
+
const comment = (0, transformer_1.buildComment)(model._id, mark.comment.text, selector, contributions);
|
|
139
|
+
comments.push(comment);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
content: result,
|
|
143
|
+
comments,
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
const createReferenceComments = (references) => {
|
|
147
|
+
const comments = [];
|
|
148
|
+
for (const item of references.getBibliographyItems()) {
|
|
149
|
+
const id = item._id;
|
|
150
|
+
for (const comment of references.getComments(id)) {
|
|
151
|
+
const contributions = [(0, transformer_1.buildContribution)(DEFAULT_PROFILE_ID)];
|
|
152
|
+
const c = (0, transformer_1.buildComment)(id, comment.text, undefined, contributions);
|
|
153
|
+
comments.push(c);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return comments;
|
|
81
157
|
};
|
|
158
|
+
exports.createReferenceComments = createReferenceComments;
|