summaryrefslogtreecommitdiff
path: root/data/pandoc.lua
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2017-05-18 00:04:48 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2017-05-18 00:04:48 +0200
commit399a36280d19cd9626d54f98bb03d9baef460409 (patch)
tree59bb6f3a5ae373c23d25d1adc8f0e7bfb090e0a6 /data/pandoc.lua
parent7b3aaee15ab69cdf3125a214c2124b91622af759 (diff)
Lua module: allow omitting Attr in element constructors
The Attr argument is made optional for all pandoc element constructors which take such a parameter. The attr param is always the last argument of the constructor functions, so the option to omit them makes it easier to construct new pandoc elements by hand.
Diffstat (limited to 'data/pandoc.lua')
-rw-r--r--data/pandoc.lua40
1 files changed, 21 insertions, 19 deletions
diff --git a/data/pandoc.lua b/data/pandoc.lua
index 2a5a945b5..750b41e86 100644
--- a/data/pandoc.lua
+++ b/data/pandoc.lua
@@ -233,11 +233,11 @@ M.BulletList = M.Block:create_constructor(
--- Creates a code block element
-- @function CodeBlock
-- @tparam string text code string
--- @tparam[opt] Attr attributes element attributes
+-- @tparam[opt] Attr attr element attributes
-- @treturn Block code block element
M.CodeBlock = M.Block:create_constructor(
"CodeBlock",
- function(text, attributes) return {c = {attributes, text}} end,
+ function(text, attr) return {c = {attr or M.Attr(), text}} end,
{{"identifier", "classes", "attributes"}, "text"}
)
@@ -254,11 +254,13 @@ M.DefinitionList = M.Block:create_constructor(
--- Creates a div element
-- @function Div
-- @tparam {Block,...} content block content
--- @tparam[opt] Attr attributes element attributes
+-- @tparam[opt] Attr attr element attributes
-- @treturn Block code block element
M.Div = M.Block:create_constructor(
"Div",
- function(content, attributes) return {c = {attributes, content}} end,
+ function(content, attr)
+ return {c = {attr or M.Attr(), content}}
+ end,
{{"identifier", "classes", "attributes"}, "content"}
)
@@ -266,12 +268,12 @@ M.Div = M.Block:create_constructor(
-- @function Header
-- @tparam int level header level
-- @tparam {Inline,...} content inline content
--- @tparam Attr attributes element attributes
+-- @tparam[opt] Attr attr element attributes
-- @treturn Block header element
M.Header = M.Block:create_constructor(
"Header",
- function(level, content, attributes)
- return {c = {level, attributes, content}}
+ function(level, content, attr)
+ return {c = {level, attr or M.Attr(), content}}
end,
{"level", {"identifier", "classes", "attributes"}, "content"}
)
@@ -386,11 +388,11 @@ M.Cite = M.Inline:create_constructor(
--- Creates a Code inline element
-- @function Code
-- @tparam string text brief image description
--- @tparam[opt] Attr attributes additional attributes
+-- @tparam[opt] Attr attr additional attributes
-- @treturn Inline code element
M.Code = M.Inline:create_constructor(
"Code",
- function(text, attributes) return {c = {attributes, text}} end,
+ function(text, attr) return {c = {attr or M.Attr(), text}} end,
{{"identifier", "classes", "attributes"}, "text"}
)
@@ -409,14 +411,14 @@ M.Emph = M.Inline:create_constructor(
-- @tparam {Inline,..} caption text used to describe the image
-- @tparam string src path to the image file
-- @tparam[opt] string title brief image description
--- @tparam[opt] Attr attributes additional attributes
+-- @tparam[opt] Attr attr additional attributes
-- @treturn Inline image element
M.Image = M.Inline:create_constructor(
"Image",
- function(caption, src, title, attributes)
+ function(caption, src, title, attr)
title = title or ""
- attributes = attributes or Attribute.empty
- return {c = {attributes, caption, {src, title}}}
+ attr = attr or M.Attr()
+ return {c = {attr, caption, {src, title}}}
end,
{"attributes", "caption", {"src", "title"}}
)
@@ -434,14 +436,14 @@ M.LineBreak = M.Inline:create_constructor(
-- @tparam {Inline,..} content text for this link
-- @tparam string target the link target
-- @tparam[opt] string title brief link description
--- @tparam[opt] Attr attributes additional attributes
+-- @tparam[opt] Attr attr additional attributes
-- @treturn Inline image element
M.Link = M.Inline:create_constructor(
"Link",
- function(content, target, title, attributes)
+ function(content, target, title, attr)
title = title or ""
- attributes = attributes or Attribute.empty
- return {c = {attributes, content, {target, title}}}
+ attr = attr or M.Attr()
+ return {c = {attr, content, {target, title}}}
end,
{"attributes", "content", {"target", "title"}}
)
@@ -560,11 +562,11 @@ M.Space = M.Inline:create_constructor(
--- Creates a Span inline element
-- @function Span
-- @tparam {Inline,..} content inline content
--- @tparam[opt] Attr attributes additional attributes
+-- @tparam[opt] Attr attr additional attributes
-- @treturn Inline span element
M.Span = M.Inline:create_constructor(
"Span",
- function(content, attributes) return {c = {attributes, content}} end,
+ function(content, attr) return {c = {attr or M.Attr(), content}} end,
{{"identifier", "classes", "attributes"}, "content"}
)