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:
parent
bf944e0aeb
commit
f5e021998e
1 changed files with 4 additions and 6 deletions
|
@ -62,7 +62,6 @@ local function create_accessor_functions (fn_template, accessors)
|
|||
if type(acc) == "string" then
|
||||
res[acc] = make_indexing_function(fn_template, {...})
|
||||
else
|
||||
local unpack = table.unpack or unpack
|
||||
for i = 1, #(acc or {}) do
|
||||
add_accessors(acc[i], i, ...)
|
||||
end
|
||||
|
@ -802,13 +801,12 @@ function M.Attr:new (identifier, classes, attributes)
|
|||
end
|
||||
M.Attr.behavior._field_names = {identifier = 1, classes = 2, attributes = 3}
|
||||
M.Attr.behavior.__index = function(t, k)
|
||||
return rawget(t, k) or
|
||||
rawget(t, M.Attr._field_names[k]) or
|
||||
rawget(getmetatable(t), k)
|
||||
return rawget(t, getmetatable(t)._field_names[k]) or
|
||||
getmetatable(t)[k]
|
||||
end
|
||||
M.Attr.behavior.__newindex = function(t, k, v)
|
||||
if M.Attr._field_names[k] then
|
||||
rawset(t, M.Attr._field_names[k], v)
|
||||
if getmetatable(t)._field_names[k] then
|
||||
rawset(t, getmetatable(t)._field_names[k], v)
|
||||
else
|
||||
rawset(t, k, v)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue