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
-- @local
local Element = {}
Element.__index = Element
--- Create a new element subtype
-- @local
function Element:make_subtype(o)
o = o or {}
setmetatable(o, self)
self.__index = self
-- Make subtype usable as a metatable
o.__index = o
return o
end
@ -57,7 +59,6 @@ function Element:new(tag, ...)
element.c = content
end
setmetatable(element, self)
self.__index = self
return element
end