data/pandoc.lua: regularize constructors.

We now use Pandoc instead of Doc (though Doc remains a deprecated
Synonym), and we deprecate DoubleQuoted, SingleQuoted,
InlineMath, and DisplayMath.
This commit is contained in:
John MacFarlane 2017-06-29 17:08:59 +02:00
parent cb25326fa3
commit 0f658eb46c
3 changed files with 13 additions and 14 deletions

View file

@ -23,7 +23,7 @@ THIS SOFTWARE.
-- @copyright © 2017 Albert Krewinkel -- @copyright © 2017 Albert Krewinkel
-- @license MIT -- @license MIT
local M = { local M = {
_VERSION = "0.2.0" _VERSION = "0.3.0"
} }
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -137,7 +137,7 @@ end
-- @function Doc -- @function Doc
-- @tparam {Block,...} blocks document content -- @tparam {Block,...} blocks document content
-- @tparam[opt] Meta meta document meta data -- @tparam[opt] Meta meta document meta data
function M.Doc(blocks, meta) function M.Pandoc(blocks, meta)
meta = meta or {} meta = meta or {}
return { return {
["blocks"] = blocks, ["blocks"] = blocks,
@ -146,6 +146,8 @@ function M.Doc(blocks, meta)
} }
end end
-- DEPRECATED synonym:
M.Doc = M.Pandoc
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- MetaValue -- MetaValue
@ -449,8 +451,7 @@ M.Link = M.Inline:create_constructor(
{"attributes", "content", {"target", "title"}} {"attributes", "content", {"target", "title"}}
) )
--- Creates a Math element, either inline or displayed. It is usually simpler to --- Creates a Math element, either inline or displayed.
-- use one of the specialized functions @{InlineMath} or @{DisplayMath} instead.
-- @function Math -- @function Math
-- @tparam "InlineMath"|"DisplayMath" mathtype rendering specifier -- @tparam "InlineMath"|"DisplayMath" mathtype rendering specifier
-- @tparam string text Math content -- @tparam string text Math content
@ -462,7 +463,7 @@ M.Math = M.Inline:create_constructor(
end, end,
{"mathtype", "text"} {"mathtype", "text"}
) )
--- Creates a DisplayMath element. --- Creates a DisplayMath element (DEPRECATED).
-- @function DisplayMath -- @function DisplayMath
-- @tparam string text Math content -- @tparam string text Math content
-- @treturn Inline Math element -- @treturn Inline Math element
@ -471,7 +472,7 @@ M.DisplayMath = M.Inline:create_constructor(
function(text) return M.Math("DisplayMath", text) end, function(text) return M.Math("DisplayMath", text) end,
{"mathtype", "text"} {"mathtype", "text"}
) )
--- Creates an InlineMath inline element. --- Creates an InlineMath inline element (DEPRECATED).
-- @function InlineMath -- @function InlineMath
-- @tparam string text Math content -- @tparam string text Math content
-- @treturn Inline Math element -- @treturn Inline Math element
@ -490,9 +491,7 @@ M.Note = M.Inline:create_constructor(
"content" "content"
) )
--- Creates a Quoted inline element given the quote type and quoted content. It --- Creates a Quoted inline element given the quote type and quoted content.
-- is usually simpler to use one of the specialized functions @{SingleQuoted} or
-- @{DoubleQuoted} instead.
-- @function Quoted -- @function Quoted
-- @tparam "DoubleQuote"|"SingleQuote" quotetype type of quotes to be used -- @tparam "DoubleQuote"|"SingleQuote" quotetype type of quotes to be used
-- @tparam {Inline,..} content inline content -- @tparam {Inline,..} content inline content
@ -502,7 +501,7 @@ M.Quoted = M.Inline:create_constructor(
function(quotetype, content) return {c = {quotetype, content}} end, function(quotetype, content) return {c = {quotetype, content}} end,
{"quotetype", "content"} {"quotetype", "content"}
) )
--- Creates a single-quoted inline element. --- Creates a single-quoted inline element (DEPRECATED).
-- @function SingleQuoted -- @function SingleQuoted
-- @tparam {Inline,..} content inline content -- @tparam {Inline,..} content inline content
-- @treturn Inline quoted element -- @treturn Inline quoted element
@ -512,7 +511,7 @@ M.SingleQuoted = M.Inline:create_constructor(
function(content) return M.Quoted(M.SingleQuote, content) end, function(content) return M.Quoted(M.SingleQuote, content) end,
{"quotetype", "content"} {"quotetype", "content"}
) )
--- Creates a single-quoted inline element. --- Creates a single-quoted inline element (DEPRECATED).
-- @function DoubleQuoted -- @function DoubleQuoted
-- @tparam {Inline,..} content inline content -- @tparam {Inline,..} content inline content
-- @treturn Inline quoted element -- @treturn Inline quoted element

View file

@ -1,10 +1,10 @@
return { return {
{ {
Doc = function(doc) Pandoc = function(doc)
local meta = {} local meta = {}
local hello = { pandoc.Str "Hello,", pandoc.Space(), pandoc.Str "World!" } local hello = { pandoc.Str "Hello,", pandoc.Space(), pandoc.Str "World!" }
local blocks = { pandoc.Para(hello) } local blocks = { pandoc.Para(hello) }
return pandoc.Doc(blocks, meta) return pandoc.Pandoc(blocks, meta)
end end
} }
} }

View file

@ -2,5 +2,5 @@ function Doc (doc)
local meta = {} local meta = {}
local hello = { pandoc.Str "Hello,", pandoc.Space(), pandoc.Str "World!" } local hello = { pandoc.Str "Hello,", pandoc.Space(), pandoc.Str "World!" }
local blocks = { pandoc.Para(hello) } local blocks = { pandoc.Para(hello) }
return pandoc.Doc(blocks, meta) return pandoc.Pandoc(blocks, meta)
end end