pandoc-lua-marshal 0.1.6 → 0.1.6.1
raw patch · 6 files changed
+38/−15 lines, 6 filesdep ~textPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: text
API changes (from Hackage documentation)
Files
- CHANGELOG.md +9/−0
- pandoc-lua-marshal.cabal +2/−2
- src/Text/Pandoc/Lua/Marshal/Block.hs +10/−8
- src/Text/Pandoc/Lua/Marshal/Inline.hs +5/−5
- test/test-block.lua +6/−0
- test/test-inline.lua +6/−0
CHANGELOG.md view
@@ -2,6 +2,15 @@ `pandoc-lua-marshal` uses [PVP Versioning][]. +## 0.1.6.1++Released 2022-06-10.++- Provide better error messages when fuzzy retrieval of Inlines+ or Blocks fails.++- Relax upper bound for text, allow text-2.0.+ ## 0.1.6 Released 2022-06-03.
pandoc-lua-marshal.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: pandoc-lua-marshal-version: 0.1.6+version: 0.1.6.1 synopsis: Use pandoc types in Lua description: This package provides functions to marshal and unmarshal pandoc document types to and from Lua.@@ -54,7 +54,7 @@ , hslua-marshalling >= 2.1 && < 2.3 , pandoc-types >= 1.22.1 && < 1.23 , safe >= 0.3 && < 0.4- , text >= 1.1.1.0 && < 1.3+ , text >= 1.1.1.0 && < 1.3 || >= 2.0 && < 2.1 ghc-options: -Wall -Wcompat
src/Text/Pandoc/Lua/Marshal/Block.hs view
@@ -90,20 +90,22 @@ -- bare strings as @Str@ values. peekBlockFuzzy :: LuaError e => Peeker e Block-peekBlockFuzzy = choice- [ peekBlock- , \idx -> Plain <$!> peekInlinesFuzzy idx- ]+peekBlockFuzzy idx =+ peekBlock idx+ <|> (Plain <$!> peekInlinesFuzzy idx)+ <|> (failPeek =<<+ typeMismatchMessage "Block or list of Inlines" idx) {-# INLINABLE peekBlockFuzzy #-} -- | Try extra-hard to return the value at the given index as a list of -- inlines. peekBlocksFuzzy :: LuaError e => Peeker e [Block]-peekBlocksFuzzy = choice- [ peekList peekBlockFuzzy- , (<$!>) pure . peekBlockFuzzy- ]+peekBlocksFuzzy idx =+ peekList peekBlockFuzzy idx+ <|> (pure <$!> peekBlockFuzzy idx)+ <|> (failPeek =<<+ typeMismatchMessage "Block, list of Blocks, or compatible element" idx) {-# INLINABLE peekBlocksFuzzy #-} -- | Block object type.
src/Text/Pandoc/Lua/Marshal/Inline.hs view
@@ -25,7 +25,7 @@ , walkInlinesStraight ) where -import Control.Applicative (optional)+import Control.Applicative ((<|>), optional) import Control.Monad.Catch (throwM) import Control.Monad ((<$!>)) import Data.Data (showConstr, toConstr)@@ -93,10 +93,10 @@ => Peeker e [Inline] peekInlinesFuzzy idx = liftLua (ltype idx) >>= \case TypeString -> B.toList . B.text <$> peekText idx- _ -> choice- [ peekList peekInlineFuzzy- , fmap pure . peekInlineFuzzy- ] idx+ _ -> peekList peekInlineFuzzy idx+ <|> (pure <$> peekInlineFuzzy idx)+ <|> (failPeek =<<+ typeMismatchMessage "Inline, list of Inlines, or string" idx) {-# INLINABLE peekInlinesFuzzy #-} -- | Inline object type.
test/test-block.lua view
@@ -349,6 +349,12 @@ {'Header', 'CodeBlock'} ) end),+ test('gives sensible error message', function ()+ assert.error_matches(+ function() Blocks(nil) end,+ 'Block, list of Blocks, or compatible element expected'+ )+ end) }, group 'walk' { test('modifies Inline subelements', function ()
test/test-inline.lua view
@@ -318,6 +318,12 @@ {'Str', 'Space', 'Str'} ) end),+ test('gives sensible error message', function ()+ assert.error_matches(+ function() Inlines(nil) end,+ "Inline, list of Inlines, or string"+ )+ end) }, group 'walk' { test('modifies Inline subelements', function ()