data/pandoc.lua: fix Element inheritance

Extending all elements of a given type (e.g., all inline elements) was
difficult, as the table used to lookup unknown methods would be reset
every time a new element of that type was created, preventing recursive
property lookup. This is was changed in that all methods and attributes
of supertypes are now available to their subtypes.
This commit is contained in:
Albert Krewinkel 2018-01-06 23:25:08 +01:00
parent 3a22907306
commit f492f5a6dd
No known key found for this signature in database
GPG key ID: 388DC0B21F631124

View file

@ -33,13 +33,15 @@ local List = require 'pandoc.List'
-- @type Element -- @type Element
-- @local -- @local
local Element = {} local Element = {}
Element.__index = Element
--- Create a new element subtype --- Create a new element subtype
-- @local -- @local
function Element:make_subtype(o) function Element:make_subtype(o)
o = o or {} o = o or {}
setmetatable(o, self) setmetatable(o, self)
self.__index = self -- Make subtype usable as a metatable
o.__index = o
return o return o
end end
@ -57,7 +59,6 @@ function Element:new(tag, ...)
element.c = content element.c = content
end end
setmetatable(element, self) setmetatable(element, self)
self.__index = self
return element return element
end end