aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2010-11-23 21:40:05 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2010-11-23 21:40:05 -0800
commit0955a0e32978d60d8f0b42a027ae1d5ebb518676 (patch)
tree84bdf97f786eb30e3660db05c2da9d73e476f9e8 /src
parent1b1287e888b02eef3f20e0ada90b51198dccbd3f (diff)
downloadpandoc-0955a0e32978d60d8f0b42a027ae1d5ebb518676.tar.gz
More flexible handling of --csl.
Look for csl files in ~/.csl if not found locally. Add .csl extension if it is not provided.
Diffstat (limited to 'src')
-rw-r--r--src/pandoc.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/pandoc.hs b/src/pandoc.hs
index f671f3155..c6e74e381 100644
--- a/src/pandoc.hs
+++ b/src/pandoc.hs
@@ -42,7 +42,7 @@ import System.FilePath
import System.Console.GetOpt
import Data.Char ( toLower, isDigit )
import Data.List ( intercalate, isSuffixOf )
-import System.Directory ( getAppUserDataDirectory )
+import System.Directory ( getAppUserDataDirectory, doesFileExist )
import System.IO ( stdout, stderr )
import qualified Text.Pandoc.UTF8 as UTF8
import Text.CSL
@@ -832,9 +832,17 @@ main = do
if null refs
then return doc'
else do
+ csldir <- getAppUserDataDirectory "csl"
cslfile' <- if null cslfile
then findDataFile datadir "default.csl"
- else return cslfile
+ else do
+ ex <- doesFileExist cslfile
+ if ex
+ then return cslfile
+ else findDataFile datadir $
+ replaceDirectory
+ (replaceExtension cslfile "csl")
+ csldir
processBiblio cslfile' refs doc'
writerOutput <- writer writerOptions doc''