Skip to content

Commit

Permalink
Merge pull request #1098 from stencila/comments-in-reference
Browse files Browse the repository at this point in the history
add decode for reference comments and update snapshots
  • Loading branch information
will-byrne authored Feb 11, 2025
2 parents 8fec866 + 753a047 commit bb9d3e9
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/codecs/jats/__file_snapshots__/ijm-00202.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,9 @@ references:
- Grown
givenNames:
- Valodia
comments:
- type: Comment
commentAspect: Chapter 1
datePublished:
type: Date
value: '2010'
Expand Down Expand Up @@ -996,6 +999,9 @@ references:
- Grown
givenNames:
- Valodia
comments:
- type: Comment
commentAspect: Chapter 3
datePublished:
type: Date
value: '2010'
Expand Down
3 changes: 3 additions & 0 deletions src/codecs/jats/__file_snapshots__/plosone-0091296.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ references:
- Banks
givenNames:
- S
comments:
- type: Comment
commentAspect: doi:10.1371/journal.pbio.1000606
datePublished:
type: Date
value: '2011'
Expand Down
66 changes: 66 additions & 0 deletions src/codecs/jats/__file_snapshots__/plosone-0178565.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ references:
- Steward
givenNames:
- GF
comments:
- type: Comment
commentAspect: 'doi: 10.1038/35088063'
datePublished:
type: Date
value: '2001'
Expand Down Expand Up @@ -304,6 +307,9 @@ references:
- Wangikar
givenNames:
- PP
comments:
- type: Comment
commentAspect: 'doi: 10.1002/bit.24882'
datePublished:
type: Date
value: '2013'
Expand Down Expand Up @@ -563,6 +569,9 @@ references:
- Atsumi
givenNames:
- S
comments:
- type: Comment
commentAspect: 'doi: 10.3389/fbioe.2013.00007'
datePublished:
type: Date
value: '2013'
Expand All @@ -586,6 +595,9 @@ references:
- Stephanopoulos
givenNames:
- G
comments:
- type: Comment
commentAspect: 'doi: 10.1006/mben.1998.0101'
datePublished:
type: Date
value: '1999'
Expand Down Expand Up @@ -638,6 +650,9 @@ references:
- Baba
givenNames:
- T
comments:
- type: Comment
commentAspect: 'doi: 10.1128/JB.00740-06'
datePublished:
type: Date
value: '2006'
Expand Down Expand Up @@ -806,6 +821,9 @@ references:
- Veronneau
givenNames:
- S
comments:
- type: Comment
commentAspect: 'doi: 10.1038/nature00935'
datePublished:
type: Date
value: '2002'
Expand Down Expand Up @@ -838,6 +856,9 @@ references:
- Arndt
givenNames:
- GM
comments:
- type: Comment
commentAspect: 'doi: 10.1111/j.1440-1711.2005.01332.x'
datePublished:
type: Date
value: '2005'
Expand Down Expand Up @@ -932,6 +953,9 @@ references:
- Oltvai
givenNames:
- ZN
comments:
- type: Comment
commentAspect: 'doi: 10.1038/35075138'
datePublished:
type: Date
value: '2001'
Expand Down Expand Up @@ -974,6 +998,9 @@ references:
- Bond
givenNames:
- AT
comments:
- type: Comment
commentAspect: 'doi: 10.1093/bioinformatics/bth234'
datePublished:
type: Date
value: '2004'
Expand Down Expand Up @@ -1118,6 +1145,9 @@ references:
- Wangikar
givenNames:
- PP
comments:
- type: Comment
commentAspect: 'doi: 10.1007/s11120-013-9911-5'
datePublished:
type: Date
value: '2013'
Expand Down Expand Up @@ -1167,6 +1197,9 @@ references:
- Blankenship
givenNames:
- RE
comments:
- type: Comment
commentAspect: 'doi: 10.1126/science.1075558'
datePublished:
type: Date
value: '2002'
Expand Down Expand Up @@ -1301,6 +1334,9 @@ references:
- Li
givenNames:
- W
comments:
- type: Comment
commentAspect: 'doi: 10.1093/bioinformatics/bts565'
datePublished:
type: Date
value: '2012'
Expand Down Expand Up @@ -1343,6 +1379,9 @@ references:
- Wangikar
givenNames:
- PP
comments:
- type: Comment
commentAspect: 'doi: 10.1007/s10482-012-9813-0'
datePublished:
type: Date
value: '2013'
Expand Down Expand Up @@ -1390,6 +1429,9 @@ references:
- Begley
givenNames:
- TP
comments:
- type: Comment
commentAspect: 'doi: 10.1074/jbc.C100033200'
datePublished:
type: Date
value: '2001'
Expand Down Expand Up @@ -1445,6 +1487,9 @@ references:
- Ladner
givenNames:
- JE
comments:
- type: Comment
commentAspect: 'doi: 10.1021/bi049059z'
datePublished:
type: Date
value: '2004'
Expand Down Expand Up @@ -1499,6 +1544,9 @@ references:
- Bayer
givenNames:
- P
comments:
- type: Comment
commentAspect: 'doi: 10.1073/pnas.0407371101'
datePublished:
type: Date
value: '2004'
Expand Down Expand Up @@ -1535,6 +1583,9 @@ references:
- Golden
givenNames:
- SS
comments:
- type: Comment
commentAspect: 'doi: 10.1128/MMBR.00036-15'
datePublished:
type: Date
value: '2015'
Expand Down Expand Up @@ -1587,6 +1638,9 @@ references:
- Chetty
givenNames:
- M
comments:
- type: Comment
commentAspect: 'doi: 10.3389/fmicb.2013.00374'
datePublished:
type: Date
value: '2013'
Expand Down Expand Up @@ -1637,6 +1691,9 @@ references:
- Moreno
givenNames:
- PA
comments:
- type: Comment
commentAspect: 'doi: 10.1023/A:1023990402346'
datePublished:
type: Date
value: '2003'
Expand Down Expand Up @@ -1680,6 +1737,9 @@ references:
- Meurer
givenNames:
- J
comments:
- type: Comment
commentAspect: 'doi: 10.1021/bi0348260'
datePublished:
type: Date
value: '2004'
Expand Down Expand Up @@ -2053,6 +2113,9 @@ references:
- Gatti
givenNames:
- DL
comments:
- type: Comment
commentAspect: 'doi: 10.1093/emboj/19.17.4838'
datePublished:
type: Date
value: '2000'
Expand Down Expand Up @@ -2171,6 +2234,9 @@ references:
- Bolt
givenNames:
- EL
comments:
- type: Comment
commentAspect: 'doi: 10.1042/BJ20110901'
datePublished:
type: Date
value: '2011'
Expand Down
11 changes: 11 additions & 0 deletions src/codecs/jats/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,16 @@ export function decodeReference(
metaEntries.label = label
}

