@manuscripts/transform 4.2.19 → 4.3.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/jats/__tests__/jats-importer.test.js +12 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +7 -2
- package/dist/cjs/schema/marks.js +65 -6
- package/dist/cjs/version.js +1 -1
- package/dist/es/jats/__tests__/jats-importer.test.js +12 -0
- package/dist/es/jats/importer/parse-jats-article.js +7 -2
- package/dist/es/schema/marks.js +65 -6
- package/dist/es/version.js +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -356,6 +356,18 @@ describe('JATS importer', () => {
|
|
|
356
356
|
const bodyNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.body);
|
|
357
357
|
expect(bodyNode).toBeDefined();
|
|
358
358
|
});
|
|
359
|
+
it('should create body element and append to article when body is missing', async () => {
|
|
360
|
+
const jats = await (0, files_1.readAndParseFixture)('jats-abstract-no-body.xml');
|
|
361
|
+
const { node } = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
362
|
+
const bodyNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.body);
|
|
363
|
+
expect(bodyNode).toBeDefined();
|
|
364
|
+
});
|
|
365
|
+
it('should have abstracts node even when no body element exists in JATS', async () => {
|
|
366
|
+
const jats = await (0, files_1.readAndParseFixture)('jats-abstract-no-body.xml');
|
|
367
|
+
const { node } = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
368
|
+
const abstractNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.abstracts);
|
|
369
|
+
expect(abstractNode).toBeDefined();
|
|
370
|
+
});
|
|
359
371
|
});
|
|
360
372
|
describe('backmatter', () => {
|
|
361
373
|
it('should have backmatter node if back element exists', async () => {
|
|
@@ -35,9 +35,14 @@ const processJATS = (doc, sectionCategories) => {
|
|
|
35
35
|
(0, jats_transformations_1.moveAffiliations)(front, createElement);
|
|
36
36
|
(0, jats_transformations_1.moveAuthorNotes)(front, createElement);
|
|
37
37
|
(0, jats_transformations_1.moveAwards)(front);
|
|
38
|
-
|
|
38
|
+
let body = doc.querySelector('body');
|
|
39
39
|
if (!body) {
|
|
40
|
-
|
|
40
|
+
body = createElement('body');
|
|
41
|
+
const article = doc.querySelector('article');
|
|
42
|
+
if (!article) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
article.append(body);
|
|
41
46
|
}
|
|
42
47
|
(0, jats_transformations_1.moveCaptionsToEnd)(body);
|
|
43
48
|
(0, jats_transformations_1.createBoxedElementSection)(body, createElement);
|
package/dist/cjs/schema/marks.js
CHANGED
|
@@ -16,7 +16,21 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.tracked_delete = exports.tracked_insert = exports.underline = exports.superscript = exports.subscript = exports.styled = exports.strikethrough = exports.smallcaps = exports.italic = exports.code = exports.bold = void 0;
|
|
19
|
+
function getTrackedMarkAttrs(el) {
|
|
20
|
+
const dataTracked = Array.isArray(el.attrs.dataTracked)
|
|
21
|
+
? el.attrs.dataTracked[0]
|
|
22
|
+
: null;
|
|
23
|
+
return dataTracked
|
|
24
|
+
? {
|
|
25
|
+
'data-track-status': dataTracked.status,
|
|
26
|
+
'data-track-op': dataTracked.operation,
|
|
27
|
+
}
|
|
28
|
+
: {};
|
|
29
|
+
}
|
|
19
30
|
exports.bold = {
|
|
31
|
+
attrs: {
|
|
32
|
+
dataTracked: { default: null },
|
|
33
|
+
},
|
|
20
34
|
parseDOM: [
|
|
21
35
|
{
|
|
22
36
|
getAttrs: (dom) => dom.style.fontWeight !== 'normal' && null,
|
|
@@ -31,15 +45,28 @@ exports.bold = {
|
|
|
31
45
|
style: 'font-weight',
|
|
32
46
|
},
|
|
33
47
|
],
|
|
34
|
-
toDOM: () =>
|
|
48
|
+
toDOM: (el) => {
|
|
49
|
+
const attrs = {
|
|
50
|
+
...getTrackedMarkAttrs(el),
|
|
51
|
+
};
|
|
52
|
+
return ['b', attrs];
|
|
53
|
+
},
|
|
35
54
|
};
|
|
36
55
|
exports.code = {
|
|
37
56
|
parseDOM: [{ tag: 'code' }],
|
|
38
57
|
toDOM: () => ['code'],
|
|
39
58
|
};
|
|
40
59
|
exports.italic = {
|
|
60
|
+
attrs: {
|
|
61
|
+
dataTracked: { default: null },
|
|
62
|
+
},
|
|
41
63
|
parseDOM: [{ tag: 'i' }, { tag: 'em' }, { style: 'font-style=italic' }],
|
|
42
|
-
toDOM: () =>
|
|
64
|
+
toDOM: (el) => {
|
|
65
|
+
const attrs = {
|
|
66
|
+
...getTrackedMarkAttrs(el),
|
|
67
|
+
};
|
|
68
|
+
return ['i', attrs];
|
|
69
|
+
},
|
|
43
70
|
};
|
|
44
71
|
exports.smallcaps = {
|
|
45
72
|
parseDOM: [
|
|
@@ -54,13 +81,21 @@ exports.smallcaps = {
|
|
|
54
81
|
],
|
|
55
82
|
};
|
|
56
83
|
exports.strikethrough = {
|
|
84
|
+
attrs: {
|
|
85
|
+
dataTracked: { default: null },
|
|
86
|
+
},
|
|
57
87
|
parseDOM: [
|
|
58
88
|
{ tag: 's' },
|
|
59
89
|
{ tag: 'strike' },
|
|
60
90
|
{ style: 'text-decoration=line-through' },
|
|
61
91
|
{ style: 'text-decoration-line=line-through' },
|
|
62
92
|
],
|
|
63
|
-
toDOM: () =>
|
|
93
|
+
toDOM: (el) => {
|
|
94
|
+
const attrs = {
|
|
95
|
+
...getTrackedMarkAttrs(el),
|
|
96
|
+
};
|
|
97
|
+
return ['s', attrs];
|
|
98
|
+
},
|
|
64
99
|
};
|
|
65
100
|
exports.styled = {
|
|
66
101
|
attrs: {
|
|
@@ -86,20 +121,44 @@ exports.styled = {
|
|
|
86
121
|
},
|
|
87
122
|
};
|
|
88
123
|
exports.subscript = {
|
|
124
|
+
attrs: {
|
|
125
|
+
dataTracked: { default: null },
|
|
126
|
+
},
|
|
89
127
|
excludes: 'superscript',
|
|
90
128
|
group: 'position',
|
|
91
129
|
parseDOM: [{ tag: 'sub' }, { style: 'vertical-align=sub' }],
|
|
92
|
-
toDOM: () =>
|
|
130
|
+
toDOM: (el) => {
|
|
131
|
+
const attrs = {
|
|
132
|
+
...getTrackedMarkAttrs(el),
|
|
133
|
+
};
|
|
134
|
+
return ['sub', attrs];
|
|
135
|
+
},
|
|
93
136
|
};
|
|
94
137
|
exports.superscript = {
|
|
138
|
+
attrs: {
|
|
139
|
+
dataTracked: { default: null },
|
|
140
|
+
},
|
|
95
141
|
excludes: 'subscript',
|
|
96
142
|
group: 'position',
|
|
97
143
|
parseDOM: [{ tag: 'sup' }, { style: 'vertical-align=super' }],
|
|
98
|
-
toDOM: () =>
|
|
144
|
+
toDOM: (el) => {
|
|
145
|
+
const attrs = {
|
|
146
|
+
...getTrackedMarkAttrs(el),
|
|
147
|
+
};
|
|
148
|
+
return ['sup', attrs];
|
|
149
|
+
},
|
|
99
150
|
};
|
|
100
151
|
exports.underline = {
|
|
152
|
+
attrs: {
|
|
153
|
+
dataTracked: { default: null },
|
|
154
|
+
},
|
|
101
155
|
parseDOM: [{ tag: 'u' }, { style: 'text-decoration=underline' }],
|
|
102
|
-
toDOM: () =>
|
|
156
|
+
toDOM: (el) => {
|
|
157
|
+
const attrs = {
|
|
158
|
+
...getTrackedMarkAttrs(el),
|
|
159
|
+
};
|
|
160
|
+
return ['u', attrs];
|
|
161
|
+
},
|
|
103
162
|
};
|
|
104
163
|
exports.tracked_insert = {
|
|
105
164
|
excludes: 'tracked_insert tracked_delete',
|
package/dist/cjs/version.js
CHANGED
|
@@ -354,6 +354,18 @@ describe('JATS importer', () => {
|
|
|
354
354
|
const bodyNode = findNodeByType(node, schema.nodes.body);
|
|
355
355
|
expect(bodyNode).toBeDefined();
|
|
356
356
|
});
|
|
357
|
+
it('should create body element and append to article when body is missing', async () => {
|
|
358
|
+
const jats = await readAndParseFixture('jats-abstract-no-body.xml');
|
|
359
|
+
const { node } = parseJATSArticle(jats, sectionCategories);
|
|
360
|
+
const bodyNode = findNodeByType(node, schema.nodes.body);
|
|
361
|
+
expect(bodyNode).toBeDefined();
|
|
362
|
+
});
|
|
363
|
+
it('should have abstracts node even when no body element exists in JATS', async () => {
|
|
364
|
+
const jats = await readAndParseFixture('jats-abstract-no-body.xml');
|
|
365
|
+
const { node } = parseJATSArticle(jats, sectionCategories);
|
|
366
|
+
const abstractNode = findNodeByType(node, schema.nodes.abstracts);
|
|
367
|
+
expect(abstractNode).toBeDefined();
|
|
368
|
+
});
|
|
357
369
|
});
|
|
358
370
|
describe('backmatter', () => {
|
|
359
371
|
it('should have backmatter node if back element exists', async () => {
|
|
@@ -32,9 +32,14 @@ const processJATS = (doc, sectionCategories) => {
|
|
|
32
32
|
moveAffiliations(front, createElement);
|
|
33
33
|
moveAuthorNotes(front, createElement);
|
|
34
34
|
moveAwards(front);
|
|
35
|
-
|
|
35
|
+
let body = doc.querySelector('body');
|
|
36
36
|
if (!body) {
|
|
37
|
-
|
|
37
|
+
body = createElement('body');
|
|
38
|
+
const article = doc.querySelector('article');
|
|
39
|
+
if (!article) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
article.append(body);
|
|
38
43
|
}
|
|
39
44
|
moveCaptionsToEnd(body);
|
|
40
45
|
createBoxedElementSection(body, createElement);
|
package/dist/es/schema/marks.js
CHANGED
|
@@ -13,7 +13,21 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
function getTrackedMarkAttrs(el) {
|
|
17
|
+
const dataTracked = Array.isArray(el.attrs.dataTracked)
|
|
18
|
+
? el.attrs.dataTracked[0]
|
|
19
|
+
: null;
|
|
20
|
+
return dataTracked
|
|
21
|
+
? {
|
|
22
|
+
'data-track-status': dataTracked.status,
|
|
23
|
+
'data-track-op': dataTracked.operation,
|
|
24
|
+
}
|
|
25
|
+
: {};
|
|
26
|
+
}
|
|
16
27
|
export const bold = {
|
|
28
|
+
attrs: {
|
|
29
|
+
dataTracked: { default: null },
|
|
30
|
+
},
|
|
17
31
|
parseDOM: [
|
|
18
32
|
{
|
|
19
33
|
getAttrs: (dom) => dom.style.fontWeight !== 'normal' && null,
|
|
@@ -28,15 +42,28 @@ export const bold = {
|
|
|
28
42
|
style: 'font-weight',
|
|
29
43
|
},
|
|
30
44
|
],
|
|
31
|
-
toDOM: () =>
|
|
45
|
+
toDOM: (el) => {
|
|
46
|
+
const attrs = {
|
|
47
|
+
...getTrackedMarkAttrs(el),
|
|
48
|
+
};
|
|
49
|
+
return ['b', attrs];
|
|
50
|
+
},
|
|
32
51
|
};
|
|
33
52
|
export const code = {
|
|
34
53
|
parseDOM: [{ tag: 'code' }],
|
|
35
54
|
toDOM: () => ['code'],
|
|
36
55
|
};
|
|
37
56
|
export const italic = {
|
|
57
|
+
attrs: {
|
|
58
|
+
dataTracked: { default: null },
|
|
59
|
+
},
|
|
38
60
|
parseDOM: [{ tag: 'i' }, { tag: 'em' }, { style: 'font-style=italic' }],
|
|
39
|
-
toDOM: () =>
|
|
61
|
+
toDOM: (el) => {
|
|
62
|
+
const attrs = {
|
|
63
|
+
...getTrackedMarkAttrs(el),
|
|
64
|
+
};
|
|
65
|
+
return ['i', attrs];
|
|
66
|
+
},
|
|
40
67
|
};
|
|
41
68
|
export const smallcaps = {
|
|
42
69
|
parseDOM: [
|
|
@@ -51,13 +78,21 @@ export const smallcaps = {
|
|
|
51
78
|
],
|
|
52
79
|
};
|
|
53
80
|
export const strikethrough = {
|
|
81
|
+
attrs: {
|
|
82
|
+
dataTracked: { default: null },
|
|
83
|
+
},
|
|
54
84
|
parseDOM: [
|
|
55
85
|
{ tag: 's' },
|
|
56
86
|
{ tag: 'strike' },
|
|
57
87
|
{ style: 'text-decoration=line-through' },
|
|
58
88
|
{ style: 'text-decoration-line=line-through' },
|
|
59
89
|
],
|
|
60
|
-
toDOM: () =>
|
|
90
|
+
toDOM: (el) => {
|
|
91
|
+
const attrs = {
|
|
92
|
+
...getTrackedMarkAttrs(el),
|
|
93
|
+
};
|
|
94
|
+
return ['s', attrs];
|
|
95
|
+
},
|
|
61
96
|
};
|
|
62
97
|
export const styled = {
|
|
63
98
|
attrs: {
|
|
@@ -83,20 +118,44 @@ export const styled = {
|
|
|
83
118
|
},
|
|
84
119
|
};
|
|
85
120
|
export const subscript = {
|
|
121
|
+
attrs: {
|
|
122
|
+
dataTracked: { default: null },
|
|
123
|
+
},
|
|
86
124
|
excludes: 'superscript',
|
|
87
125
|
group: 'position',
|
|
88
126
|
parseDOM: [{ tag: 'sub' }, { style: 'vertical-align=sub' }],
|
|
89
|
-
toDOM: () =>
|
|
127
|
+
toDOM: (el) => {
|
|
128
|
+
const attrs = {
|
|
129
|
+
...getTrackedMarkAttrs(el),
|
|
130
|
+
};
|
|
131
|
+
return ['sub', attrs];
|
|
132
|
+
},
|
|
90
133
|
};
|
|
91
134
|
export const superscript = {
|
|
135
|
+
attrs: {
|
|
136
|
+
dataTracked: { default: null },
|
|
137
|
+
},
|
|
92
138
|
excludes: 'subscript',
|
|
93
139
|
group: 'position',
|
|
94
140
|
parseDOM: [{ tag: 'sup' }, { style: 'vertical-align=super' }],
|
|
95
|
-
toDOM: () =>
|
|
141
|
+
toDOM: (el) => {
|
|
142
|
+
const attrs = {
|
|
143
|
+
...getTrackedMarkAttrs(el),
|
|
144
|
+
};
|
|
145
|
+
return ['sup', attrs];
|
|
146
|
+
},
|
|
96
147
|
};
|
|
97
148
|
export const underline = {
|
|
149
|
+
attrs: {
|
|
150
|
+
dataTracked: { default: null },
|
|
151
|
+
},
|
|
98
152
|
parseDOM: [{ tag: 'u' }, { style: 'text-decoration=underline' }],
|
|
99
|
-
toDOM: () =>
|
|
153
|
+
toDOM: (el) => {
|
|
154
|
+
const attrs = {
|
|
155
|
+
...getTrackedMarkAttrs(el),
|
|
156
|
+
};
|
|
157
|
+
return ['u', attrs];
|
|
158
|
+
},
|
|
100
159
|
};
|
|
101
160
|
export const tracked_insert = {
|
|
102
161
|
excludes: 'tracked_insert tracked_delete',
|
package/dist/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "4.
|
|
1
|
+
export const VERSION = "4.3.0";
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.3.0";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/transform",
|
|
3
3
|
"description": "ProseMirror transformer for Manuscripts applications",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.0",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|