From 35350fac85f671079d4ce433263e15de646d55f9 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Sun, 27 Mar 2022 09:32:55 -0700
Subject: [PATCH] JATS writer: avoid doubled ref-list element.

Previously when generating JATS with the `element_citations`
extension enabled, the references were put in a doubly-nested
ref-list element (`<ref-list><ref-list>...`).  This is now fixed.

Closes #7990.
---
 src/Text/Pandoc/Writers/JATS/References.hs |   2 +-
 test/command/7042.md                       | 122 ++++++++++-----------
 2 files changed, 61 insertions(+), 63 deletions(-)

diff --git a/src/Text/Pandoc/Writers/JATS/References.hs b/src/Text/Pandoc/Writers/JATS/References.hs
index 382931a86..2e4283dbe 100644
--- a/src/Text/Pandoc/Writers/JATS/References.hs
+++ b/src/Text/Pandoc/Writers/JATS/References.hs
@@ -37,7 +37,7 @@ referencesToJATS :: PandocMonad m
                  -> [Reference Inlines]
                  -> JATS m (Doc Text)
 referencesToJATS opts =
-  fmap (inTags True "ref-list" [] . vcat) . mapM (referenceToJATS opts)
+  fmap vcat . mapM (referenceToJATS opts)
 
 referenceToJATS :: PandocMonad m
                 => WriterOptions
diff --git a/test/command/7042.md b/test/command/7042.md
index 5c4b90d48..413ebe704 100644
--- a/test/command/7042.md
+++ b/test/command/7042.md
@@ -79,68 +79,66 @@ references:
 </body>
 <back>
 <ref-list>
-  <ref-list>
-    <ref id="ref-year-month">
-      <element-citation publication-type="article-journal">
-        <person-group person-group-type="author">
-          <name><surname>Jane</surname><given-names>Doe</given-names></name>
-        </person-group>
-        <article-title>Year and month</article-title>
-        <source>Public Library of Tests</source>
-        <year iso-8601-date="1999-08">1999</year><month>08</month>
-      </element-citation>
-    </ref>
-    <ref id="ref-access-date">
-      <element-citation publication-type="article-journal">
-        <person-group person-group-type="author">
-          <name><surname>Negidius</surname><given-names>Numerius</given-names></name>
-          <etal/>
-        </person-group>
-        <article-title>Entry with access date and et al.</article-title>
-        <source>Public Library of Tests</source>
-        <year iso-8601-date="1911-10-03">1911</year><month>10</month><day>03</day>
-        <date-in-citation content-type="access-date"><year iso-8601-date="1999-01-22">1999</year><month>01</month><day>22</day></date-in-citation>
-      </element-citation>
-    </ref>
-    <ref id="ref-name-particles">
-      <element-citation publication-type="article-journal">
-        <person-group person-group-type="author">
-          <name><surname>Beethoven</surname><given-names>Ludwig van</given-names></name>
-          <name><surname>de Bray</surname><given-names>Jan</given-names></name>
-        </person-group>
-        <article-title>Name particles, dropping and non-dropping</article-title>
-        <source>Public Library of Tests</source>
-        <year iso-8601-date="1820">1820</year>
-      </element-citation>
-    </ref>
-    <ref id="ref-book-with-japanese-authors">
-      <element-citation publication-type="book">
-        <person-group person-group-type="author">
-          <string-name>宮水 三葉</string-name>
-          <string-name>立花 瀧</string-name>
-        </person-group>
-        <source>Big Book of Tests</source>
-        <year iso-8601-date="2016">2016</year>
-      </element-citation>
-    </ref>
-    <ref id="ref-full-journal-article-entry">
-      <element-citation publication-type="article-journal">
-        <person-group person-group-type="author">
-          <name><surname>Watson</surname><given-names>J. D.</given-names></name>
-          <name><surname>Crick</surname><given-names>F. H. C.</given-names></name>
-        </person-group>
-        <article-title>Molecular Structure of Nucleic Acids: A Structure for Deoxyribose Nucleic Acid</article-title>
-        <source>Nature</source>
-        <year iso-8601-date="1953-04-01">1953</year><month>04</month><day>01</day>
-        <volume>171</volume>
-        <issue>4356</issue>
-        <fpage>737</fpage>
-        <page-range>737-738</page-range>
-        <pub-id pub-id-type="doi">10.1038/171737a0</pub-id>
-        <pub-id pub-id-type="pmid">13054692</pub-id>
-      </element-citation>
-    </ref>
-  </ref-list>
+  <ref id="ref-year-month">
+    <element-citation publication-type="article-journal">
+      <person-group person-group-type="author">
+        <name><surname>Jane</surname><given-names>Doe</given-names></name>
+      </person-group>
+      <article-title>Year and month</article-title>
+      <source>Public Library of Tests</source>
+      <year iso-8601-date="1999-08">1999</year><month>08</month>
+    </element-citation>
+  </ref>
+  <ref id="ref-access-date">
+    <element-citation publication-type="article-journal">
+      <person-group person-group-type="author">
+        <name><surname>Negidius</surname><given-names>Numerius</given-names></name>
+        <etal/>
+      </person-group>
+      <article-title>Entry with access date and et al.</article-title>
+      <source>Public Library of Tests</source>
+      <year iso-8601-date="1911-10-03">1911</year><month>10</month><day>03</day>
+      <date-in-citation content-type="access-date"><year iso-8601-date="1999-01-22">1999</year><month>01</month><day>22</day></date-in-citation>
+    </element-citation>
+  </ref>
+  <ref id="ref-name-particles">
+    <element-citation publication-type="article-journal">
+      <person-group person-group-type="author">
+        <name><surname>Beethoven</surname><given-names>Ludwig van</given-names></name>
+        <name><surname>de Bray</surname><given-names>Jan</given-names></name>
+      </person-group>
+      <article-title>Name particles, dropping and non-dropping</article-title>
+      <source>Public Library of Tests</source>
+      <year iso-8601-date="1820">1820</year>
+    </element-citation>
+  </ref>
+  <ref id="ref-book-with-japanese-authors">
+    <element-citation publication-type="book">
+      <person-group person-group-type="author">
+        <string-name>宮水 三葉</string-name>
+        <string-name>立花 瀧</string-name>
+      </person-group>
+      <source>Big Book of Tests</source>
+      <year iso-8601-date="2016">2016</year>
+    </element-citation>
+  </ref>
+  <ref id="ref-full-journal-article-entry">
+    <element-citation publication-type="article-journal">
+      <person-group person-group-type="author">
+        <name><surname>Watson</surname><given-names>J. D.</given-names></name>
+        <name><surname>Crick</surname><given-names>F. H. C.</given-names></name>
+      </person-group>
+      <article-title>Molecular Structure of Nucleic Acids: A Structure for Deoxyribose Nucleic Acid</article-title>
+      <source>Nature</source>
+      <year iso-8601-date="1953-04-01">1953</year><month>04</month><day>01</day>
+      <volume>171</volume>
+      <issue>4356</issue>
+      <fpage>737</fpage>
+      <page-range>737-738</page-range>
+      <pub-id pub-id-type="doi">10.1038/171737a0</pub-id>
+      <pub-id pub-id-type="pmid">13054692</pub-id>
+    </element-citation>
+  </ref>
 </ref-list>
 </back>
 </article>