diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2010-01-18 07:01:29 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2010-01-18 07:01:29 +0000 |
commit | b412a9cf4a3bf841f4fb4fb1bf63590f3c9c43e6 (patch) | |
tree | c2a9d1a07e8e1f534f5b33655b865900b5929c3c /src/Text/Pandoc | |
parent | 9fed26181f7cc8aa0f3bd2a01332204389c8979c (diff) | |
download | pandoc-b412a9cf4a3bf841f4fb4fb1bf63590f3c9c43e6.tar.gz |
Made user directory a Maybe in readFile, s5HeaderIncludes, laTeXMathML.
This is more uniform, and calling libraries can always disable
searching of user directories for overrides.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1821 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/LaTeXMathML.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 10 | ||||
-rw-r--r-- | src/Text/Pandoc/Templates.hs | 5 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/S5.hs | 6 |
4 files changed, 11 insertions, 12 deletions
diff --git a/src/Text/Pandoc/LaTeXMathML.hs b/src/Text/Pandoc/LaTeXMathML.hs index 362e7b084..0c8f74bdf 100644 --- a/src/Text/Pandoc/LaTeXMathML.hs +++ b/src/Text/Pandoc/LaTeXMathML.hs @@ -5,7 +5,7 @@ import System.FilePath ( (</>) ) import Text.Pandoc.Shared (readDataFile) -- | String containing LaTeXMathML javascript. -latexMathMLScript :: FilePath -> IO String +latexMathMLScript :: Maybe FilePath -> IO String latexMathMLScript datadir = do jsCom <- readDataFile datadir $ "data" </> "LaTeXMathML.js.comment" jsPacked <- readDataFile datadir $ "data" </> "LaTeXMathML.js.packed" diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 5657321d8..14086c20f 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -1046,7 +1046,9 @@ inDirectory path action = do -- | Read file from specified user data directory or, if not found there, from -- Cabal data directory. -readDataFile :: FilePath -> FilePath -> IO String -readDataFile userDir fname = catch - (readFile $ userDir </> fname) - (\_ -> getDataFileName fname >>= readFile) +readDataFile :: Maybe FilePath -> FilePath -> IO String +readDataFile userDir fname = + case userDir of + Nothing -> getDataFileName fname >>= readFile + Just u -> catch (readFile $ u </> fname) + (\_ -> getDataFileName fname >>= readFile) diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs index 9f677608d..8fb155c25 100644 --- a/src/Text/Pandoc/Templates.hs +++ b/src/Text/Pandoc/Templates.hs @@ -84,7 +84,6 @@ import Text.Pandoc.Shared (readDataFile) import Prelude hiding ( readFile ) import System.IO.UTF8 ( readFile ) #endif -import Paths_pandoc (getDataFileName) -- | Get default template for the specified writer. getDefaultTemplate :: (Maybe FilePath) -- ^ User data directory to search first @@ -96,9 +95,7 @@ getDefaultTemplate user "odt" = getDefaultTemplate user "opendocument" getDefaultTemplate user writer = do let format = takeWhile (/='+') writer -- strip off "+lhs" if present let fname = "templates" </> format <.> "template" - E.try $ case user of - Just d -> readDataFile d fname - Nothing -> getDataFileName fname >>= readFile + E.try $ readDataFile user fname data TemplateState = TemplateState Int [(String,String)] diff --git a/src/Text/Pandoc/Writers/S5.hs b/src/Text/Pandoc/Writers/S5.hs index c5b6b05ce..1dff06e62 100644 --- a/src/Text/Pandoc/Writers/S5.hs +++ b/src/Text/Pandoc/Writers/S5.hs @@ -44,7 +44,7 @@ import Text.XHtml.Strict import System.FilePath ( (</>) ) import Data.List ( intercalate ) -s5HeaderIncludes :: FilePath -> IO String +s5HeaderIncludes :: Maybe FilePath -> IO String s5HeaderIncludes datadir = do c <- s5CSS datadir j <- s5Javascript datadir @@ -53,14 +53,14 @@ s5HeaderIncludes datadir = do s5Meta :: String s5Meta = "<!-- configuration parameters -->\n<meta name=\"defaultView\" content=\"slideshow\" />\n<meta name=\"controlVis\" content=\"hidden\" />\n" -s5Javascript :: FilePath -> IO String +s5Javascript :: Maybe FilePath -> IO String s5Javascript datadir = do jsCom <- readDataFile datadir $ "s5" </> "default" </> "slides.js.comment" jsPacked <- readDataFile datadir $ "s5" </> "default" </> "slides.js.packed" return $ "<script type=\"text/javascript\">\n" ++ jsCom ++ jsPacked ++ "</script>\n" -s5CSS :: FilePath -> IO String +s5CSS :: Maybe FilePath -> IO String s5CSS datadir = do s5CoreCSS <- readDataFile datadir $ "s5" </> "default" </> "s5-core.css" s5FramingCSS <- readDataFile datadir $ "s5" </> "default" </> "framing.css" |