git.iko.soy/typeable/pandoc
on master help sign in
Lua filters: make attr argument optional in Table constructor

This changes the Lua API. It is highly unlikely for this change to affect existing filters, since the documentation for the new Table constructor (and type) was incomplete and partly wrong before. The Lua API is now more consistent, as all constructors for elements with attributes now take attributes as the last parameter.

commit44c4660a31fcb6034a7368a3596ab7a252a87ad4 authorAlbert Krewinkel <albert@zeitkraut.de> dateSat 25 Jul 2020, 20:29 (6 years ago) parent9dd4d07
3 files changed+19−10
data/pandoc.lua+3−3 doc/lua-filters.md+15−6 src/Text/Pandoc/Lua/Marshaling/AST.hs+1−1
data/pandoc.lua+3−3
@@ -556,18 +556,18 @@ M.RawBlock = M.Block:create_constructor(
556556
557557--- Creates a table element.
558558-- @function Table
559−-- @tparam Attr attr attributes
560559-- @tparam Caption caption table caption
561560-- @tparam {ColSpec,...} colspecs column alignments and widths
562561-- @tparam TableHead head table head
563562-- @tparam {TableBody,..} bodies table bodies
564563-- @treturn TableFoot foot table foot
564+-- @tparam[opt] Attr attr attributes
565565M.Table = M.Block:create_constructor(
566566 "Table",
567− function(attr, caption, colspecs, head, bodies, foot)
567+ function(caption, colspecs, head, bodies, foot, attr)
568568 return {
569569 c = {
570− attr,
570+ ensureAttr(attr),
571571 caption,
572572 List:new(colspecs),
573573 head,
doc/lua-filters.md+15−6
@@ -1104,6 +1104,9 @@ Values of this type can be created with the
11041104
11051105Fields:
11061106
1107+`attr`
1108+: table attributes ([Attr])
1109+
11071110`caption`
11081111: table caption ([Caption])
11091112
@@ -1120,8 +1123,14 @@ Fields:
11201123`foot`
11211124: table foot ([TableFoot])
11221125
1123−`attr`
1124−: element attributes ([Attr])
1126+`identifier`
1127+: alias for `attr.identifier` (string)
1128+
1129+`classes`
1130+: alias for `attr.classes` ([List] of strings)
1131+
1132+`attributes`
1133+: alias for `attr.attributes` ([Attributes])
11251134
11261135`tag`, `t`
11271136: the literal `Table` (string)
@@ -2144,15 +2153,12 @@ format, and functions to filter and modify a subtree.
21442153
21452154 Returns: [RawBlock](#type-rawblock) object
21462155
2147−[`Table (attr, caption, colspecs, head, bodies, foot)`]{#pandoc.table}
2156+[`Table (caption, colspecs, head, bodies, foot[, attr])`]{#pandoc.table}
21482157
21492158: Creates a table element.
21502159
21512160 Parameters:
21522161
2153− `attr`:
2154− : element attributes
2155−
21562162 `caption`:
21572163 : table [caption](#type-caption)
21582164
@@ -2168,6 +2174,9 @@ format, and functions to filter and modify a subtree.
21682174 `foot`:
21692175 : [table foot](#type-tablefoot)
21702176
2177+ `attr`:
2178+ : element attributes
2179+
21712180 Returns: [Table](#type-table) object
21722181
21732182## Inline
src/Text/Pandoc/Lua/Marshaling/AST.hs+1−1
@@ -170,7 +170,7 @@ pushBlock = \case
170170 Plain blcks -> pushViaConstructor "Plain" blcks
171171 RawBlock f cs -> pushViaConstructor "RawBlock" f cs
172172 Table attr blkCapt specs thead tbody tfoot ->
173− pushViaConstructor "Table" attr blkCapt specs thead tbody tfoot
173+ pushViaConstructor "Table" blkCapt specs thead tbody tfoot attr
174174
175175-- | Return the value at the given index as block if possible.
176176peekBlock :: StackIndex -> Lua Block