@@ -49,11 +49,7 @@ import Text.ParserCombinators.Parsec
4949import Control.Monad (liftM)
5050import qualified Control.Exception as E (try, IOException)
5151import System.FilePath
52−import System.Directory
53−import Prelude hiding (readFile)
54−import System.IO.UTF8 (readFile)
5552import Text.Pandoc.Shared (readDataFile)
56−import Paths_pandoc
5753
5854-- | Get the default template, either from the application's user data
5955-- directory (~/.pandoc on unix) or from the cabal data directory.
@@ -62,21 +58,8 @@ getDefaultTemplate "native" = return $ Right ""
6258getDefaultTemplate "odt" = getDefaultTemplate "opendocument"
6359getDefaultTemplate format = do
6460 let format' = takeWhile (/='+') format -- strip off "+lhs" if present
65− ut <- getTemplateFromUserDataDirectory format'
66− case ut of
67− Right t -> return $ Right t
68− Left _ -> getTemplateFromCabalDataDirectory format'
61+ E.try $ readDataFile $ "templates" </> format' <.> "template"
6962
70−getTemplateFromUserDataDirectory :: String -> IO (Either E.IOException String)
71−getTemplateFromUserDataDirectory format = E.try $ do
72− userDir <- getAppUserDataDirectory "pandoc"
73− let templatePath = userDir </> "templates" </> format <.> "template"
74− readFile templatePath
75−
76−getTemplateFromCabalDataDirectory :: String -> IO (Either E.IOException String)
77−getTemplateFromCabalDataDirectory format = E.try $
78− readDataFile $ "templates" </> format <.> "template"
79−
8063-- | Renders a template
8164renderTemplate :: [(String,String)] -- ^ Assoc. list of values for variables
8265 -> String -- ^ Template