data/pandoc.lua: fix access to Attr components

Accessing an Attr value (e.g., ` Attr().classes`) was broken; the more
common case of accessing it via an Inline or Block element was
unaffected by this.
This commit is contained in:
Albert Krewinkel 2018-01-09 19:44:42 +01:00
parent bf944e0aeb
commit f5e021998e
No known key found for this signature in database
GPG key ID: 388DC0B21F631124

View file

@ -62,7 +62,6 @@ local function create_accessor_functions (fn_template, accessors)
if type(acc) == "string" then if type(acc) == "string" then
res[acc] = make_indexing_function(fn_template, {...}) res[acc] = make_indexing_function(fn_template, {...})
else else
local unpack = table.unpack or unpack
for i = 1, #(acc or {}) do for i = 1, #(acc or {}) do
add_accessors(acc[i], i, ...) add_accessors(acc[i], i, ...)
end end
@ -802,13 +801,12 @@ function M.Attr:new (identifier, classes, attributes)
end end
M.Attr.behavior._field_names = {identifier = 1, classes = 2, attributes = 3} M.Attr.behavior._field_names = {identifier = 1, classes = 2, attributes = 3}
M.Attr.behavior.__index = function(t, k) M.Attr.behavior.__index = function(t, k)
return rawget(t, k) or return rawget(t, getmetatable(t)._field_names[k]) or
rawget(t, M.Attr._field_names[k]) or getmetatable(t)[k]
rawget(getmetatable(t), k)
end end
M.Attr.behavior.__newindex = function(t, k, v) M.Attr.behavior.__newindex = function(t, k, v)
if M.Attr._field_names[k] then if getmetatable(t)._field_names[k] then
rawset(t, M.Attr._field_names[k], v) rawset(t, getmetatable(t)._field_names[k], v)
else else
rawset(t, k, v) rawset(t, k, v)
end end