@manuscripts/transform 4.3.22 → 4.3.24
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/README.md +2 -2
- package/dist/cjs/jats/__tests__/jats-exporter.test.js +11 -45
- package/dist/cjs/jats/__tests__/jats-importer.test.js +54 -76
- package/dist/cjs/jats/__tests__/jats-roundtrip.test.js +1 -2
- package/dist/cjs/jats/__tests__/utils.js +4 -17
- package/dist/cjs/jats/exporter/jats-exporter.js +190 -279
- package/dist/cjs/jats/importer/jats-dom-parser.js +16 -42
- package/dist/cjs/jats/importer/jats-parser-utils.js +5 -29
- package/dist/cjs/jats/importer/jats-transformations.js +10 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +1 -6
- package/dist/cjs/schema/__tests__/docs.js +1830 -0
- package/dist/cjs/schema/__tests__/migration.test.js +3 -37
- package/dist/cjs/schema/migration/migration-scripts/4.3.12.js +39 -0
- package/dist/cjs/schema/migration/migration-scripts/index.js +2 -0
- package/dist/cjs/schema/nodes/blockquote_element.js +0 -2
- package/dist/cjs/schema/nodes/comment.js +2 -1
- package/dist/cjs/schema/nodes/contributor.js +11 -11
- package/dist/cjs/schema/nodes/equation.js +1 -3
- package/dist/cjs/schema/nodes/list.js +0 -2
- package/dist/cjs/schema/nodes/listing.js +1 -3
- package/dist/cjs/schema/nodes/paragraph.js +0 -2
- package/dist/cjs/schema/nodes/pullquote_element.js +0 -2
- package/dist/cjs/transformer/id.js +2 -14
- package/dist/cjs/transformer/node-names.js +6 -1
- package/dist/cjs/transformer/node-types.js +1 -47
- package/dist/cjs/version.js +1 -1
- package/dist/es/jats/__tests__/jats-exporter.test.js +11 -45
- package/dist/es/jats/__tests__/jats-importer.test.js +54 -76
- package/dist/es/jats/__tests__/jats-roundtrip.test.js +1 -2
- package/dist/es/jats/__tests__/utils.js +4 -17
- package/dist/es/jats/exporter/jats-exporter.js +190 -279
- package/dist/es/jats/importer/jats-dom-parser.js +16 -42
- package/dist/es/jats/importer/jats-parser-utils.js +6 -30
- package/dist/es/jats/importer/jats-transformations.js +10 -0
- package/dist/es/jats/importer/parse-jats-article.js +1 -6
- package/dist/es/schema/__tests__/docs.js +1827 -0
- package/dist/es/schema/__tests__/migration.test.js +3 -4
- package/dist/es/schema/migration/migration-scripts/4.3.12.js +37 -0
- package/dist/es/schema/migration/migration-scripts/index.js +2 -0
- package/dist/es/schema/nodes/blockquote_element.js +0 -2
- package/dist/es/schema/nodes/comment.js +2 -1
- package/dist/es/schema/nodes/contributor.js +11 -11
- package/dist/es/schema/nodes/equation.js +1 -3
- package/dist/es/schema/nodes/list.js +0 -2
- package/dist/es/schema/nodes/listing.js +1 -3
- package/dist/es/schema/nodes/paragraph.js +0 -2
- package/dist/es/schema/nodes/pullquote_element.js +0 -2
- package/dist/es/transformer/id.js +2 -14
- package/dist/es/transformer/node-names.js +4 -0
- package/dist/es/transformer/node-types.js +1 -47
- package/dist/es/version.js +1 -1
- package/dist/types/jats/__tests__/utils.d.ts +1 -11
- package/dist/types/jats/exporter/jats-exporter.d.ts +5 -10
- package/dist/types/jats/importer/jats-dom-parser.d.ts +0 -15
- package/dist/types/jats/importer/parse-jats-article.d.ts +1 -11
- package/dist/types/schema/__tests__/docs.d.ts +2 -0
- package/dist/types/schema/migration/migration-scripts/4.3.12.d.ts +8 -0
- package/dist/types/schema/migration/migration-scripts/index.d.ts +2 -1
- package/dist/types/schema/nodes/comment.d.ts +2 -2
- package/dist/types/schema/nodes/contributor.d.ts +11 -21
- package/dist/types/schema/types.d.ts +22 -0
- package/dist/types/transformer/node-names.d.ts +1 -0
- package/dist/types/transformer/node-types.d.ts +0 -2
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +0 -103
- package/dist/cjs/lib/styled-content.js +0 -28
- package/dist/es/jats/importer/jats-journal-meta-parser.js +0 -95
- package/dist/es/lib/styled-content.js +0 -23
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +0 -46
- package/dist/types/lib/styled-content.d.ts +0 -22
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { isContributorNode, schema } from '../../schema';
|
|
17
17
|
import { generateNodeID } from '../../transformer';
|
|
18
18
|
export const updateDocumentIDs = (node) => {
|
|
19
19
|
const replacements = new Map();
|
|
@@ -77,37 +77,13 @@ const updateNodeRIDS = (node, replacements, warnings) => {
|
|
|
77
77
|
};
|
|
78
78
|
};
|
|
79
79
|
const updateContributorNodesIDS = (node, replacements, warnings) => {
|
|
80
|
-
if (node
|
|
81
|
-
const
|
|
82
|
-
?.map((fn) => {
|
|
83
|
-
return replacements.get(fn.noteID)
|
|
84
|
-
? {
|
|
85
|
-
...fn,
|
|
86
|
-
noteID: replacements.get(fn.noteID),
|
|
87
|
-
}
|
|
88
|
-
: undefined;
|
|
89
|
-
})
|
|
90
|
-
.filter(Boolean);
|
|
91
|
-
const corresp = node.attrs.corresp
|
|
92
|
-
?.map((corresp) => {
|
|
93
|
-
return replacements.get(corresp.correspID)
|
|
94
|
-
? {
|
|
95
|
-
...corresp,
|
|
96
|
-
correspID: replacements.get(corresp.correspID),
|
|
97
|
-
}
|
|
98
|
-
: undefined;
|
|
99
|
-
})
|
|
100
|
-
.filter(Boolean);
|
|
101
|
-
const affiliations = node.attrs.affiliations
|
|
102
|
-
.map((affiliation) => {
|
|
103
|
-
return replacements.get(affiliation);
|
|
104
|
-
})
|
|
105
|
-
.filter(Boolean);
|
|
80
|
+
if (isContributorNode(node)) {
|
|
81
|
+
const replaceAll = (ids) => ids?.map((i) => replacements.get(i)).filter((id) => !!id);
|
|
106
82
|
node.attrs = {
|
|
107
83
|
...node.attrs,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
84
|
+
footnoteIDs: replaceAll(node.attrs.footnoteIDs),
|
|
85
|
+
correspIDs: replaceAll(node.attrs.correspIDs),
|
|
86
|
+
affiliationIDs: replaceAll(node.attrs.affiliationIDs),
|
|
111
87
|
};
|
|
112
88
|
}
|
|
113
89
|
if (node.type !== schema.nodes.contributors) {
|
|
@@ -364,6 +364,16 @@ export const fixTables = (doc, body, createElement) => {
|
|
|
364
364
|
if (!table) {
|
|
365
365
|
return;
|
|
366
366
|
}
|
|
367
|
+
const tfoot = table.querySelector('tfoot');
|
|
368
|
+
const tbody = table.querySelector('tbody');
|
|
369
|
+
if (tfoot && tbody) {
|
|
370
|
+
const tfootRows = Array.from(tfoot.querySelectorAll(':scope > tr'));
|
|
371
|
+
for (const row of tfootRows) {
|
|
372
|
+
removeNodeFromParent(row);
|
|
373
|
+
tbody.appendChild(row);
|
|
374
|
+
}
|
|
375
|
+
removeNodeFromParent(tfoot);
|
|
376
|
+
}
|
|
367
377
|
const colgroup = table.querySelector('colgroup');
|
|
368
378
|
const cols = table.querySelectorAll('col');
|
|
369
379
|
if (!colgroup && table.firstChild && cols.length > 0) {
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
import { schema } from '../../schema';
|
|
17
17
|
import { markComments } from './jats-comments';
|
|
18
18
|
import { JATSDOMParser } from './jats-dom-parser';
|
|
19
|
-
import { parseJournal } from './jats-journal-meta-parser';
|
|
20
19
|
import { updateDocumentIDs } from './jats-parser-utils';
|
|
21
20
|
import { addMissingCaptions, createAbstracts, createAccessibilityItems, createAttachments, createBackmatter, createBody, createBoxedElementSection, createKeywordsSection, createSupplementaryMaterialsSection, createTitles, fixTables, moveAffiliations, moveAuthorNotes, moveAwards, moveCaptionsToEnd, moveContributors, moveHeroImage, moveReferencesToBackmatter, orderTableFootnote, } from './jats-transformations';
|
|
22
21
|
const processJATS = (doc, sectionCategories) => {
|
|
@@ -61,7 +60,6 @@ const processJATS = (doc, sectionCategories) => {
|
|
|
61
60
|
};
|
|
62
61
|
const createElementFn = (doc) => (tagName) => doc.createElement(tagName);
|
|
63
62
|
export const parseJATSArticle = (doc, sectionCategories, template) => {
|
|
64
|
-
const journal = parseJournal(doc);
|
|
65
63
|
processJATS(doc, sectionCategories);
|
|
66
64
|
const node = new JATSDOMParser(sectionCategories, schema).parse(doc)
|
|
67
65
|
.firstChild;
|
|
@@ -72,8 +70,5 @@ export const parseJATSArticle = (doc, sectionCategories, template) => {
|
|
|
72
70
|
if (template) {
|
|
73
71
|
node.attrs.prototype = template;
|
|
74
72
|
}
|
|
75
|
-
return
|
|
76
|
-
node,
|
|
77
|
-
journal,
|
|
78
|
-
};
|
|
73
|
+
return node;
|
|
79
74
|
};
|