aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/JATS.hs9
-rw-r--r--test/Tests/Readers/JATS.hs17
2 files changed, 26 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/JATS.hs b/src/Text/Pandoc/Readers/JATS.hs
index d7f87f695..d3d742de3 100644
--- a/src/Text/Pandoc/Readers/JATS.hs
+++ b/src/Text/Pandoc/Readers/JATS.hs
@@ -317,6 +317,7 @@ parseMetadata e = do
getTitle e
getAuthors e
getAffiliations e
+ getAbstract e
return mempty
getTitle :: PandocMonad m => Element -> JATS m ()
@@ -348,6 +349,14 @@ getAffiliations x = do
affs <- mapM getInlines $ filterChildren (named "aff") x
unless (null affs) $ addMeta "institute" affs
+getAbstract :: PandocMonad m => Element -> JATS m ()
+getAbstract e =
+ case filterElement (named "abstract") e of
+ Just s -> do
+ blks <- getBlocks s
+ addMeta "abstract" blks
+ Nothing -> pure ()
+
getContrib :: PandocMonad m => Element -> JATS m Inlines
getContrib x = do
given <- maybe (return mempty) getInlines
diff --git a/test/Tests/Readers/JATS.hs b/test/Tests/Readers/JATS.hs
index 2ac0f6d8f..3c61f602f 100644
--- a/test/Tests/Readers/JATS.hs
+++ b/test/Tests/Readers/JATS.hs
@@ -21,6 +21,8 @@ import Text.Pandoc
import Text.Pandoc.Arbitrary ()
import Text.Pandoc.Builder
+import qualified Data.Text as T
+
jats :: Text -> Pandoc
jats = purely $ readJATS def
@@ -126,4 +128,19 @@ tests = [ testGroup "inline code"
\</sec>"
=?> header 1 (image "imgs/foo.jpg" "" mempty)
]
+
+ , testGroup "metadata"
+ [ test jats "abstract" $
+ T.unlines [ "<front>"
+ , "<article-meta>"
+ , "<abstract>"
+ , "<p>Paragraph 1</p>"
+ , "<p>Paragraph 2</p>"
+ , "</abstract>"
+ , "</article-meta>"
+ , "</front>"
+ ] =?>
+ let abstract = para "Paragraph 1" <> para "Paragraph 2"
+ in setMeta "abstract" abstract $ doc mempty
+ ]
]