git.iko.soy/typeable/pandoc
on master help sign in
Templates: Change type of renderTemplate'.
1187ca3John MacFarlane
pandoc.cabal+1−1
@@ -408,7 +408,7 @@ library
408 JuicyPixels >= 3.1.6.1 && < 3.4,
408 JuicyPixels >= 3.1.6.1 && < 3.4,
409 Glob >= 0.7 && < 0.11,
409 Glob >= 0.7 && < 0.11,
410 cmark-gfm >= 0.2 && < 0.3,
410 cmark-gfm >= 0.2 && < 0.3,
411− doctemplates >= 0.2.1 && < 0.3,
411+ doctemplates >= 0.2.2.1 && < 0.4,
412 network-uri >= 2.6 && < 2.7,
412 network-uri >= 2.6 && < 2.7,
413 network >= 2.6,
413 network >= 2.6,
414 http-client >= 0.4.30 && < 0.7,
414 http-client >= 0.4.30 && < 0.7,
src/Text/Pandoc/Templates.hs+3−3
@@ -22,7 +22,7 @@ import Control.Monad.Except (throwError)
22import Data.Aeson (ToJSON (..))
22import Data.Aeson (ToJSON (..))
23import qualified Data.Text as T
23import qualified Data.Text as T
24import System.FilePath ((<.>), (</>))
24import System.FilePath ((<.>), (</>))
25−import Text.DocTemplates (Template, TemplateTarget, applyTemplate,
25+import Text.DocTemplates (Template, applyTemplate,
26 compileTemplate, renderTemplate, varListToJSON)
26 compileTemplate, renderTemplate, varListToJSON)
27import Text.Pandoc.Class (PandocMonad, readDataFile)
27import Text.Pandoc.Class (PandocMonad, readDataFile)
28import Text.Pandoc.Error
28import Text.Pandoc.Error
@@ -57,8 +57,8 @@ getDefaultTemplate writer = do
57
57
58-- | Like 'applyTemplate', but runs in PandocMonad and
58-- | Like 'applyTemplate', but runs in PandocMonad and
59-- raises an error if compilation fails.
59-- raises an error if compilation fails.
60−renderTemplate' :: (PandocMonad m, ToJSON a, TemplateTarget b)
60+renderTemplate' :: (PandocMonad m, ToJSON a)
61− => String -> a -> m b
61+ => String -> a -> m T.Text
62renderTemplate' template context =
62renderTemplate' template context =
63 case applyTemplate (T.pack template) context of
63 case applyTemplate (T.pack template) context of
64 Left e -> throwError (PandocTemplateError e)
64 Left e -> throwError (PandocTemplateError e)
src/Text/Pandoc/Writers/Custom.hs+1−1
@@ -114,7 +114,7 @@ writeCustom luaFile opts doc@(Pandoc meta _) = do
114 Just tpl ->
114 Just tpl ->
115 case applyTemplate (pack tpl) $ setField "body" body context of
115 case applyTemplate (pack tpl) $ setField "body" body context of
116 Left e -> throw (PandocTemplateError e)
116 Left e -> throw (PandocTemplateError e)
117− Right r -> return (pack r)
117+ Right r -> return r
118
118
119docToCustom :: WriterOptions -> Pandoc -> Lua String
119docToCustom :: WriterOptions -> Pandoc -> Lua String
120docToCustom opts (Pandoc (Meta metamap) blocks) = do
120docToCustom opts (Pandoc (Meta metamap) blocks) = do
src/Text/Pandoc/Writers/MediaWiki.hs+3−3
@@ -66,9 +66,9 @@ pandocToMediaWiki (Pandoc meta blocks) = do
66 let main = body ++ notes
66 let main = body ++ notes
67 let context = defField "body" main
67 let context = defField "body" main
68 $ defField "toc" (writerTableOfContents opts) metadata
68 $ defField "toc" (writerTableOfContents opts) metadata
69− pack <$> case writerTemplate opts of
69+ case writerTemplate opts of
70− Nothing -> return main
70+ Nothing -> return $ pack main
71− Just tpl -> renderTemplate' tpl context
71+ Just tpl -> renderTemplate' tpl context
72
72
73-- | Escape special characters for MediaWiki.
73-- | Escape special characters for MediaWiki.
74escapeString :: String -> String
74escapeString :: String -> String
src/Text/Pandoc/Writers/RTF.hs+6−7
@@ -112,13 +112,12 @@ writeRTF options doc = do
112 -- of the toc rather than a boolean:
112 -- of the toc rather than a boolean:
113 . defField "toc" toc
113 . defField "toc" toc
114 else id) metadata
114 else id) metadata
115− T.pack <$>
116− case writerTemplate options of
115+ case writerTemplate options of
117− Just tpl -> renderTemplate' tpl context
116+ Just tpl -> renderTemplate' tpl context
118− Nothing -> return $
117+ Nothing -> return $ T.pack $
119− case reverse body of
118+ case reverse body of
120− ('\n':_) -> body
119+ ('\n':_) -> body
121− _ -> body ++ "\n"
120+ _ -> body ++ "\n"
122
121
123-- | Convert unicode characters (> 127) into rich text format representation.
122-- | Convert unicode characters (> 127) into rich text format representation.
124handleUnicode :: String -> String
123handleUnicode :: String -> String