diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-12-15 09:09:51 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-12-15 09:09:51 -0800 |
commit | 87033b285669901505f6da8b2969911a29c448fd (patch) | |
tree | 5488f742ed59ad6c74be9177c9433578b18c814f /src/Text/Pandoc | |
parent | 7d799bfcda749e4a3ad6fcae59ac5ccb80b77ffd (diff) | |
download | pandoc-87033b285669901505f6da8b2969911a29c448fd.tar.gz |
Use fetchItem to get external bibliography.
This means that:
- a URL may be provided, and pandoc will fetch the resource.
- Pandoc will search the resource path for the bibliography
if it is not found relative to the working directory.
Closes #6940.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Citeproc.hs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs index 82d1dc32f..770d571a6 100644 --- a/src/Text/Pandoc/Citeproc.hs +++ b/src/Text/Pandoc/Citeproc.hs @@ -190,24 +190,23 @@ insertSpace ils = getRefsFromBib :: PandocMonad m => Locale -> (Text -> Bool) -> Text -> m [Reference Inlines] -getRefsFromBib locale idpred t = do - let fp = T.unpack t - raw <- readFileStrict fp - case formatFromExtension fp of +getRefsFromBib locale idpred fp = do + (raw, _) <- fetchItem fp + case formatFromExtension (T.unpack fp) of Just f -> getRefs locale f idpred (Just fp) raw Nothing -> throwError $ PandocAppError $ - "Could not determine bibliography format for " <> t + "Could not determine bibliography format for " <> fp getRefs :: PandocMonad m => Locale -> BibFormat -> (Text -> Bool) - -> Maybe FilePath + -> Maybe Text -> ByteString -> m [Reference Inlines] getRefs locale format idpred mbfp raw = do let err' = throwError . - PandocBibliographyError (maybe mempty T.pack mbfp) + PandocBibliographyError (fromMaybe mempty mbfp) case format of Format_bibtex -> either (err' . tshow) return . @@ -222,7 +221,7 @@ getRefs locale format idpred mbfp raw = do Format_yaml -> do rs <- yamlToRefs idpred def{ readerExtensions = pandocExtensions } - mbfp + (T.unpack <$> mbfp) (L.fromStrict raw) return $ mapMaybe metaValueToReference rs |