@manuscripts/transform 4.3.22 → 4.3.23

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.
Files changed (69) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/jats/__tests__/jats-exporter.test.js +11 -45
  3. package/dist/cjs/jats/__tests__/jats-importer.test.js +54 -76
  4. package/dist/cjs/jats/__tests__/jats-roundtrip.test.js +1 -2
  5. package/dist/cjs/jats/__tests__/utils.js +4 -17
  6. package/dist/cjs/jats/exporter/jats-exporter.js +190 -271
  7. package/dist/cjs/jats/importer/jats-dom-parser.js +16 -42
  8. package/dist/cjs/jats/importer/jats-parser-utils.js +5 -29
  9. package/dist/cjs/jats/importer/parse-jats-article.js +1 -6
  10. package/dist/cjs/schema/__tests__/docs.js +1830 -0
  11. package/dist/cjs/schema/__tests__/migration.test.js +3 -37
  12. package/dist/cjs/schema/migration/migration-scripts/4.3.12.js +39 -0
  13. package/dist/cjs/schema/migration/migration-scripts/index.js +2 -0
  14. package/dist/cjs/schema/nodes/blockquote_element.js +0 -2
  15. package/dist/cjs/schema/nodes/comment.js +2 -1
  16. package/dist/cjs/schema/nodes/contributor.js +11 -11
  17. package/dist/cjs/schema/nodes/equation.js +1 -3
  18. package/dist/cjs/schema/nodes/list.js +0 -2
  19. package/dist/cjs/schema/nodes/listing.js +1 -3
  20. package/dist/cjs/schema/nodes/paragraph.js +0 -2
  21. package/dist/cjs/schema/nodes/pullquote_element.js +0 -2
  22. package/dist/cjs/transformer/id.js +2 -14
  23. package/dist/cjs/transformer/node-names.js +6 -1
  24. package/dist/cjs/transformer/node-types.js +1 -47
  25. package/dist/cjs/version.js +1 -1
  26. package/dist/es/jats/__tests__/jats-exporter.test.js +11 -45
  27. package/dist/es/jats/__tests__/jats-importer.test.js +54 -76
  28. package/dist/es/jats/__tests__/jats-roundtrip.test.js +1 -2
  29. package/dist/es/jats/__tests__/utils.js +4 -17
  30. package/dist/es/jats/exporter/jats-exporter.js +190 -271
  31. package/dist/es/jats/importer/jats-dom-parser.js +16 -42
  32. package/dist/es/jats/importer/jats-parser-utils.js +6 -30
  33. package/dist/es/jats/importer/parse-jats-article.js +1 -6
  34. package/dist/es/schema/__tests__/docs.js +1827 -0
  35. package/dist/es/schema/__tests__/migration.test.js +3 -4
  36. package/dist/es/schema/migration/migration-scripts/4.3.12.js +37 -0
  37. package/dist/es/schema/migration/migration-scripts/index.js +2 -0
  38. package/dist/es/schema/nodes/blockquote_element.js +0 -2
  39. package/dist/es/schema/nodes/comment.js +2 -1
  40. package/dist/es/schema/nodes/contributor.js +11 -11
  41. package/dist/es/schema/nodes/equation.js +1 -3
  42. package/dist/es/schema/nodes/list.js +0 -2
  43. package/dist/es/schema/nodes/listing.js +1 -3
  44. package/dist/es/schema/nodes/paragraph.js +0 -2
  45. package/dist/es/schema/nodes/pullquote_element.js +0 -2
  46. package/dist/es/transformer/id.js +2 -14
  47. package/dist/es/transformer/node-names.js +4 -0
  48. package/dist/es/transformer/node-types.js +1 -47
  49. package/dist/es/version.js +1 -1
  50. package/dist/types/jats/__tests__/utils.d.ts +1 -11
  51. package/dist/types/jats/exporter/jats-exporter.d.ts +5 -10
  52. package/dist/types/jats/importer/jats-dom-parser.d.ts +0 -15
  53. package/dist/types/jats/importer/parse-jats-article.d.ts +1 -11
  54. package/dist/types/schema/__tests__/docs.d.ts +2 -0
  55. package/dist/types/schema/migration/migration-scripts/4.3.12.d.ts +8 -0
  56. package/dist/types/schema/migration/migration-scripts/index.d.ts +2 -1
  57. package/dist/types/schema/nodes/comment.d.ts +2 -2
  58. package/dist/types/schema/nodes/contributor.d.ts +11 -21
  59. package/dist/types/schema/types.d.ts +22 -0
  60. package/dist/types/transformer/node-names.d.ts +1 -0
  61. package/dist/types/transformer/node-types.d.ts +0 -2
  62. package/dist/types/version.d.ts +1 -1
  63. package/package.json +2 -2
  64. package/dist/cjs/jats/importer/jats-journal-meta-parser.js +0 -103
  65. package/dist/cjs/lib/styled-content.js +0 -28
  66. package/dist/es/jats/importer/jats-journal-meta-parser.js +0 -95
  67. package/dist/es/lib/styled-content.js +0 -23
  68. package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +0 -46
  69. 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 { schema, } from '../../schema';
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.type === schema.nodes.contributor) {
81
- const footnote = node.attrs.footnote
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
- footnote,
109
- corresp,
110
- affiliations,
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) {
@@ -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
  };