From d0a5f2aded6ace0e6310b622d6560fa9fee1d9e3 Mon Sep 17 00:00:00 2001
From: Mauro Bieg <mb21@users.noreply.github.com>
Date: Sun, 10 Feb 2019 16:22:12 +0100
Subject: [PATCH] JATS writer: wrap figure caption in <p> to fix validation
 (#5292)

closes #5290
---
 src/Text/Pandoc/Writers/JATS.hs | 2 +-
 test/writer.jats                | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Text/Pandoc/Writers/JATS.hs b/src/Text/Pandoc/Writers/JATS.hs
index 565ed6589..03bcde414 100644
--- a/src/Text/Pandoc/Writers/JATS.hs
+++ b/src/Text/Pandoc/Writers/JATS.hs
@@ -230,7 +230,7 @@ blockToJATS opts (Para [Image (ident,_,kvs) txt
   let (maintype, subtype) = imageMimeType src kvs
   let capt = if null txt
                 then empty
-                else inTagsSimple "caption" alt
+                else inTagsSimple "caption" $ inTagsSimple "p" alt
   let attr = [("id", ident) | not (null ident)] ++
              [(k,v) | (k,v) <- kvs, k `elem` ["fig-type", "orientation",
                                               "position", "specific-use"]]
diff --git a/test/writer.jats b/test/writer.jats
index f87b2325a..a4d604607 100644
--- a/test/writer.jats
+++ b/test/writer.jats
@@ -835,7 +835,7 @@ These should not be escaped:  \$ \\ \&gt; \[ \{</preformat>
   <title>Images</title>
   <p>From “Voyage dans la Lune” by Georges Melies (1902):</p>
   <fig>
-    <caption>lalune</caption>
+    <caption><p>lalune</p></caption>
     <graphic mimetype="image" mime-subtype="jpeg" xlink:href="lalune.jpg" xlink:title="Voyage dans la Lune" />
   </fig>
   <p>Here is a movie