diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-10-09 13:17:29 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-10-09 13:35:53 -0700 |
commit | e7adc2917bcc0813576eecd15b849dbcbde7394d (patch) | |
tree | 411a086423e1af3d513a3a85c73fff32db2cf01b /src/Text/Pandoc/Citeproc.hs | |
parent | 9a6c42590f42601329db3fb42296db1a04ee3ff5 (diff) | |
download | pandoc-e7adc2917bcc0813576eecd15b849dbcbde7394d.tar.gz |
In fetching parent of dependent CSL style, first...
look locally, and only do an HTTP request if it's not
found locally.
Diffstat (limited to 'src/Text/Pandoc/Citeproc.hs')
-rw-r--r-- | src/Text/Pandoc/Citeproc.hs | 6 |
1 files changed, 5 insertions, 1 deletions
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 |