diff options
-rw-r--r-- | pandoc.cabal | 4 | ||||
-rw-r--r-- | src/Text/Pandoc/Lua/StackInstances.hs | 14 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Custom.hs | 6 | ||||
-rw-r--r-- | stack.full.yaml | 2 | ||||
-rw-r--r-- | stack.pkg.yaml | 2 | ||||
-rw-r--r-- | stack.yaml | 2 |
6 files changed, 23 insertions, 7 deletions
diff --git a/pandoc.cabal b/pandoc.cabal index 1eabc9a80..7e7ed97b7 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -316,7 +316,7 @@ Library yaml >= 0.8.8.2 && < 0.9, scientific >= 0.2 && < 0.4, vector >= 0.10 && < 0.13, - hslua >= 0.7 && < 0.8, + hslua >= 0.8 && < 0.9, binary >= 0.5 && < 0.9, SHA >= 1.6 && < 1.7, haddock-library >= 1.1 && < 1.5, @@ -542,7 +542,7 @@ Test-Suite test-pandoc text >= 0.11 && < 1.3, directory >= 1 && < 1.4, filepath >= 1.1 && < 1.5, - hslua >= 0.7 && < 0.8, + hslua >= 0.8 && < 0.9, process >= 1.2.3 && < 1.7, skylighting >= 0.3.3 && < 0.4, temporary >= 1.1 && < 1.3, diff --git a/src/Text/Pandoc/Lua/StackInstances.hs b/src/Text/Pandoc/Lua/StackInstances.hs index da9c33183..15a7cdd84 100644 --- a/src/Text/Pandoc/Lua/StackInstances.hs +++ b/src/Text/Pandoc/Lua/StackInstances.hs @@ -33,8 +33,8 @@ StackValue instances for pandoc types. module Text.Pandoc.Lua.StackInstances () where import Control.Applicative ((<|>)) -import Foreign.Lua (Lua, Type (..), FromLuaStack (peek), ToLuaStack (push), - StackIndex, throwLuaError, tryLua) +import Foreign.Lua (Lua, LuaInteger, LuaNumber, Type (..), FromLuaStack (peek), + ToLuaStack (push), StackIndex, throwLuaError, tryLua) import Foreign.Lua.Api (getmetatable, ltype, newtable, pop, rawget, rawlen) import Text.Pandoc.Definition import Text.Pandoc.Lua.Util (addValue, adjustIndexBy, getTable, pushViaConstructor) @@ -125,6 +125,16 @@ instance ToLuaStack QuoteType where instance FromLuaStack QuoteType where peek idx = safeRead' =<< peek idx +instance ToLuaStack Double where + push = push . (realToFrac :: Double -> LuaNumber) +instance FromLuaStack Double where + peek = fmap (realToFrac :: LuaNumber -> Double) . peek + +instance ToLuaStack Int where + push = push . (fromIntegral :: Int -> LuaInteger) +instance FromLuaStack Int where + peek = fmap (fromIntegral :: LuaInteger-> Int) . peek + safeRead' :: Read a => String -> Lua a safeRead' s = case safeRead s of Nothing -> throwLuaError ("Could not read: " ++ s) diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs index 63725bb60..d7dff6d19 100644 --- a/src/Text/Pandoc/Writers/Custom.hs +++ b/src/Text/Pandoc/Writers/Custom.hs @@ -60,6 +60,12 @@ attrToMap (id',classes,keyvals) = M.fromList : ("class", unwords classes) : keyvals +instance ToLuaStack Double where + push = push . (realToFrac :: Double -> LuaNumber) + +instance ToLuaStack Int where + push = push . (fromIntegral :: Int -> LuaInteger) + instance ToLuaStack Format where push (Format f) = push (map toLower f) diff --git a/stack.full.yaml b/stack.full.yaml index c75f5b89f..b331a9870 100644 --- a/stack.full.yaml +++ b/stack.full.yaml @@ -20,6 +20,6 @@ packages: - '../pandoc-types' - '../texmath' extra-deps: -- hslua-0.7.0 +- hslua-0.8.0 - skylighting-0.3.3 resolver: lts-8.12 diff --git a/stack.pkg.yaml b/stack.pkg.yaml index 290c35726..3832bc5d9 100644 --- a/stack.pkg.yaml +++ b/stack.pkg.yaml @@ -17,7 +17,7 @@ packages: commit: 6930cd18087190133e600533a8d335a718cddf76 extra-dep: false extra-deps: -- hslua-0.7.0 +- hslua-0.8.0 - skylighting-0.3.3 - cmark-gfm-0.1.1 - QuickCheck-2.10.0.1 diff --git a/stack.yaml b/stack.yaml index c3bc1041d..6b4ba2277 100644 --- a/stack.yaml +++ b/stack.yaml @@ -7,7 +7,7 @@ flags: packages: - '.' extra-deps: -- hslua-0.7.0 +- hslua-0.8.0 - skylighting-0.3.3 - cmark-gfm-0.1.1 - QuickCheck-2.10.0.1 |