aboutsummaryrefslogtreecommitdiff
path: root/data/pandoc.lua
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2018-11-19 21:36:02 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2018-11-19 21:46:20 +0100
commitc0d8b0abcb99adf5f7d2ddac3ad343d48da94910 (patch)
treea417b0f20fd0f297c41e686b1d2120698e27424c /data/pandoc.lua
parente80bcb9bea4e39dd62a984695f2c72d1a9a83ee2 (diff)
downloadpandoc-c0d8b0abcb99adf5f7d2ddac3ad343d48da94910.tar.gz
Lua filters: test AST object equality via Haskell
Equality of Lua objects representing pandoc AST elements is tested by unmarshalling the objects and comparing the result in Haskell. A new function `equals` which performs this test has been added to the `pandoc.utils` module. Closes: #5092
Diffstat (limited to 'data/pandoc.lua')
-rw-r--r--data/pandoc.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/data/pandoc.lua b/data/pandoc.lua
index e69f8ac9c..9289c177f 100644
--- a/data/pandoc.lua
+++ b/data/pandoc.lua
@@ -25,6 +25,7 @@ THIS SOFTWARE.
local M = {}
local List = require 'pandoc.List'
+local utils = require 'pandoc.utils'
------------------------------------------------------------------------
-- Accessor objects
@@ -119,6 +120,7 @@ local function create_accessor_behavior (tag, accessors)
'function (x, v) x.c%s = v end',
accessors
)
+ behavior.__eq = utils.equals
behavior.__index = function(t, k)
if getmetatable(t).getters[k] then
return getmetatable(t).getters[k](t)
@@ -873,6 +875,7 @@ function M.Attr:new (identifier, classes, attributes)
return {identifier, classes, attributes}
end
M.Attr.behavior._field_names = {identifier = 1, classes = 2, attributes = 3}
+M.Attr.behavior.__eq = utils.equals
M.Attr.behavior.__index = function(t, k)
return rawget(t, getmetatable(t)._field_names[k]) or
getmetatable(t)[k]
@@ -931,6 +934,7 @@ function M.ListAttributes:new (start, style, delimiter)
return {start, style, delimiter}
end
M.ListAttributes.behavior._field_names = {start = 1, style = 2, delimiter = 3}
+M.ListAttributes.behavior.__eq = utils.equals
M.ListAttributes.behavior.__index = function (t, k)
return rawget(t, getmetatable(t)._field_names[k]) or
getmetatable(t)[k]
@@ -1033,7 +1037,6 @@ M.UpperAlpha = "UpperAlpha"
------------------------------------------------------------------------
-- Functions which have moved to different modules
-local utils = require 'pandoc.utils'
M.sha1 = utils.sha1
return M