const comment = textOrUndefined(child(elem, 'comment'))
const comments: stencila.CreativeWork['comments'] = comment
? [
{
type: 'Comment',
commentAspect: comment,
},
]
: []

return stencila.article({
id,
authors,
Expand All @@ -1510,6 +1520,7 @@ export function decodeReference(
publisher,
identifiers,
url,
...(comments.length ? { comments } : {}),
meta: {
...(metaEntries ? { ...metaEntries } : {}),
...(publicationType
Expand Down
15 changes: 15 additions & 0 deletions src/codecs/jats/jats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,21 @@ test('decode: reference issue number parsed as a string', () => {
expect((result.isPartOf as PublicationIssue)?.issueNumber).toEqual('The Issue')
})

test('decode: reference comment is parsed out', () => {
const reference = `
<mixed-citation publication-type="journal">
<string-name><surname>Calabrese</surname> <given-names>C</given-names></string-name>, <string-name><surname>Panuzzo</surname> <given-names>C</given-names></string-name> <etal>et al</etal> (<year>n.d.</year>)<comment>This is a comment</comment><article-title>Deferasirox-Dependent Iron Chelation Enhances Mitochondrial Dysfunction and Restores p53 Signaling by Stabilization of p53 Family Members in Leukemic Cells</article-title>. <source>International journal of molecular sciences</source>
</mixed-citation>
`
const citation = xml.load(reference).elements?.[0]!

const result = decodeReference(citation, null, undefined)
expect(result?.comments).toEqual([{
type: 'Comment',
commentAspect: 'This is a comment',
}]);
})

test('decode: <table-wrap> element that has more than one <graphic>', () => {
const fig = xml.load(`
<table-wrap id="tblS1" orientation="portrait" position="float">
Expand Down

0 comments on commit bb9d3e9

Please sign in to comment.