aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
4 files changed, 13 insertions, 14 deletions
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