git.iko.soy/typeable/pandoc
on master help sign in
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.

commit87033b285669901505f6da8b2969911a29c448fd authorJohn MacFarlane <jgm@berkeley.edu> dateTue 15 Dec 2020, 09:09 (6 years ago) parent7d799bf
1 file changed+7−8
src/Text/Pandoc/Citeproc.hs+7−8
src/Text/Pandoc/Citeproc.hs+7−8
@@ -190,24 +190,23 @@ insertSpace ils =
190190
191191getRefsFromBib :: PandocMonad m
192192 => Locale -> (Text -> Bool) -> Text -> m [Reference Inlines]
193−getRefsFromBib locale idpred t = do
194− let fp = T.unpack t
195− raw <- readFileStrict fp
196− case formatFromExtension fp of
193+getRefsFromBib locale idpred fp = do
194+ (raw, _) <- fetchItem fp
195+ case formatFromExtension (T.unpack fp) of
197196 Just f -> getRefs locale f idpred (Just fp) raw
198197 Nothing -> throwError $ PandocAppError $
199− "Could not determine bibliography format for " <> t
198+ "Could not determine bibliography format for " <> fp
200199
201200getRefs :: PandocMonad m
202201 => Locale
203202 -> BibFormat
204203 -> (Text -> Bool)
205− -> Maybe FilePath
204+ -> Maybe Text
206205 -> ByteString
207206 -> m [Reference Inlines]
208207getRefs locale format idpred mbfp raw = do
209208 let err' = throwError .
210− PandocBibliographyError (maybe mempty T.pack mbfp)
209+ PandocBibliographyError (fromMaybe mempty mbfp)
211210 case format of
212211 Format_bibtex ->
213212 either (err' . tshow) return .
@@ -222,7 +221,7 @@ getRefs locale format idpred mbfp raw = do
222221 Format_yaml -> do
223222 rs <- yamlToRefs idpred
224223 def{ readerExtensions = pandocExtensions }
225− mbfp
224+ (T.unpack <$> mbfp)
226225 (L.fromStrict raw)
227226 return $ mapMaybe metaValueToReference rs
228227