From a1c71af371dc86b210bc4a2351828bf4b04786b8 Mon Sep 17 00:00:00 2001 From: Robert Gieseke Date: Tue, 6 Jul 2021 19:23:11 +0200 Subject: [PATCH 1/2] fix(JATS): Don't duplicate footnote content in abstract Previously all `

`s would be rendered. With footnotes a paragraph can appear nested "inside" of a paragraph. --- src/codecs/jats/__fixtures__/footnote.xml | 7 ++++++- src/codecs/jats/index.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/codecs/jats/__fixtures__/footnote.xml b/src/codecs/jats/__fixtures__/footnote.xml index dacf91862..b2cacf0ef 100644 --- a/src/codecs/jats/__fixtures__/footnote.xml +++ b/src/codecs/jats/__fixtures__/footnote.xml @@ -1,6 +1,11 @@

+ + +

The abstract can contain a footnote.

A footnote from the abstract.

+
+
-

Further

An important footnote.

thoughts below.

+

Further

An important footnote.

thoughts below.

diff --git a/src/codecs/jats/index.ts b/src/codecs/jats/index.ts index 311f4891d..547d37f6b 100644 --- a/src/codecs/jats/index.ts +++ b/src/codecs/jats/index.ts @@ -509,7 +509,7 @@ function decodeAbstract( state: DecodeState ): stencila.Article['description'] { if (elem === null) return undefined - const ps = all(elem, 'p') + const ps = children(elem, 'p') if (ps.length === 0) return undefined if (ps.length === 1) { const content = decodeInlineContent(ps, state) From b52f8dbe381043217ea79750cb60d4626af861d9 Mon Sep 17 00:00:00 2001 From: Robert Gieseke Date: Wed, 28 Jul 2021 12:22:46 +0200 Subject: [PATCH 2/2] fix(JATS): Update test snapshot --- .../jats/__file_snapshots__/footnote.jats.xml | 21 +++++++++++++ .../jats/__file_snapshots__/footnote.yaml | 31 +++++++++++++++++++ src/codecs/jats/jats.test.ts | 1 + 3 files changed, 53 insertions(+) create mode 100644 src/codecs/jats/__file_snapshots__/footnote.jats.xml create mode 100644 src/codecs/jats/__file_snapshots__/footnote.yaml diff --git a/src/codecs/jats/__file_snapshots__/footnote.jats.xml b/src/codecs/jats/__file_snapshots__/footnote.jats.xml new file mode 100644 index 000000000..01f7d7b9d --- /dev/null +++ b/src/codecs/jats/__file_snapshots__/footnote.jats.xml @@ -0,0 +1,21 @@ + + +
+ + + + Untitled + + + +

The abstract can contain a footnote.

+
+
+
+ + +

Further thoughts below.

+
+ + +
\ No newline at end of file diff --git a/src/codecs/jats/__file_snapshots__/footnote.yaml b/src/codecs/jats/__file_snapshots__/footnote.yaml new file mode 100644 index 000000000..900ee79c6 --- /dev/null +++ b/src/codecs/jats/__file_snapshots__/footnote.yaml @@ -0,0 +1,31 @@ +type: Article +description: + - The abstract can contain a footnote. + - type: Note + id: note-1 + noteType: Footnote + content: + - type: Paragraph + id: footnote1 + content: + - A footnote from the abstract. +identifiers: [] +title: Untitled +meta: {} +content: + - type: Paragraph + content: + - Further + - type: Note + id: note-2 + noteType: Footnote + content: + - type: Paragraph + id: footnote2 + content: + - 'An ' + - type: Strong + content: + - important + - ' footnote.' + - ' thoughts below.' diff --git a/src/codecs/jats/jats.test.ts b/src/codecs/jats/jats.test.ts index a95439c69..d3c09a3aa 100644 --- a/src/codecs/jats/jats.test.ts +++ b/src/codecs/jats/jats.test.ts @@ -77,6 +77,7 @@ describe('encode: Math', () => { test.each([ 'fig.xml', 'statement.xml', + 'footnote.xml', 'elife-30274-v1', 'elife-43154-v2', 'elife-46472-v3',