stencila / encoda

↔️ A format converter for Stencila documents
https://stencila.github.io/encoda/
Apache License 2.0
35 stars 9 forks source link

JATS: Encoding tables without labels #420

Open fred-atherden opened 4 years ago

fred-atherden commented 4 years ago

Tables without labels are given one when encoded in jats.

Steps to reproduce

Visit here and note the table without a label.

This command

encoda convert https://elifesciences.org/articles/48093v2 48093.jsonld

produces a jsonld file containing the table without a label:

{
   ...
    "type": "Table",
    "id": "inlinetable1"
}

However this command

encoda convert https://elifesciences.org/articles/48093v2 48093.xml --to jats

produces an xml file where the label has been given the label 'Table 1':

<table-wrap id="inlinetable1">
    <label>Table 1.</label>
    <caption/>
    <table>
        ...
    </table>
</table-wrap>
nokome commented 4 years ago

The offending line is in encodeTable:

https://github.com/stencila/encoda/blob/53ceb9f3018fabf9755c84538a469cbf61f05248/src/codecs/jats/index.ts#L1577

It should not create a label automatically.

However, currently there is no Table.label (or CreativeWork.label property analogous to JATS <label>) and so in decodeTableWrap, this information is not captured. I lean towards using Thing.name for this (an alternative would be to use Entity.meta but that feels temporary).

nokome commented 4 years ago

Noting that the label has been added as a property of Table and the above line changed, but that it still defaults to generating a label if the table does not have one.

https://github.com/stencila/encoda/blob/ac9fddb8c8007edcb0399af864fc0b6cfd9ed6ab/src/codecs/jats/index.ts#L1769