@manuscripts/transform 1.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/LICENSE +201 -0
- package/README.md +193 -0
- package/dist/cjs/errors.js +17 -0
- package/dist/cjs/index.js +27 -0
- package/dist/cjs/jats/importer/index.js +24 -0
- package/dist/cjs/jats/importer/jats-body-dom-parser.js +650 -0
- package/dist/cjs/jats/importer/jats-body-transformations.js +269 -0
- package/dist/cjs/jats/importer/jats-comments.js +131 -0
- package/dist/cjs/jats/importer/jats-front-parser.js +341 -0
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +77 -0
- package/dist/cjs/jats/importer/jats-parser-utils.js +145 -0
- package/dist/cjs/jats/importer/jats-reference-parser.js +180 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +237 -0
- package/dist/cjs/jats/index.js +40 -0
- package/dist/cjs/jats/jats-exporter.js +1569 -0
- package/dist/cjs/jats/jats-versions.js +41 -0
- package/dist/cjs/lib/attributes.js +26 -0
- package/dist/cjs/lib/html.js +48 -0
- package/dist/cjs/lib/styled-content.js +28 -0
- package/dist/cjs/lib/table-cell-styles.js +52 -0
- package/dist/cjs/lib/utils.js +66 -0
- package/dist/cjs/mathjax/index.js +41 -0
- package/dist/cjs/mathjax/mathjax-packages.js +20 -0
- package/dist/cjs/mathjax/mathml-to-svg.js +56 -0
- package/dist/cjs/mathjax/tex-to-mathml.js +49 -0
- package/dist/cjs/mathjax/tex-to-svg.js +59 -0
- package/dist/cjs/schema/groups.js +31 -0
- package/dist/cjs/schema/index.js +195 -0
- package/dist/cjs/schema/marks.js +159 -0
- package/dist/cjs/schema/nodes/attribution.js +32 -0
- package/dist/cjs/schema/nodes/bibliography_element.js +44 -0
- package/dist/cjs/schema/nodes/bibliography_item.js +101 -0
- package/dist/cjs/schema/nodes/bibliography_section.js +46 -0
- package/dist/cjs/schema/nodes/blockquote_element.js +62 -0
- package/dist/cjs/schema/nodes/caption.js +52 -0
- package/dist/cjs/schema/nodes/caption_title.js +51 -0
- package/dist/cjs/schema/nodes/citation.js +52 -0
- package/dist/cjs/schema/nodes/comment.js +26 -0
- package/dist/cjs/schema/nodes/cross_reference.js +58 -0
- package/dist/cjs/schema/nodes/doc.js +21 -0
- package/dist/cjs/schema/nodes/equation.js +55 -0
- package/dist/cjs/schema/nodes/equation_element.js +52 -0
- package/dist/cjs/schema/nodes/figcaption.js +31 -0
- package/dist/cjs/schema/nodes/figure.js +52 -0
- package/dist/cjs/schema/nodes/figure_element.js +78 -0
- package/dist/cjs/schema/nodes/footnote.js +67 -0
- package/dist/cjs/schema/nodes/footnotes_element.js +54 -0
- package/dist/cjs/schema/nodes/footnotes_section.js +45 -0
- package/dist/cjs/schema/nodes/graphical_abstract_section.js +46 -0
- package/dist/cjs/schema/nodes/hard_break.js +30 -0
- package/dist/cjs/schema/nodes/highlight_marker.js +53 -0
- package/dist/cjs/schema/nodes/inline_equation.js +58 -0
- package/dist/cjs/schema/nodes/inline_footnote.js +51 -0
- package/dist/cjs/schema/nodes/keywords_element.js +52 -0
- package/dist/cjs/schema/nodes/keywords_section.js +46 -0
- package/dist/cjs/schema/nodes/link.js +61 -0
- package/dist/cjs/schema/nodes/list.js +121 -0
- package/dist/cjs/schema/nodes/listing.js +73 -0
- package/dist/cjs/schema/nodes/listing_element.js +52 -0
- package/dist/cjs/schema/nodes/manuscript.js +46 -0
- package/dist/cjs/schema/nodes/missing_figure.js +50 -0
- package/dist/cjs/schema/nodes/paragraph.js +63 -0
- package/dist/cjs/schema/nodes/placeholder.js +49 -0
- package/dist/cjs/schema/nodes/placeholder_element.js +48 -0
- package/dist/cjs/schema/nodes/pullquote_element.js +65 -0
- package/dist/cjs/schema/nodes/section.js +94 -0
- package/dist/cjs/schema/nodes/section_label.js +30 -0
- package/dist/cjs/schema/nodes/section_title.js +48 -0
- package/dist/cjs/schema/nodes/table.js +70 -0
- package/dist/cjs/schema/nodes/table_col.js +57 -0
- package/dist/cjs/schema/nodes/table_element.js +62 -0
- package/dist/cjs/schema/nodes/table_row.js +123 -0
- package/dist/cjs/schema/nodes/text.js +21 -0
- package/dist/cjs/schema/nodes/toc_element.js +52 -0
- package/dist/cjs/schema/nodes/toc_section.js +46 -0
- package/dist/cjs/schema/types.js +17 -0
- package/dist/cjs/tests.js +30 -0
- package/dist/cjs/transformer/builders.js +305 -0
- package/dist/cjs/transformer/bundles-data.js +36 -0
- package/dist/cjs/transformer/bundles.js +32 -0
- package/dist/cjs/transformer/decode.js +619 -0
- package/dist/cjs/transformer/document-object-types.js +31 -0
- package/dist/cjs/transformer/encode.js +545 -0
- package/dist/cjs/transformer/filename.js +27 -0
- package/dist/cjs/transformer/footnote-category.js +20 -0
- package/dist/cjs/transformer/footnotes-order.js +59 -0
- package/dist/cjs/transformer/highlight-markers.js +126 -0
- package/dist/cjs/transformer/html.js +414 -0
- package/dist/cjs/transformer/id.js +28 -0
- package/dist/cjs/transformer/index.js +54 -0
- package/dist/cjs/transformer/labels.js +85 -0
- package/dist/cjs/transformer/manuscript-dependencies.js +74 -0
- package/dist/cjs/transformer/model-map.js +26 -0
- package/dist/cjs/transformer/models.js +17 -0
- package/dist/cjs/transformer/node-names.js +42 -0
- package/dist/cjs/transformer/node-title.js +87 -0
- package/dist/cjs/transformer/node-types.js +62 -0
- package/dist/cjs/transformer/object-types.js +57 -0
- package/dist/cjs/transformer/project-bundle.js +86 -0
- package/dist/cjs/transformer/section-category.js +222 -0
- package/dist/cjs/transformer/serializer.js +23 -0
- package/dist/cjs/transformer/shared-data.js +31 -0
- package/dist/cjs/transformer/tei-grobid-importer.js +121 -0
- package/dist/cjs/transformer/timestamp.js +20 -0
- package/dist/cjs/transformer/update-identifiers.js +93 -0
- package/dist/cjs/types.js +2 -0
- package/dist/es/errors.js +12 -0
- package/dist/es/index.js +9 -0
- package/dist/es/jats/importer/index.js +16 -0
- package/dist/es/jats/importer/jats-body-dom-parser.js +644 -0
- package/dist/es/jats/importer/jats-body-transformations.js +266 -0
- package/dist/es/jats/importer/jats-comments.js +124 -0
- package/dist/es/jats/importer/jats-front-parser.js +335 -0
- package/dist/es/jats/importer/jats-journal-meta-parser.js +70 -0
- package/dist/es/jats/importer/jats-parser-utils.js +139 -0
- package/dist/es/jats/importer/jats-reference-parser.js +177 -0
- package/dist/es/jats/importer/parse-jats-article.js +229 -0
- package/dist/es/jats/index.js +18 -0
- package/dist/es/jats/jats-exporter.js +1561 -0
- package/dist/es/jats/jats-versions.js +36 -0
- package/dist/es/lib/attributes.js +22 -0
- package/dist/es/lib/html.js +43 -0
- package/dist/es/lib/styled-content.js +23 -0
- package/dist/es/lib/table-cell-styles.js +47 -0
- package/dist/es/lib/utils.js +59 -0
- package/dist/es/mathjax/index.js +12 -0
- package/dist/es/mathjax/mathjax-packages.js +17 -0
- package/dist/es/mathjax/mathml-to-svg.js +52 -0
- package/dist/es/mathjax/tex-to-mathml.js +45 -0
- package/dist/es/mathjax/tex-to-svg.js +55 -0
- package/dist/es/schema/groups.js +27 -0
- package/dist/es/schema/index.js +178 -0
- package/dist/es/schema/marks.js +156 -0
- package/dist/es/schema/nodes/attribution.js +29 -0
- package/dist/es/schema/nodes/bibliography_element.js +41 -0
- package/dist/es/schema/nodes/bibliography_item.js +98 -0
- package/dist/es/schema/nodes/bibliography_section.js +42 -0
- package/dist/es/schema/nodes/blockquote_element.js +58 -0
- package/dist/es/schema/nodes/caption.js +49 -0
- package/dist/es/schema/nodes/caption_title.js +48 -0
- package/dist/es/schema/nodes/citation.js +48 -0
- package/dist/es/schema/nodes/comment.js +23 -0
- package/dist/es/schema/nodes/cross_reference.js +55 -0
- package/dist/es/schema/nodes/doc.js +18 -0
- package/dist/es/schema/nodes/equation.js +52 -0
- package/dist/es/schema/nodes/equation_element.js +49 -0
- package/dist/es/schema/nodes/figcaption.js +28 -0
- package/dist/es/schema/nodes/figure.js +49 -0
- package/dist/es/schema/nodes/figure_element.js +74 -0
- package/dist/es/schema/nodes/footnote.js +63 -0
- package/dist/es/schema/nodes/footnotes_element.js +50 -0
- package/dist/es/schema/nodes/footnotes_section.js +41 -0
- package/dist/es/schema/nodes/graphical_abstract_section.js +42 -0
- package/dist/es/schema/nodes/hard_break.js +27 -0
- package/dist/es/schema/nodes/highlight_marker.js +49 -0
- package/dist/es/schema/nodes/inline_equation.js +55 -0
- package/dist/es/schema/nodes/inline_footnote.js +47 -0
- package/dist/es/schema/nodes/keywords_element.js +49 -0
- package/dist/es/schema/nodes/keywords_section.js +42 -0
- package/dist/es/schema/nodes/link.js +58 -0
- package/dist/es/schema/nodes/list.js +117 -0
- package/dist/es/schema/nodes/listing.js +69 -0
- package/dist/es/schema/nodes/listing_element.js +49 -0
- package/dist/es/schema/nodes/manuscript.js +43 -0
- package/dist/es/schema/nodes/missing_figure.js +47 -0
- package/dist/es/schema/nodes/paragraph.js +59 -0
- package/dist/es/schema/nodes/placeholder.js +46 -0
- package/dist/es/schema/nodes/placeholder_element.js +45 -0
- package/dist/es/schema/nodes/pullquote_element.js +61 -0
- package/dist/es/schema/nodes/section.js +90 -0
- package/dist/es/schema/nodes/section_label.js +26 -0
- package/dist/es/schema/nodes/section_title.js +44 -0
- package/dist/es/schema/nodes/table.js +67 -0
- package/dist/es/schema/nodes/table_col.js +54 -0
- package/dist/es/schema/nodes/table_element.js +59 -0
- package/dist/es/schema/nodes/table_row.js +120 -0
- package/dist/es/schema/nodes/text.js +18 -0
- package/dist/es/schema/nodes/toc_element.js +49 -0
- package/dist/es/schema/nodes/toc_section.js +42 -0
- package/dist/es/schema/types.js +16 -0
- package/dist/es/tests.js +28 -0
- package/dist/es/transformer/builders.js +261 -0
- package/dist/es/transformer/bundles-data.js +8 -0
- package/dist/es/transformer/bundles.js +27 -0
- package/dist/es/transformer/decode.js +608 -0
- package/dist/es/transformer/document-object-types.js +28 -0
- package/dist/es/transformer/encode.js +535 -0
- package/dist/es/transformer/filename.js +23 -0
- package/dist/es/transformer/footnote-category.js +16 -0
- package/dist/es/transformer/footnotes-order.js +53 -0
- package/dist/es/transformer/highlight-markers.js +120 -0
- package/dist/es/transformer/html.js +407 -0
- package/dist/es/transformer/id.js +23 -0
- package/dist/es/transformer/index.js +38 -0
- package/dist/es/transformer/labels.js +81 -0
- package/dist/es/transformer/manuscript-dependencies.js +64 -0
- package/dist/es/transformer/model-map.js +22 -0
- package/dist/es/transformer/models.js +16 -0
- package/dist/es/transformer/node-names.js +39 -0
- package/dist/es/transformer/node-title.js +82 -0
- package/dist/es/transformer/node-types.js +55 -0
- package/dist/es/transformer/object-types.js +52 -0
- package/dist/es/transformer/project-bundle.js +77 -0
- package/dist/es/transformer/section-category.js +210 -0
- package/dist/es/transformer/serializer.js +17 -0
- package/dist/es/transformer/shared-data.js +1 -0
- package/dist/es/transformer/tei-grobid-importer.js +115 -0
- package/dist/es/transformer/timestamp.js +16 -0
- package/dist/es/transformer/update-identifiers.js +87 -0
- package/dist/es/types.js +1 -0
- package/dist/types/errors.d.ts +6 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/jats/importer/index.d.ts +16 -0
- package/dist/types/jats/importer/jats-body-dom-parser.d.ts +24 -0
- package/dist/types/jats/importer/jats-body-transformations.d.ts +31 -0
- package/dist/types/jats/importer/jats-comments.d.ts +26 -0
- package/dist/types/jats/importer/jats-front-parser.d.ts +62 -0
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +37 -0
- package/dist/types/jats/importer/jats-parser-utils.d.ts +23 -0
- package/dist/types/jats/importer/jats-reference-parser.d.ts +23 -0
- package/dist/types/jats/importer/parse-jats-article.d.ts +30 -0
- package/dist/types/jats/index.d.ts +18 -0
- package/dist/types/jats/jats-exporter.d.ts +72 -0
- package/dist/types/jats/jats-versions.d.ts +23 -0
- package/dist/types/lib/attributes.d.ts +20 -0
- package/dist/types/lib/html.d.ts +17 -0
- package/dist/types/lib/styled-content.d.ts +22 -0
- package/dist/types/lib/table-cell-styles.d.ts +27 -0
- package/dist/types/lib/utils.d.ts +26 -0
- package/dist/types/mathjax/index.d.ts +3 -0
- package/dist/types/mathjax/mathjax-packages.d.ts +16 -0
- package/dist/types/mathjax/mathml-to-svg.d.ts +17 -0
- package/dist/types/mathjax/tex-to-mathml.d.ts +17 -0
- package/dist/types/mathjax/tex-to-svg.d.ts +17 -0
- package/dist/types/schema/groups.d.ts +22 -0
- package/dist/types/schema/index.d.ts +65 -0
- package/dist/types/schema/marks.d.ts +27 -0
- package/dist/types/schema/nodes/attribution.d.ts +21 -0
- package/dist/types/schema/nodes/bibliography_element.d.ts +26 -0
- package/dist/types/schema/nodes/bibliography_item.d.ts +36 -0
- package/dist/types/schema/nodes/bibliography_section.d.ts +26 -0
- package/dist/types/schema/nodes/blockquote_element.d.ts +28 -0
- package/dist/types/schema/nodes/caption.d.ts +25 -0
- package/dist/types/schema/nodes/caption_title.d.ts +25 -0
- package/dist/types/schema/nodes/citation.d.ts +27 -0
- package/dist/types/schema/nodes/comment.d.ts +31 -0
- package/dist/types/schema/nodes/cross_reference.d.ts +26 -0
- package/dist/types/schema/nodes/doc.d.ts +17 -0
- package/dist/types/schema/nodes/equation.d.ts +28 -0
- package/dist/types/schema/nodes/equation_element.d.ts +29 -0
- package/dist/types/schema/nodes/figcaption.d.ts +21 -0
- package/dist/types/schema/nodes/figure.d.ts +25 -0
- package/dist/types/schema/nodes/figure_element.d.ts +44 -0
- package/dist/types/schema/nodes/footnote.d.ts +32 -0
- package/dist/types/schema/nodes/footnotes_element.d.ts +28 -0
- package/dist/types/schema/nodes/footnotes_section.d.ts +26 -0
- package/dist/types/schema/nodes/graphical_abstract_section.d.ts +26 -0
- package/dist/types/schema/nodes/hard_break.d.ts +21 -0
- package/dist/types/schema/nodes/highlight_marker.d.ts +29 -0
- package/dist/types/schema/nodes/inline_equation.d.ts +28 -0
- package/dist/types/schema/nodes/inline_footnote.d.ts +27 -0
- package/dist/types/schema/nodes/keywords_element.d.ts +27 -0
- package/dist/types/schema/nodes/keywords_section.d.ts +26 -0
- package/dist/types/schema/nodes/link.d.ts +26 -0
- package/dist/types/schema/nodes/list.d.ts +39 -0
- package/dist/types/schema/nodes/listing.d.ts +33 -0
- package/dist/types/schema/nodes/listing_element.d.ts +29 -0
- package/dist/types/schema/nodes/manuscript.d.ts +23 -0
- package/dist/types/schema/nodes/missing_figure.d.ts +23 -0
- package/dist/types/schema/nodes/paragraph.d.ts +30 -0
- package/dist/types/schema/nodes/placeholder.d.ts +26 -0
- package/dist/types/schema/nodes/placeholder_element.d.ts +25 -0
- package/dist/types/schema/nodes/pullquote_element.d.ts +28 -0
- package/dist/types/schema/nodes/section.d.ts +36 -0
- package/dist/types/schema/nodes/section_label.d.ts +22 -0
- package/dist/types/schema/nodes/section_title.d.ts +22 -0
- package/dist/types/schema/nodes/table.d.ts +27 -0
- package/dist/types/schema/nodes/table_col.d.ts +24 -0
- package/dist/types/schema/nodes/table_element.d.ts +35 -0
- package/dist/types/schema/nodes/table_row.d.ts +41 -0
- package/dist/types/schema/nodes/text.d.ts +17 -0
- package/dist/types/schema/nodes/toc_element.d.ts +27 -0
- package/dist/types/schema/nodes/toc_section.d.ts +26 -0
- package/dist/types/schema/types.d.ts +45 -0
- package/dist/types/tests.d.ts +16 -0
- package/dist/types/transformer/builders.d.ts +74 -0
- package/dist/types/transformer/bundles-data.d.ts +3 -0
- package/dist/types/transformer/bundles.d.ts +3 -0
- package/dist/types/transformer/decode.d.ts +38 -0
- package/dist/types/transformer/document-object-types.d.ts +17 -0
- package/dist/types/transformer/encode.d.ts +29 -0
- package/dist/types/transformer/filename.d.ts +16 -0
- package/dist/types/transformer/footnote-category.d.ts +17 -0
- package/dist/types/transformer/footnotes-order.d.ts +23 -0
- package/dist/types/transformer/highlight-markers.d.ts +26 -0
- package/dist/types/transformer/html.d.ts +36 -0
- package/dist/types/transformer/id.d.ts +20 -0
- package/dist/types/transformer/index.d.ts +38 -0
- package/dist/types/transformer/labels.d.ts +24 -0
- package/dist/types/transformer/manuscript-dependencies.d.ts +12 -0
- package/dist/types/transformer/model-map.d.ts +19 -0
- package/dist/types/transformer/models.d.ts +48 -0
- package/dist/types/transformer/node-names.d.ts +17 -0
- package/dist/types/transformer/node-title.d.ts +19 -0
- package/dist/types/transformer/node-types.d.ts +22 -0
- package/dist/types/transformer/object-types.d.ts +29 -0
- package/dist/types/transformer/project-bundle.d.ts +30 -0
- package/dist/types/transformer/section-category.d.ts +28 -0
- package/dist/types/transformer/serializer.d.ts +19 -0
- package/dist/types/transformer/shared-data.d.ts +2 -0
- package/dist/types/transformer/tei-grobid-importer.d.ts +20 -0
- package/dist/types/transformer/timestamp.d.ts +16 -0
- package/dist/types/transformer/update-identifiers.d.ts +23 -0
- package/dist/types/types.d.ts +2 -0
- package/package.json +89 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 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.insertHighlightMarkers = exports.extractHighlightMarkers = exports.isHighlightableModel = void 0;
|
|
19
|
+
const builders_1 = require("./builders");
|
|
20
|
+
const highlightableFields = [
|
|
21
|
+
'caption',
|
|
22
|
+
'contents',
|
|
23
|
+
'title',
|
|
24
|
+
];
|
|
25
|
+
const isHighlightableModel = (model) => {
|
|
26
|
+
for (const field of highlightableFields) {
|
|
27
|
+
if (field in model) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
exports.isHighlightableModel = isHighlightableModel;
|
|
34
|
+
const extractHighlightMarkers = (model, commentAnnotationsMap) => {
|
|
35
|
+
for (const field of highlightableFields) {
|
|
36
|
+
let html = model[field];
|
|
37
|
+
if (html === undefined) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const template = document.createElement('template');
|
|
41
|
+
template.innerHTML = `<div>${html}</div>`;
|
|
42
|
+
const element = template.content.firstChild;
|
|
43
|
+
if (!(element instanceof Element)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const markers = element.querySelectorAll('span.highlight-marker');
|
|
47
|
+
if (markers.length) {
|
|
48
|
+
for (const marker of markers) {
|
|
49
|
+
const markerHTML = marker.outerHTML;
|
|
50
|
+
const offset = html.indexOf(markerHTML);
|
|
51
|
+
if (offset === -1) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const _id = marker.getAttribute('id');
|
|
55
|
+
const target = marker.getAttribute('data-target-id');
|
|
56
|
+
if (_id && target) {
|
|
57
|
+
const position = marker.getAttribute('data-position');
|
|
58
|
+
const commentAnnotation = Object.assign(Object.assign({}, (0, builders_1.buildComment)(target, '')), { _id: _id });
|
|
59
|
+
if (position === 'start') {
|
|
60
|
+
commentAnnotationsMap.set(commentAnnotation._id, Object.assign(Object.assign({}, commentAnnotation), { selector: {
|
|
61
|
+
from: offset,
|
|
62
|
+
to: -1,
|
|
63
|
+
} }));
|
|
64
|
+
}
|
|
65
|
+
else if (position === 'end') {
|
|
66
|
+
const comment = commentAnnotationsMap.get(commentAnnotation._id);
|
|
67
|
+
if (comment && comment.selector) {
|
|
68
|
+
commentAnnotationsMap.set(comment._id, Object.assign(Object.assign({}, comment), { selector: Object.assign(Object.assign({}, comment.selector), { to: offset }) }));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else if (position === 'point') {
|
|
72
|
+
commentAnnotationsMap.set(commentAnnotation._id, Object.assign(Object.assign({}, commentAnnotation), { selector: { from: offset, to: offset } }));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
html = html.substr(0, offset) + html.substr(offset + markerHTML.length);
|
|
76
|
+
}
|
|
77
|
+
model[field] = html;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
exports.extractHighlightMarkers = extractHighlightMarkers;
|
|
82
|
+
const insertHighlightMarkers = (contents, commentAnnotations) => {
|
|
83
|
+
let output = contents;
|
|
84
|
+
const sortedComments = commentAnnotations.sort((a, b) => {
|
|
85
|
+
if (a.selector && b.selector) {
|
|
86
|
+
return b.selector.from - a.selector.from;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return 0;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
for (const comment of sortedComments) {
|
|
93
|
+
let element;
|
|
94
|
+
if (comment.selector) {
|
|
95
|
+
if (comment.selector.from === comment.selector.to) {
|
|
96
|
+
element = createHighlightElement(comment, 'point');
|
|
97
|
+
output = injectHighlightMarker(element, comment.selector.from, output);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
element = createHighlightElement(comment, 'start');
|
|
101
|
+
output = injectHighlightMarker(element, comment.selector.from, output);
|
|
102
|
+
const updatedEndOffset = element.outerHTML.length + comment.selector.to;
|
|
103
|
+
element = createHighlightElement(comment, 'end');
|
|
104
|
+
output = injectHighlightMarker(element, updatedEndOffset, output);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return output;
|
|
109
|
+
};
|
|
110
|
+
exports.insertHighlightMarkers = insertHighlightMarkers;
|
|
111
|
+
function injectHighlightMarker(element, offset, contents) {
|
|
112
|
+
const parts = [
|
|
113
|
+
contents.substring(0, offset),
|
|
114
|
+
element.outerHTML,
|
|
115
|
+
contents.substring(offset),
|
|
116
|
+
];
|
|
117
|
+
return parts.join('');
|
|
118
|
+
}
|
|
119
|
+
const createHighlightElement = (comment, position) => {
|
|
120
|
+
const element = document.createElement('span');
|
|
121
|
+
element.className = 'highlight-marker';
|
|
122
|
+
element.setAttribute('id', comment._id);
|
|
123
|
+
element.setAttribute('data-target-id', comment.target);
|
|
124
|
+
element.setAttribute('data-position', position);
|
|
125
|
+
return element;
|
|
126
|
+
};
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.HTMLTransformer = void 0;
|
|
22
|
+
const manuscripts_json_schema_1 = require("@manuscripts/manuscripts-json-schema");
|
|
23
|
+
const prosemirror_model_1 = require("prosemirror-model");
|
|
24
|
+
const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
|
|
25
|
+
const jats_exporter_1 = require("../jats/jats-exporter");
|
|
26
|
+
const styled_content_1 = require("../lib/styled-content");
|
|
27
|
+
const schema_1 = require("../schema");
|
|
28
|
+
const filename_1 = require("./filename");
|
|
29
|
+
const labels_1 = require("./labels");
|
|
30
|
+
const node_types_1 = require("./node-types");
|
|
31
|
+
const object_types_1 = require("./object-types");
|
|
32
|
+
const project_bundle_1 = require("./project-bundle");
|
|
33
|
+
const section_category_1 = require("./section-category");
|
|
34
|
+
const chooseNodeName = (element) => {
|
|
35
|
+
const nodeName = element.nodeName.toLowerCase();
|
|
36
|
+
if (nodeName === 'figure') {
|
|
37
|
+
if (element.classList.contains('table')) {
|
|
38
|
+
return 'figure-table';
|
|
39
|
+
}
|
|
40
|
+
if (element.classList.contains('listing')) {
|
|
41
|
+
return 'figure-listing';
|
|
42
|
+
}
|
|
43
|
+
if (element.classList.contains('equation')) {
|
|
44
|
+
return 'figure-equation';
|
|
45
|
+
}
|
|
46
|
+
return 'figure';
|
|
47
|
+
}
|
|
48
|
+
else if (nodeName === 'section') {
|
|
49
|
+
const sectionCategory = element.getAttribute('data-category');
|
|
50
|
+
if (sectionCategory) {
|
|
51
|
+
const secType = (0, section_category_1.chooseSecType)(sectionCategory);
|
|
52
|
+
if (secType) {
|
|
53
|
+
return secType;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (element.classList.length === 1) {
|
|
58
|
+
const className = element.classList.item(0);
|
|
59
|
+
if (className && !className.startsWith('MP')) {
|
|
60
|
+
return className;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return nodeName;
|
|
64
|
+
};
|
|
65
|
+
const createDefaultIdGenerator = () => {
|
|
66
|
+
const counter = (0, jats_exporter_1.createCounter)();
|
|
67
|
+
return async (element) => {
|
|
68
|
+
const nodeName = chooseNodeName(element);
|
|
69
|
+
const index = counter.increment(nodeName);
|
|
70
|
+
return `${nodeName}-${index}`;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
class HTMLTransformer {
|
|
74
|
+
constructor() {
|
|
75
|
+
this.serializeToHTML = async (fragment, modelMap, options = {}) => {
|
|
76
|
+
const { idGenerator, mediaPathGenerator } = options;
|
|
77
|
+
this.modelMap = modelMap;
|
|
78
|
+
const manuscript = (0, project_bundle_1.findManuscript)(this.modelMap);
|
|
79
|
+
this.labelTargets = (0, labels_1.buildTargets)(fragment, manuscript);
|
|
80
|
+
this.document = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', document.implementation.createDocumentType('html', '', ''));
|
|
81
|
+
const article = this.document.createElement('article');
|
|
82
|
+
this.document.documentElement.appendChild(article);
|
|
83
|
+
article.appendChild(this.buildFront());
|
|
84
|
+
article.appendChild(this.buildBody(fragment));
|
|
85
|
+
this.fixBody(fragment);
|
|
86
|
+
await this.rewriteIDs(idGenerator);
|
|
87
|
+
if (mediaPathGenerator) {
|
|
88
|
+
await this.rewriteMediaPaths(mediaPathGenerator);
|
|
89
|
+
}
|
|
90
|
+
return (0, w3c_xmlserializer_1.default)(this.document);
|
|
91
|
+
};
|
|
92
|
+
this.rewriteMediaPaths = async (mediaPathGenerator) => {
|
|
93
|
+
for (const image of this.document.querySelectorAll('figure > img')) {
|
|
94
|
+
const parentFigure = image.parentNode;
|
|
95
|
+
if (parentFigure) {
|
|
96
|
+
const parentID = parentFigure.getAttribute('data-uuid');
|
|
97
|
+
if (parentID) {
|
|
98
|
+
const newSrc = await mediaPathGenerator(image, parentID);
|
|
99
|
+
image.setAttribute('src', newSrc);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
this.rewriteIDs = async (idGenerator = createDefaultIdGenerator()) => {
|
|
105
|
+
const idMap = new Map();
|
|
106
|
+
for (const element of this.document.querySelectorAll('[id]')) {
|
|
107
|
+
const previousID = element.getAttribute('id');
|
|
108
|
+
if (previousID && !previousID.match(/^MP[a-z]+:[a-z0-9-]+$/i)) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const newID = await idGenerator(element);
|
|
112
|
+
if (newID) {
|
|
113
|
+
element.setAttribute('id', newID);
|
|
114
|
+
if (previousID) {
|
|
115
|
+
const ancores = [
|
|
116
|
+
...this.document.querySelectorAll(`a[href="#${previousID}"]`),
|
|
117
|
+
];
|
|
118
|
+
ancores.map((a) => a.setAttribute('href', `#${newID}`));
|
|
119
|
+
element.setAttribute('data-uuid', previousID);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
element.removeAttribute('id');
|
|
124
|
+
}
|
|
125
|
+
if (previousID) {
|
|
126
|
+
idMap.set(previousID, newID);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
for (const node of this.document.querySelectorAll('[data-reference-ids]')) {
|
|
130
|
+
const rids = node.getAttribute('data-reference-ids');
|
|
131
|
+
if (rids) {
|
|
132
|
+
const newRIDs = rids
|
|
133
|
+
.split(/\s+/)
|
|
134
|
+
.filter(Boolean)
|
|
135
|
+
.map((previousRID) => idMap.get(previousRID))
|
|
136
|
+
.filter(Boolean);
|
|
137
|
+
if (newRIDs.length) {
|
|
138
|
+
node.setAttribute('data-reference-ids', newRIDs.join(' '));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
for (const node of this.document.querySelectorAll('[data-reference-id]')) {
|
|
143
|
+
const rid = node.getAttribute('data-reference-id');
|
|
144
|
+
if (rid) {
|
|
145
|
+
const newRID = idMap.get(rid);
|
|
146
|
+
if (newRID) {
|
|
147
|
+
node.setAttribute('data-reference-id', newRID);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
this.buildFront = () => {
|
|
153
|
+
const manuscript = (0, project_bundle_1.findManuscript)(this.modelMap);
|
|
154
|
+
const journal = (0, project_bundle_1.findJournal)(this.modelMap);
|
|
155
|
+
if (!manuscript) {
|
|
156
|
+
throw new Error('Manuscript not found in project modelMap');
|
|
157
|
+
}
|
|
158
|
+
const front = this.document.createElement('header');
|
|
159
|
+
if (manuscript.headerFigure) {
|
|
160
|
+
const figure = this.modelMap.get(manuscript.headerFigure);
|
|
161
|
+
if (figure) {
|
|
162
|
+
const headerFigure = document.createElement('figure');
|
|
163
|
+
headerFigure.setAttribute('id', figure._id);
|
|
164
|
+
front.appendChild(headerFigure);
|
|
165
|
+
const filename = (0, filename_1.generateAttachmentFilename)(figure._id, figure.contentType);
|
|
166
|
+
const img = this.document.createElement('img');
|
|
167
|
+
img.setAttribute('src', filename);
|
|
168
|
+
headerFigure.appendChild(img);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const articleMeta = this.document.createElement('div');
|
|
172
|
+
front.appendChild(articleMeta);
|
|
173
|
+
const articleTitle = this.document.createElement('h1');
|
|
174
|
+
if (manuscript.title) {
|
|
175
|
+
articleTitle.innerHTML = manuscript.title;
|
|
176
|
+
}
|
|
177
|
+
if (journal === null || journal === void 0 ? void 0 : journal.title) {
|
|
178
|
+
articleTitle.setAttribute('data-journal', journal.title);
|
|
179
|
+
}
|
|
180
|
+
articleMeta.appendChild(articleTitle);
|
|
181
|
+
if (manuscript.DOI) {
|
|
182
|
+
const articleID = this.document.createElement('article-id');
|
|
183
|
+
articleID.setAttribute('pub-id-type', 'doi');
|
|
184
|
+
articleID.innerHTML = manuscript.DOI;
|
|
185
|
+
articleMeta.append(articleID);
|
|
186
|
+
}
|
|
187
|
+
this.buildContributors(articleMeta);
|
|
188
|
+
return front;
|
|
189
|
+
};
|
|
190
|
+
this.buildBody = (fragment) => {
|
|
191
|
+
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
192
|
+
const nodes = {};
|
|
193
|
+
for (const [name, node] of Object.entries(schema_1.schema.nodes)) {
|
|
194
|
+
if (node.spec.toDOM) {
|
|
195
|
+
nodes[name] = node.spec.toDOM;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
nodes.citation = (node) => {
|
|
199
|
+
const citationNode = node;
|
|
200
|
+
const element = this.document.createElement('span');
|
|
201
|
+
element.setAttribute('class', 'citation');
|
|
202
|
+
const citation = getModel(citationNode.attrs.rid);
|
|
203
|
+
if (citation) {
|
|
204
|
+
element.setAttribute('data-reference-ids', citation.embeddedCitationItems
|
|
205
|
+
.map((item) => item.bibliographyItem)
|
|
206
|
+
.join(' '));
|
|
207
|
+
}
|
|
208
|
+
if (citationNode.attrs.contents) {
|
|
209
|
+
element.innerHTML = citationNode.attrs.contents;
|
|
210
|
+
}
|
|
211
|
+
return element;
|
|
212
|
+
};
|
|
213
|
+
nodes.cross_reference = (node) => {
|
|
214
|
+
const crossReferenceNode = node;
|
|
215
|
+
const element = this.document.createElement('a');
|
|
216
|
+
element.classList.add('cross-reference');
|
|
217
|
+
const auxiliaryObjectReference = getModel(crossReferenceNode.attrs.rid);
|
|
218
|
+
if (auxiliaryObjectReference &&
|
|
219
|
+
auxiliaryObjectReference.referencedObject) {
|
|
220
|
+
if (auxiliaryObjectReference.referencedObject.startsWith('MPFigureElement')) {
|
|
221
|
+
const model = getModel(auxiliaryObjectReference.referencedObject);
|
|
222
|
+
if (model && model.containedObjectIDs.length > 0) {
|
|
223
|
+
element.setAttribute('href', `#${model.containedObjectIDs[0]}`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
element.setAttribute('href', `#${auxiliaryObjectReference.referencedObject}`);
|
|
228
|
+
}
|
|
229
|
+
element.setAttribute('data-reference-ids', crossReferenceNode.attrs.rid);
|
|
230
|
+
}
|
|
231
|
+
element.textContent = crossReferenceNode.attrs.label;
|
|
232
|
+
return element;
|
|
233
|
+
};
|
|
234
|
+
nodes.listing = (node) => {
|
|
235
|
+
const listingNode = node;
|
|
236
|
+
const pre = this.document.createElement('pre');
|
|
237
|
+
if (listingNode.attrs.id) {
|
|
238
|
+
pre.setAttribute('id', listingNode.attrs.id);
|
|
239
|
+
}
|
|
240
|
+
pre.classList.add('listing');
|
|
241
|
+
const code = this.document.createElement('code');
|
|
242
|
+
if (listingNode.attrs.languageKey) {
|
|
243
|
+
code.setAttribute('data-language', listingNode.attrs.languageKey);
|
|
244
|
+
}
|
|
245
|
+
code.textContent = listingNode.attrs.contents;
|
|
246
|
+
pre.appendChild(code);
|
|
247
|
+
return pre;
|
|
248
|
+
};
|
|
249
|
+
nodes.text = (node) => node.text;
|
|
250
|
+
const marks = {};
|
|
251
|
+
for (const [name, mark] of Object.entries(schema_1.schema.marks)) {
|
|
252
|
+
if (mark.spec.toDOM) {
|
|
253
|
+
marks[name] = mark.spec.toDOM;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
marks.styled = (mark) => {
|
|
257
|
+
const inlineStyle = getModel(mark.attrs.rid);
|
|
258
|
+
const attrs = {
|
|
259
|
+
class: (0, styled_content_1.buildStyledContentClass)(mark.attrs, inlineStyle),
|
|
260
|
+
};
|
|
261
|
+
return ['span', attrs];
|
|
262
|
+
};
|
|
263
|
+
const serializer = new prosemirror_model_1.DOMSerializer(nodes, marks);
|
|
264
|
+
return serializer.serializeFragment(fragment, { document });
|
|
265
|
+
};
|
|
266
|
+
this.idSelector = (id) => '#' + id.replace(/:/g, '\\:');
|
|
267
|
+
this.fixFigure = (node) => {
|
|
268
|
+
const figure = this.document.querySelector(`[id="${node.attrs.id}"]`);
|
|
269
|
+
if (figure) {
|
|
270
|
+
const filename = (0, filename_1.generateAttachmentFilename)(node.attrs.id, node.attrs.contentType);
|
|
271
|
+
const img = this.document.createElement('img');
|
|
272
|
+
img.setAttribute('src', filename);
|
|
273
|
+
figure.insertBefore(img, figure.firstChild);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
this.fixBody = (fragment) => {
|
|
277
|
+
fragment.descendants((node) => {
|
|
278
|
+
if (node.attrs.id) {
|
|
279
|
+
const selector = this.idSelector(node.attrs.id);
|
|
280
|
+
const element = this.document.querySelector(`${selector}`);
|
|
281
|
+
if (element && this.labelTargets) {
|
|
282
|
+
const target = this.labelTargets.get(node.attrs.id);
|
|
283
|
+
if (target) {
|
|
284
|
+
const label = this.document.createElement('label');
|
|
285
|
+
label.textContent = target.label;
|
|
286
|
+
element.appendChild(label);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (node.attrs.titleSuppressed) {
|
|
290
|
+
const title = this.document.querySelector(`${selector} > h1`);
|
|
291
|
+
if (title && title.parentNode) {
|
|
292
|
+
title.parentNode.removeChild(title);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (node.attrs.suppressCaption) {
|
|
296
|
+
const caption = this.document.querySelector(`${selector} > figcaption`);
|
|
297
|
+
if (caption && caption.parentNode) {
|
|
298
|
+
caption.parentNode.removeChild(caption);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if ((0, node_types_1.isNodeType)(node, 'figure')) {
|
|
302
|
+
this.fixFigure(node);
|
|
303
|
+
}
|
|
304
|
+
if ((0, node_types_1.isNodeType)(node, 'figure_element')) {
|
|
305
|
+
const figureGroup = this.document.querySelector(`${selector}`);
|
|
306
|
+
if (figureGroup) {
|
|
307
|
+
const figures = this.document.querySelectorAll(`${selector} > figure`);
|
|
308
|
+
const caption = this.document.querySelector(`${selector} > figcaption`);
|
|
309
|
+
const listing = this.document.querySelector(`${selector} > pre.listing`);
|
|
310
|
+
if (listing && !listing.textContent) {
|
|
311
|
+
listing.remove();
|
|
312
|
+
}
|
|
313
|
+
if (figures.length === 1) {
|
|
314
|
+
const [figure] = figures;
|
|
315
|
+
figure.setAttribute('data-fig-type', 'figure');
|
|
316
|
+
if (caption) {
|
|
317
|
+
figure.insertBefore(caption, figure.firstChild);
|
|
318
|
+
}
|
|
319
|
+
const label = this.document.querySelector(`${selector} > label`);
|
|
320
|
+
if (label) {
|
|
321
|
+
figure.insertBefore(label, figure.firstChild);
|
|
322
|
+
}
|
|
323
|
+
if (figureGroup.parentElement) {
|
|
324
|
+
figureGroup.parentElement.replaceChild(figure, figureGroup);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (figures.length === 0 && !caption) {
|
|
328
|
+
figureGroup.remove();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
buildContributors(articleMeta) {
|
|
337
|
+
const contributors = Array.from(this.modelMap.values()).filter((0, object_types_1.hasObjectType)(manuscripts_json_schema_1.ObjectTypes.Contributor));
|
|
338
|
+
const affiliationIDs = [];
|
|
339
|
+
if (contributors && contributors.length) {
|
|
340
|
+
const contribGroup = this.document.createElement('div');
|
|
341
|
+
contribGroup.classList.add('contrib-group');
|
|
342
|
+
articleMeta.appendChild(contribGroup);
|
|
343
|
+
contributors.sort((a, b) => Number(a.priority) - Number(b.priority));
|
|
344
|
+
contributors.forEach((contributor) => {
|
|
345
|
+
const contrib = this.document.createElement('span');
|
|
346
|
+
contrib.classList.add('contrib');
|
|
347
|
+
contrib.setAttribute('id', contributor._id);
|
|
348
|
+
if (contributor.isCorresponding) {
|
|
349
|
+
contrib.setAttribute('data-corresp', 'yes');
|
|
350
|
+
}
|
|
351
|
+
const name = this.document.createElement('span');
|
|
352
|
+
name.classList.add('contrib-name');
|
|
353
|
+
contrib.appendChild(name);
|
|
354
|
+
const { given, family } = contributor.bibliographicName;
|
|
355
|
+
if (given) {
|
|
356
|
+
const givenNames = this.document.createElement('span');
|
|
357
|
+
givenNames.classList.add('contrib-given-names');
|
|
358
|
+
givenNames.textContent = given;
|
|
359
|
+
name.appendChild(givenNames);
|
|
360
|
+
}
|
|
361
|
+
if (family) {
|
|
362
|
+
if (given) {
|
|
363
|
+
const separator = document.createTextNode(' ');
|
|
364
|
+
name.appendChild(separator);
|
|
365
|
+
}
|
|
366
|
+
const surname = this.document.createElement('span');
|
|
367
|
+
surname.classList.add('contrib-surname');
|
|
368
|
+
surname.textContent = family;
|
|
369
|
+
name.appendChild(surname);
|
|
370
|
+
}
|
|
371
|
+
if (contributor.email) {
|
|
372
|
+
const link = this.document.createElement('a');
|
|
373
|
+
link.href = `mailto:${contributor.email}`;
|
|
374
|
+
contrib.appendChild(link);
|
|
375
|
+
}
|
|
376
|
+
if (contributor.affiliations) {
|
|
377
|
+
contributor.affiliations.forEach((rid) => {
|
|
378
|
+
const link = this.document.createElement('a');
|
|
379
|
+
link.setAttribute('data-ref-type', 'aff');
|
|
380
|
+
link.setAttribute('href', '#' + rid);
|
|
381
|
+
const affiliationIndex = affiliationIDs.indexOf(rid);
|
|
382
|
+
if (affiliationIndex > -1) {
|
|
383
|
+
link.textContent = String(affiliationIndex + 1);
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
affiliationIDs.push(rid);
|
|
387
|
+
link.textContent = String(affiliationIDs.length);
|
|
388
|
+
}
|
|
389
|
+
contrib.appendChild(link);
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
contribGroup.appendChild(contrib);
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
if (affiliationIDs.length) {
|
|
396
|
+
const affiliationList = this.document.createElement('ol');
|
|
397
|
+
affiliationList.classList.add('affiliations-list');
|
|
398
|
+
articleMeta.appendChild(affiliationList);
|
|
399
|
+
for (const affiliationID of affiliationIDs) {
|
|
400
|
+
const affiliation = this.modelMap.get(affiliationID);
|
|
401
|
+
if (affiliation) {
|
|
402
|
+
const affiliationItem = this.document.createElement('li');
|
|
403
|
+
affiliationItem.classList.add('affiliation');
|
|
404
|
+
affiliationItem.setAttribute('id', affiliation._id);
|
|
405
|
+
if (affiliation.institution) {
|
|
406
|
+
affiliationItem.textContent = affiliation.institution;
|
|
407
|
+
}
|
|
408
|
+
affiliationList.appendChild(affiliationItem);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
exports.HTMLTransformer = HTMLTransformer;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 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.generateID = exports.generateNodeID = void 0;
|
|
19
|
+
const uuid_1 = require("uuid");
|
|
20
|
+
const node_types_1 = require("./node-types");
|
|
21
|
+
const generateNodeID = (type) => {
|
|
22
|
+
return node_types_1.nodeTypesMap.get(type) + ':' + (0, uuid_1.v4)().toUpperCase();
|
|
23
|
+
};
|
|
24
|
+
exports.generateNodeID = generateNodeID;
|
|
25
|
+
const generateID = (objectType) => {
|
|
26
|
+
return objectType + ':' + (0, uuid_1.v4)().toUpperCase();
|
|
27
|
+
};
|
|
28
|
+
exports.generateID = generateID;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
29
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
__exportStar(require("./builders"), exports);
|
|
33
|
+
__exportStar(require("./bundles"), exports);
|
|
34
|
+
__exportStar(require("./decode"), exports);
|
|
35
|
+
__exportStar(require("./document-object-types"), exports);
|
|
36
|
+
__exportStar(require("./encode"), exports);
|
|
37
|
+
__exportStar(require("./filename"), exports);
|
|
38
|
+
__exportStar(require("./highlight-markers"), exports);
|
|
39
|
+
__exportStar(require("./html"), exports);
|
|
40
|
+
__exportStar(require("./id"), exports);
|
|
41
|
+
__exportStar(require("./labels"), exports);
|
|
42
|
+
__exportStar(require("./manuscript-dependencies"), exports);
|
|
43
|
+
__exportStar(require("./models"), exports);
|
|
44
|
+
__exportStar(require("./node-names"), exports);
|
|
45
|
+
__exportStar(require("./node-title"), exports);
|
|
46
|
+
__exportStar(require("./node-types"), exports);
|
|
47
|
+
__exportStar(require("./object-types"), exports);
|
|
48
|
+
__exportStar(require("./project-bundle"), exports);
|
|
49
|
+
__exportStar(require("./section-category"), exports);
|
|
50
|
+
__exportStar(require("./serializer"), exports);
|
|
51
|
+
__exportStar(require("./shared-data"), exports);
|
|
52
|
+
__exportStar(require("./tei-grobid-importer"), exports);
|
|
53
|
+
__exportStar(require("./timestamp"), exports);
|
|
54
|
+
__exportStar(require("./update-identifiers"), exports);
|