git.iko.soy/typeable/pandoc
on master help sign in
Fix fallback to default partials on templates.

If the directory containing a template does not contain the partial, it should be sought in the default data files. Closes #7164.

commiteacead3eb316dd8e2d75737589dc017de36326fb authorJohn MacFarlane <jgm@berkeley.edu> dateFri 19 Mar 2021, 22:57 (6 years ago) parentdc94601
1 file changed+4
src/Text/Pandoc/Templates.hs+4
src/Text/Pandoc/Templates.hs+4
@@ -34,6 +34,7 @@ import Control.Monad.Except (catchError, throwError)
3434import Data.Text (Text)
3535import qualified Data.Text as T
3636import Text.Pandoc.Error
37+import System.IO.Error (isDoesNotExistError)
3738
3839-- | Wrap a Monad in this if you want partials to
3940-- be taken only from the default data files.
@@ -70,6 +71,9 @@ getTemplate tp = UTF8.toText <$>
7071 PandocResourceNotFound _ ->
7172 -- see #5987 on reason for takeFileName
7273 readDataFile ("templates" </> takeFileName tp)
74+ PandocIOError _ ioe | isDoesNotExistError ioe ->
75+ -- see #5987 on reason for takeFileName
76+ readDataFile ("templates" </> takeFileName tp)
7377 _ -> throwError e))
7478
7579-- | Get default template for the specified writer.