diff options
-rw-r--r-- | src/Text/Pandoc/Lua/Marshaling/AST.hs | 13 | ||||
-rw-r--r-- | test/lua/module/pandoc.lua | 16 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Lua/Marshaling/AST.hs b/src/Text/Pandoc/Lua/Marshaling/AST.hs index 883a6dce2..469dd4285 100644 --- a/src/Text/Pandoc/Lua/Marshaling/AST.hs +++ b/src/Text/Pandoc/Lua/Marshaling/AST.hs @@ -111,7 +111,18 @@ instance Pushable Block where push = pushBlock typeCitation :: LuaError e => DocumentedType e Citation -typeCitation = deftype "Citation" [] +typeCitation = deftype "Citation" + [ operation Eq $ lambda + ### liftPure2 (==) + <#> parameter (optional . peekCitation) "Citation" "a" "" + <#> parameter (optional . peekCitation) "Citation" "b" "" + =#> functionResult pushBool "boolean" "true iff the citations are equal" + + , operation Tostring $ lambda + ### liftPure show + <#> parameter peekCitation "Citation" "citation" "" + =#> functionResult pushString "string" "native Haskell representation" + ] [ property "id" "citation ID / key" (pushText, citationId) (peekText, \citation cid -> citation{ citationId = cid }) diff --git a/test/lua/module/pandoc.lua b/test/lua/module/pandoc.lua index a0b888c74..4792e0949 100644 --- a/test/lua/module/pandoc.lua +++ b/test/lua/module/pandoc.lua @@ -481,6 +481,22 @@ return { end) }, group 'Other types' { + group 'Citation' { + test('checks equality by comparing Haskell values', function() + assert.are_equal( + pandoc.Citation('a', pandoc.NormalCitation), + pandoc.Citation('a', pandoc.NormalCitation) + ) + assert.is_falsy( + pandoc.Citation('a', pandoc.NormalCitation) == + pandoc.Citation('a', pandoc.AuthorInText) + ) + assert.is_falsy( + pandoc.Citation('a', pandoc.NormalCitation) == + pandoc.Citation('b', pandoc.NormalCitation) + ) + end), + }, group 'SimpleTable' { test('can access properties', function () local spc = pandoc.Space() |