Allow building with hslua 0.4.
This commit is contained in:
parent
e0aed52c07
commit
c327b283c1
2 changed files with 21 additions and 1 deletions
|
@ -265,7 +265,7 @@ Library
|
||||||
yaml >= 0.8.8.2 && < 0.9,
|
yaml >= 0.8.8.2 && < 0.9,
|
||||||
scientific >= 0.2 && < 0.4,
|
scientific >= 0.2 && < 0.4,
|
||||||
vector >= 0.10 && < 0.11,
|
vector >= 0.10 && < 0.11,
|
||||||
hslua >= 0.3 && < 0.4,
|
hslua >= 0.3 && < 0.5,
|
||||||
binary >= 0.5 && < 0.8,
|
binary >= 0.5 && < 0.8,
|
||||||
SHA >= 1.6 && < 1.7,
|
SHA >= 1.6 && < 1.7,
|
||||||
haddock-library >= 1.1 && < 1.3,
|
haddock-library >= 1.1 && < 1.3,
|
||||||
|
|
|
@ -69,6 +69,13 @@ getList lua i' = do
|
||||||
return (x : rest)
|
return (x : rest)
|
||||||
else return []
|
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)
|
#if MIN_VERSION_base(4,8,0)
|
||||||
instance {-# OVERLAPS #-} StackValue a => StackValue [a] where
|
instance {-# OVERLAPS #-} StackValue a => StackValue [a] where
|
||||||
#else
|
#else
|
||||||
|
@ -86,6 +93,7 @@ instance StackValue a => StackValue [a] where
|
||||||
Lua.pop lua 1
|
Lua.pop lua 1
|
||||||
return (Just lst)
|
return (Just lst)
|
||||||
valuetype _ = Lua.TTABLE
|
valuetype _ = Lua.TTABLE
|
||||||
|
#endif
|
||||||
|
|
||||||
instance StackValue Format where
|
instance StackValue Format where
|
||||||
push lua (Format f) = Lua.push lua (map toLower f)
|
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
|
peek _ _ = undefined -- not needed for our purposes
|
||||||
valuetype _ = Lua.TTABLE
|
valuetype _ = Lua.TTABLE
|
||||||
|
|
||||||
|
#if MIN_VERSION_base(4,8,0)
|
||||||
|
instance {-# OVERLAPS #-} StackValue [Inline] where
|
||||||
|
#else
|
||||||
instance StackValue [Inline] where
|
instance StackValue [Inline] where
|
||||||
|
#endif
|
||||||
push l ils = Lua.push l =<< inlineListToCustom l ils
|
push l ils = Lua.push l =<< inlineListToCustom l ils
|
||||||
peek _ _ = undefined
|
peek _ _ = undefined
|
||||||
valuetype _ = Lua.TSTRING
|
valuetype _ = Lua.TSTRING
|
||||||
|
|
||||||
|
#if MIN_VERSION_base(4,8,0)
|
||||||
|
instance {-# OVERLAPS #-} StackValue [Block] where
|
||||||
|
#else
|
||||||
instance StackValue [Block] where
|
instance StackValue [Block] where
|
||||||
|
#endif
|
||||||
push l ils = Lua.push l =<< blockListToCustom l ils
|
push l ils = Lua.push l =<< blockListToCustom l ils
|
||||||
peek _ _ = undefined
|
peek _ _ = undefined
|
||||||
valuetype _ = Lua.TSTRING
|
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
|
-- check for error in lua script (later we'll change the return type
|
||||||
-- to handle this more gracefully):
|
-- to handle this more gracefully):
|
||||||
when (status /= 0) $
|
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
|
Lua.tostring lua 1 >>= throw . PandocLuaException
|
||||||
|
#endif
|
||||||
Lua.call lua 0 0
|
Lua.call lua 0 0
|
||||||
-- TODO - call hierarchicalize, so we have that info
|
-- TODO - call hierarchicalize, so we have that info
|
||||||
rendered <- docToCustom lua opts doc
|
rendered <- docToCustom lua opts doc
|
||||||
|
|
Loading…
Reference in a new issue