From fd34dcba851ad1567b8969676174fc03a3afb958 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 22 Jul 2011 22:49:38 -0700 Subject: Changed default template naming scheme. Instead of latex.template, we now have default.latex. An appropriate extension is added automatically if the value of `--template` has no extension. So, `pandoc --template=special -t latex` looks for `special.latex`, while `pandoc --template=special -t man` looks for `special.man`. --- src/Text/Pandoc/Templates.hs | 2 +- src/pandoc.hs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs index cad89f35f..8b966ca7a 100644 --- a/src/Text/Pandoc/Templates.hs +++ b/src/Text/Pandoc/Templates.hs @@ -85,7 +85,7 @@ getDefaultTemplate _ "native" = return $ Right "" getDefaultTemplate user "odt" = getDefaultTemplate user "opendocument" getDefaultTemplate user writer = do let format = takeWhile (/='+') writer -- strip off "+lhs" if present - let fname = "templates" format <.> "template" + let fname = "templates" "default" <.> format E.try $ readDataFile user fname data TemplateState = TemplateState Int [(String,String)] diff --git a/src/pandoc.hs b/src/pandoc.hs index 5900574ce..22afd77ea 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -738,10 +738,17 @@ main = do case deftemp of Left e -> throwIO e Right t -> return t - Just tp -> catch (UTF8.readFile tp) + Just tp -> do + -- strip off "+lhs" if present + let format = takeWhile (/='+') writerName' + let tp' = case takeExtension tp of + "" -> tp <.> format + _ -> tp + catch (UTF8.readFile tp') (\e -> if isDoesNotExistError e then catch - (readDataFile datadir tp) + (readDataFile datadir $ + "templates" tp') (\_ -> throwIO e) else throwIO e) -- cgit v1.2.3