stencila / encoda

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

fix(JATS): Don't duplicate footnote content in abstract #969

Open rgieseke opened 3 years ago

rgieseke commented 3 years ago

Previously all <p>s in an abstract would be rendered. With footnotes a paragraph can appear nested "inside" of a paragraph.

Before:

{
  "type": "Article",
  "description": [
    {
      "type": "Paragraph",
      "content": [
        "The abstract can contain a footnote.",
        {
          "type": "Note",
          "id": "note-1",
          "noteType": "Footnote",
          "content": [
            {
              "type": "Paragraph",
              "id": "footnote1",
              "content": [
                "A footnote from the abstract."
              ]
            }
          ]
        }
      ]
    },
    {
      "type": "Paragraph",
      "id": "footnote1",
      "content": [
        "A footnote from the abstract."
      ]
    }
  ],

With using children instead of all:

  "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."
          ]
        }
      ]
    }
  ],

I tried updating the fixtures, but couldn't get it to work, even with --clearCache.

nokome commented 3 years ago

Thanks for this fix. I have updated the snapshots locally and unfortunately it breaks the snapshot src/codecs/plos/__file_snapshots__/pmed-1002858.yaml by removing the abstract completely: https://dev.azure.com/stencila/stencila/_build/results?buildId=14028&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb&t=d9b15392-e4ce-5e4c-0c8c-b69645229181&l=2005. I'll look into it some more - it may need on level of unwrapping of the abstract contents.

rgieseke commented 3 years ago

That's ... a problem! I just tested adding more paragraphs to the abstact in __fixtures__/footnote.xml and those didn't disappear.

rgieseke commented 3 years ago

I looked a bit into the plos problem, but couldn't figure it out. I thought the decoder should be able to handle an array of paragraphs as an abstract.