aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2021-11-02 16:49:50 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2021-11-02 16:49:50 +0100
commit210e4c98b0d09dd8e25c108dda14fdb17ba90192 (patch)
tree9c0fc244c6761a23f8c13406a8c3f3790151af84 /src
parent3a0ac52f7b23b555a7eeb9e3df10536b809f95ac (diff)
downloadpandoc-210e4c98b0d09dd8e25c108dda14fdb17ba90192.tar.gz
Lua: allow to compare, show Citation values
Comparisons of Citation values are performed in Haskell; values are equal if they represent the same Haskell value. Converting a Citation value to a string now yields its native Haskell string representation.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Lua/Marshaling/AST.hs13
1 files changed, 12 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 })