From d4c73d5e6536535015f953ba2e5c3b83979819af Mon Sep 17 00:00:00 2001
From: Albert Krewinkel <albert@zeitkraut.de>
Date: Tue, 9 Nov 2021 14:43:18 +0100
Subject: [PATCH] Lua: fix argument order in constructor `pandoc.Cite`.

This restores the old behavior; argument order had been switched
accidentally in pandoc 2.15.
---
 src/Text/Pandoc/Lua/Module/Pandoc.hs | 4 ++--
 test/lua/module/pandoc.lua           | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/Text/Pandoc/Lua/Module/Pandoc.hs b/src/Text/Pandoc/Lua/Module/Pandoc.hs
index 8f42a2988..a8b111092 100644
--- a/src/Text/Pandoc/Lua/Module/Pandoc.hs
+++ b/src/Text/Pandoc/Lua/Module/Pandoc.hs
@@ -135,9 +135,9 @@ pushWithConstructorsSubtable constructors = do
 inlineConstructors :: LuaError e =>  [DocumentedFunction e]
 inlineConstructors =
   [ defun "Cite"
-    ### liftPure2 Cite
-    <#> parameter (peekList peekCitation) "citations" "list of Citations" ""
+    ### liftPure2 (flip Cite)
     <#> parameter peekInlinesFuzzy "content" "Inline" "placeholder content"
+    <#> parameter (peekList peekCitation) "citations" "list of Citations" ""
     =#> functionResult pushInline "Inline" "cite element"
   , defun "Code"
     ### liftPure2 (\text mattr -> Code (fromMaybe nullAttr mattr) text)
diff --git a/test/lua/module/pandoc.lua b/test/lua/module/pandoc.lua
index 5a58914ef..4f4a9b27e 100644
--- a/test/lua/module/pandoc.lua
+++ b/test/lua/module/pandoc.lua
@@ -151,17 +151,17 @@ return {
   group "Inline elements" {
     group 'Cite' {
       test('has property `content`', function ()
-        local cite = pandoc.Cite({}, {pandoc.Emph 'important'})
+        local cite = pandoc.Cite({pandoc.Emph 'important'}, {})
         assert.are_same(cite.content, {pandoc.Emph {pandoc.Str 'important'}})
 
         cite.content = 'boring'
-        assert.are_equal(cite, pandoc.Cite({}, {pandoc.Str 'boring'}))
+        assert.are_equal(cite, pandoc.Cite({pandoc.Str 'boring'}, {}))
       end),
       test('has list of citations in property `cite`', function ()
         local citations = {
           pandoc.Citation('einstein1905', 'NormalCitation')
         }
-        local cite = pandoc.Cite(citations, 'relativity')
+        local cite = pandoc.Cite('relativity', citations)
         assert.are_same(cite.citations, citations)
 
         local new_citations = {
@@ -169,7 +169,7 @@ return {
           pandoc.Citation('Poincaré1905', 'NormalCitation')
         }
         cite.citations = new_citations
-        assert.are_equal(cite, pandoc.Cite(new_citations, {'relativity'}))
+        assert.are_equal(cite, pandoc.Cite({'relativity'}, new_citations))
       end),
     },
     group 'Code' {