diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-05-31 13:57:14 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-05-31 13:57:14 +0200 |
commit | c327b283c1e1b07be95cee0b2e8719b61ea12b3a (patch) | |
tree | 5dd412d0f6661d445b34c2daabb4e7e738706d8c /src/Text/Pandoc | |
parent | e0aed52c076134efb34380c5c155ff32aaebd087 (diff) | |
download | pandoc-c327b283c1e1b07be95cee0b2e8719b61ea12b3a.tar.gz |
Allow building with hslua 0.4.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Writers/Custom.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs index bdcbba275..abf676fdf 100644 --- a/src/Text/Pandoc/Writers/Custom.hs +++ b/src/Text/Pandoc/Writers/Custom.hs @@ -69,6 +69,13 @@ getList lua i' = do return (x : rest) else return [] +#if MIN_VERSION_hslua(0,4,0) +instance {-# OVERLAPS #-} StackValue [Char] where + push lua cs = Lua.push lua (UTF8.fromString cs) + peek lua i = do + res <- Lua.peek lua i + return $ UTF8.toString `fmap` res +#else #if MIN_VERSION_base(4,8,0) instance {-# OVERLAPS #-} StackValue a => StackValue [a] where #else @@ -86,6 +93,7 @@ instance StackValue a => StackValue [a] where Lua.pop lua 1 return (Just lst) valuetype _ = Lua.TTABLE +#endif instance StackValue Format where push lua (Format f) = Lua.push lua (map toLower f) @@ -111,12 +119,20 @@ instance (StackValue a, StackValue b) => StackValue (a,b) where peek _ _ = undefined -- not needed for our purposes valuetype _ = Lua.TTABLE +#if MIN_VERSION_base(4,8,0) +instance {-# OVERLAPS #-} StackValue [Inline] where +#else instance StackValue [Inline] where +#endif push l ils = Lua.push l =<< inlineListToCustom l ils peek _ _ = undefined valuetype _ = Lua.TSTRING +#if MIN_VERSION_base(4,8,0) +instance {-# OVERLAPS #-} StackValue [Block] where +#else instance StackValue [Block] where +#endif push l ils = Lua.push l =<< blockListToCustom l ils peek _ _ = undefined valuetype _ = Lua.TSTRING @@ -167,7 +183,11 @@ writeCustom luaFile opts doc@(Pandoc meta _) = do -- check for error in lua script (later we'll change the return type -- to handle this more gracefully): when (status /= 0) $ +#if MIN_VERSION_hslua(0,4,0) + Lua.tostring lua 1 >>= throw . PandocLuaException . UTF8.toString +#else Lua.tostring lua 1 >>= throw . PandocLuaException +#endif Lua.call lua 0 0 -- TODO - call hierarchicalize, so we have that info rendered <- docToCustom lua opts doc |