aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-03-19 22:57:48 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-03-19 22:57:48 -0700
commiteacead3eb316dd8e2d75737589dc017de36326fb (patch)
tree93ede68ea5bc79eb0d84189029ca8bc2356ad02a /src
parentdc94601eb5d90d315d8eae3bca57a652da3fa598 (diff)
downloadpandoc-eacead3eb316dd8e2d75737589dc017de36326fb.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Templates.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs
index e83f26329..7fd896641 100644
--- a/src/Text/Pandoc/Templates.hs
+++ b/src/Text/Pandoc/Templates.hs
@@ -34,6 +34,7 @@ import Control.Monad.Except (catchError, throwError)
import Data.Text (Text)
import qualified Data.Text as T
import Text.Pandoc.Error
+import System.IO.Error (isDoesNotExistError)
-- | Wrap a Monad in this if you want partials to
-- be taken only from the default data files.
@@ -70,6 +71,9 @@ getTemplate tp = UTF8.toText <$>
PandocResourceNotFound _ ->
-- see #5987 on reason for takeFileName
readDataFile ("templates" </> takeFileName tp)
+ PandocIOError _ ioe | isDoesNotExistError ioe ->
+ -- see #5987 on reason for takeFileName
+ readDataFile ("templates" </> takeFileName tp)
_ -> throwError e))
-- | Get default template for the specified writer.