git.iko.soy/typeable/pandoc
on master help sign in
In fetching parent of dependent CSL style, first...

look locally, and only do an HTTP request if it's not found locally.

commite7adc2917bcc0813576eecd15b849dbcbde7394d authorJohn MacFarlane <jgm@berkeley.edu> dateFri 9 Oct 2020, 13:17 (6 years ago) parent9a6c425
1 file changed+5−1
src/Text/Pandoc/Citeproc.hs+5−1
src/Text/Pandoc/Citeproc.hs+5−1
@@ -84,7 +84,11 @@ processCitations (Pandoc meta bs) = do
8484 <> "\n" <> T.pack err
8585 Right abbr -> return $ Just abbr
8686
87− let getParentStyle url = UTF8.toText . fst <$> fetchItem url
87+ let getParentStyle url = do
88+ -- first, try to retrieve the style locally, then use HTTP.
89+ let basename = T.takeWhileEnd (/='/') url
90+ UTF8.toText <$>
91+ catchError (getFile ".csl" basename) (\_ -> fst <$> fetchItem url)
8892
8993 -- TODO check .csl directory if not found
9094 styleRes <- Citeproc.parseStyle getParentStyle cslContents