Lua: restore List behavior of MetaList

Fixes a regression introduced in 2.16 which had MetaList elements loose
the `pandoc.List` properties.

Fixes #7650
This commit is contained in:
Albert Krewinkel 2021-11-01 08:14:44 +01:00
parent 171bfd3d65
commit 96e76d4cd4
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
2 changed files with 14 additions and 0 deletions

View file

@ -55,6 +55,7 @@ local function create_accessor_behavior (tag)
if k == "t" then if k == "t" then
return getmetatable(t)["tag"] return getmetatable(t)["tag"]
end end
return getmetatable(t)[k]
end end
behavior.__pairs = function (t) behavior.__pairs = function (t)
return next, t return next, t

View file

@ -278,6 +278,19 @@ return {
end) end)
}, },
}, },
group 'MetaValue elements' {
test('MetaList elements behave like lists', function ()
local metalist = pandoc.MetaList{}
assert.are_equal(type(metalist.insert), 'function')
assert.are_equal(type(metalist.remove), 'function')
end),
test('MetaList, MetaMap, MetaInlines, MetaBlocks have `t` tag', function ()
assert.are_equal((pandoc.MetaList{}).t, 'MetaList')
assert.are_equal((pandoc.MetaMap{}).t, 'MetaMap')
assert.are_equal((pandoc.MetaInlines{}).t, 'MetaInlines')
assert.are_equal((pandoc.MetaBlocks{}).t, 'MetaBlocks')
end)
},
group 'Other types' { group 'Other types' {
group 'SimpleTable' { group 'SimpleTable' {
test('can access properties', function () test('can access properties', function ()