pandoc.lua: set metatable on List MetaValues

The `List` metatable is assigned to the tables which get passed to the
constructors `MetaBlocks`, `MetaInline`, and `MetaList`. This enables
the use of the resulting objects as lists.  This is part of the changes
discussed in #4081.
This commit is contained in:
Albert Krewinkel 2017-12-01 18:47:33 +01:00
parent 6640506ddc
commit 3f1f9536d4
No known key found for this signature in database
GPG key ID: 388DC0B21F631124

View file

@ -185,24 +185,24 @@ end
--- Meta list
-- @function MetaList
-- @tparam {MetaValue,...} meta_values list of meta values
M.meta_value_list_types = {
"MetaBlocks",
"MetaInlines",
"MetaList",
}
for i = 1, #M.meta_value_list_types do
M[M.meta_value_list_types[i]] = M.MetaValue:create_constructor(
M.meta_value_list_types[i],
function(content)
return List:new(content)
end
)
end
--- Meta map
-- @function MetaMap
-- @tparam table key_value_map a string-indexed map of meta values
M.meta_value_types = {
"MetaBlocks",
"MetaInlines",
"MetaList",
"MetaMap",
}
for i = 1, #M.meta_value_types do
M[M.meta_value_types[i]] = M.MetaValue:create_constructor(
M.meta_value_types[i],
function(content)
return content
end
)
end
M.MetaValue:create_constructor("MetaMap", function (mm) return mm end)
--- Creates string to be used in meta data.
-- Does nothing, lua strings are meta strings.