git.iko.soy/typeable/pandoc
on master help sign in
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.

commitf5e021998efcebb32d03bd03ace57c825f55a20d authorAlbert Krewinkel <albert@zeitkraut.de> dateTue 9 Jan 2018, 19:44 (9 years ago) parentbf944e0
1 file changed+4−6
data/pandoc.lua+4−6
data/pandoc.lua+4−6
@@ -62,7 +62,6 @@ local function create_accessor_functions (fn_template, accessors)
6262 if type(acc) == "string" then
6363 res[acc] = make_indexing_function(fn_template, {...})
6464 else
65− local unpack = table.unpack or unpack
6665 for i = 1, #(acc or {}) do
6766 add_accessors(acc[i], i, ...)
6867 end
@@ -802,13 +801,12 @@ function M.Attr:new (identifier, classes, attributes)
802801end
803802M.Attr.behavior._field_names = {identifier = 1, classes = 2, attributes = 3}
804803M.Attr.behavior.__index = function(t, k)
805− return rawget(t, k) or
806− rawget(t, M.Attr._field_names[k]) or
807− rawget(getmetatable(t), k)
804+ return rawget(t, getmetatable(t)._field_names[k]) or
805+ getmetatable(t)[k]
808806end
809807M.Attr.behavior.__newindex = function(t, k, v)
810− if M.Attr._field_names[k] then
811− rawset(t, M.Attr._field_names[k], v)
808+ if getmetatable(t)._field_names[k] then
809+ rawset(t, getmetatable(t)._field_names[k], v)
812810 else
813811 rawset(t, k, v)
814812 end