From 8c2e6a66b91f36bb7a9f4e1aa0dbb31f2ed14ecd Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sat, 15 Apr 2017 00:10:33 +0200 Subject: Lua module: provide builder functions for math and quoted Provide functions `pandoc.SingleQuoted`, `pandoc.DoubleQuoted`, `pandoc.DisplayMath`, and `pandoc.InlineMath` to allow simple building of Math and Quoted elements. --- data/pandoc.lua | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/data/pandoc.lua b/data/pandoc.lua index 79cf83deb..21ad31cdf 100644 --- a/data/pandoc.lua +++ b/data/pandoc.lua @@ -439,9 +439,10 @@ M.Link = M.Inline:create_constructor( end ) ---- Creates a Math inline element +--- Creates a Math element, either inline or displayed. It is usually simpler to +-- use one of the specialized functions @{InlineMath} or @{DisplayMath} instead. -- @function Math --- @tparam InlineMath|DisplayMath mathtype Display specifier +-- @tparam "InlineMath"|"DisplayMath" mathtype rendering specifier -- @tparam string text Math content -- @treturn Inline Math element M.Math = M.Inline:create_constructor( @@ -450,6 +451,22 @@ M.Math = M.Inline:create_constructor( return {c = {mathtype, text}} end ) +--- Creates a DisplayMath element. +-- @function DisplayMath +-- @tparam string text Math content +-- @treturn Inline Math element +M.DisplayMath = M.Inline:create_constructor( + "DisplayMath", + function(text) return M.Math("DisplayMath", text) end +) +--- Creates an InlineMath inline element. +-- @function InlineMath +-- @tparam string text Math content +-- @treturn Inline Math element +M.InlineMath = M.Inline:create_constructor( + "InlineMath", + function(text) return M.Math("InlineMath", text) end +) --- Creates a Note inline element -- @function Note @@ -459,15 +476,36 @@ M.Note = M.Inline:create_constructor( function(contents) return {c = contents} end ) ---- Creates a Quoted inline element +--- Creates a Quoted inline element given the quote type and quoted content. It +-- is usually simpler to use one of the specialized functions @{SingleQuoted} or +-- @{DoubleQuoted} instead. -- @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 -- @treturn Inline quoted element M.Quoted = M.Inline:create_constructor( "Quoted", function(quotetype, content) return {c = {quotetype, content}} end ) +--- Creates a single-quoted inline element. +-- @function SingleQuoted +-- @tparam {Inline,..} content inline content +-- @treturn Inline quoted element +-- @see Quoted +M.SingleQuoted = M.Inline:create_constructor( + "SingleQuoted", + function(content) return M.Quoted(M.SingleQuote, content) end +) +--- Creates a single-quoted inline element. +-- @function DoubleQuoted +-- @tparam {Inline,..} content inline content +-- @treturn Inline quoted element +-- @see Quoted +M.DoubleQuoted = M.Inline:create_constructor( + "DoubleQuoted", + function(content) return M.Quoted("DoubleQuote", content) end +) + --- Creates a RawInline inline element -- @function RawInline -- @tparam string format format of the contents -- cgit v1.2.3