aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANUAL.txt12
-rw-r--r--src/Text/Pandoc/Shared.hs20
2 files changed, 18 insertions, 14 deletions
diff --git a/MANUAL.txt b/MANUAL.txt
index 667a784e0..d97cbcbc9 100644
--- a/MANUAL.txt
+++ b/MANUAL.txt
@@ -361,15 +361,15 @@ header when requesting a document from a URL:
will be used. On \*nix and macOS systems this will be the `pandoc`
subdirectory of the XDG data directory (by default,
`$HOME/.local/share`, overridable by setting the `XDG_DATA_HOME`
- environment variable). If that directory does not exist,
- `$HOME/.pandoc` will be used (for backwards compatibility).
- In Windows the default user data directory is
+ environment variable). If that directory does not exist and
+ `$HOME/.pandoc` exists, it will be used (for backwards compatibility).
+ On Windows the default user data directory is
`C:\Users\USERNAME\AppData\Roaming\pandoc`.
You can find the default user data directory on your system by
looking at the output of `pandoc --version`.
- A `reference.odt`, `reference.docx`, `epub.css`, `templates`,
- `slidy`, `slideous`, or `s5` directory
- placed in this directory will override pandoc's normal defaults.
+ Data files placed in this directory (for example, `reference.odt`,
+ `reference.docx`, `epub.css`, `templates`) will override
+ pandoc's normal defaults.
`-d` *FILE*, `--defaults=`*FILE*
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 922df7922..2aba9b2e1 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -95,7 +95,7 @@ module Text.Pandoc.Shared (
safeRead,
safeStrRead,
-- * User data directory
- defaultUserDataDirs,
+ defaultUserDataDir,
-- * Version
pandocVersion
) where
@@ -1012,12 +1012,16 @@ safeStrRead s = case reads s of
--
-- | Return appropriate user data directory for platform. We use
--- XDG_DATA_HOME (or its default value), but fall back to the
--- legacy user data directory ($HOME/.pandoc on *nix) if this is
--- missing.
-defaultUserDataDirs :: IO [FilePath]
-defaultUserDataDirs = E.catch (do
+-- XDG_DATA_HOME (or its default value), but for backwards compatibility,
+-- we fall back to the legacy user data directory ($HOME/.pandoc on *nix)
+-- if the XDG_DATA_HOME is missing and this exists. If neither directory
+-- is present, we return the XDG data directory.
+defaultUserDataDir :: IO FilePath
+defaultUserDataDir = do
xdgDir <- getXdgDirectory XdgData "pandoc"
legacyDir <- getAppUserDataDirectory "pandoc"
- return $ ordNub [xdgDir, legacyDir])
- (\(_ :: E.SomeException) -> return [])
+ xdgExists <- doesDirectoryExist xdgDir
+ legacyDirExists <- doesDirectoryExist legacyDir
+ if not xdgExists && legacyDirExists
+ then return legacyDir
+ else return xdgDir