summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2022-03-28 16:34:44 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2022-03-28 17:04:10 -0700
commit5c7dc4c7f342114cdcd033086987ca36dfb177f0 (patch)
treeea6646d79d3b7650cb4e992e5e9fabf53143b0c5 /src
parentc5cd03a022c4baf7cb81c7f651946476eeed051d (diff)
JATS reader: support PMID, DOI, issue in citations.
Closes #7995.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/JATS.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/JATS.hs b/src/Text/Pandoc/Readers/JATS.hs
index 03ed4a659..516bf2f14 100644
--- a/src/Text/Pandoc/Readers/JATS.hs
+++ b/src/Text/Pandoc/Readers/JATS.hs
@@ -21,7 +21,7 @@ import Data.Default
import Data.Generics
import Data.List (foldl', intersperse)
import qualified Data.Map as Map
-import Data.Maybe (maybeToList, fromMaybe)
+import Data.Maybe (maybeToList, fromMaybe, mapMaybe)
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
@@ -417,6 +417,7 @@ parseRef e = do
refLabel <- getInlineText "label" c
refYear <- getInlineText "year" c
refVolume <- getInlineText "volume" c
+ refIssue <- getInlineText "issue" c
refFirstPage <- getInlineText "fpage" c
refLastPage <- getInlineText "lpage" c
refPublisher <- getInlineText "publisher-name" c
@@ -434,6 +435,15 @@ parseRef e = do
("given" :: Text, given)
, ("family", family)
]
+ let extractObjectId e' =
+ let v = toMetaValue (strContent e')
+ in case attrValue "pub-id-type" e' of
+ "doi" -> Just ("DOI", v)
+ "pmid" -> Just ("PMID", v)
+ _ -> Nothing
+ let objectIds = mapMaybe extractObjectId $
+ (filterChildren (\e' -> named "object-id" e' ||
+ named "pub-id" e') c)
personGroups <- mapM (\pg ->
do names <- mapM getName
(filterChildren (named "name") pg)
@@ -453,9 +463,10 @@ parseRef e = do
("year" :: Text, refYear)
])
, ("volume", toMetaValue refVolume)
+ , ("issue", toMetaValue refIssue)
, ("page", toMetaValue refPages)
, ("citation-label", toMetaValue refLabel)
- ] ++ personGroups
+ ] ++ objectIds ++ personGroups
Nothing -> return $ Map.insert "id" (toMetaValue refId) mempty
-- TODO handle mixed-citation