Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<![CDATA[ not always recognized #342

Open
peterdesmet opened this issue May 4, 2022 · 1 comment
Open

<![CDATA[ not always recognized #342

peterdesmet opened this issue May 4, 2022 · 1 comment

Comments

@peterdesmet
Copy link
Member

write_eml() will preserve text wrapped in <![CDATA[ and ]]> (expected), but the behaviour is not consistent:

library(EML)

text_1 <- "My text is <a href=\"https://example.com\">html</a>." # Does not work
text_2 <- "<em></em>My text is <a href=\"https://example.com\">html</a>." # Works
text_3 <- "My text is <em>html</em>." # Works

eml <- list(
  dataset = list(
    abstract = list(
      para = list(
        paste0("<![CDATA[", text_1, "]]>"),
        paste0("<![CDATA[", text_2, "]]>"),
        paste0("<![CDATA[", text_3, "]]>")
      )
    )
  )
)

EML::write_eml(eml, "test.xml")

Resulting XML:

<?xml version="1.0" encoding="UTF-8"?>
<eml:eml xmlns:eml="https://eml.ecoinformatics.org/eml-2.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:stmml="http://www.xml-cml.org/schema/stmml-1.2" packageId="ed7f9836-d2ae-4a04-9473-d377db387c54" system="uuid" xsi:schemaLocation="https://eml.ecoinformatics.org/eml-2.2.0 https://eml.ecoinformatics.org/eml-2.2.0/eml.xsd">
  <dataset>
    <abstract>
      <para>&lt;![CDATA[My text is &lt;a href="https://example.com"&gt;html&lt;/a&gt;.]]&gt;</para>
      <para><![CDATA[<em></em>My text is <a href="https://example.com">html</a>.]]></para>
      <para><![CDATA[My text is <em>html</em>.]]></para>
    </abstract>
  </dataset>
</eml:eml>
@mbjones
Copy link
Member

mbjones commented May 4, 2022

My immediate guess is that this has the same root cause as #315 , and is a side-effect of the approach used to simplify docbook processing. There are some fundamental issues discussed in #315 that would need to be resolved to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants