@manuscripts/transform 1.0.1 → 1.1.0-LEAN-2070
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/jats/jats-exporter.js +3 -0
- package/dist/cjs/schema/index.js +7 -0
- package/dist/cjs/schema/nodes/comment_list.js +24 -0
- package/dist/cjs/schema/nodes/keyword.js +53 -0
- package/dist/cjs/schema/nodes/keywords_element.js +9 -9
- package/dist/cjs/schema/nodes/keywords_section.js +3 -3
- package/dist/cjs/schema/nodes/manuscript.js +1 -1
- package/dist/cjs/transformer/decode.js +91 -20
- package/dist/cjs/transformer/encode.js +20 -11
- package/dist/cjs/transformer/node-names.js +1 -0
- package/dist/cjs/transformer/node-types.js +2 -0
- package/dist/es/jats/jats-exporter.js +3 -0
- package/dist/es/schema/index.js +7 -0
- package/dist/es/schema/nodes/comment_list.js +21 -0
- package/dist/es/schema/nodes/keyword.js +50 -0
- package/dist/es/schema/nodes/keywords_element.js +9 -9
- package/dist/es/schema/nodes/keywords_section.js +3 -3
- package/dist/es/schema/nodes/manuscript.js +1 -1
- package/dist/es/transformer/decode.js +91 -20
- package/dist/es/transformer/encode.js +21 -12
- package/dist/es/transformer/node-names.js +1 -0
- package/dist/es/transformer/node-types.js +2 -0
- package/dist/types/schema/index.d.ts +2 -0
- package/dist/types/schema/nodes/comment_list.d.ts +25 -0
- package/dist/types/schema/nodes/keyword.d.ts +28 -0
- package/dist/types/schema/nodes/keywords_element.d.ts +2 -2
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/decode.d.ts +2 -0
- package/package.json +2 -2
|
@@ -623,6 +623,7 @@ class JATSExporter {
|
|
|
623
623
|
attribution: () => ['attrib', 0],
|
|
624
624
|
bibliography_element: () => '',
|
|
625
625
|
bibliography_item: () => '',
|
|
626
|
+
comment_list: () => '',
|
|
626
627
|
bibliography_section: (node) => [
|
|
627
628
|
'ref-list',
|
|
628
629
|
{ id: normalizeID(node.attrs.id) },
|
|
@@ -803,6 +804,7 @@ class JATSExporter {
|
|
|
803
804
|
xref.textContent = node.attrs.contents;
|
|
804
805
|
return xref;
|
|
805
806
|
},
|
|
807
|
+
keyword: () => '',
|
|
806
808
|
keywords_element: () => '',
|
|
807
809
|
keywords_section: () => '',
|
|
808
810
|
link: (node) => {
|
|
@@ -881,6 +883,7 @@ class JATSExporter {
|
|
|
881
883
|
},
|
|
882
884
|
section_label: () => ['label', 0],
|
|
883
885
|
section_title: () => ['title', 0],
|
|
886
|
+
section_title_plain: () => ['title', 0],
|
|
884
887
|
table: (node) => ['table', { id: normalizeID(node.attrs.id) }, 0],
|
|
885
888
|
table_element: (node) => {
|
|
886
889
|
const element = createFigureElement(node, 'table-wrap', node.type.schema.nodes.table);
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -41,6 +41,7 @@ const caption_1 = require("./nodes/caption");
|
|
|
41
41
|
const caption_title_1 = require("./nodes/caption_title");
|
|
42
42
|
const citation_1 = require("./nodes/citation");
|
|
43
43
|
const comment_1 = require("./nodes/comment");
|
|
44
|
+
const comment_list_1 = require("./nodes/comment_list");
|
|
44
45
|
const cross_reference_1 = require("./nodes/cross_reference");
|
|
45
46
|
const doc_1 = require("./nodes/doc");
|
|
46
47
|
const equation_1 = require("./nodes/equation");
|
|
@@ -56,6 +57,7 @@ const hard_break_1 = require("./nodes/hard_break");
|
|
|
56
57
|
const highlight_marker_1 = require("./nodes/highlight_marker");
|
|
57
58
|
const inline_equation_1 = require("./nodes/inline_equation");
|
|
58
59
|
const inline_footnote_1 = require("./nodes/inline_footnote");
|
|
60
|
+
const keyword_1 = require("./nodes/keyword");
|
|
59
61
|
const keywords_element_1 = require("./nodes/keywords_element");
|
|
60
62
|
const keywords_section_1 = require("./nodes/keywords_section");
|
|
61
63
|
const link_1 = require("./nodes/link");
|
|
@@ -81,6 +83,7 @@ const toc_section_1 = require("./nodes/toc_section");
|
|
|
81
83
|
__exportStar(require("./groups"), exports);
|
|
82
84
|
__exportStar(require("./types"), exports);
|
|
83
85
|
__exportStar(require("./nodes/comment"), exports);
|
|
86
|
+
__exportStar(require("./nodes/comment_list"), exports);
|
|
84
87
|
__exportStar(require("./nodes/attribution"), exports);
|
|
85
88
|
__exportStar(require("./nodes/bibliography_item"), exports);
|
|
86
89
|
__exportStar(require("./nodes/bibliography_element"), exports);
|
|
@@ -104,6 +107,7 @@ __exportStar(require("./nodes/hard_break"), exports);
|
|
|
104
107
|
__exportStar(require("./nodes/highlight_marker"), exports);
|
|
105
108
|
__exportStar(require("./nodes/inline_equation"), exports);
|
|
106
109
|
__exportStar(require("./nodes/inline_footnote"), exports);
|
|
110
|
+
__exportStar(require("./nodes/keyword"), exports);
|
|
107
111
|
__exportStar(require("./nodes/keywords_element"), exports);
|
|
108
112
|
__exportStar(require("./nodes/keywords_section"), exports);
|
|
109
113
|
__exportStar(require("./nodes/link"), exports);
|
|
@@ -141,6 +145,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
141
145
|
},
|
|
142
146
|
nodes: {
|
|
143
147
|
comment: comment_1.comment,
|
|
148
|
+
comment_list: comment_list_1.commentList,
|
|
144
149
|
attribution: attribution_1.attribution,
|
|
145
150
|
bibliography_item: bibliography_item_1.bibliographyItem,
|
|
146
151
|
bibliography_element: bibliography_element_1.bibliographyElement,
|
|
@@ -165,6 +170,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
165
170
|
highlight_marker: highlight_marker_1.highlightMarker,
|
|
166
171
|
inline_equation: inline_equation_1.inlineEquation,
|
|
167
172
|
inline_footnote: inline_footnote_1.inlineFootnote,
|
|
173
|
+
keyword: keyword_1.keyword,
|
|
168
174
|
keywords_element: keywords_element_1.keywordsElement,
|
|
169
175
|
keywords_section: keywords_section_1.keywordsSection,
|
|
170
176
|
link: link_1.link,
|
|
@@ -181,6 +187,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
181
187
|
section: section_1.section,
|
|
182
188
|
section_label: section_label_1.sectionLabel,
|
|
183
189
|
section_title: section_title_1.sectionTitle,
|
|
190
|
+
section_title_plain: section_title_1.sectionTitle,
|
|
184
191
|
table: table_1.table,
|
|
185
192
|
table_body: table_1.tableBody,
|
|
186
193
|
table_cell: table_row_1.tableCell,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 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.commentList = void 0;
|
|
19
|
+
exports.commentList = {
|
|
20
|
+
content: 'comment*',
|
|
21
|
+
attrs: {
|
|
22
|
+
id: { default: '' },
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 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.keyword = void 0;
|
|
19
|
+
exports.keyword = {
|
|
20
|
+
atom: true,
|
|
21
|
+
content: 'text*',
|
|
22
|
+
attrs: {
|
|
23
|
+
id: { default: '' },
|
|
24
|
+
contents: { default: '' },
|
|
25
|
+
dataTracked: { default: null },
|
|
26
|
+
comments: { default: null },
|
|
27
|
+
},
|
|
28
|
+
inline: true,
|
|
29
|
+
group: 'inline',
|
|
30
|
+
selectable: false,
|
|
31
|
+
parseDOM: [
|
|
32
|
+
{
|
|
33
|
+
tag: 'span.keyword',
|
|
34
|
+
getAttrs: (node) => {
|
|
35
|
+
const dom = node;
|
|
36
|
+
return {
|
|
37
|
+
id: dom.getAttribute('id'),
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
toDOM: (node) => {
|
|
43
|
+
const keywordNode = node;
|
|
44
|
+
return [
|
|
45
|
+
'span',
|
|
46
|
+
{
|
|
47
|
+
class: 'keyword',
|
|
48
|
+
id: keywordNode.attrs.id,
|
|
49
|
+
},
|
|
50
|
+
0,
|
|
51
|
+
];
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -16,15 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.keywordsElement = void 0;
|
|
19
|
-
const html_1 = require("../../lib/html");
|
|
20
|
-
const createBodyElement = (node) => {
|
|
21
|
-
const dom = document.createElement('div');
|
|
22
|
-
dom.className = 'manuscript-keywords';
|
|
23
|
-
dom.id = node.attrs.id;
|
|
24
|
-
return dom;
|
|
25
|
-
};
|
|
26
19
|
exports.keywordsElement = {
|
|
27
20
|
atom: true,
|
|
21
|
+
content: 'keyword*',
|
|
28
22
|
attrs: {
|
|
29
23
|
id: { default: '' },
|
|
30
24
|
contents: { default: '' },
|
|
@@ -46,7 +40,13 @@ exports.keywordsElement = {
|
|
|
46
40
|
],
|
|
47
41
|
toDOM: (node) => {
|
|
48
42
|
const keywordsElementNode = node;
|
|
49
|
-
return
|
|
50
|
-
|
|
43
|
+
return [
|
|
44
|
+
'div',
|
|
45
|
+
{
|
|
46
|
+
class: 'manuscript-keywords',
|
|
47
|
+
id: keywordsElementNode.attrs.id,
|
|
48
|
+
},
|
|
49
|
+
0,
|
|
50
|
+
];
|
|
51
51
|
},
|
|
52
52
|
};
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.isKeywordsSectionNode = exports.keywordsSection = void 0;
|
|
19
19
|
exports.keywordsSection = {
|
|
20
|
-
content: '
|
|
20
|
+
content: 'section_title_plain (keywords_element | placeholder_element)',
|
|
21
21
|
attrs: {
|
|
22
22
|
id: { default: '' },
|
|
23
23
|
dataTracked: { default: null },
|
|
@@ -26,13 +26,13 @@ exports.keywordsSection = {
|
|
|
26
26
|
selectable: false,
|
|
27
27
|
parseDOM: [
|
|
28
28
|
{
|
|
29
|
-
tag: '
|
|
29
|
+
tag: 'div.keywords',
|
|
30
30
|
},
|
|
31
31
|
],
|
|
32
32
|
toDOM: (node) => {
|
|
33
33
|
const keywordsSectionNode = node;
|
|
34
34
|
return [
|
|
35
|
-
'
|
|
35
|
+
'div',
|
|
36
36
|
{
|
|
37
37
|
id: keywordsSectionNode.attrs.id,
|
|
38
38
|
class: 'keywords',
|
|
@@ -64,6 +64,7 @@ const isManuscriptNode = (model) => model !== null;
|
|
|
64
64
|
exports.isManuscriptNode = isManuscriptNode;
|
|
65
65
|
const isParagraphElement = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.ParagraphElement);
|
|
66
66
|
const isFootnote = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Footnote);
|
|
67
|
+
const isKeyword = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Keyword);
|
|
67
68
|
const hasParentSection = (id) => (section) => section.path &&
|
|
68
69
|
section.path.length > 1 &&
|
|
69
70
|
section.path[section.path.length - 2] === id;
|
|
@@ -98,6 +99,7 @@ class Decoder {
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
constructor(modelMap, allowMissingElements = false) {
|
|
102
|
+
this.comments = new Map();
|
|
101
103
|
this.creators = {
|
|
102
104
|
[json_schema_1.ObjectTypes.BibliographyElement]: (data) => {
|
|
103
105
|
var _a;
|
|
@@ -144,12 +146,14 @@ class Decoder {
|
|
|
144
146
|
},
|
|
145
147
|
[json_schema_1.ObjectTypes.Figure]: (data) => {
|
|
146
148
|
const model = data;
|
|
149
|
+
const commentNodes = this.createCommentsNode(model);
|
|
150
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
147
151
|
return schema_1.schema.nodes.figure.create({
|
|
148
152
|
id: model._id,
|
|
149
153
|
contentType: model.contentType,
|
|
150
154
|
src: model.src,
|
|
151
155
|
position: model.position,
|
|
152
|
-
comments:
|
|
156
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
153
157
|
});
|
|
154
158
|
},
|
|
155
159
|
[json_schema_1.ObjectTypes.FigureElement]: (data) => {
|
|
@@ -178,6 +182,8 @@ class Decoder {
|
|
|
178
182
|
figures.push(schema_1.schema.nodes.figure.createAndFill());
|
|
179
183
|
}
|
|
180
184
|
const figcaption = this.getFigcaption(model);
|
|
185
|
+
const commentNodes = this.createCommentsNode(model);
|
|
186
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
181
187
|
const content = [...paragraphs, ...figures, figcaption];
|
|
182
188
|
const listing = this.extractListing(model);
|
|
183
189
|
if (listing) {
|
|
@@ -198,7 +204,7 @@ class Decoder {
|
|
|
198
204
|
suppressTitle: Boolean(model.suppressTitle === undefined ? true : model.suppressTitle),
|
|
199
205
|
attribution: model.attribution,
|
|
200
206
|
alternatives: model.alternatives,
|
|
201
|
-
comments:
|
|
207
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
202
208
|
}, content);
|
|
203
209
|
},
|
|
204
210
|
[json_schema_1.ObjectTypes.Equation]: (data) => {
|
|
@@ -239,11 +245,13 @@ class Decoder {
|
|
|
239
245
|
const footnotesOfKind = [];
|
|
240
246
|
for (const model of this.modelMap.values()) {
|
|
241
247
|
if (isFootnote(model) && model.kind === collateByKind) {
|
|
248
|
+
const commentNodes = this.createCommentsNode(model);
|
|
249
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
242
250
|
const footnote = this.parseContents(model.contents || '<div></div>', undefined, this.getComments(model), {
|
|
243
251
|
topNode: schema_1.schema.nodes.footnote.create({
|
|
244
252
|
id: model._id,
|
|
245
253
|
kind: model.kind,
|
|
246
|
-
comments:
|
|
254
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
247
255
|
}),
|
|
248
256
|
});
|
|
249
257
|
footnotesOfKind.push(footnote);
|
|
@@ -257,31 +265,41 @@ class Decoder {
|
|
|
257
265
|
},
|
|
258
266
|
[json_schema_1.ObjectTypes.Footnote]: (data) => {
|
|
259
267
|
const model = data;
|
|
268
|
+
const commentNodes = this.createCommentsNode(model);
|
|
269
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
260
270
|
return schema_1.schema.nodes.footnote.create({
|
|
261
271
|
id: model._id,
|
|
262
272
|
kind: model.kind,
|
|
263
|
-
comments:
|
|
273
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
264
274
|
});
|
|
265
275
|
},
|
|
266
276
|
[json_schema_1.ObjectTypes.KeywordsElement]: (data) => {
|
|
267
277
|
const model = data;
|
|
278
|
+
const keywords = this.getKeywords();
|
|
268
279
|
return schema_1.schema.nodes.keywords_element.create({
|
|
269
280
|
id: model._id,
|
|
270
|
-
contents: model.contents
|
|
271
|
-
? model.contents.replace(/\s+xmlns=".+?"/, '')
|
|
272
|
-
: '',
|
|
273
281
|
paragraphStyle: model.paragraphStyle,
|
|
274
|
-
});
|
|
282
|
+
}, keywords);
|
|
283
|
+
},
|
|
284
|
+
[json_schema_1.ObjectTypes.Keyword]: (data) => {
|
|
285
|
+
const model = data;
|
|
286
|
+
return schema_1.schema.nodes.keyword.create({
|
|
287
|
+
id: model._id,
|
|
288
|
+
contents: model.name,
|
|
289
|
+
comments: this.createCommentsNode(model),
|
|
290
|
+
}, schema_1.schema.text(model.name));
|
|
275
291
|
},
|
|
276
292
|
[json_schema_1.ObjectTypes.ListElement]: (data) => {
|
|
277
293
|
const model = data;
|
|
294
|
+
const commentNodes = this.createCommentsNode(model);
|
|
295
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
278
296
|
switch (model.elementType) {
|
|
279
297
|
case 'ol':
|
|
280
298
|
return this.parseContents(model.contents || '<ol></ol>', undefined, this.getComments(model), {
|
|
281
299
|
topNode: schema_1.schema.nodes.ordered_list.create({
|
|
282
300
|
id: model._id,
|
|
283
301
|
paragraphStyle: model.paragraphStyle,
|
|
284
|
-
comments:
|
|
302
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
285
303
|
}),
|
|
286
304
|
});
|
|
287
305
|
case 'ul':
|
|
@@ -297,12 +315,14 @@ class Decoder {
|
|
|
297
315
|
},
|
|
298
316
|
[json_schema_1.ObjectTypes.Listing]: (data) => {
|
|
299
317
|
const model = data;
|
|
318
|
+
const commentNodes = this.createCommentsNode(model);
|
|
319
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
300
320
|
return schema_1.schema.nodes.listing.createChecked({
|
|
301
321
|
id: model._id,
|
|
302
322
|
contents: model.contents,
|
|
303
323
|
language: model.language,
|
|
304
324
|
languageKey: model.languageKey,
|
|
305
|
-
comments:
|
|
325
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
306
326
|
});
|
|
307
327
|
},
|
|
308
328
|
[json_schema_1.ObjectTypes.ListingElement]: (data) => {
|
|
@@ -322,11 +342,13 @@ class Decoder {
|
|
|
322
342
|
throw new errors_1.MissingElement(model.containedObjectID);
|
|
323
343
|
}
|
|
324
344
|
const figcaption = this.getFigcaption(model);
|
|
345
|
+
const commentNodes = this.createCommentsNode(model);
|
|
346
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
325
347
|
return schema_1.schema.nodes.listing_element.createChecked({
|
|
326
348
|
id: model._id,
|
|
327
349
|
suppressCaption: model.suppressCaption,
|
|
328
350
|
suppressTitle: Boolean(model.suppressTitle === undefined ? true : model.suppressTitle),
|
|
329
|
-
comments:
|
|
351
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
330
352
|
}, [listing, figcaption]);
|
|
331
353
|
},
|
|
332
354
|
[json_schema_1.ObjectTypes.MissingFigure]: (data) => {
|
|
@@ -338,12 +360,14 @@ class Decoder {
|
|
|
338
360
|
},
|
|
339
361
|
[json_schema_1.ObjectTypes.ParagraphElement]: (data) => {
|
|
340
362
|
const model = data;
|
|
363
|
+
const commentNodes = this.createCommentsNode(model);
|
|
364
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
341
365
|
return this.parseContents(model.contents || '<p></p>', undefined, this.getComments(model), {
|
|
342
366
|
topNode: schema_1.schema.nodes.paragraph.create({
|
|
343
367
|
id: model._id,
|
|
344
368
|
paragraphStyle: model.paragraphStyle,
|
|
345
369
|
placeholder: model.placeholderInnerHTML,
|
|
346
|
-
comments:
|
|
370
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
347
371
|
}),
|
|
348
372
|
});
|
|
349
373
|
},
|
|
@@ -402,11 +426,14 @@ class Decoder {
|
|
|
402
426
|
const elementNodes = elements
|
|
403
427
|
.map(this.decode)
|
|
404
428
|
.filter(exports.isManuscriptNode);
|
|
429
|
+
const sectionTitle = isKeywordsSection
|
|
430
|
+
? 'section_title_plain'
|
|
431
|
+
: 'section_title';
|
|
405
432
|
const sectionTitleNode = model.title
|
|
406
433
|
? this.parseContents(model.title, 'h1', this.getComments(model), {
|
|
407
|
-
topNode: schema_1.schema.nodes.
|
|
434
|
+
topNode: schema_1.schema.nodes[sectionTitle].create(),
|
|
408
435
|
})
|
|
409
|
-
: schema_1.schema.nodes.
|
|
436
|
+
: schema_1.schema.nodes[sectionTitle].create();
|
|
410
437
|
let sectionLabelNode = undefined;
|
|
411
438
|
if (model.label) {
|
|
412
439
|
sectionLabelNode = this.parseContents(model.label, 'label', this.getComments(model), {
|
|
@@ -418,6 +445,8 @@ class Decoder {
|
|
|
418
445
|
.map(this.creators[json_schema_1.ObjectTypes.Section]);
|
|
419
446
|
const sectionCategory = model.category || (0, section_category_1.guessSectionCategory)(elements);
|
|
420
447
|
const sectionNodeType = (0, section_category_1.chooseSectionNodeType)(sectionCategory);
|
|
448
|
+
const commentNodes = this.createCommentsNode(model);
|
|
449
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
421
450
|
const content = (sectionLabelNode
|
|
422
451
|
? [sectionLabelNode, sectionTitleNode]
|
|
423
452
|
: [sectionTitleNode])
|
|
@@ -429,7 +458,7 @@ class Decoder {
|
|
|
429
458
|
titleSuppressed: model.titleSuppressed,
|
|
430
459
|
pageBreakStyle: model.pageBreakStyle,
|
|
431
460
|
generatedLabel: model.generatedLabel,
|
|
432
|
-
comments:
|
|
461
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
433
462
|
}, content);
|
|
434
463
|
if (!sectionNode) {
|
|
435
464
|
console.error(model);
|
|
@@ -439,10 +468,12 @@ class Decoder {
|
|
|
439
468
|
},
|
|
440
469
|
[json_schema_1.ObjectTypes.Table]: (data) => {
|
|
441
470
|
const model = data;
|
|
471
|
+
const commentNodes = this.createCommentsNode(model);
|
|
472
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
442
473
|
return this.parseContents(model.contents, undefined, this.getComments(model), {
|
|
443
474
|
topNode: schema_1.schema.nodes.table.create({
|
|
444
475
|
id: model._id,
|
|
445
|
-
comments:
|
|
476
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
446
477
|
}),
|
|
447
478
|
});
|
|
448
479
|
},
|
|
@@ -463,6 +494,8 @@ class Decoder {
|
|
|
463
494
|
throw new errors_1.MissingElement(model.containedObjectID);
|
|
464
495
|
}
|
|
465
496
|
const figcaption = this.getFigcaption(model);
|
|
497
|
+
const commentNodes = this.createCommentsNode(model);
|
|
498
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
466
499
|
const content = [table, figcaption];
|
|
467
500
|
if (model.listingID) {
|
|
468
501
|
const listingModel = this.getModel(model.listingID);
|
|
@@ -494,7 +527,7 @@ class Decoder {
|
|
|
494
527
|
suppressHeader: model.suppressHeader,
|
|
495
528
|
tableStyle: model.tableStyle,
|
|
496
529
|
paragraphStyle: model.paragraphStyle,
|
|
497
|
-
comments:
|
|
530
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
498
531
|
}, content);
|
|
499
532
|
},
|
|
500
533
|
[json_schema_1.ObjectTypes.TOCElement]: (data) => {
|
|
@@ -536,9 +569,29 @@ class Decoder {
|
|
|
536
569
|
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
|
|
537
570
|
}));
|
|
538
571
|
}
|
|
572
|
+
const keywordsSection = getSections(this.modelMap).filter((section) => section.category === 'MPSectionCategory:keywords');
|
|
573
|
+
const keywords = this.getKeywords();
|
|
574
|
+
if (keywordsSection.length === 0 && keywords.length > 0) {
|
|
575
|
+
const keywordsSection = schema_1.schema.nodes.keywords_section.createAndFill({
|
|
576
|
+
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.keywords_section),
|
|
577
|
+
}, [
|
|
578
|
+
schema_1.schema.nodes.section_title_plain.create({}, schema_1.schema.text('Keywords')),
|
|
579
|
+
schema_1.schema.nodes.keywords_element.create({
|
|
580
|
+
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.keywords_element),
|
|
581
|
+
}, keywords),
|
|
582
|
+
]);
|
|
583
|
+
rootSectionNodes.unshift(keywordsSection);
|
|
584
|
+
}
|
|
585
|
+
const contents = rootSectionNodes;
|
|
586
|
+
if (this.comments.size) {
|
|
587
|
+
const comments = schema_1.schema.nodes.comment_list.createAndFill({
|
|
588
|
+
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.comment_list),
|
|
589
|
+
}, [...this.comments.values()]);
|
|
590
|
+
contents.push(comments);
|
|
591
|
+
}
|
|
539
592
|
return schema_1.schema.nodes.manuscript.create({
|
|
540
593
|
id: manuscriptID || this.getManuscriptID(),
|
|
541
|
-
},
|
|
594
|
+
}, contents);
|
|
542
595
|
};
|
|
543
596
|
this.addGeneratedLabels = (sections) => {
|
|
544
597
|
const nextLableCount = { Appendix: 1 };
|
|
@@ -571,10 +624,28 @@ class Decoder {
|
|
|
571
624
|
}
|
|
572
625
|
const template = document.createElement('template');
|
|
573
626
|
template.innerHTML = html;
|
|
574
|
-
if (!template.content.
|
|
627
|
+
if (!template.content.firstElementChild) {
|
|
575
628
|
throw new Error('No content could be parsed');
|
|
576
629
|
}
|
|
577
|
-
return parser.parse(template.content.
|
|
630
|
+
return parser.parse(template.content.firstElementChild, options);
|
|
631
|
+
};
|
|
632
|
+
this.getKeywords = () => {
|
|
633
|
+
const keywordsOfKind = [];
|
|
634
|
+
for (const model of this.modelMap.values()) {
|
|
635
|
+
const commentNodes = this.createCommentsNode(model);
|
|
636
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
637
|
+
if (isKeyword(model)) {
|
|
638
|
+
const keyword = this.parseContents(model.name || '', 'div', this.getComments(model), {
|
|
639
|
+
topNode: schema_1.schema.nodes.keyword.create({
|
|
640
|
+
id: model._id,
|
|
641
|
+
contents: model.name,
|
|
642
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
643
|
+
}),
|
|
644
|
+
});
|
|
645
|
+
keywordsOfKind.push(keyword);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return keywordsOfKind;
|
|
578
649
|
};
|
|
579
650
|
this.getManuscriptID = () => {
|
|
580
651
|
for (const item of this.modelMap.values()) {
|
|
@@ -40,6 +40,10 @@ const footnoteContents = (node) => {
|
|
|
40
40
|
});
|
|
41
41
|
return (0, w3c_xmlserializer_1.default)(output);
|
|
42
42
|
};
|
|
43
|
+
const keywordContents = (node) => {
|
|
44
|
+
const text = serializer.serializeNode(node).textContent;
|
|
45
|
+
return text === null ? '' : text;
|
|
46
|
+
};
|
|
43
47
|
const inlineContents = (node) => serializer.serializeNode(node).innerHTML;
|
|
44
48
|
exports.inlineContents = inlineContents;
|
|
45
49
|
const inlineText = (node) => {
|
|
@@ -393,6 +397,10 @@ const encoders = {
|
|
|
393
397
|
SVGRepresentation: node.attrs.SVGRepresentation,
|
|
394
398
|
SVGGlyphs: svgDefs(node.attrs.SVGRepresentation),
|
|
395
399
|
}),
|
|
400
|
+
keyword: (node, parent) => ({
|
|
401
|
+
containerID: parent.attrs.id,
|
|
402
|
+
name: keywordContents(node),
|
|
403
|
+
}),
|
|
396
404
|
keywords_element: (node) => ({
|
|
397
405
|
contents: elementContents(node),
|
|
398
406
|
elementType: 'div',
|
|
@@ -401,7 +409,7 @@ const encoders = {
|
|
|
401
409
|
keywords_section: (node, parent, path, priority) => ({
|
|
402
410
|
category: (0, section_category_1.buildSectionCategory)(node),
|
|
403
411
|
priority: priority.value++,
|
|
404
|
-
title: inlineContentsOfNodeType(node, node.type.schema.nodes.
|
|
412
|
+
title: inlineContentsOfNodeType(node, node.type.schema.nodes.section_title_plain),
|
|
405
413
|
path: path.concat([node.attrs.id]),
|
|
406
414
|
elementIDs: childElements(node)
|
|
407
415
|
.map((childNode) => childNode.attrs.id)
|
|
@@ -501,16 +509,6 @@ const modelFromNode = (node, parent, path, priority) => {
|
|
|
501
509
|
const model = data;
|
|
502
510
|
if ((0, highlight_markers_1.isHighlightableModel)(model)) {
|
|
503
511
|
(0, highlight_markers_1.extractHighlightMarkers)(model, commentAnnotationsMap);
|
|
504
|
-
if (node.attrs.comments) {
|
|
505
|
-
const commentNodes = node.attrs.comments;
|
|
506
|
-
commentNodes
|
|
507
|
-
.filter((commentNode) => !commentNode.attrs.selector)
|
|
508
|
-
.forEach((c) => {
|
|
509
|
-
const commentAnnotation = (0, builders_1.buildComment)(model._id, c.attrs.contents, c.attrs.selector);
|
|
510
|
-
commentAnnotation._id = c.attrs.id;
|
|
511
|
-
commentAnnotationsMap.set(commentAnnotation._id, commentAnnotation);
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
512
|
}
|
|
515
513
|
return { model, commentAnnotationsMap };
|
|
516
514
|
};
|
|
@@ -528,6 +526,9 @@ const encode = (node) => {
|
|
|
528
526
|
if ((0, schema_1.isHighlightMarkerNode)(child)) {
|
|
529
527
|
return;
|
|
530
528
|
}
|
|
529
|
+
if (child.type === schema_1.schema.nodes.comment_list) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
531
532
|
if (placeholders.includes(child.type.name)) {
|
|
532
533
|
return;
|
|
533
534
|
}
|
|
@@ -539,6 +540,14 @@ const encode = (node) => {
|
|
|
539
540
|
commentAnnotationsMap.forEach((val, key) => models.set(key, val));
|
|
540
541
|
child.forEach(addModel(path.concat(child.attrs.id), child));
|
|
541
542
|
};
|
|
543
|
+
node.forEach((cNode) => {
|
|
544
|
+
if (cNode.type === schema_1.schema.nodes.comment_list) {
|
|
545
|
+
cNode.forEach((child) => {
|
|
546
|
+
const { model } = (0, exports.modelFromNode)(child, cNode, [], priority);
|
|
547
|
+
models.set(model._id, model);
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
});
|
|
542
551
|
node.forEach(addModel([], node));
|
|
543
552
|
return models;
|
|
544
553
|
};
|
|
@@ -33,6 +33,7 @@ exports.nodeNames = new Map([
|
|
|
33
33
|
[schema_1.schema.nodes.paragraph, 'Paragraph'],
|
|
34
34
|
[schema_1.schema.nodes.section, 'Section'],
|
|
35
35
|
[schema_1.schema.nodes.section_title, 'Section'],
|
|
36
|
+
[schema_1.schema.nodes.section_title_plain, 'Section'],
|
|
36
37
|
[schema_1.schema.nodes.table, 'Table'],
|
|
37
38
|
[schema_1.schema.nodes.table_element, 'Table'],
|
|
38
39
|
[schema_1.schema.nodes.blockquote_element, 'Block Quote'],
|
|
@@ -38,6 +38,7 @@ exports.nodeTypesMap = new Map([
|
|
|
38
38
|
[schema_1.schema.nodes.graphical_abstract_section, json_schema_1.ObjectTypes.Section],
|
|
39
39
|
[schema_1.schema.nodes.highlight_marker, json_schema_1.ObjectTypes.HighlightMarker],
|
|
40
40
|
[schema_1.schema.nodes.inline_equation, json_schema_1.ObjectTypes.InlineMathFragment],
|
|
41
|
+
[schema_1.schema.nodes.keyword, json_schema_1.ObjectTypes.Keyword],
|
|
41
42
|
[schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
|
|
42
43
|
[schema_1.schema.nodes.keywords_section, json_schema_1.ObjectTypes.Section],
|
|
43
44
|
[schema_1.schema.nodes.listing, json_schema_1.ObjectTypes.Listing],
|
|
@@ -51,6 +52,7 @@ exports.nodeTypesMap = new Map([
|
|
|
51
52
|
[schema_1.schema.nodes.table_element, json_schema_1.ObjectTypes.TableElement],
|
|
52
53
|
[schema_1.schema.nodes.toc_element, json_schema_1.ObjectTypes.TOCElement],
|
|
53
54
|
[schema_1.schema.nodes.toc_section, json_schema_1.ObjectTypes.Section],
|
|
55
|
+
[schema_1.schema.nodes.comment_list, json_schema_1.ObjectTypes.MetaSection],
|
|
54
56
|
]);
|
|
55
57
|
const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
|
|
56
58
|
exports.isExecutableNodeType = isExecutableNodeType;
|
|
@@ -616,6 +616,7 @@ export class JATSExporter {
|
|
|
616
616
|
attribution: () => ['attrib', 0],
|
|
617
617
|
bibliography_element: () => '',
|
|
618
618
|
bibliography_item: () => '',
|
|
619
|
+
comment_list: () => '',
|
|
619
620
|
bibliography_section: (node) => [
|
|
620
621
|
'ref-list',
|
|
621
622
|
{ id: normalizeID(node.attrs.id) },
|
|
@@ -796,6 +797,7 @@ export class JATSExporter {
|
|
|
796
797
|
xref.textContent = node.attrs.contents;
|
|
797
798
|
return xref;
|
|
798
799
|
},
|
|
800
|
+
keyword: () => '',
|
|
799
801
|
keywords_element: () => '',
|
|
800
802
|
keywords_section: () => '',
|
|
801
803
|
link: (node) => {
|
|
@@ -874,6 +876,7 @@ export class JATSExporter {
|
|
|
874
876
|
},
|
|
875
877
|
section_label: () => ['label', 0],
|
|
876
878
|
section_title: () => ['title', 0],
|
|
879
|
+
section_title_plain: () => ['title', 0],
|
|
877
880
|
table: (node) => ['table', { id: normalizeID(node.attrs.id) }, 0],
|
|
878
881
|
table_element: (node) => {
|
|
879
882
|
const element = createFigureElement(node, 'table-wrap', node.type.schema.nodes.table);
|