aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pandoc.cabal2
-rw-r--r--src/Text/Pandoc/Templates.hs6
-rw-r--r--src/Text/Pandoc/Writers/Custom.hs2
-rw-r--r--src/Text/Pandoc/Writers/MediaWiki.hs6
-rw-r--r--src/Text/Pandoc/Writers/RTF.hs13
5 files changed, 14 insertions, 15 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index a8286abf9..6356e1be4 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -408,7 +408,7 @@ library
JuicyPixels >= 3.1.6.1 && < 3.4,
Glob >= 0.7 && < 0.11,
cmark-gfm >= 0.2 && < 0.3,
- doctemplates >= 0.2.1 && < 0.3,
+ doctemplates >= 0.2.2.1 && < 0.4,
network-uri >= 2.6 && < 2.7,
network >= 2.6,
http-client >= 0.4.30 && < 0.7,
diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs
index f84239dff..419697941 100644
--- a/src/Text/Pandoc/Templates.hs
+++ b/src/Text/Pandoc/Templates.hs
@@ -22,7 +22,7 @@ import Control.Monad.Except (throwError)
import Data.Aeson (ToJSON (..))
import qualified Data.Text as T
import System.FilePath ((<.>), (</>))
-import Text.DocTemplates (Template, TemplateTarget, applyTemplate,
+import Text.DocTemplates (Template, applyTemplate,
compileTemplate, renderTemplate, varListToJSON)
import Text.Pandoc.Class (PandocMonad, readDataFile)
import Text.Pandoc.Error
@@ -57,8 +57,8 @@ getDefaultTemplate writer = do
-- | Like 'applyTemplate', but runs in PandocMonad and
-- raises an error if compilation fails.
-renderTemplate' :: (PandocMonad m, ToJSON a, TemplateTarget b)
- => String -> a -> m b
+renderTemplate' :: (PandocMonad m, ToJSON a)
+ => String -> a -> m T.Text
renderTemplate' template context =
case applyTemplate (T.pack template) context of
Left e -> throwError (PandocTemplateError e)
diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs
index 091310c24..5e2f3a583 100644
--- a/src/Text/Pandoc/Writers/Custom.hs
+++ b/src/Text/Pandoc/Writers/Custom.hs
@@ -114,7 +114,7 @@ writeCustom luaFile opts doc@(Pandoc meta _) = do
Just tpl ->
case applyTemplate (pack tpl) $ setField "body" body context of
Left e -> throw (PandocTemplateError e)
- Right r -> return (pack r)
+ Right r -> return r
docToCustom :: WriterOptions -> Pandoc -> Lua String
docToCustom opts (Pandoc (Meta metamap) blocks) = do
diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs
index ba15d3a21..a461daee4 100644
--- a/src/Text/Pandoc/Writers/MediaWiki.hs
+++ b/src/Text/Pandoc/Writers/MediaWiki.hs
@@ -66,9 +66,9 @@ pandocToMediaWiki (Pandoc meta blocks) = do
let main = body ++ notes
let context = defField "body" main
$ defField "toc" (writerTableOfContents opts) metadata
- pack <$> case writerTemplate opts of
- Nothing -> return main
- Just tpl -> renderTemplate' tpl context
+ case writerTemplate opts of
+ Nothing -> return $ pack main
+ Just tpl -> renderTemplate' tpl context
-- | Escape special characters for MediaWiki.
escapeString :: String -> String
diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs
index a7f795d3f..3d7657bb0 100644
--- a/src/Text/Pandoc/Writers/RTF.hs
+++ b/src/Text/Pandoc/Writers/RTF.hs
@@ -112,13 +112,12 @@ writeRTF options doc = do
-- of the toc rather than a boolean:
. defField "toc" toc
else id) metadata
- T.pack <$>
- case writerTemplate options of
- Just tpl -> renderTemplate' tpl context
- Nothing -> return $
- case reverse body of
- ('\n':_) -> body
- _ -> body ++ "\n"
+ case writerTemplate options of
+ Just tpl -> renderTemplate' tpl context
+ Nothing -> return $ T.pack $
+ case reverse body of
+ ('\n':_) -> body
+ _ -> body ++ "\n"
-- | Convert unicode characters (> 127) into rich text format representation.
handleUnicode :: String -> String