@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
@@ -1,103 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2020 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.parseJournal = exports.parseJournalMeta = exports.parseJournalISSNs = exports.parseJournalAbbreviatedTitles = exports.parseJournalIdentifiers = void 0;
19
- const json_schema_1 = require("@manuscripts/json-schema");
20
- const utils_1 = require("../../lib/utils");
21
- const parseJournalIdentifiers = (element) => {
22
- if (!element) {
23
- return [];
24
- }
25
- const output = [];
26
- const ids = element.querySelectorAll('journal-id');
27
- for (const id of ids) {
28
- const type = id.getAttribute('journal-id-type');
29
- const value = id.textContent?.trim();
30
- if (!value) {
31
- continue;
32
- }
33
- output.push({
34
- journalID: value,
35
- journalIDType: type ?? undefined,
36
- });
37
- }
38
- return output;
39
- };
40
- exports.parseJournalIdentifiers = parseJournalIdentifiers;
41
- const parseJournalAbbreviatedTitles = (element) => {
42
- if (!element) {
43
- return [];
44
- }
45
- const output = [];
46
- const titles = element.querySelectorAll('journal-title-group > abbrev-journal-title');
47
- for (const title of titles) {
48
- const type = title.getAttribute('abbrev-type');
49
- const value = title.textContent?.trim();
50
- if (!value) {
51
- continue;
52
- }
53
- output.push({
54
- abbreviatedTitle: value,
55
- abbrevType: type ?? undefined,
56
- });
57
- }
58
- return output;
59
- };
60
- exports.parseJournalAbbreviatedTitles = parseJournalAbbreviatedTitles;
61
- const parseJournalISSNs = (element) => {
62
- if (!element) {
63
- return [];
64
- }
65
- const output = [];
66
- const issns = element.querySelectorAll('issn');
67
- for (const issn of issns) {
68
- const type = issn.getAttribute('pub-type');
69
- const value = issn.textContent?.trim();
70
- if (!value) {
71
- continue;
72
- }
73
- output.push({
74
- ISSN: value,
75
- publicationType: type ?? undefined,
76
- });
77
- }
78
- return output;
79
- };
80
- exports.parseJournalISSNs = parseJournalISSNs;
81
- const parseJournalMeta = (element) => {
82
- return {
83
- abbreviatedTitles: (0, exports.parseJournalAbbreviatedTitles)(element),
84
- journalIdentifiers: (0, exports.parseJournalIdentifiers)(element),
85
- ISSNs: (0, exports.parseJournalISSNs)(element),
86
- publisherName: (0, utils_1.getTrimmedTextContent)(element, 'publisher > publisher-name') ?? undefined,
87
- title: (0, utils_1.getTrimmedTextContent)(element, 'journal-title-group > journal-title') ??
88
- undefined,
89
- };
90
- };
91
- exports.parseJournalMeta = parseJournalMeta;
92
- const parseJournal = (doc) => {
93
- const journalMeta = doc.querySelector('journal-meta');
94
- if (!journalMeta) {
95
- return;
96
- }
97
- const meta = (0, exports.parseJournalMeta)(journalMeta);
98
- return {
99
- ...meta,
100
- objectType: json_schema_1.ObjectTypes.Journal,
101
- };
102
- };
103
- exports.parseJournal = parseJournal;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2020 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.buildStyledContentClass = exports.normalizeStyleName = void 0;
19
- const normalizeStyleName = (title) => title.replace(/\W+/, '-').toLowerCase();
20
- exports.normalizeStyleName = normalizeStyleName;
21
- const buildStyledContentClass = (attrs, inlineStyle) => {
22
- const classes = ['styled-content'];
23
- if (inlineStyle && inlineStyle.title) {
24
- classes.push((0, exports.normalizeStyleName)(inlineStyle.title));
25
- }
26
- return classes.join(' ');
27
- };
28
- exports.buildStyledContentClass = buildStyledContentClass;
@@ -1,95 +0,0 @@
1
- /*!
2
- * © 2020 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { ObjectTypes } from '@manuscripts/json-schema';
17
- import { getTrimmedTextContent } from '../../lib/utils';
18
- export const parseJournalIdentifiers = (element) => {
19
- if (!element) {
20
- return [];
21
- }
22
- const output = [];
23
- const ids = element.querySelectorAll('journal-id');
24
- for (const id of ids) {
25
- const type = id.getAttribute('journal-id-type');
26
- const value = id.textContent?.trim();
27
- if (!value) {
28
- continue;
29
- }
30
- output.push({
31
- journalID: value,
32
- journalIDType: type ?? undefined,
33
- });
34
- }
35
- return output;
36
- };
37
- export const parseJournalAbbreviatedTitles = (element) => {
38
- if (!element) {
39
- return [];
40
- }
41
- const output = [];
42
- const titles = element.querySelectorAll('journal-title-group > abbrev-journal-title');
43
- for (const title of titles) {
44
- const type = title.getAttribute('abbrev-type');
45
- const value = title.textContent?.trim();
46
- if (!value) {
47
- continue;
48
- }
49
- output.push({
50
- abbreviatedTitle: value,
51
- abbrevType: type ?? undefined,
52
- });
53
- }
54
- return output;
55
- };
56
- export const parseJournalISSNs = (element) => {
57
- if (!element) {
58
- return [];
59
- }
60
- const output = [];
61
- const issns = element.querySelectorAll('issn');
62
- for (const issn of issns) {
63
- const type = issn.getAttribute('pub-type');
64
- const value = issn.textContent?.trim();
65
- if (!value) {
66
- continue;
67
- }
68
- output.push({
69
- ISSN: value,
70
- publicationType: type ?? undefined,
71
- });
72
- }
73
- return output;
74
- };
75
- export const parseJournalMeta = (element) => {
76
- return {
77
- abbreviatedTitles: parseJournalAbbreviatedTitles(element),
78
- journalIdentifiers: parseJournalIdentifiers(element),
79
- ISSNs: parseJournalISSNs(element),
80
- publisherName: getTrimmedTextContent(element, 'publisher > publisher-name') ?? undefined,
81
- title: getTrimmedTextContent(element, 'journal-title-group > journal-title') ??
82
- undefined,
83
- };
84
- };
85
- export const parseJournal = (doc) => {
86
- const journalMeta = doc.querySelector('journal-meta');
87
- if (!journalMeta) {
88
- return;
89
- }
90
- const meta = parseJournalMeta(journalMeta);
91
- return {
92
- ...meta,
93
- objectType: ObjectTypes.Journal,
94
- };
95
- };
@@ -1,23 +0,0 @@
1
- /*!
2
- * © 2020 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- export const normalizeStyleName = (title) => title.replace(/\W+/, '-').toLowerCase();
17
- export const buildStyledContentClass = (attrs, inlineStyle) => {
18
- const classes = ['styled-content'];
19
- if (inlineStyle && inlineStyle.title) {
20
- classes.push(normalizeStyleName(inlineStyle.title));
21
- }
22
- return classes.join(' ');
23
- };
@@ -1,46 +0,0 @@
1
- /*!
2
- * © 2020 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { ObjectTypes } from '@manuscripts/json-schema';
17
- export type ISSN = {
18
- ISSN: string;
19
- publicationType?: string;
20
- };
21
- export type AbbreviatedTitle = {
22
- abbreviatedTitle: string;
23
- abbrevType?: string;
24
- };
25
- export type JournalIdentifier = {
26
- journalID: string;
27
- journalIDType?: string;
28
- };
29
- export declare const parseJournalIdentifiers: (element: Element | null) => JournalIdentifier[];
30
- export declare const parseJournalAbbreviatedTitles: (element: Element | null) => AbbreviatedTitle[];
31
- export declare const parseJournalISSNs: (element: Element | null) => ISSN[];
32
- export declare const parseJournalMeta: (element: Element | null) => {
33
- abbreviatedTitles: AbbreviatedTitle[];
34
- journalIdentifiers: JournalIdentifier[];
35
- ISSNs: ISSN[];
36
- publisherName: string | undefined;
37
- title: string | undefined;
38
- };
39
- export declare const parseJournal: (doc: Document) => {
40
- objectType: ObjectTypes;
41
- abbreviatedTitles: AbbreviatedTitle[];
42
- journalIdentifiers: JournalIdentifier[];
43
- ISSNs: ISSN[];
44
- publisherName: string | undefined;
45
- title: string | undefined;
46
- } | undefined;
@@ -1,22 +0,0 @@
1
- /*!
2
- * © 2020 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { InlineStyle } from '@manuscripts/json-schema';
17
- interface StyledContentAttrs {
18
- rid?: string;
19
- }
20
- export declare const normalizeStyleName: (title: string) => string;
21
- export declare const buildStyledContentClass: (attrs: StyledContentAttrs, inlineStyle?: InlineStyle) => string;
22
- export {};