@@ -72,7 +72,7 @@ local function copy_table (tbl, depth)
7272end
7373
7474--- Checks if two tables are equal
75- function equals (o1 , o2 , seen )
75+ function equals (o1 , o2 )
7676 if o1 == o2 then
7777 return true
7878 end
@@ -83,22 +83,16 @@ function equals(o1, o2, seen)
8383 end
8484
8585 local keys = {}
86- seen = seen or {}
87- if seen [o1 ] then
88- return true
89- end
90-
91- seen [o1 ] = true
9286
9387 for key1 , value1 in pairs (o1 ) do
9488 local value2 = o2 [key1 ]
95- if value2 == nil or equals (value1 , value2 , seen ) == false then
89+ if value2 == nil or equals (value1 , value2 ) == false then
9690 return false
9791 end
9892 keys [key1 ] = true
9993 end
10094
101- for key2 , _ in pairs (o2 ) do
95+ for key2 in pairs (o2 ) do
10296 if not keys [key2 ] then return false end
10397 end
10498 return true
@@ -117,13 +111,15 @@ local function check_nondestructive_property (namedfilter)
117111 for name , fn in pairs (namedfilter .filter ) do
118112 if type (fn ) == ' function' then
119113 local copy = function (x )
120- return type (x ) == ' table' and copy_table (x ) or x :clone ()
114+ local tp = type (x )
115+ return tp ~= ' table' and x :clone () or
116+ (pandoc .utils .type (x ) == ' Meta' and pandoc .Meta (x ) or copy_table (x ))
121117 end
122118 namedfilter .filter [name ] = function (obj , context )
123119 local orig = copy (obj )
124120 local result , descend = fn (obj , context )
125121 if result == nil then
126- if not equals (obj , orig ) then
122+ if type ( obj ) ~= ' table ' and not equals (obj , orig ) then
127123 warn (
128124 " \n Function '" .. name .. " ' in filter '" .. namedfilter .name ..
129125 " ' returned `nil`, but modified the input."
0 commit comments