Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@manuscripts/transform",
"description": "ProseMirror transformer for Manuscripts applications",
"version": "4.5.7",
"version": "4.5.8-LEAN-6032.0",
"repository": "github:Atypon-OpenSource/manuscripts-transform",
"license": "Apache-2.0",
"main": "dist/cjs",
Expand Down
6 changes: 3 additions & 3 deletions src/jats/__tests__/__snapshots__/jats-exporter.test.ts.snap

Large diffs are not rendered by default.

76 changes: 25 additions & 51 deletions src/jats/__tests__/__snapshots__/jats-importer.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3163,7 +3163,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -18051,7 +18050,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -18279,7 +18277,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -18964,7 +18961,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -23392,7 +23388,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -27254,7 +27249,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -27410,7 +27404,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -31390,9 +31383,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": Object {
"literal": "Source: Wikipedia.",
},
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -31420,18 +31410,6 @@ Object {
},
"type": "figure",
},
Object {
"attrs": Object {
"dataTracked": null,
},
"content": Array [
Object {
"text": "Source: Wikipedia.",
"type": "text",
},
],
"type": "attribution",
},
Object {
"attrs": Object {
"dataTracked": null,
Expand Down Expand Up @@ -31465,6 +31443,18 @@ Object {
],
"type": "caption",
},
Object {
"attrs": Object {
"dataTracked": null,
},
"content": Array [
Object {
"text": "Source: Wikipedia.",
"type": "text",
},
],
"type": "attribution",
},
Object {
"attrs": Object {
"id": "MPAltText:test",
Expand Down Expand Up @@ -31494,9 +31484,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": Object {
"literal": "Source: Wikipedia.",
},
"dataTracked": null,
"id": "fig1",
},
Expand All @@ -31522,18 +31509,6 @@ Object {
},
"type": "missing_figure",
},
Object {
"attrs": Object {
"dataTracked": null,
},
"content": Array [
Object {
"text": "Source: Wikipedia.",
"type": "text",
},
],
"type": "attribution",
},
Object {
"attrs": Object {
"dataTracked": null,
Expand Down Expand Up @@ -31567,6 +31542,18 @@ Object {
],
"type": "caption",
},
Object {
"attrs": Object {
"dataTracked": null,
},
"content": Array [
Object {
"text": "Source: Wikipedia.",
"type": "text",
},
],
"type": "attribution",
},
Object {
"attrs": Object {
"id": "MPAltText:test",
Expand Down Expand Up @@ -31868,7 +31855,7 @@ Object {
"type": "cross_reference",
},
Object {
"text": ". Kinds of tables This is a table title continued paragraph Table_Head Table_Body* * Table_Footnote Block_Quote Source: Wikipedia Paragraph_Continued with a graphic in the middlewhere the paragraph continues.",
"text": ". Kinds of tables This is a table title continued paragraph Table_Head Table_Body* * Table_Footnote Block_Quote Source: WikipediaParagraph_Continued with a graphic in the middlewhere the paragraph continues.",
"type": "text",
},
],
Expand Down Expand Up @@ -33365,7 +33352,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -33445,7 +33431,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -35144,7 +35129,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -39030,7 +39014,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -39186,7 +39169,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -45241,7 +45223,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -51869,7 +51850,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -52386,7 +52366,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -52948,7 +52927,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -53604,7 +53582,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -54014,7 +53991,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -54518,7 +54494,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down Expand Up @@ -54964,7 +54939,6 @@ Object {
},
Object {
"attrs": Object {
"attribution": undefined,
"dataTracked": null,
"id": "MPFigureElement:test",
},
Expand Down
15 changes: 6 additions & 9 deletions src/jats/exporter/jats-exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class JATSExporter {
type: ManuscriptNodeType
) => {
const childNode = this.getFirstChildOfType(type, node)
if (childNode) {
if (childNode && childNode.content.size > 0) {
$element.appendChild(this.serializeNode(childNode))
}
}
Expand Down Expand Up @@ -1167,13 +1167,6 @@ export class JATSExporter {
}
}
}
const appendAttributions = ($element: Element, node: ManuscriptNode) => {
if (node.attrs.attribution) {
const $attrib = this.createElement('attrib')
$attrib.textContent = node.attrs.attribution.literal
$element.appendChild($attrib)
}
}

const appendTable = ($element: Element, node: ManuscriptNode) => {
const tableNode = this.getFirstChildOfType(schema.nodes.table, node)
Expand Down Expand Up @@ -1271,6 +1264,7 @@ export class JATSExporter {
this.appendCaption($graphic, node)
this.appendChildNodeOfType($graphic, node, schema.nodes.alt_text)
this.appendChildNodeOfType($graphic, node, schema.nodes.long_desc)
this.appendChildNodeOfType($graphic, node, schema.nodes.attribution)
return $graphic
Comment thread
asouqi marked this conversation as resolved.
}

Expand Down Expand Up @@ -1309,11 +1303,11 @@ export class JATSExporter {
node.type.schema.nodes.footnotes_element
)
processChildNodes($fig, node, contentNodeType)
appendAttributions($fig, node)
if (isExecutableNodeType(node.type)) {
processExecutableNode(node, $fig)
}
moveAltTextAndLongDescToGraphics($fig)
this.appendChildNodeOfType($fig, node, schema.nodes.attribution)
return $fig
}

Expand Down Expand Up @@ -1817,6 +1811,9 @@ export class JATSExporter {
$graphic = this.serializeNode(node) as Element
$floatsGroup.appendChild($graphic)
} else {
if (node.type === schema.nodes.attribution && node.content.size === 0) {
return
}
const $serializedNode = this.serializeNode(node)
$graphic?.appendChild($serializedNode)
}
Expand Down
20 changes: 12 additions & 8 deletions src/jats/importer/jats-dom-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ export class JATSDOMParser {
private getFigContent = (node: Node) => {
const element = node as HTMLElement
const content = [this.schema.nodes.figure.create(this.getFigAttrs(element))]
const attribution = element.querySelector('attrib')
if (attribution) {
const attributionNode = this.schema.nodes.attribution.create()
content.push(this.parse(attribution, { topNode: attributionNode }))
}
const altText = element.querySelector('alt-text')
if (altText) {
const altTextNode = this.schema.nodes.alt_text.create()
Expand Down Expand Up @@ -608,10 +613,11 @@ export class JATSDOMParser {
return Fragment.from(this.schema.text('_'))
},
},

{
tag: 'attrib',
node: 'attribution',
context:
'figure_element/|image_element/|hero_image/|blockquote_element/|pullquote_element/',
},
{
tag: 'back',
Expand Down Expand Up @@ -884,15 +890,8 @@ export class JATSDOMParser {
node: 'figure_element',
getAttrs: (node) => {
const element = node as HTMLElement
const attrib = element.querySelector('attrib')
const attribution = attrib
? {
literal: getTrimmedTextContent(attrib) ?? '',
}
: undefined
return {
id: element.getAttribute('id'),
attribution,
}
},
},
Expand Down Expand Up @@ -979,6 +978,11 @@ export class JATSDOMParser {
tag: 'p[content-type="headshots"]',
node: 'headshot_grid',
},
{
tag: 'p',
node: 'text_block',
context: 'pullquote_element/|blockquote_element/',
},
{
tag: 'p',
node: 'paragraph',
Expand Down
Loading