git.iko.soy/typeable/pandoc
on master help sign in
Shared: Change defaultUserDataDirs -> defaultUserDataDir.
31d007cJohn MacFarlane
MANUAL.txt+6−6
@@ -361,15 +361,15 @@ header when requesting a document from a URL:
361 will be used. On \*nix and macOS systems this will be the `pandoc`
361 will be used. On \*nix and macOS systems this will be the `pandoc`
362 subdirectory of the XDG data directory (by default,
362 subdirectory of the XDG data directory (by default,
363 `$HOME/.local/share`, overridable by setting the `XDG_DATA_HOME`
363 `$HOME/.local/share`, overridable by setting the `XDG_DATA_HOME`
364− environment variable). If that directory does not exist,
364+ environment variable). If that directory does not exist and
365− `$HOME/.pandoc` will be used (for backwards compatibility).
365+ `$HOME/.pandoc` exists, it will be used (for backwards compatibility).
366− In Windows the default user data directory is
366+ On Windows the default user data directory is
367 `C:\Users\USERNAME\AppData\Roaming\pandoc`.
367 `C:\Users\USERNAME\AppData\Roaming\pandoc`.
368 You can find the default user data directory on your system by
368 You can find the default user data directory on your system by
369 looking at the output of `pandoc --version`.
369 looking at the output of `pandoc --version`.
370+ Data files placed in this directory (for example, `reference.odt`,
370− A `reference.odt`, `reference.docx`, `epub.css`, `templates`,
371+ `reference.docx`, `epub.css`, `templates`) will override
371− `slidy`, `slideous`, or `s5` directory
372− placed in this directory will override pandoc's normal defaults.
372+ pandoc's normal defaults.
373
373
374`-d` *FILE*, `--defaults=`*FILE*
374`-d` *FILE*, `--defaults=`*FILE*
375
375
src/Text/Pandoc/Shared.hs+12−8
@@ -95,7 +95,7 @@ module Text.Pandoc.Shared (
95 safeRead,
95 safeRead,
96 safeStrRead,
96 safeStrRead,
97 -- * User data directory
97 -- * User data directory
98− defaultUserDataDirs,
98+ defaultUserDataDir,
99 -- * Version
99 -- * Version
100 pandocVersion
100 pandocVersion
101 ) where
101 ) where
@@ -1012,12 +1012,16 @@ safeStrRead s = case reads s of
1012--
1012--
1013
1013
1014-- | Return appropriate user data directory for platform. We use
1014-- | Return appropriate user data directory for platform. We use
1015−-- XDG_DATA_HOME (or its default value), but fall back to the
1015+-- XDG_DATA_HOME (or its default value), but for backwards compatibility,
1016−-- legacy user data directory ($HOME/.pandoc on *nix) if this is
1016+-- we fall back to the legacy user data directory ($HOME/.pandoc on *nix)
1017−-- missing.
1017+-- if the XDG_DATA_HOME is missing and this exists. If neither directory
1018−defaultUserDataDirs :: IO [FilePath]
1018+-- is present, we return the XDG data directory.
1019−defaultUserDataDirs = E.catch (do
1019+defaultUserDataDir :: IO FilePath
1020+defaultUserDataDir = do
1020 xdgDir <- getXdgDirectory XdgData "pandoc"
1021 xdgDir <- getXdgDirectory XdgData "pandoc"
1021 legacyDir <- getAppUserDataDirectory "pandoc"
1022 legacyDir <- getAppUserDataDirectory "pandoc"
1022− return $ ordNub [xdgDir, legacyDir])
1023+ xdgExists <- doesDirectoryExist xdgDir
1023− (\(_ :: E.SomeException) -> return [])
1024+ legacyDirExists <- doesDirectoryExist legacyDir
1025+ if not xdgExists && legacyDirExists
1026+ then return legacyDir
1027+ else return xdgDir