diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-06-27 22:55:10 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-06-27 22:55:10 -0700 |
commit | 644e3239a9d1fc92f7409db8612ced39e38fde2f (patch) | |
tree | 0e6607b432067a5eebc404245dff1e32ed97adbe /src/Text/Pandoc | |
parent | 899a65b7d157193bdcb05bd4027a9e7a7fc3c9cc (diff) | |
download | pandoc-644e3239a9d1fc92f7409db8612ced39e38fde2f.tar.gz |
Custom writer: Pass full metadata, not just tit/auth/date.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Writers/Custom.hs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs index e6d912e78..732497616 100644 --- a/src/Text/Pandoc/Writers/Custom.hs +++ b/src/Text/Pandoc/Writers/Custom.hs @@ -107,6 +107,19 @@ instance StackValue [Block] where peek _ _ = undefined valuetype _ = Lua.TSTRING +instance StackValue MetaValue where + push l (MetaMap m) = Lua.push l m + push l (MetaList xs) = Lua.push l xs + push l (MetaString s) = Lua.push l s + push l (MetaInlines ils) = Lua.push l ils + push l (MetaBlocks bs) = Lua.push l bs + peek _ _ = undefined + valuetype (MetaMap _) = Lua.TTABLE + valuetype (MetaList _) = Lua.TTABLE + valuetype (MetaString _) = Lua.TSTRING + valuetype (MetaInlines _) = Lua.TSTRING + valuetype (MetaBlocks _) = Lua.TSTRING + -- | Convert Pandoc to custom markup. writeCustom :: FilePath -> WriterOptions -> Pandoc -> IO String writeCustom luaFile opts doc = do @@ -121,12 +134,9 @@ writeCustom luaFile opts doc = do return $ toString rendered docToCustom :: LuaState -> WriterOptions -> Pandoc -> IO ByteString -docToCustom lua opts (Pandoc meta blocks) = do - title' <- inlineListToCustom lua $ docTitle meta - authors' <- mapM (inlineListToCustom lua) $ docAuthors meta - date' <- inlineListToCustom lua $ docDate meta +docToCustom lua opts (Pandoc (Meta metamap) blocks) = do body <- blockListToCustom lua blocks - callfunc lua "Doc" body title' authors' date' (writerVariables opts) + callfunc lua "Doc" body metamap (writerVariables opts) -- | Convert Pandoc block element to Custom. blockToCustom :: LuaState -- ^ Lua state |