@manuscripts/transform 4.2.10 → 4.2.11

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.
@@ -50,13 +50,12 @@ const citeproc_1 = require("../../lib/citeproc");
50
50
  const credit_roles_1 = require("../../lib/credit-roles");
51
51
  const footnotes_1 = require("../../lib/footnotes");
52
52
  const html_1 = require("../../lib/html");
53
+ const xml_1 = require("../../lib/xml");
53
54
  const schema_1 = require("../../schema");
54
55
  const transformer_1 = require("../../transformer");
55
56
  const citeproc_2 = require("./citeproc");
56
57
  const jats_versions_1 = require("./jats-versions");
57
58
  const labels_1 = require("./labels");
58
- const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
59
- const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
60
59
  const normalizeID = (id) => id.replace(/:/g, '_');
61
60
  const parser = prosemirror_model_1.DOMParser.fromSchema(schema_1.schema);
62
61
  const insertAbstractNode = (front, abstractNode) => {
@@ -128,10 +127,11 @@ class JATSExporter {
128
127
  const versionIds = (0, jats_versions_1.selectVersionIds)(options.version ?? '1.2');
129
128
  this.document = document.implementation.createDocument(null, 'article', document.implementation.createDocumentType('article', versionIds.publicId, versionIds.systemId));
130
129
  const article = this.document.documentElement;
131
- article.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', XLINK_NAMESPACE);
130
+ article.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', xml_1.XLINK_NAMESPACE);
132
131
  const front = this.buildFront(options.journal);
133
132
  article.appendChild(front);
134
133
  article.setAttribute('article-type', manuscriptNode.attrs.articleType || 'other');
134
+ article.setAttributeNS(xml_1.XML_NAMESPACE, 'lang', manuscriptNode.attrs.primaryLanguageCode || 'en');
135
135
  this.labelTargets = (0, labels_1.buildTargets)(manuscriptNode);
136
136
  this.footnoteLabels = (0, footnotes_1.generateFootnoteLabels)(manuscriptNode);
137
137
  const body = this.buildBody();
@@ -315,7 +315,7 @@ class JATSExporter {
315
315
  supplementsNodes.forEach((node) => {
316
316
  const supplementaryMaterial = this.createElement('supplementary-material');
317
317
  supplementaryMaterial.setAttribute('id', normalizeID(node.attrs.id));
318
- supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', node.attrs.href ?? '');
318
+ supplementaryMaterial.setAttributeNS(xml_1.XLINK_NAMESPACE, 'href', node.attrs.href ?? '');
319
319
  supplementaryMaterial.setAttribute('mimetype', node.attrs.mimeType ?? '');
320
320
  supplementaryMaterial.setAttribute('mime-subtype', node.attrs.mimeSubType ?? '');
321
321
  const caption = this.createElement('caption');
@@ -378,7 +378,7 @@ class JATSExporter {
378
378
  selfUriAttachments.forEach((attachment) => {
379
379
  const selfUriElement = this.createElement('self-uri');
380
380
  selfUriElement.setAttribute('content-type', attachment.attrs.type);
381
- selfUriElement.setAttributeNS(XLINK_NAMESPACE, 'href', attachment.attrs.href);
381
+ selfUriElement.setAttributeNS(xml_1.XLINK_NAMESPACE, 'href', attachment.attrs.href);
382
382
  const insertBeforeElements = articleMeta.querySelector('related-article, related-object, abstract, trans-abstract, kwd-group, funding-group, support-group, conference, counts, custom-meta-group');
383
383
  insertBeforeElements
384
384
  ? articleMeta.insertBefore(selfUriElement, insertBeforeElements)
@@ -443,7 +443,7 @@ class JATSExporter {
443
443
  const parser = new DOMParser();
444
444
  const [_, bibliography] = this.engine.makeBibliography();
445
445
  for (let i = 0; i < bibliography.length; i++) {
446
- const item = `<template xmlns:xlink="${XLINK_NAMESPACE}">${bibliography[i]}</template>`;
446
+ const item = `<template xmlns:xlink="${xml_1.XLINK_NAMESPACE}">${bibliography[i]}</template>`;
447
447
  const ref = parser.parseFromString(item, 'text/xml').querySelector('ref');
448
448
  if (ref) {
449
449
  refList.appendChild(ref);
@@ -473,7 +473,7 @@ class JATSExporter {
473
473
  id: normalizeID(node.attrs.id),
474
474
  };
475
475
  if (node.attrs.lang) {
476
- attrs[`${XML_NAMESPACE} lang`] = node.attrs.lang;
476
+ attrs[`${xml_1.XML_NAMESPACE} lang`] = node.attrs.lang;
477
477
  }
478
478
  if (node.attrs.category) {
479
479
  attrs['sec-type'] = node.attrs.category;
@@ -507,8 +507,8 @@ class JATSExporter {
507
507
  }
508
508
  const mediaElement = this.createElement('media');
509
509
  mediaElement.setAttribute('id', normalizeID(id));
510
- mediaElement.setAttributeNS(XLINK_NAMESPACE, 'show', 'embed');
511
- mediaElement.setAttributeNS(XLINK_NAMESPACE, 'href', href);
510
+ mediaElement.setAttributeNS(xml_1.XLINK_NAMESPACE, 'show', 'embed');
511
+ mediaElement.setAttributeNS(xml_1.XLINK_NAMESPACE, 'href', href);
512
512
  if (mimetype) {
513
513
  mediaElement.setAttribute('mimetype', node.attrs.mimetype);
514
514
  }
@@ -686,10 +686,10 @@ class JATSExporter {
686
686
  }
687
687
  const linkNode = this.createElement('ext-link');
688
688
  linkNode.setAttribute('ext-link-type', 'uri');
689
- linkNode.setAttributeNS(XLINK_NAMESPACE, 'href', node.attrs.href);
689
+ linkNode.setAttributeNS(xml_1.XLINK_NAMESPACE, 'href', node.attrs.href);
690
690
  linkNode.textContent = text;
691
691
  if (node.attrs.title) {
692
- linkNode.setAttributeNS(XLINK_NAMESPACE, 'xlink:title', node.attrs.title);
692
+ linkNode.setAttributeNS(xml_1.XLINK_NAMESPACE, 'xlink:title', node.attrs.title);
693
693
  }
694
694
  return linkNode;
695
695
  },
@@ -706,7 +706,7 @@ class JATSExporter {
706
706
  missing_figure: () => {
707
707
  const graphic = this.createElement('graphic');
708
708
  graphic.setAttribute('specific-use', 'MISSING');
709
- graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', '');
709
+ graphic.setAttributeNS(xml_1.XLINK_NAMESPACE, 'xlink:href', '');
710
710
  return graphic;
711
711
  },
712
712
  paragraph: (node) => {
@@ -909,7 +909,7 @@ class JATSExporter {
909
909
  const graphicElement = createGraphic(graphicNode);
910
910
  if (node.attrs.extLink) {
911
911
  const extLink = this.appendElement(graphicElement, 'ext-link');
912
- extLink.setAttributeNS(XLINK_NAMESPACE, 'href', node.attrs.extLink);
912
+ extLink.setAttributeNS(xml_1.XLINK_NAMESPACE, 'href', node.attrs.extLink);
913
913
  }
914
914
  appendChildNodeOfType(graphicElement, node, schema_1.schema.nodes.alt_text);
915
915
  appendChildNodeOfType(graphicElement, node, schema_1.schema.nodes.long_desc);
@@ -917,7 +917,7 @@ class JATSExporter {
917
917
  };
918
918
  const createGraphic = (node) => {
919
919
  const graphic = this.createElement('graphic');
920
- graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', node.attrs.src);
920
+ graphic.setAttributeNS(xml_1.XLINK_NAMESPACE, 'xlink:href', node.attrs.src);
921
921
  if (isChildOfNodeType(node.attrs.id, schema_1.schema.nodes.hero_image)) {
922
922
  graphic.setAttribute('content-type', 'leading');
923
923
  }
@@ -1134,7 +1134,7 @@ class JATSExporter {
1134
1134
  }
1135
1135
  if (affiliation.attrs.email) {
1136
1136
  const email = this.createElement('email');
1137
- email.setAttributeNS(XLINK_NAMESPACE, 'href', affiliation.attrs.email.href ?? '');
1137
+ email.setAttributeNS(xml_1.XLINK_NAMESPACE, 'href', affiliation.attrs.email.href ?? '');
1138
1138
  email.textContent = affiliation.attrs.email.text ?? '';
1139
1139
  aff.appendChild(email);
1140
1140
  }
@@ -1531,7 +1531,7 @@ class JATSExporter {
1531
1531
  }
1532
1532
  createTransAbstractNode(transAbstract) {
1533
1533
  const transAbstractNode = this.createElement('trans-abstract');
1534
- transAbstractNode.setAttributeNS(XML_NAMESPACE, 'lang', transAbstract.getAttributeNS(XML_NAMESPACE, 'lang') ?? '');
1534
+ transAbstractNode.setAttributeNS(xml_1.XML_NAMESPACE, 'lang', transAbstract.getAttributeNS(xml_1.XML_NAMESPACE, 'lang') ?? '');
1535
1535
  this.setAbstractType(transAbstractNode, transAbstract);
1536
1536
  transAbstractNode.append(...transAbstract.childNodes);
1537
1537
  return transAbstractNode;
@@ -19,12 +19,12 @@ exports.JATSDOMParser = void 0;
19
19
  const json_schema_1 = require("@manuscripts/json-schema");
20
20
  const prosemirror_model_1 = require("prosemirror-model");
21
21
  const utils_1 = require("../../lib/utils");
22
+ const xml_1 = require("../../lib/xml");
22
23
  const jats_comments_1 = require("./jats-comments");
23
24
  class JATSDOMParser {
24
25
  constructor(sectionCategories, schema) {
25
26
  this.sectionCategories = sectionCategories;
26
27
  this.schema = schema;
27
- this.XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
28
28
  this.parsePriority = (priority) => {
29
29
  if (!priority) {
30
30
  return undefined;
@@ -92,7 +92,7 @@ class JATSDOMParser {
92
92
  const email = element.querySelector('email');
93
93
  if (email) {
94
94
  return {
95
- href: email.getAttributeNS(this.XLINK_NAMESPACE, 'href') ?? '',
95
+ href: email.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href') ?? '',
96
96
  text: (0, utils_1.getTrimmedTextContent)(email) ?? '',
97
97
  };
98
98
  }
@@ -106,8 +106,8 @@ class JATSDOMParser {
106
106
  type: parentElement?.getAttribute('fig-type') ??
107
107
  element.getAttribute('content-type') ??
108
108
  '',
109
- src: element.getAttributeNS(this.XLINK_NAMESPACE, 'href'),
110
- extLink: extLink?.getAttributeNS(this.XLINK_NAMESPACE, 'href'),
109
+ src: element.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href'),
110
+ extLink: extLink?.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href'),
111
111
  };
112
112
  };
113
113
  this.getInstitutionDetails = (element) => {
@@ -220,7 +220,7 @@ class JATSDOMParser {
220
220
  const element = node;
221
221
  return {
222
222
  id: element.getAttribute('id'),
223
- href: element.getAttributeNS(this.XLINK_NAMESPACE, 'href') || '',
223
+ href: element.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href') || '',
224
224
  type: element.getAttribute('content-type') || '',
225
225
  };
226
226
  },
@@ -236,7 +236,7 @@ class JATSDOMParser {
236
236
  return {
237
237
  doi: (0, utils_1.getTrimmedTextContent)(doi),
238
238
  articleType: element.getAttribute('article-type') || '',
239
- primaryLanguageCode: element.getAttribute('lang') ?? '',
239
+ primaryLanguageCode: element.getAttributeNS(xml_1.XML_NAMESPACE, 'lang'),
240
240
  ...dates,
241
241
  };
242
242
  },
@@ -576,8 +576,8 @@ class JATSDOMParser {
576
576
  getAttrs: (node) => {
577
577
  const element = node;
578
578
  return {
579
- href: element.getAttributeNS(this.XLINK_NAMESPACE, 'href') || '',
580
- title: element.getAttributeNS(this.XLINK_NAMESPACE, 'title') || '',
579
+ href: element.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href') || '',
580
+ title: element.getAttributeNS(xml_1.XLINK_NAMESPACE, 'title') || '',
581
581
  };
582
582
  },
583
583
  },
@@ -598,7 +598,7 @@ class JATSDOMParser {
598
598
  const element = node;
599
599
  return {
600
600
  id: element.getAttribute('id'),
601
- href: element.getAttributeNS(this.XLINK_NAMESPACE, 'href'),
601
+ href: element.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href'),
602
602
  mimetype: element.getAttribute('mimetype'),
603
603
  mimeSubtype: element.getAttribute('mime-subtype'),
604
604
  };
@@ -773,7 +773,7 @@ class JATSDOMParser {
773
773
  const element = node;
774
774
  return {
775
775
  id: element.getAttribute('id'),
776
- href: element.getAttributeNS(this.XLINK_NAMESPACE, 'href'),
776
+ href: element.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href'),
777
777
  mimeType: element.getAttribute('mimetype'),
778
778
  mimeSubType: element.getAttribute('mime-subtype'),
779
779
  title: (0, utils_1.getTrimmedTextContent)(element, 'title'),
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2025 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.XML_NAMESPACE = exports.XLINK_NAMESPACE = void 0;
19
+ exports.XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
20
+ exports.XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "4.2.10";
4
+ exports.VERSION = "4.2.11";
@@ -21,13 +21,12 @@ import { buildCiteprocCitation } from '../../lib/citeproc';
21
21
  import { CreditRoleUrls } from '../../lib/credit-roles';
22
22
  import { generateFootnoteLabels } from '../../lib/footnotes';
23
23
  import { nodeFromHTML } from '../../lib/html';
24
+ import { XLINK_NAMESPACE, XML_NAMESPACE } from '../../lib/xml';
24
25
  import { isBibliographyItemNode, isCitationNode, isNodeOfType, schema, } from '../../schema';
25
26
  import { isExecutableNodeType, isNodeType } from '../../transformer';
26
27
  import { initJats, jatsVariableWrapper } from './citeproc';
27
28
  import { selectVersionIds } from './jats-versions';
28
29
  import { buildTargets } from './labels';
29
- const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
30
- const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
31
30
  const normalizeID = (id) => id.replace(/:/g, '_');
32
31
  const parser = ProsemirrorDOMParser.fromSchema(schema);
33
32
  const insertAbstractNode = (front, abstractNode) => {
@@ -102,6 +101,7 @@ export class JATSExporter {
102
101
  const front = this.buildFront(options.journal);
103
102
  article.appendChild(front);
104
103
  article.setAttribute('article-type', manuscriptNode.attrs.articleType || 'other');
104
+ article.setAttributeNS(XML_NAMESPACE, 'lang', manuscriptNode.attrs.primaryLanguageCode || 'en');
105
105
  this.labelTargets = buildTargets(manuscriptNode);
106
106
  this.footnoteLabels = generateFootnoteLabels(manuscriptNode);
107
107
  const body = this.buildBody();
@@ -16,12 +16,12 @@
16
16
  import { buildContribution, ObjectTypes } from '@manuscripts/json-schema';
17
17
  import { DOMParser, Fragment } from 'prosemirror-model';
18
18
  import { dateToTimestamp, getCreditRole, getHTMLContent, getTrimmedTextContent, } from '../../lib/utils';
19
+ import { XLINK_NAMESPACE, XML_NAMESPACE } from '../../lib/xml';
19
20
  import { DEFAULT_PROFILE_ID } from './jats-comments';
20
21
  export class JATSDOMParser {
21
22
  constructor(sectionCategories, schema) {
22
23
  this.sectionCategories = sectionCategories;
23
24
  this.schema = schema;
24
- this.XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
25
25
  this.parsePriority = (priority) => {
26
26
  if (!priority) {
27
27
  return undefined;
@@ -89,7 +89,7 @@ export class JATSDOMParser {
89
89
  const email = element.querySelector('email');
90
90
  if (email) {
91
91
  return {
92
- href: email.getAttributeNS(this.XLINK_NAMESPACE, 'href') ?? '',
92
+ href: email.getAttributeNS(XLINK_NAMESPACE, 'href') ?? '',
93
93
  text: getTrimmedTextContent(email) ?? '',
94
94
  };
95
95
  }
@@ -103,8 +103,8 @@ export class JATSDOMParser {
103
103
  type: parentElement?.getAttribute('fig-type') ??
104
104
  element.getAttribute('content-type') ??
105
105
  '',
106
- src: element.getAttributeNS(this.XLINK_NAMESPACE, 'href'),
107
- extLink: extLink?.getAttributeNS(this.XLINK_NAMESPACE, 'href'),
106
+ src: element.getAttributeNS(XLINK_NAMESPACE, 'href'),
107
+ extLink: extLink?.getAttributeNS(XLINK_NAMESPACE, 'href'),
108
108
  };
109
109
  };
110
110
  this.getInstitutionDetails = (element) => {
@@ -217,7 +217,7 @@ export class JATSDOMParser {
217
217
  const element = node;
218
218
  return {
219
219
  id: element.getAttribute('id'),
220
- href: element.getAttributeNS(this.XLINK_NAMESPACE, 'href') || '',
220
+ href: element.getAttributeNS(XLINK_NAMESPACE, 'href') || '',
221
221
  type: element.getAttribute('content-type') || '',
222
222
  };
223
223
  },
@@ -233,7 +233,7 @@ export class JATSDOMParser {
233
233
  return {
234
234
  doi: getTrimmedTextContent(doi),
235
235
  articleType: element.getAttribute('article-type') || '',
236
- primaryLanguageCode: element.getAttribute('lang') ?? '',
236
+ primaryLanguageCode: element.getAttributeNS(XML_NAMESPACE, 'lang'),
237
237
  ...dates,
238
238
  };
239
239
  },
@@ -573,8 +573,8 @@ export class JATSDOMParser {
573
573
  getAttrs: (node) => {
574
574
  const element = node;
575
575
  return {
576
- href: element.getAttributeNS(this.XLINK_NAMESPACE, 'href') || '',
577
- title: element.getAttributeNS(this.XLINK_NAMESPACE, 'title') || '',
576
+ href: element.getAttributeNS(XLINK_NAMESPACE, 'href') || '',
577
+ title: element.getAttributeNS(XLINK_NAMESPACE, 'title') || '',
578
578
  };
579
579
  },
580
580
  },
@@ -595,7 +595,7 @@ export class JATSDOMParser {
595
595
  const element = node;
596
596
  return {
597
597
  id: element.getAttribute('id'),
598
- href: element.getAttributeNS(this.XLINK_NAMESPACE, 'href'),
598
+ href: element.getAttributeNS(XLINK_NAMESPACE, 'href'),
599
599
  mimetype: element.getAttribute('mimetype'),
600
600
  mimeSubtype: element.getAttribute('mime-subtype'),
601
601
  };
@@ -770,7 +770,7 @@ export class JATSDOMParser {
770
770
  const element = node;
771
771
  return {
772
772
  id: element.getAttribute('id'),
773
- href: element.getAttributeNS(this.XLINK_NAMESPACE, 'href'),
773
+ href: element.getAttributeNS(XLINK_NAMESPACE, 'href'),
774
774
  mimeType: element.getAttribute('mimetype'),
775
775
  mimeSubType: element.getAttribute('mime-subtype'),
776
776
  title: getTrimmedTextContent(element, 'title'),
@@ -0,0 +1,17 @@
1
+ /*!
2
+ * © 2025 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 XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
17
+ export const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
@@ -1 +1 @@
1
- export const VERSION = "4.2.10";
1
+ export const VERSION = "4.2.11";
@@ -18,7 +18,6 @@ import { SectionCategory } from '../../schema';
18
18
  export declare class JATSDOMParser {
19
19
  private sectionCategories;
20
20
  private schema;
21
- private XLINK_NAMESPACE;
22
21
  private parser;
23
22
  constructor(sectionCategories: SectionCategory[], schema: Schema);
24
23
  parse(doc: Node, options?: ParseOptions): import("prosemirror-model").Node;
@@ -0,0 +1,17 @@
1
+ /*!
2
+ * © 2025 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 declare const XLINK_NAMESPACE = "http://www.w3.org/1999/xlink";
17
+ export declare const XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
@@ -1 +1 @@
1
- export declare const VERSION = "4.2.10";
1
+ export declare const VERSION = "4.2.11";
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.2.10",
4
+ "version": "4.2.11",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",