From f492f5a6dd991530241529d1110e73260d3a1d43 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sat, 6 Jan 2018 23:25:08 +0100 Subject: 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. --- data/pandoc.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data/pandoc.lua b/data/pandoc.lua index 86bb5b8ea..d96d5e702 100644 --- a/data/pandoc.lua +++ b/data/pandoc.lua @@ -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 -- cgit v1.2.3