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:
parent
3a22907306
commit
f492f5a6dd
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue