aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-12-17 11:10:16 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2019-12-17 11:59:52 -0800
commit01b89d87f4d69a3d5a9cefbb6ff3f5808531e648 (patch)
treeb777931d8128c6988278697ee291d4a41c1a0f84 /src
parent20cf4e47b069f76839b4223cbfecbf96875aadb4 (diff)
downloadpandoc-01b89d87f4d69a3d5a9cefbb6ff3f5808531e648.tar.gz
Templates: strip directory before trying to find partial in data files.
Closes #5987.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Templates.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs
index daf9c02fb..f04a73b58 100644
--- a/src/Text/Pandoc/Templates.hs
+++ b/src/Text/Pandoc/Templates.hs
@@ -25,7 +25,7 @@ module Text.Pandoc.Templates ( Template
) where
import Prelude
-import System.FilePath ((<.>), (</>))
+import System.FilePath ((<.>), (</>), takeFileName)
import Text.DocTemplates (Template, TemplateMonad(..), compileTemplate, renderTemplate)
import Text.Pandoc.Class (PandocMonad, readDataFile, fetchItem,
CommonState(..), getCommonState, modifyCommonState)
@@ -48,7 +48,7 @@ newtype WithPartials m a = WithPartials { runWithPartials :: m a }
instance PandocMonad m => TemplateMonad (WithDefaultPartials m) where
getPartial fp = WithDefaultPartials $
- UTF8.toText <$> readDataFile fp
+ UTF8.toText <$> readDataFile ("templates" </> takeFileName fp)
instance PandocMonad m => TemplateMonad (WithPartials m) where
getPartial fp = WithPartials $ getTemplate fp
@@ -68,7 +68,8 @@ getTemplate tp = UTF8.toText <$>
`catchError`
(\e -> case e of
PandocResourceNotFound _ ->
- readDataFile ("templates" </> tp)
+ -- see #5987 on reason for takeFileName
+ readDataFile ("templates" </> takeFileName tp)
_ -> throwError e))
-- | Get default template for the specified writer.