@@ -25,7 +25,7 @@ module Text.Pandoc.Templates ( Template
27import Prelude
27import Prelude
28−import System.FilePath ((<.>), (</>))
28+import System.FilePath ((<.>), (</>), takeFileName)
29import Text.DocTemplates (Template, TemplateMonad(..), compileTemplate, renderTemplate)
29import Text.DocTemplates (Template, TemplateMonad(..), compileTemplate, renderTemplate)
30import Text.Pandoc.Class (PandocMonad, readDataFile, fetchItem,
30import Text.Pandoc.Class (PandocMonad, readDataFile, fetchItem,
31 CommonState(..), getCommonState, modifyCommonState)
31 CommonState(..), getCommonState, modifyCommonState)
@@ -48,7 +48,7 @@ newtype WithPartials m a = WithPartials { runWithPartials :: m a }
49instance PandocMonad m => TemplateMonad (WithDefaultPartials m) where
49instance PandocMonad m => TemplateMonad (WithDefaultPartials m) where
50 getPartial fp = WithDefaultPartials $
50 getPartial fp = WithDefaultPartials $
51− UTF8.toText <$> readDataFile fp
51+ UTF8.toText <$> readDataFile ("templates" </> takeFileName fp)
53instance PandocMonad m => TemplateMonad (WithPartials m) where
53instance PandocMonad m => TemplateMonad (WithPartials m) where
54 getPartial fp = WithPartials $ getTemplate fp
54 getPartial fp = WithPartials $ getTemplate fp
@@ -68,7 +68,8 @@ getTemplate tp = UTF8.toText <$>
68 `catchError`
68 `catchError`
69 (\e -> case e of
69 (\e -> case e of
70 PandocResourceNotFound _ ->
70 PandocResourceNotFound _ ->
71+ -- see #5987 on reason for takeFileName
71− readDataFile ("templates" </> tp)
72+ readDataFile ("templates" </> takeFileName tp)
72 _ -> throwError e))
73 _ -> throwError e))
74-- | Get default template for the specified writer.
75-- | Get default template for the specified writer.