From e7adc2917bcc0813576eecd15b849dbcbde7394d Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 9 Oct 2020 13:17:29 -0700 Subject: In fetching parent of dependent CSL style, first... look locally, and only do an HTTP request if it's not found locally. --- src/Text/Pandoc/Citeproc.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs index 202fc5506..ee78bb3ff 100644 --- a/src/Text/Pandoc/Citeproc.hs +++ b/src/Text/Pandoc/Citeproc.hs @@ -84,7 +84,11 @@ processCitations (Pandoc meta bs) = do <> "\n" <> T.pack err Right abbr -> return $ Just abbr - let getParentStyle url = UTF8.toText . fst <$> fetchItem url + let getParentStyle url = do + -- first, try to retrieve the style locally, then use HTTP. + let basename = T.takeWhileEnd (/='/') url + UTF8.toText <$> + catchError (getFile ".csl" basename) (\_ -> fst <$> fetchItem url) -- TODO check .csl directory if not found styleRes <- Citeproc.parseStyle getParentStyle cslContents -- cgit v1.2.3