aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-07-23 21:40:24 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-07-23 21:40:24 -0700
commit1187ca3517b9fdd625e4dadda58b1fbf8862d55b (patch)
treec3ce3e741f5facbd3fb2b7073326762fb70964ae /src/Text/Pandoc/Writers
parent54b50cb29a4c6569878227972b8bc5ad93384713 (diff)
downloadpandoc-1187ca3517b9fdd625e4dadda58b1fbf8862d55b.tar.gz
Templates: Change type of renderTemplate'.
Return value is now Text rather than being polymorphic. This makes room for upcoming removal of the TemplateTarget class from doctemplates. Other code modified accordingly, and should compile with both current and upcoming version of doctemplates.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-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
3 files changed, 10 insertions, 11 deletions
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