data/pandoc.lua: add datatype ListAttributes
Make ListAttributes a datatype. The type is similar to Attr.
This commit is contained in:
parent
484056a4cd
commit
5f6f2c69f5
2 changed files with 46 additions and 1 deletions
|
@ -403,7 +403,7 @@ M.Null = M.Block:create_constructor(
|
||||||
M.OrderedList = M.Block:create_constructor(
|
M.OrderedList = M.Block:create_constructor(
|
||||||
"OrderedList",
|
"OrderedList",
|
||||||
function(items, listAttributes)
|
function(items, listAttributes)
|
||||||
listAttributes = listAttributes or {1, M.DefaultStyle, M.DefaultDelim}
|
listAttributes = listAttributes or M.ListAttributes()
|
||||||
return {c = {listAttributes, ensureList(items)}}
|
return {c = {listAttributes, ensureList(items)}}
|
||||||
end,
|
end,
|
||||||
{{listAttributes = {"start", "style", "delimiter"}}, "content"}
|
{{listAttributes = {"start", "style", "delimiter"}}, "content"}
|
||||||
|
@ -857,6 +857,34 @@ function M.Citation:new (id, mode, prefix, suffix, note_num, hash)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ListAttributes
|
||||||
|
M.ListAttributes = AstElement:make_subtype 'ListAttributes'
|
||||||
|
|
||||||
|
--- Creates a set of list attributes.
|
||||||
|
-- @function ListAttributes
|
||||||
|
-- @tparam[opt] integer start number of the first list item
|
||||||
|
-- @tparam[opt] string style style used for list numbering
|
||||||
|
-- @tparam[opt] DefaultDelim|Period|OneParen|TwoParens delimiter delimiter of list numbers
|
||||||
|
-- @treturn table list attributes table
|
||||||
|
function M.ListAttributes:new (start, style, delimiter)
|
||||||
|
start = start or 1
|
||||||
|
style = style or 'DefaultStyle'
|
||||||
|
delimiter = delimiter or 'DefaultDelim'
|
||||||
|
return {start, style, delimiter}
|
||||||
|
end
|
||||||
|
M.ListAttributes.behavior._field_names = {start = 1, style = 2, delimiter = 3}
|
||||||
|
M.ListAttributes.behavior.__index = function (t, k)
|
||||||
|
return rawget(t, getmetatable(t)._field_names[k]) or
|
||||||
|
getmetatable(t)[k]
|
||||||
|
end
|
||||||
|
M.ListAttributes.behavior.__newindex = function (t, k, v)
|
||||||
|
if getmetatable(t)._field_names[k] then
|
||||||
|
rawset(t, getmetatable(t)._field_names[k], v)
|
||||||
|
else
|
||||||
|
rawset(t, k, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
-- Constants
|
-- Constants
|
||||||
|
|
|
@ -1253,6 +1253,23 @@ Lua functions for pandoc scripts.
|
||||||
`hash`:
|
`hash`:
|
||||||
: hash number
|
: hash number
|
||||||
|
|
||||||
|
[`ListAttributes ([start[, style[, delimiter]]])`](#ListAttributes)
|
||||||
|
|
||||||
|
: Creates a set of list attributes
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
`start`:
|
||||||
|
: number of the first list item (default: 1)
|
||||||
|
|
||||||
|
`style`:
|
||||||
|
: style used for list numbering (default: `DefaultStyle`)
|
||||||
|
|
||||||
|
`delimiter`:
|
||||||
|
: delimiter of list numbers (default: `DefaultDelim`)
|
||||||
|
|
||||||
|
Returns: list attributes table
|
||||||
|
|
||||||
## Constants
|
## Constants
|
||||||
|
|
||||||
[`AuthorInText`]{#AuthorInText}
|
[`AuthorInText`]{#AuthorInText}
|
||||||
|
|
Loading…
Add table
Reference in a new issue