@manuscripts/transform 1.0.0 → 1.0.1-LEAN-2105
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/dist/cjs/jats/importer/jats-parser-utils.js +2 -2
- package/dist/cjs/jats/jats-exporter.js +17 -16
- package/dist/cjs/schema/index.js +2 -0
- package/dist/cjs/schema/nodes/blockquote_element.js +2 -2
- package/dist/{types/transformer/tei-grobid-importer.d.ts → cjs/schema/nodes/comment_list.js} +10 -6
- package/dist/cjs/schema/nodes/equation.js +3 -3
- package/dist/cjs/schema/nodes/inline_equation.js +3 -3
- package/dist/cjs/schema/nodes/list.js +3 -3
- package/dist/cjs/schema/nodes/listing.js +3 -3
- package/dist/cjs/schema/nodes/manuscript.js +1 -1
- package/dist/cjs/schema/nodes/paragraph.js +2 -2
- package/dist/cjs/schema/nodes/pullquote_element.js +2 -2
- package/dist/cjs/transformer/builders.js +73 -73
- package/dist/cjs/transformer/decode.js +67 -37
- package/dist/cjs/transformer/document-object-types.js +11 -11
- package/dist/cjs/transformer/encode.js +11 -10
- package/dist/cjs/transformer/html.js +2 -2
- package/dist/cjs/transformer/index.js +0 -1
- package/dist/cjs/transformer/labels.js +1 -2
- package/dist/cjs/transformer/manuscript-dependencies.js +3 -3
- package/dist/cjs/transformer/node-types.js +34 -33
- package/dist/cjs/transformer/object-types.js +23 -23
- package/dist/cjs/transformer/project-bundle.js +4 -4
- package/dist/cjs/transformer/section-category.js +5 -5
- package/dist/es/jats/importer/jats-parser-utils.js +1 -1
- package/dist/es/jats/jats-exporter.js +2 -1
- package/dist/es/schema/index.js +2 -0
- package/dist/es/schema/nodes/blockquote_element.js +1 -1
- package/dist/es/schema/nodes/comment_list.js +21 -0
- package/dist/es/schema/nodes/equation.js +1 -1
- package/dist/es/schema/nodes/inline_equation.js +1 -1
- package/dist/es/schema/nodes/list.js +1 -1
- package/dist/es/schema/nodes/listing.js +1 -1
- package/dist/es/schema/nodes/manuscript.js +1 -1
- package/dist/es/schema/nodes/paragraph.js +1 -1
- package/dist/es/schema/nodes/pullquote_element.js +1 -1
- package/dist/es/transformer/builders.js +1 -1
- package/dist/es/transformer/decode.js +43 -13
- package/dist/es/transformer/document-object-types.js +1 -1
- package/dist/es/transformer/encode.js +12 -11
- package/dist/es/transformer/html.js +1 -1
- package/dist/es/transformer/index.js +0 -1
- package/dist/es/transformer/labels.js +1 -2
- package/dist/es/transformer/manuscript-dependencies.js +1 -1
- package/dist/es/transformer/node-types.js +2 -1
- package/dist/es/transformer/object-types.js +1 -1
- package/dist/es/transformer/project-bundle.js +1 -1
- package/dist/es/transformer/section-category.js +1 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -1
- package/dist/types/jats/importer/jats-comments.d.ts +1 -1
- package/dist/types/jats/importer/jats-front-parser.d.ts +6 -6
- package/dist/types/jats/importer/jats-parser-utils.d.ts +1 -1
- package/dist/types/jats/importer/jats-reference-parser.d.ts +2 -2
- package/dist/types/jats/importer/parse-jats-article.d.ts +2 -2
- package/dist/types/jats/jats-exporter.d.ts +1 -1
- package/dist/types/lib/styled-content.d.ts +1 -1
- package/dist/types/schema/nodes/comment_list.d.ts +25 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +1 -1
- package/dist/types/transformer/bundles-data.d.ts +1 -1
- package/dist/types/transformer/bundles.d.ts +1 -1
- package/dist/types/transformer/decode.d.ts +2 -1
- package/dist/types/transformer/document-object-types.d.ts +1 -1
- package/dist/types/transformer/encode.d.ts +1 -1
- package/dist/types/transformer/footnotes-order.d.ts +1 -1
- package/dist/types/transformer/highlight-markers.d.ts +1 -1
- package/dist/types/transformer/html.d.ts +1 -1
- package/dist/types/transformer/id.d.ts +1 -1
- package/dist/types/transformer/index.d.ts +0 -1
- package/dist/types/transformer/labels.d.ts +1 -1
- package/dist/types/transformer/manuscript-dependencies.d.ts +1 -1
- package/dist/types/transformer/model-map.d.ts +1 -1
- package/dist/types/transformer/models.d.ts +1 -1
- package/dist/types/transformer/node-types.d.ts +1 -1
- package/dist/types/transformer/object-types.d.ts +1 -1
- package/dist/types/transformer/project-bundle.d.ts +1 -1
- package/dist/types/transformer/section-category.d.ts +1 -1
- package/dist/types/transformer/shared-data.d.ts +1 -1
- package/dist/types/transformer/update-identifiers.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/transformer/tei-grobid-importer.js +0 -121
- package/dist/es/transformer/tei-grobid-importer.js +0 -115
|
@@ -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 { Model } from '@manuscripts/
|
|
16
|
+
import { Model } from '@manuscripts/json-schema';
|
|
17
17
|
import { DOMSerializer } from 'prosemirror-model';
|
|
18
18
|
import { ManuscriptFragment, ManuscriptNode } from '../schema';
|
|
19
19
|
import { Target } from '../transformer/labels';
|
|
@@ -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 { InlineStyle } from '@manuscripts/
|
|
16
|
+
import { InlineStyle } from '@manuscripts/json-schema';
|
|
17
17
|
interface StyledContentAttrs {
|
|
18
18
|
rid?: string;
|
|
19
19
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 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 { NodeSpec } from 'prosemirror-model';
|
|
17
|
+
import { ManuscriptNode } from '../types';
|
|
18
|
+
interface Attrs {
|
|
19
|
+
id: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CommentListNode extends ManuscriptNode {
|
|
22
|
+
attrs: Attrs;
|
|
23
|
+
}
|
|
24
|
+
export declare const commentList: NodeSpec;
|
|
25
|
+
export {};
|
|
@@ -17,7 +17,7 @@ import { Fragment, Mark as ProsemirrorMark, MarkType, Node as ProsemirrorNode, N
|
|
|
17
17
|
import { EditorState, NodeSelection, Plugin, TextSelection, Transaction } from 'prosemirror-state';
|
|
18
18
|
import { EditorView, NodeView } from 'prosemirror-view';
|
|
19
19
|
export type Marks = 'bold' | 'code' | 'italic' | 'smallcaps' | 'strikethrough' | 'styled' | 'subscript' | 'superscript' | 'underline' | 'tracked_insert' | 'tracked_delete';
|
|
20
|
-
export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keywords_element' | 'keywords_section' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'table' | 'table_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section';
|
|
20
|
+
export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comment_list' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keywords_element' | 'keywords_section' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'table' | 'table_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section';
|
|
21
21
|
export type ManuscriptSchema = Schema<Nodes, Marks>;
|
|
22
22
|
export type ManuscriptEditorState = EditorState;
|
|
23
23
|
export type ManuscriptEditorView = EditorView;
|
|
@@ -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 { Affiliation, Attribution, AuxiliaryObjectReference, BibliographicDate, BibliographicName, BibliographyItem, Citation, CitationItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, Highlight, HighlightMarker, InlineMathFragment, InlineStyle, Journal, Keyword, KeywordGroup, LibraryCollection, Manuscript, ManuscriptKeyword, ManuscriptNote, ObjectTypes, ParagraphElement, Project, RequirementsValidation, RequirementsValidationData, Section, StatusLabel, Submission, Supplement, UserProfileAffiliation, UserProfileFootNote } from '@manuscripts/
|
|
16
|
+
import { Affiliation, Attribution, AuxiliaryObjectReference, BibliographicDate, BibliographicName, BibliographyItem, Citation, CitationItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, Highlight, HighlightMarker, InlineMathFragment, InlineStyle, Journal, Keyword, KeywordGroup, LibraryCollection, Manuscript, ManuscriptKeyword, ManuscriptNote, ObjectTypes, ParagraphElement, Project, RequirementsValidation, RequirementsValidationData, Section, StatusLabel, Submission, Supplement, UserProfileAffiliation, UserProfileFootNote } from '@manuscripts/json-schema';
|
|
17
17
|
import { FootnotesOrderIndexList } from './footnotes-order';
|
|
18
18
|
import { CommentSelector, ManuscriptModel, ModelAttachment } from './models';
|
|
19
19
|
export declare const DEFAULT_BUNDLE = "MPBundle:www-zotero-org-styles-nature";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Bundle } from '@manuscripts/
|
|
1
|
+
import { Bundle } from '@manuscripts/json-schema';
|
|
2
2
|
export declare const createParentBundle: (bundle: Bundle, bundles: Map<string, Bundle>) => Bundle | undefined;
|
|
3
3
|
export declare const createNewBundle: (bundleID: string, bundles: Map<string, Bundle>) => Bundle;
|
|
@@ -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 { CommentAnnotation, Model, Section } from '@manuscripts/
|
|
16
|
+
import { CommentAnnotation, Model, Section } from '@manuscripts/json-schema';
|
|
17
17
|
import { ParseOptions } from 'prosemirror-model';
|
|
18
18
|
import { ManuscriptNode } from '../schema';
|
|
19
19
|
export declare const getModelData: <T extends Model>(model: Model) => T;
|
|
@@ -23,6 +23,7 @@ export declare const isManuscriptNode: (model: ManuscriptNode | null) => model i
|
|
|
23
23
|
export declare class Decoder {
|
|
24
24
|
private readonly modelMap;
|
|
25
25
|
private readonly allowMissingElements;
|
|
26
|
+
private comments;
|
|
26
27
|
private creators;
|
|
27
28
|
private createCommentsNode;
|
|
28
29
|
private getComments;
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
export declare const documentObjectTypes: ObjectTypes[];
|
|
@@ -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 { CommentAnnotation, Model } from '@manuscripts/
|
|
16
|
+
import { CommentAnnotation, Model } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptNode } from '../schema';
|
|
18
18
|
import { Build } from './builders';
|
|
19
19
|
export declare const inlineContents: (node: ManuscriptNode) => string;
|
|
@@ -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 { FootnotesOrder } from '@manuscripts/
|
|
16
|
+
import { FootnotesOrder } from '@manuscripts/json-schema';
|
|
17
17
|
export type FootnotesOrderIndexList = {
|
|
18
18
|
id: string;
|
|
19
19
|
index: number;
|
|
@@ -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 { CommentAnnotation, Model } from '@manuscripts/
|
|
16
|
+
import { CommentAnnotation, Model } from '@manuscripts/json-schema';
|
|
17
17
|
import { Build } from './builders';
|
|
18
18
|
export type HighlightableField = 'title' | 'caption' | 'contents';
|
|
19
19
|
export declare const isHighlightableModel: (model: Model) => model is HighlightableModel;
|
|
@@ -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 { Model } from '@manuscripts/
|
|
16
|
+
import { Model } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptFragment } from '../schema';
|
|
18
18
|
import { IDGenerator, MediaPathGenerator } from '../types';
|
|
19
19
|
export interface HTMLExporterOptions {
|
|
@@ -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 { ObjectTypes } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptNodeType } from '../schema';
|
|
18
18
|
import { ExtraObjectTypes } from './object-types';
|
|
19
19
|
export declare const generateNodeID: (type: ManuscriptNodeType) => string;
|
|
@@ -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 { Manuscript } from '@manuscripts/
|
|
16
|
+
import { Manuscript } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptFragment } from '../schema';
|
|
18
18
|
export interface Target {
|
|
19
19
|
type: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuxiliaryObjectReferenceStyle, BorderStyle, CaptionStyle, Color, ColorScheme, ContributorRole, FigureLayout, FigureStyle, Model, PageLayout, ParagraphStyle, TableStyle } from '@manuscripts/
|
|
1
|
+
import { AuxiliaryObjectReferenceStyle, BorderStyle, CaptionStyle, Color, ColorScheme, ContributorRole, FigureLayout, FigureStyle, Model, PageLayout, ParagraphStyle, TableStyle } from '@manuscripts/json-schema';
|
|
2
2
|
import { ContainedModel } from './models';
|
|
3
3
|
export type StyleObject = AuxiliaryObjectReferenceStyle | BorderStyle | CaptionStyle | Color | ColorScheme | FigureLayout | FigureStyle | PageLayout | ParagraphStyle | TableStyle;
|
|
4
4
|
export declare const loadStyles: () => Promise<StyleObject[]>;
|
|
@@ -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 { Model } from '@manuscripts/
|
|
16
|
+
import { Model } from '@manuscripts/json-schema';
|
|
17
17
|
import { Build } from './builders';
|
|
18
18
|
export type AddModel = <T extends Model>(data: Partial<T> | Build<T>) => void;
|
|
19
19
|
export declare const addModelToMap: (modelMap: Map<string, Model>) => AddModel;
|
|
@@ -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 { Model, UserProfile } from '@manuscripts/
|
|
16
|
+
import { Model, UserProfile } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptNode } from '../schema';
|
|
18
18
|
export interface Attachment {
|
|
19
19
|
id: string;
|
|
@@ -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 { ObjectTypes } from '@manuscripts/
|
|
16
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptNode, ManuscriptNodeType, Nodes } from '../schema';
|
|
18
18
|
export declare const nodeTypesMap: Map<ManuscriptNodeType, ObjectTypes>;
|
|
19
19
|
export declare const isExecutableNodeType: (type: ManuscriptNodeType) => boolean;
|
|
@@ -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 { CommentAnnotation, Figure, Manuscript, Model, ObjectTypes, Table } from '@manuscripts/
|
|
16
|
+
import { CommentAnnotation, Figure, Manuscript, Model, ObjectTypes, Table } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptModel, UserProfileWithAvatar } from './models';
|
|
18
18
|
export declare enum ExtraObjectTypes {
|
|
19
19
|
PlaceholderElement = "MPPlaceholderElement"
|
|
@@ -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 { Journal, Manuscript, Model, ObjectTypes, Submission } from '@manuscripts/
|
|
16
|
+
import { Journal, Manuscript, Model, ObjectTypes, Submission } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptModel } from './models';
|
|
18
18
|
export interface ProjectBundle {
|
|
19
19
|
version: string;
|
|
@@ -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 { Element } from '@manuscripts/
|
|
16
|
+
import { Element } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptNode, ManuscriptNodeType } from '../schema';
|
|
18
18
|
export declare const isAnySectionNode: (node: ManuscriptNode) => boolean;
|
|
19
19
|
export type SectionCategory = 'MPSectionCategory:abstract' | 'MPSectionCategory:abstract-teaser' | 'MPSectionCategory:abstract-graphical' | 'MPSectionCategory:acknowledgement' | 'MPSectionCategory:availability' | 'MPSectionCategory:bibliography' | 'MPSectionCategory:conclusions' | 'MPSectionCategory:discussion' | 'MPSectionCategory:endnotes' | 'MPSectionCategory:introduction' | 'MPSectionCategory:keywords' | 'MPSectionCategory:materials-method' | 'MPSectionCategory:results' | 'MPSectionCategory:toc' | 'MPSectionCategory:floating-element' | 'MPSectionCategory:appendices' | 'MPSectionCategory:competing-interests' | 'MPSectionCategory:financial-disclosure' | 'MPSectionCategory:con' | 'MPSectionCategory:deceased' | 'MPSectionCategory:equal' | 'MPSectionCategory:present-address' | 'MPSectionCategory:presented-at' | 'MPSectionCategory:previously-at' | 'MPSectionCategory:supplementary-material' | 'MPSectionCategory:supported-by' | 'MPSectionCategory:ethics-statement';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Model } from '@manuscripts/
|
|
1
|
+
import { Model } from '@manuscripts/json-schema';
|
|
2
2
|
export declare const loadSharedData: <T extends Model>(file: string) => Promise<T[]>;
|
|
@@ -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 { Model } from '@manuscripts/
|
|
16
|
+
import { Model } from '@manuscripts/json-schema';
|
|
17
17
|
import JSZip from 'jszip';
|
|
18
18
|
export declare const updateIdentifiers: (data: Model[]) => Promise<{
|
|
19
19
|
data: Model[];
|
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": "1.0.
|
|
4
|
+
"version": "1.0.1-LEAN-2105",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@manuscripts/data": "^0.1.12",
|
|
44
44
|
"@manuscripts/eslint-config": "^0.5.1",
|
|
45
45
|
"@manuscripts/examples": "^0.1.0",
|
|
46
|
-
"@manuscripts/
|
|
46
|
+
"@manuscripts/json-schema": "^1.1.0",
|
|
47
47
|
"@types/debug": "^4.1.7",
|
|
48
48
|
"@types/jest": "^29.2.4",
|
|
49
49
|
"@types/lodash.pickby": "^4.6.7",
|
|
@@ -1,121 +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.parseTEIGROBIDArticle = exports.parseBack = exports.parseFront = void 0;
|
|
19
|
-
const builders_1 = require("./builders");
|
|
20
|
-
const model_map_1 = require("./model-map");
|
|
21
|
-
const iterateSnapshot = function* (snapshot) {
|
|
22
|
-
for (let i = 0; i < snapshot.snapshotLength; i++) {
|
|
23
|
-
yield snapshot.snapshotItem(i);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const namespaces = new Map([
|
|
27
|
-
[null, 'http://www.tei-c.org/ns/1.0'],
|
|
28
|
-
]);
|
|
29
|
-
const namespaceResolver = (prefix) => namespaces.get(prefix) || null;
|
|
30
|
-
const parseFront = (doc, addModel) => {
|
|
31
|
-
const headerNode = doc.evaluate('/TEI/teiHeader', doc, namespaceResolver, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue;
|
|
32
|
-
if (!headerNode) {
|
|
33
|
-
throw new Error('No header element found!');
|
|
34
|
-
}
|
|
35
|
-
const title = doc.evaluate('fileDesc/titleStmt/title', headerNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
36
|
-
const manuscript = (0, builders_1.buildManuscript)(title);
|
|
37
|
-
addModel(manuscript);
|
|
38
|
-
const affiliationsMap = new Map();
|
|
39
|
-
const authorNodes = doc.evaluate('fileDesc/sourceDesc/biblStruct/analytic/author', headerNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
|
|
40
|
-
for (const authorNode of iterateSnapshot(authorNodes)) {
|
|
41
|
-
const name = (0, builders_1.buildBibliographicName)({});
|
|
42
|
-
name.given = doc.evaluate('persName/forename', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
43
|
-
name.family = doc.evaluate('persName/surname', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
44
|
-
const contributor = (0, builders_1.buildContributor)(name, 'author', 1);
|
|
45
|
-
contributor.affiliations = [];
|
|
46
|
-
const affiliationNodes = doc.evaluate('affiliation', authorNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
|
|
47
|
-
for (const affiliationNode of iterateSnapshot(affiliationNodes)) {
|
|
48
|
-
const key = affiliationNode.getAttribute('key');
|
|
49
|
-
if (key) {
|
|
50
|
-
const affiliation = affiliationsMap.get(key);
|
|
51
|
-
if (affiliation) {
|
|
52
|
-
contributor.affiliations.push(affiliation._id);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
const affiliation = (0, builders_1.buildAffiliation)('', 1);
|
|
56
|
-
affiliation.institution = doc.evaluate('orgName[@type="institution"]', affiliationNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
57
|
-
affiliation.department = doc.evaluate('orgName[@type="department"]', affiliationNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
58
|
-
addModel(affiliation);
|
|
59
|
-
affiliationsMap.set(key, affiliation);
|
|
60
|
-
contributor.affiliations.push(affiliation._id);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
addModel(contributor);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
exports.parseFront = parseFront;
|
|
68
|
-
const chooseBibliographyItemType = (publicationType) => {
|
|
69
|
-
switch (publicationType) {
|
|
70
|
-
case 'book':
|
|
71
|
-
case 'thesis':
|
|
72
|
-
return publicationType;
|
|
73
|
-
case 'journal':
|
|
74
|
-
default:
|
|
75
|
-
return 'article-journal';
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
const parseBack = (doc, addModel) => {
|
|
79
|
-
const backNode = doc.evaluate('/TEI/text/back', doc, namespaceResolver, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue;
|
|
80
|
-
if (!backNode) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const referenceNodes = doc.evaluate('div[@type="references"]/listBibl/biblStruct', backNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
|
|
84
|
-
for (const referenceNode of iterateSnapshot(referenceNodes)) {
|
|
85
|
-
const bibliographyItem = (0, builders_1.buildBibliographyItem)({
|
|
86
|
-
type: chooseBibliographyItemType(null),
|
|
87
|
-
});
|
|
88
|
-
bibliographyItem.title = doc.evaluate('analytic/title', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
89
|
-
bibliographyItem.source = doc.evaluate('monogr/title', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
90
|
-
bibliographyItem.volume = doc.evaluate('monogr/imprint/biblScope[unit="volume"]', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
91
|
-
const fpage = doc.evaluate('monogr/imprint/biblScope[unit="page"]/@from', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
92
|
-
const lpage = doc.evaluate('monogr/imprint/biblScope[unit="page"]/@to', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
93
|
-
if (fpage) {
|
|
94
|
-
bibliographyItem.page = lpage ? `${fpage}-${lpage}` : fpage;
|
|
95
|
-
}
|
|
96
|
-
const date = doc.evaluate('monogr/imprint/date[type="published"]/@when', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
97
|
-
if (date) {
|
|
98
|
-
bibliographyItem.issued = (0, builders_1.buildBibliographicDate)({
|
|
99
|
-
'date-parts': [date.split(/-/)],
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
const authorNodes = doc.evaluate('analytic/author', referenceNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
|
|
103
|
-
bibliographyItem.author = [];
|
|
104
|
-
for (const authorNode of iterateSnapshot(authorNodes)) {
|
|
105
|
-
const name = (0, builders_1.buildBibliographicName)({});
|
|
106
|
-
name.given = doc.evaluate('persName/forename', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
107
|
-
name.family = doc.evaluate('persName/surname', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
108
|
-
bibliographyItem.author.push(name);
|
|
109
|
-
}
|
|
110
|
-
addModel(bibliographyItem);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
exports.parseBack = parseBack;
|
|
114
|
-
const parseTEIGROBIDArticle = (doc) => {
|
|
115
|
-
const modelMap = new Map();
|
|
116
|
-
const addModel = (0, model_map_1.addModelToMap)(modelMap);
|
|
117
|
-
(0, exports.parseFront)(doc, addModel);
|
|
118
|
-
(0, exports.parseBack)(doc, addModel);
|
|
119
|
-
return [...modelMap.values()];
|
|
120
|
-
};
|
|
121
|
-
exports.parseTEIGROBIDArticle = parseTEIGROBIDArticle;
|
|
@@ -1,115 +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 { buildAffiliation, buildBibliographicDate, buildBibliographicName, buildBibliographyItem, buildContributor, buildManuscript, } from './builders';
|
|
17
|
-
import { addModelToMap } from './model-map';
|
|
18
|
-
const iterateSnapshot = function* (snapshot) {
|
|
19
|
-
for (let i = 0; i < snapshot.snapshotLength; i++) {
|
|
20
|
-
yield snapshot.snapshotItem(i);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const namespaces = new Map([
|
|
24
|
-
[null, 'http://www.tei-c.org/ns/1.0'],
|
|
25
|
-
]);
|
|
26
|
-
const namespaceResolver = (prefix) => namespaces.get(prefix) || null;
|
|
27
|
-
export const parseFront = (doc, addModel) => {
|
|
28
|
-
const headerNode = doc.evaluate('/TEI/teiHeader', doc, namespaceResolver, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue;
|
|
29
|
-
if (!headerNode) {
|
|
30
|
-
throw new Error('No header element found!');
|
|
31
|
-
}
|
|
32
|
-
const title = doc.evaluate('fileDesc/titleStmt/title', headerNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
33
|
-
const manuscript = buildManuscript(title);
|
|
34
|
-
addModel(manuscript);
|
|
35
|
-
const affiliationsMap = new Map();
|
|
36
|
-
const authorNodes = doc.evaluate('fileDesc/sourceDesc/biblStruct/analytic/author', headerNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
|
|
37
|
-
for (const authorNode of iterateSnapshot(authorNodes)) {
|
|
38
|
-
const name = buildBibliographicName({});
|
|
39
|
-
name.given = doc.evaluate('persName/forename', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
40
|
-
name.family = doc.evaluate('persName/surname', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
41
|
-
const contributor = buildContributor(name, 'author', 1);
|
|
42
|
-
contributor.affiliations = [];
|
|
43
|
-
const affiliationNodes = doc.evaluate('affiliation', authorNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
|
|
44
|
-
for (const affiliationNode of iterateSnapshot(affiliationNodes)) {
|
|
45
|
-
const key = affiliationNode.getAttribute('key');
|
|
46
|
-
if (key) {
|
|
47
|
-
const affiliation = affiliationsMap.get(key);
|
|
48
|
-
if (affiliation) {
|
|
49
|
-
contributor.affiliations.push(affiliation._id);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
const affiliation = buildAffiliation('', 1);
|
|
53
|
-
affiliation.institution = doc.evaluate('orgName[@type="institution"]', affiliationNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
54
|
-
affiliation.department = doc.evaluate('orgName[@type="department"]', affiliationNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
55
|
-
addModel(affiliation);
|
|
56
|
-
affiliationsMap.set(key, affiliation);
|
|
57
|
-
contributor.affiliations.push(affiliation._id);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
addModel(contributor);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const chooseBibliographyItemType = (publicationType) => {
|
|
65
|
-
switch (publicationType) {
|
|
66
|
-
case 'book':
|
|
67
|
-
case 'thesis':
|
|
68
|
-
return publicationType;
|
|
69
|
-
case 'journal':
|
|
70
|
-
default:
|
|
71
|
-
return 'article-journal';
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
export const parseBack = (doc, addModel) => {
|
|
75
|
-
const backNode = doc.evaluate('/TEI/text/back', doc, namespaceResolver, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue;
|
|
76
|
-
if (!backNode) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const referenceNodes = doc.evaluate('div[@type="references"]/listBibl/biblStruct', backNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
|
|
80
|
-
for (const referenceNode of iterateSnapshot(referenceNodes)) {
|
|
81
|
-
const bibliographyItem = buildBibliographyItem({
|
|
82
|
-
type: chooseBibliographyItemType(null),
|
|
83
|
-
});
|
|
84
|
-
bibliographyItem.title = doc.evaluate('analytic/title', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
85
|
-
bibliographyItem.source = doc.evaluate('monogr/title', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
86
|
-
bibliographyItem.volume = doc.evaluate('monogr/imprint/biblScope[unit="volume"]', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
87
|
-
const fpage = doc.evaluate('monogr/imprint/biblScope[unit="page"]/@from', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
88
|
-
const lpage = doc.evaluate('monogr/imprint/biblScope[unit="page"]/@to', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
89
|
-
if (fpage) {
|
|
90
|
-
bibliographyItem.page = lpage ? `${fpage}-${lpage}` : fpage;
|
|
91
|
-
}
|
|
92
|
-
const date = doc.evaluate('monogr/imprint/date[type="published"]/@when', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
93
|
-
if (date) {
|
|
94
|
-
bibliographyItem.issued = buildBibliographicDate({
|
|
95
|
-
'date-parts': [date.split(/-/)],
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
const authorNodes = doc.evaluate('analytic/author', referenceNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
|
|
99
|
-
bibliographyItem.author = [];
|
|
100
|
-
for (const authorNode of iterateSnapshot(authorNodes)) {
|
|
101
|
-
const name = buildBibliographicName({});
|
|
102
|
-
name.given = doc.evaluate('persName/forename', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
103
|
-
name.family = doc.evaluate('persName/surname', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
104
|
-
bibliographyItem.author.push(name);
|
|
105
|
-
}
|
|
106
|
-
addModel(bibliographyItem);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
export const parseTEIGROBIDArticle = (doc) => {
|
|
110
|
-
const modelMap = new Map();
|
|
111
|
-
const addModel = addModelToMap(modelMap);
|
|
112
|
-
parseFront(doc, addModel);
|
|
113
|
-
parseBack(doc, addModel);
|
|
114
|
-
return [...modelMap.values()];
|
|
115
|
-
};
|