Skip to content

Newline before XML element is lost when reading JATS XML #72

@castedo

Description

@castedo

REPO STEPS:
With the following article.xml:

<article>
  <front>
    <article-meta>
      <title-group>
        <article-title>Newline before XML element test</article-title>
      </title-group>
    </article-meta>
  </front>
  <body>
    <p>Lines
       before
      <ext-link ext-link-type="uri" xlink:href="https://en.wikipedia.org/wiki/XML">XML</ext-link> element.</p>
  </body>
</article>

run

jats convert --frontmatter page article.xml

GOT:
A article.myst.json file with:

{
  "mdast": {
    "type": "root",
    "children": [
      {
        "type": "block",
        "data": {},
        "children": [
          {
            "type": "paragraph",
            "children": [
              {
                "type": "text",
                "value": "Lines\n       before"
              },
              {
                "type": "link",
                "url": "https://en.wikipedia.org/wiki/XML",
                "children": [
                  {
                    "type": "text",
                    "value": "XML"
                  }
                ]
              },
              {
                "type": "text",
                "value": " element."
              }
            ]
          }
        ]
      }
    ]
  },
  "frontmatter": {
    "title": "Newline before XML element test",
    "abbreviations": {}
  }
}

EXPECTED:
The "value": "Lines\n before" to have a newline character \n after before.

IMPACT:
Information is lost. The XML has whitespace between the word "before" and the ext-link XML element, but the output JSON has lost that information. When this article.myst.json is used to generate a webpage using the myst CLI (mystmd) the HTML hyperlink is stuck right next to the text "before" without any whitespace.

VERSION:

$ jats -v
v1.0.18

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions