From e32a8f5981969bb6d0a11bd945188c35817e4d96 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 16 May 2013 23:00:58 -0700 Subject: Revised Text.Pandoc.Templates to accept JSON contexts. Currently the library is set up with a shim for association lists, for compatibility, but this can change when the writers are changed. New export: `varListToJSON`. Removed `Empty`. Simplified template type to a newtype. --- src/Text/Pandoc/Writers/Man.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers/Man.hs') diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs index 5541aeb3b..17be983ce 100644 --- a/src/Text/Pandoc/Writers/Man.hs +++ b/src/Text/Pandoc/Writers/Man.hs @@ -38,6 +38,7 @@ import Text.Printf ( printf ) import Data.List ( isPrefixOf, intersperse, intercalate ) import Text.Pandoc.Pretty import Control.Monad.State +import qualified Data.Text as T type Notes = [[Block]] data WriterState = WriterState { stNotes :: Notes @@ -77,8 +78,11 @@ pandocToMan opts (Pandoc (Meta title authors date) blocks) = do , ("description", render' description) ] ++ [ ("has-tables", "yes") | hasTables ] ++ [ ("author", render' a) | a <- authors' ] + template = case compileTemplate (T.pack $ writerTemplate opts) of + Left e -> error e + Right t -> t if writerStandalone opts - then return $ renderTemplate context $ writerTemplate opts + then return $ renderTemplate template (varListToJSON context) else return main -- | Return man representation of notes. -- cgit v1.2.3