aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-02-01 21:32:23 -0800
committerJohn MacFarlane <[email protected]>2022-02-01 21:32:42 -0800
commitb4bc7fd17bf70cb0fc3ee1e3ecad36710e2144b9 (patch)
tree8b24c723caffce02c97039c4446e3d13194d4950
parentb138b312d7004c04c78e88e22625577ae1f784e8 (diff)
T.P.Readers.EndNote: export readEndNoteXMLReferences.
[API change]
-rw-r--r--src/Text/Pandoc/Readers/EndNote.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/EndNote.hs b/src/Text/Pandoc/Readers/EndNote.hs
index 1cbfd2678..9fe1496be 100644
--- a/src/Text/Pandoc/Readers/EndNote.hs
+++ b/src/Text/Pandoc/Readers/EndNote.hs
@@ -17,6 +17,7 @@ entire bibliography will be printed.
-}
module Text.Pandoc.Readers.EndNote
( readEndNoteXML
+ , readEndNoteXMLReferences
)
where
@@ -27,7 +28,7 @@ import Text.Pandoc.Builder as B
import Text.Pandoc.Error (PandocError(..))
import Text.Pandoc.Class (PandocMonad)
import Text.Pandoc.Citeproc.MetaValue (referenceToMetaValue)
-import Text.Pandoc.Sources (ToSources(..), sourcesToText)
+import Text.Pandoc.Sources (Sources(..), ToSources(..), sourcesToText)
import Text.Pandoc.Citeproc.BibTeX (toName)
import Control.Applicative ((<|>))
import Control.Monad.Except (throwError)
@@ -57,11 +58,17 @@ readEndNoteXML :: (PandocMonad m, ToSources a)
=> ReaderOptions -> a -> m Pandoc
readEndNoteXML _opts inp = do
let sources = toSources inp
+ refs <- readEndNoteXMLReferences sources
+ return $ setMeta "references" (map referenceToMetaValue refs) $ B.doc mempty
+
+readEndNoteXMLReferences :: PandocMonad m
+ => Sources -> m [Reference Inlines]
+readEndNoteXMLReferences sources = do
tree <- either (throwError . PandocXMLError "") return $
parseXMLElement (TL.fromStrict . sourcesToText $ sources)
let records = filterElementsName ((== "record") . qName) tree
- let refs = map (referenceToMetaValue . recordToReference) records
- return $ setMeta "references" refs $ B.doc mempty
+ return $ map recordToReference records
+
recordToReference :: Element -> Reference Inlines
recordToReference e =