@manuscripts/transform 1.5.8 → 2.0.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/index.js +1 -1
- package/dist/cjs/jats/importer/index.js +1 -3
- package/dist/cjs/jats/importer/jats-body-dom-parser.js +23 -227
- package/dist/cjs/jats/importer/jats-body-transformations.js +110 -201
- package/dist/cjs/jats/importer/jats-comments.js +100 -98
- package/dist/cjs/jats/importer/jats-front-parser.js +87 -81
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +51 -39
- package/dist/cjs/jats/importer/jats-parser-utils.js +17 -56
- package/dist/cjs/jats/importer/jats-reference-parser.js +24 -79
- package/dist/cjs/jats/importer/jats-references.js +34 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +67 -173
- package/dist/cjs/jats/index.js +1 -3
- package/dist/cjs/jats/jats-exporter.js +34 -55
- package/dist/cjs/lib/section-group-type.js +30 -0
- package/dist/cjs/lib/utils.js +1 -25
- package/dist/cjs/schema/index.js +20 -17
- package/dist/cjs/schema/nodes/abstracts.js +27 -0
- package/dist/cjs/schema/nodes/affiliations.js +27 -0
- package/dist/cjs/schema/nodes/backmatter.js +27 -0
- package/dist/cjs/schema/nodes/body.js +27 -0
- package/dist/cjs/schema/nodes/citation.js +10 -15
- package/dist/cjs/schema/nodes/{comment_list.js → comments.js} +4 -4
- package/dist/cjs/schema/nodes/contributors.js +27 -0
- package/dist/cjs/schema/nodes/{meta_section.js → core_section.js} +6 -5
- package/dist/cjs/schema/nodes/cross_reference.js +4 -3
- package/dist/cjs/schema/nodes/inline_footnote.js +6 -5
- package/dist/cjs/schema/nodes/keyword.js +0 -1
- package/dist/cjs/schema/nodes/{keywords_group.js → keyword_group.js} +6 -6
- package/dist/cjs/schema/nodes/{keywords_section.js → keywords.js} +7 -7
- package/dist/cjs/schema/nodes/keywords_element.js +1 -1
- package/dist/cjs/schema/nodes/manuscript.js +5 -2
- package/dist/cjs/transformer/builders.js +9 -86
- package/dist/cjs/transformer/decode.js +147 -176
- package/dist/cjs/transformer/encode.js +66 -67
- package/dist/cjs/transformer/highlight-markers.js +48 -36
- package/dist/cjs/transformer/html.js +7 -23
- package/dist/cjs/transformer/labels.js +3 -17
- package/dist/cjs/transformer/node-names.js +1 -1
- package/dist/cjs/transformer/node-title.js +1 -1
- package/dist/cjs/transformer/node-types.js +7 -6
- package/dist/cjs/transformer/object-types.js +1 -2
- package/dist/cjs/transformer/section-category.js +31 -31
- package/dist/es/index.js +1 -1
- package/dist/es/jats/importer/index.js +1 -1
- package/dist/es/jats/importer/jats-body-dom-parser.js +23 -227
- package/dist/es/jats/importer/jats-body-transformations.js +111 -202
- package/dist/es/jats/importer/jats-comments.js +97 -96
- package/dist/es/jats/importer/jats-front-parser.js +88 -82
- package/dist/es/jats/importer/jats-journal-meta-parser.js +51 -39
- package/dist/es/jats/importer/jats-parser-utils.js +16 -54
- package/dist/es/jats/importer/jats-reference-parser.js +27 -82
- package/dist/es/jats/importer/jats-references.js +30 -0
- package/dist/es/jats/importer/parse-jats-article.js +70 -174
- package/dist/es/jats/index.js +1 -1
- package/dist/es/jats/jats-exporter.js +34 -55
- package/dist/es/lib/section-group-type.js +27 -0
- package/dist/es/lib/utils.js +0 -22
- package/dist/es/schema/index.js +21 -18
- package/dist/es/schema/nodes/abstracts.js +24 -0
- package/dist/es/schema/nodes/affiliations.js +24 -0
- package/dist/es/schema/nodes/backmatter.js +24 -0
- package/dist/es/schema/nodes/body.js +24 -0
- package/dist/es/schema/nodes/citation.js +10 -15
- package/dist/es/schema/nodes/{comment_list.js → comments.js} +3 -3
- package/dist/es/schema/nodes/contributors.js +24 -0
- package/dist/es/schema/nodes/{meta_section.js → core_section.js} +5 -4
- package/dist/es/schema/nodes/cross_reference.js +4 -3
- package/dist/es/schema/nodes/inline_footnote.js +6 -5
- package/dist/es/schema/nodes/keyword.js +0 -1
- package/dist/es/schema/nodes/{keywords_group.js → keyword_group.js} +4 -4
- package/dist/es/schema/nodes/{keywords_section.js → keywords.js} +5 -5
- package/dist/es/schema/nodes/keywords_element.js +1 -1
- package/dist/es/schema/nodes/manuscript.js +3 -1
- package/dist/es/transformer/builders.js +6 -73
- package/dist/es/transformer/decode.js +147 -175
- package/dist/es/transformer/encode.js +70 -71
- package/dist/es/transformer/highlight-markers.js +44 -32
- package/dist/es/transformer/html.js +7 -23
- package/dist/es/transformer/labels.js +3 -17
- package/dist/es/transformer/node-names.js +1 -1
- package/dist/es/transformer/node-title.js +1 -1
- package/dist/es/transformer/node-types.js +7 -6
- package/dist/es/transformer/object-types.js +0 -1
- package/dist/es/transformer/section-category.js +29 -29
- package/dist/types/index.d.ts +1 -1
- package/dist/types/jats/importer/index.d.ts +1 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +16 -19
- package/dist/types/jats/importer/jats-comments.d.ts +13 -9
- package/dist/types/jats/importer/jats-front-parser.d.ts +35 -12
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +4 -4
- package/dist/types/jats/importer/jats-parser-utils.d.ts +1 -6
- package/dist/types/jats/importer/jats-reference-parser.d.ts +2 -6
- package/dist/types/jats/importer/jats-references.d.ts +12 -0
- package/dist/types/jats/importer/parse-jats-article.d.ts +5 -17
- package/dist/types/jats/index.d.ts +1 -1
- package/dist/types/lib/section-group-type.d.ts +23 -0
- package/dist/types/lib/utils.d.ts +1 -4
- package/dist/types/schema/index.d.ts +4 -5
- package/dist/types/schema/nodes/{meta_section.d.ts → abstracts.d.ts} +1 -9
- package/dist/types/schema/nodes/affiliations.d.ts +17 -0
- package/dist/types/schema/nodes/backmatter.d.ts +17 -0
- package/dist/types/schema/nodes/body.d.ts +17 -0
- package/dist/types/schema/nodes/citation.d.ts +3 -5
- package/dist/types/schema/nodes/comments.d.ts +17 -0
- package/dist/types/schema/nodes/contributors.d.ts +17 -0
- package/dist/types/schema/nodes/core_section.d.ts +17 -0
- package/dist/types/schema/nodes/cross_reference.d.ts +1 -1
- package/dist/types/schema/nodes/inline_footnote.d.ts +1 -1
- package/dist/types/schema/nodes/keyword.d.ts +0 -1
- package/dist/types/schema/nodes/{contributors_element.d.ts → keyword_group.d.ts} +3 -4
- package/dist/types/schema/nodes/{comment_list.d.ts → keywords.d.ts} +3 -2
- package/dist/types/schema/nodes/manuscript.d.ts +1 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +2 -14
- package/dist/types/transformer/decode.d.ts +5 -9
- package/dist/types/transformer/encode.d.ts +4 -4
- package/dist/types/transformer/highlight-markers.d.ts +7 -2
- package/dist/types/transformer/object-types.d.ts +1 -2
- package/dist/types/transformer/section-category.d.ts +4 -3
- package/package.json +1 -6
- package/dist/cjs/lib/core-section-categories.js +0 -29
- package/dist/cjs/schema/nodes/affiliations_section.js +0 -36
- package/dist/cjs/schema/nodes/contributors_element.js +0 -49
- package/dist/cjs/schema/nodes/contributors_section.js +0 -36
- package/dist/es/lib/core-section-categories.js +0 -26
- package/dist/es/schema/nodes/affiliations_section.js +0 -32
- package/dist/es/schema/nodes/contributors_element.js +0 -46
- package/dist/es/schema/nodes/contributors_section.js +0 -32
- package/dist/types/lib/core-section-categories.d.ts +0 -8
- package/dist/types/schema/nodes/affiliations_section.d.ts +0 -11
- package/dist/types/schema/nodes/contributors_section.d.ts +0 -12
- package/dist/types/schema/nodes/keywords_group.d.ts +0 -26
- package/dist/types/schema/nodes/keywords_section.d.ts +0 -26
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export const
|
|
16
|
+
export const keywords = {
|
|
17
17
|
content: 'section_title (keywords_element | placeholder_element)',
|
|
18
18
|
attrs: {
|
|
19
19
|
id: { default: '' },
|
|
20
20
|
dataTracked: { default: null },
|
|
21
21
|
},
|
|
22
|
-
group: 'block
|
|
22
|
+
group: 'block',
|
|
23
23
|
selectable: false,
|
|
24
24
|
parseDOM: [
|
|
25
25
|
{
|
|
@@ -27,11 +27,11 @@ export const keywordsSection = {
|
|
|
27
27
|
},
|
|
28
28
|
],
|
|
29
29
|
toDOM: (node) => {
|
|
30
|
-
const
|
|
30
|
+
const keywords = node;
|
|
31
31
|
return [
|
|
32
32
|
'div',
|
|
33
33
|
{
|
|
34
|
-
id:
|
|
34
|
+
id: keywords.attrs.id,
|
|
35
35
|
class: 'keywords',
|
|
36
36
|
spellcheck: 'false',
|
|
37
37
|
contenteditable: false,
|
|
@@ -40,4 +40,4 @@ export const keywordsSection = {
|
|
|
40
40
|
];
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
|
-
export const
|
|
43
|
+
export const isKeywordsNode = (node) => node.type === node.type.schema.nodes.keywords;
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { schema } from '../index';
|
|
16
17
|
export const manuscript = {
|
|
17
|
-
content: 'title
|
|
18
|
+
content: 'title? contributors? affiliations? keywords? abstracts body backmatter comments',
|
|
18
19
|
attrs: {
|
|
19
20
|
id: { default: '' },
|
|
20
21
|
},
|
|
@@ -41,3 +42,4 @@ export const manuscript = {
|
|
|
41
42
|
];
|
|
42
43
|
},
|
|
43
44
|
};
|
|
45
|
+
export const isManuscriptNode = (node) => node.type === schema.nodes.manuscript;
|
|
@@ -18,8 +18,6 @@ import serializeToXML from 'w3c-xmlserializer';
|
|
|
18
18
|
import { schema } from '../schema';
|
|
19
19
|
import { generateID } from './id';
|
|
20
20
|
import { timestamp } from './timestamp';
|
|
21
|
-
export const DEFAULT_BUNDLE = 'MPBundle:www-zotero-org-styles-nature';
|
|
22
|
-
export const DEFAULT_PAGE_LAYOUT = 'MPPageLayout:defaultA4';
|
|
23
21
|
export const buildProject = (owner) => ({
|
|
24
22
|
_id: generateID(ObjectTypes.Project),
|
|
25
23
|
objectType: ObjectTypes.Project,
|
|
@@ -45,30 +43,12 @@ export const buildContributor = (bibliographicName, role = 'author', priority =
|
|
|
45
43
|
export const buildBibliographyItem = (data) => (Object.assign(Object.assign({}, data), { type: data.type || 'article-journal', _id: generateID(ObjectTypes.BibliographyItem), objectType: ObjectTypes.BibliographyItem }));
|
|
46
44
|
export const buildBibliographicName = (data) => (Object.assign(Object.assign({}, data), { _id: generateID(ObjectTypes.BibliographicName), objectType: ObjectTypes.BibliographicName }));
|
|
47
45
|
export const buildBibliographicDate = (data) => (Object.assign(Object.assign({}, data), { _id: generateID(ObjectTypes.BibliographicDate), objectType: ObjectTypes.BibliographicDate }));
|
|
48
|
-
export const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (rids.length < 2) {
|
|
55
|
-
Object.assign(auxiliaryObjectReference, { referencedObject: rids[0] });
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
Object.assign(auxiliaryObjectReference, { referencedObjects: rids });
|
|
59
|
-
}
|
|
60
|
-
return auxiliaryObjectReference;
|
|
61
|
-
};
|
|
62
|
-
export const buildEmbeddedCitationItem = (bibliographyItem) => ({
|
|
63
|
-
_id: generateID(ObjectTypes.CitationItem),
|
|
64
|
-
objectType: ObjectTypes.CitationItem,
|
|
65
|
-
bibliographyItem,
|
|
66
|
-
});
|
|
67
|
-
export const buildCitation = (containingObject, embeddedCitationItems) => ({
|
|
68
|
-
_id: generateID(ObjectTypes.Citation),
|
|
69
|
-
objectType: ObjectTypes.Citation,
|
|
70
|
-
containingObject: containingObject || undefined,
|
|
71
|
-
embeddedCitationItems: embeddedCitationItems.map(buildEmbeddedCitationItem),
|
|
46
|
+
export const buildBibliographyElement = (bibliographyItems) => ({
|
|
47
|
+
_id: generateID(ObjectTypes.BibliographyElement),
|
|
48
|
+
objectType: ObjectTypes.BibliographyElement,
|
|
49
|
+
contents: '',
|
|
50
|
+
elementType: 'div',
|
|
51
|
+
containedObjectIDs: bibliographyItems.map((b) => b._id),
|
|
72
52
|
});
|
|
73
53
|
export const buildKeyword = (name) => ({
|
|
74
54
|
_id: generateID(ObjectTypes.Keyword),
|
|
@@ -76,19 +56,6 @@ export const buildKeyword = (name) => ({
|
|
|
76
56
|
name,
|
|
77
57
|
});
|
|
78
58
|
export const buildKeywordGroup = (attributes) => (Object.assign(Object.assign(Object.assign({ _id: generateID(ObjectTypes.KeywordGroup), objectType: ObjectTypes.KeywordGroup }, (attributes.type && { type: attributes.type })), (attributes.title && { title: attributes.title })), (attributes.label && { label: attributes.label })));
|
|
79
|
-
export const buildManuscriptKeyword = (name) => ({
|
|
80
|
-
_id: generateID(ObjectTypes.ManuscriptKeyword),
|
|
81
|
-
objectType: ObjectTypes.ManuscriptKeyword,
|
|
82
|
-
name,
|
|
83
|
-
});
|
|
84
|
-
export const buildLibraryCollection = (owner, name) => ({
|
|
85
|
-
_id: generateID(ObjectTypes.LibraryCollection),
|
|
86
|
-
objectType: ObjectTypes.LibraryCollection,
|
|
87
|
-
owners: [owner],
|
|
88
|
-
writers: [],
|
|
89
|
-
viewers: [],
|
|
90
|
-
name,
|
|
91
|
-
});
|
|
92
59
|
export const buildFigure = (blob) => ({
|
|
93
60
|
_id: generateID(ObjectTypes.Figure),
|
|
94
61
|
objectType: ObjectTypes.Figure,
|
|
@@ -112,12 +79,6 @@ export const buildSupplementaryMaterial = (title, href) => ({
|
|
|
112
79
|
title,
|
|
113
80
|
href,
|
|
114
81
|
});
|
|
115
|
-
export const buildUserProfileAffiliation = (institution, priority = 0) => ({
|
|
116
|
-
_id: generateID(ObjectTypes.UserProfileAffiliation),
|
|
117
|
-
objectType: ObjectTypes.UserProfileAffiliation,
|
|
118
|
-
institution,
|
|
119
|
-
priority,
|
|
120
|
-
});
|
|
121
82
|
export const buildComment = (target, contents = '', selector, contributions, annotationColor) => ({
|
|
122
83
|
_id: generateID(ObjectTypes.CommentAnnotation),
|
|
123
84
|
objectType: ObjectTypes.CommentAnnotation,
|
|
@@ -134,11 +95,6 @@ export const buildNote = (target, source, contents = '') => ({
|
|
|
134
95
|
source,
|
|
135
96
|
contents,
|
|
136
97
|
});
|
|
137
|
-
export const buildValidation = (results) => ({
|
|
138
|
-
_id: generateID(ObjectTypes.RequirementsValidation),
|
|
139
|
-
objectType: ObjectTypes.RequirementsValidation,
|
|
140
|
-
results,
|
|
141
|
-
});
|
|
142
98
|
export const buildInlineMathFragment = (containingObject, TeXRepresentation) => ({
|
|
143
99
|
_id: generateID(ObjectTypes.InlineMathFragment),
|
|
144
100
|
objectType: ObjectTypes.InlineMathFragment,
|
|
@@ -194,18 +150,6 @@ export const buildColor = (value, priority) => ({
|
|
|
194
150
|
priority,
|
|
195
151
|
value,
|
|
196
152
|
});
|
|
197
|
-
export const buildHighlight = () => ({
|
|
198
|
-
_id: generateID(ObjectTypes.Highlight),
|
|
199
|
-
objectType: ObjectTypes.Highlight,
|
|
200
|
-
});
|
|
201
|
-
export const buildHighlightMarker = (highlightID, start, offset, field) => ({
|
|
202
|
-
highlightID,
|
|
203
|
-
objectType: ObjectTypes.HighlightMarker,
|
|
204
|
-
_id: generateID(ObjectTypes.HighlightMarker),
|
|
205
|
-
start,
|
|
206
|
-
offset,
|
|
207
|
-
field,
|
|
208
|
-
});
|
|
209
153
|
export const buildContribution = (profileID) => ({
|
|
210
154
|
_id: generateID(ObjectTypes.Contribution),
|
|
211
155
|
objectType: ObjectTypes.Contribution,
|
|
@@ -217,12 +161,6 @@ export const buildContributorRole = (name) => ({
|
|
|
217
161
|
objectType: ObjectTypes.ContributorRole,
|
|
218
162
|
name,
|
|
219
163
|
});
|
|
220
|
-
export const buildInlineStyle = (priority, title) => ({
|
|
221
|
-
_id: generateID(ObjectTypes.InlineStyle),
|
|
222
|
-
objectType: ObjectTypes.InlineStyle,
|
|
223
|
-
priority,
|
|
224
|
-
title,
|
|
225
|
-
});
|
|
226
164
|
export const buildAttribution = () => ({
|
|
227
165
|
_id: generateID(ObjectTypes.Attribution),
|
|
228
166
|
objectType: ObjectTypes.Attribution,
|
|
@@ -231,11 +169,6 @@ export const buildJournal = () => ({
|
|
|
231
169
|
_id: generateID(ObjectTypes.Journal),
|
|
232
170
|
objectType: ObjectTypes.Journal,
|
|
233
171
|
});
|
|
234
|
-
export const buildStatusLabel = (name) => ({
|
|
235
|
-
_id: generateID(ObjectTypes.StatusLabel),
|
|
236
|
-
objectType: ObjectTypes.StatusLabel,
|
|
237
|
-
name,
|
|
238
|
-
});
|
|
239
172
|
export const auxiliaryObjectTypes = new Set([
|
|
240
173
|
schema.nodes.figure_element,
|
|
241
174
|
schema.nodes.table_element,
|