aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pandoc.cabal2
-rw-r--r--src/Text/Pandoc/Writers/Custom.hs20
2 files changed, 21 insertions, 1 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index e2a6396a5..c6e3ffe48 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -265,7 +265,7 @@ Library
yaml >= 0.8.8.2 && < 0.9,
scientific >= 0.2 && < 0.4,
vector >= 0.10 && < 0.11,
- hslua >= 0.3 && < 0.4,
+ hslua >= 0.3 && < 0.5,
binary >= 0.5 && < 0.8,
SHA >= 1.6 && < 1.7,
haddock-library >= 1.1 && < 1.3,
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