pandoc-lua-marshal 0.1.5.1 → 0.1.6
raw patch · 5 files changed
+44/−25 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +13/−1
- pandoc-lua-marshal.cabal +3/−3
- src/Text/Pandoc/Lua/Marshal/Pandoc.hs +16/−19
- src/Text/Pandoc/Lua/Marshal/TableParts.hs +2/−2
- test/test-pandoc.lua +10/−0
CHANGELOG.md view
@@ -2,9 +2,21 @@ `pandoc-lua-marshal` uses [PVP Versioning][]. +## 0.1.6++Released 2022-06-03.++- Fix `applyFully`: the function always traversed the document+ type-wise, never topdown.++- Avoid shadowing of a function name that was added in+ hslua-2.2.++- Support concatenating of Pandoc values with the `..` operator.+ ## 0.1.5.1 -Release pending.+Released 2022-02-19. - Relax upper bound for lua and hslua.
pandoc-lua-marshal.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: pandoc-lua-marshal-version: 0.1.5.1+version: 0.1.6 synopsis: Use pandoc types in Lua description: This package provides functions to marshal and unmarshal pandoc document types to and from Lua.@@ -27,8 +27,8 @@ tested-with: GHC == 8.6.5 GHC == 8.8.4 GHC == 8.10.7- GHC == 9.0.1- GHC == 9.2.1+ GHC == 9.0.2+ GHC == 9.2.2 extra-source-files: test/test-attr.lua , test/test-block.lua , test/test-cell.lua
src/Text/Pandoc/Lua/Marshal/Pandoc.hs view
@@ -20,12 +20,10 @@ ) where import Control.Applicative (optional)-import Control.Monad ((<$!>), (>=>))+import Control.Monad ((<$!>)) import Data.Maybe (fromMaybe) import HsLua-import Text.Pandoc.Lua.Marshal.Block- (peekBlocksFuzzy, pushBlocks, walkBlockSplicing, walkBlocksStraight)-import Text.Pandoc.Lua.Marshal.Inline (walkInlineSplicing, walkInlinesStraight)+import Text.Pandoc.Lua.Marshal.Block (peekBlocksFuzzy, pushBlocks) import Text.Pandoc.Lua.Marshal.Filter import Text.Pandoc.Lua.Marshal.MetaValue (peekMetaValue, pushMetaValue) import Text.Pandoc.Lua.Marshal.Shared (walkBlocksAndInlines)@@ -43,7 +41,12 @@ -- | Pandoc object type. typePandoc :: LuaError e => DocumentedType e Pandoc typePandoc = deftype "Pandoc"- [ operation Eq $ defun "__eq"+ [ operation Concat $ lambda+ ### liftPure2 (<>)+ <#> parameter peekPandoc "Pandoc" "a" ""+ <#> parameter peekPandoc "Pandoc" "b" ""+ =#> functionResult pushPandoc "Pandoc" "combined documents"+ , operation Eq $ defun "__eq" ### liftPure2 (\a b -> fromMaybe False ((==) <$> a <*> b)) <#> parameter (optional . peekPandoc) "doc1" "pandoc" "" <#> parameter (optional . peekPandoc) "doc2" "pandoc" ""@@ -61,13 +64,7 @@ (peekMeta, \(Pandoc _ blks) meta -> Pandoc meta blks) , method $ defun "walk"- ### (\doc filter' -> case filterWalkingOrder filter' of- WalkForEachType -> walkBlocksAndInlines filter' doc- >>= applyMetaFunction filter'- >>= applyPandocFunction filter'- WalkTopdown -> applyPandocFunction filter' doc- >>= applyMetaFunction filter'- >>= walkBlocksAndInlines filter')+ ### flip applyFully <#> parameter peekPandoc "Pandoc" "self" "" <#> parameter peekFilter "Filter" "lua_filter" "table of filter functions" =#> functionResult pushPandoc "Pandoc" "modified element"@@ -134,10 +131,10 @@ applyFully :: LuaError e => Filter -> Pandoc -> LuaE e Pandoc-applyFully filter' =- walkInlineSplicing filter'- >=> walkInlinesStraight filter'- >=> walkBlockSplicing filter'- >=> walkBlocksStraight filter'- >=> applyMetaFunction filter'- >=> applyPandocFunction filter'+applyFully filter' doc = case filterWalkingOrder filter' of+ WalkForEachType -> walkBlocksAndInlines filter' doc+ >>= applyMetaFunction filter'+ >>= applyPandocFunction filter'+ WalkTopdown -> applyPandocFunction filter' doc+ >>= applyMetaFunction filter'+ >>= walkBlocksAndInlines filter'
src/Text/Pandoc/Lua/Marshal/TableParts.hs view
@@ -99,7 +99,7 @@ -- | Add a value to the table at the top of the stack at a string-index. addField :: LuaError e => Name -> LuaE e () -> LuaE e ()-addField key pushValue = do+addField key pushFieldValue = do pushName key- pushValue+ pushFieldValue rawset (nth 3)
test/test-pandoc.lua view
@@ -35,6 +35,16 @@ assert.are_same(meta.zahlen, {'eins', 'zwei', 'drei'}) end), },+ group 'operations' {+ test('concatenation', function ()+ local doc1 = Pandoc({Para 'Lovely'}, {title='first'})+ local doc2 = Pandoc({Para 'Day'}, {title='second'})+ assert.are_equal(+ Pandoc({Para 'Lovely', Para 'Day'}, {title='second'}),+ doc1 .. doc2+ )+ end)+ }, group 'walk' { test('uses `Meta` function', function () local meta = {