aboutsummaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2021-10-20 21:40:07 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2021-10-22 11:16:51 -0700
commit6a03aca906c1e714aea7e34acdf10105e3272d6b (patch)
tree335579fc5ad0f69e7f841634d94cc3539d63c397 /data
parent8523bb01b24424249aa409ea577388a1ea10d70a (diff)
downloadpandoc-6a03aca906c1e714aea7e34acdf10105e3272d6b.tar.gz
Lua: marshal Inline elements as userdata
This includes the following user-facing changes: - Deprecated inline constructors are removed. These are `DoubleQuoted`, `SingleQuoted`, `DisplayMath`, and `InlineMath`. - Attr values are no longer normalized when assigned to an Inline element property. - It's no longer possible to access parts of Inline elements via numerical indexes. E.g., `pandoc.Span('test')[2]` used to give `pandoc.Str 'test'`, but yields `nil` now. This was undocumented behavior not intended to be used in user scripts. Use named properties instead. - Accessing `.c` to get a JSON-like tuple of all components no longer works. This was undocumented behavior. - Only known properties can be set on an element value. Trying to set a different property will now raise an error.
Diffstat (limited to 'data')
-rw-r--r--data/pandoc.lua271
1 files changed, 0 insertions, 271 deletions
diff --git a/data/pandoc.lua b/data/pandoc.lua
index 059ff9a3a..8fbd2259b 100644
--- a/data/pandoc.lua
+++ b/data/pandoc.lua
@@ -540,273 +540,6 @@ M.Table = M.Block:create_constructor(
------------------------------------------------------------------------
--- Inline
--- @section Inline
-
---- Inline element class
-M.Inline = AstElement:make_subtype'Inline'
-M.Inline.behavior.clone = M.types.clone.Inline
-
---- Creates a Cite inline element
--- @function Cite
--- @tparam {Inline,...} content List of inlines
--- @tparam {Citation,...} citations List of citations
--- @treturn Inline citations element
-M.Cite = M.Inline:create_constructor(
- "Cite",
- function(content, citations)
- return {c = {ensureList(citations), ensureInlineList(content)}}
- end,
- {"citations", "content"}
-)
-
---- Creates a Code inline element
--- @function Code
--- @tparam string text code string
--- @tparam[opt] Attr attr additional attributes
--- @treturn Inline code element
-M.Code = M.Inline:create_constructor(
- "Code",
- function(text, attr) return {c = {ensureAttr(attr), text}} end,
- {{attr = {"identifier", "classes", "attributes"}}, "text"}
-)
-
---- Creates an inline element representing emphasised text.
--- @function Emph
--- @tparam {Inline,..} content inline content
--- @treturn Inline emphasis element
-M.Emph = M.Inline:create_constructor(
- "Emph",
- function(content) return {c = ensureInlineList(content)} end,
- "content"
-)
-
---- Creates a Image inline element
--- @function Image
--- @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 attr additional attributes
--- @treturn Inline image element
-M.Image = M.Inline:create_constructor(
- "Image",
- function(caption, src, title, attr)
- title = title or ""
- return {c = {ensureAttr(attr), ensureInlineList(caption), {src, title}}}
- end,
- {{attr = {"identifier", "classes", "attributes"}}, "caption", {"src", "title"}}
-)
-
---- Create a LineBreak inline element
--- @function LineBreak
--- @treturn Inline linebreak element
-M.LineBreak = M.Inline:create_constructor(
- "LineBreak",
- function() return {} end
-)
-
---- Creates a link inline element, usually a hyperlink.
--- @function Link
--- @tparam {Inline,..} content text for this link
--- @tparam string target the link target
--- @tparam[opt] string title brief link description
--- @tparam[opt] Attr attr additional attributes
--- @treturn Inline image element
-M.Link = M.Inline:create_constructor(
- "Link",
- function(content, target, title, attr)
- title = title or ""
- attr = ensureAttr(attr)
- return {c = {attr, ensureInlineList(content), {target, title}}}
- end,
- {{attr = {"identifier", "classes", "attributes"}}, "content", {"target", "title"}}
-)
-
---- Creates a Math element, either inline or displayed.
--- @function Math
--- @tparam "InlineMath"|"DisplayMath" mathtype rendering specifier
--- @tparam string text Math content
--- @treturn Inline Math element
-M.Math = M.Inline:create_constructor(
- "Math",
- function(mathtype, text)
- return {c = {mathtype, text}}
- end,
- {"mathtype", "text"}
-)
---- Creates a DisplayMath element (DEPRECATED).
--- @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,
- {"mathtype", "text"}
-)
---- Creates an InlineMath inline element (DEPRECATED).
--- @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,
- {"mathtype", "text"}
-)
-
---- Creates a Note inline element
--- @function Note
--- @tparam {Block,...} content footnote block content
-M.Note = M.Inline:create_constructor(
- "Note",
- function(content) return {c = ensureList(content)} end,
- "content"
-)
-
---- Creates a Quoted inline element given the quote type and quoted content.
--- @function Quoted
--- @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, ensureInlineList(content)}}
- end,
- {"quotetype", "content"}
-)
---- Creates a single-quoted inline element (DEPRECATED).
--- @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,
- {"quotetype", "content"}
-)
---- Creates a single-quoted inline element (DEPRECATED).
--- @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,
- {"quotetype", "content"}
-)
-
---- Creates a RawInline inline element
--- @function RawInline
--- @tparam string format format of the contents
--- @tparam string text string content
--- @treturn Inline raw inline element
-M.RawInline = M.Inline:create_constructor(
- "RawInline",
- function(format, text) return {c = {format, text}} end,
- {"format", "text"}
-)
-
---- Creates text rendered in small caps
--- @function SmallCaps
--- @tparam {Inline,..} content inline content
--- @treturn Inline smallcaps element
-M.SmallCaps = M.Inline:create_constructor(
- "SmallCaps",
- function(content) return {c = ensureInlineList(content)} end,
- "content"
-)
-
---- Creates a SoftBreak inline element.
--- @function SoftBreak
--- @treturn Inline softbreak element
-M.SoftBreak = M.Inline:create_constructor(
- "SoftBreak",
- function() return {} end
-)
-
---- Create a Space inline element
--- @function Space
--- @treturn Inline space element
-M.Space = M.Inline:create_constructor(
- "Space",
- function() return {} end
-)
-
---- Creates a Span inline element
--- @function Span
--- @tparam {Inline,..} content inline content
--- @tparam[opt] Attr attr additional attributes
--- @treturn Inline span element
-M.Span = M.Inline:create_constructor(
- "Span",
- function(content, attr)
- return {c = {ensureAttr(attr), ensureInlineList(content)}}
- end,
- {{attr = {"identifier", "classes", "attributes"}}, "content"}
-)
-
---- Creates a Str inline element
--- @function Str
--- @tparam string text content
--- @treturn Inline string element
-M.Str = M.Inline:create_constructor(
- "Str",
- function(text) return {c = text} end,
- "text"
-)
-
---- Creates text which is striked out.
--- @function Strikeout
--- @tparam {Inline,..} content inline content
--- @treturn Inline strikeout element
-M.Strikeout = M.Inline:create_constructor(
- "Strikeout",
- function(content) return {c = ensureInlineList(content)} end,
- "content"
-)
-
---- Creates a Strong element, whose text is usually displayed in a bold font.
--- @function Strong
--- @tparam {Inline,..} content inline content
--- @treturn Inline strong element
-M.Strong = M.Inline:create_constructor(
- "Strong",
- function(content) return {c = ensureInlineList(content)} end,
- "content"
-)
-
---- Creates a Subscript inline element
--- @function Subscript
--- @tparam {Inline,..} content inline content
--- @treturn Inline subscript element
-M.Subscript = M.Inline:create_constructor(
- "Subscript",
- function(content) return {c = ensureInlineList(content)} end,
- "content"
-)
-
---- Creates a Superscript inline element
--- @function Superscript
--- @tparam {Inline,..} content inline content
--- @treturn Inline superscript element
-M.Superscript = M.Inline:create_constructor(
- "Superscript",
- function(content) return {c = ensureInlineList(content)} end,
- "content"
-)
-
---- Creates an Underline inline element
--- @function Underline
--- @tparam {Inline,..} content inline content
--- @treturn Inline underline element
-M.Underline = M.Inline:create_constructor(
- "Underline",
- function(content) return {c = ensureInlineList(content)} end,
- "content"
-)
-
-
-------------------------------------------------------------------------
-- Element components
-- @section components
@@ -823,10 +556,6 @@ end
for _, blk in pairs(M.Block.constructor) do
augment_attr_setter(blk.behavior.setters)
end
-for _, inln in pairs(M.Inline.constructor) do
- augment_attr_setter(inln.behavior.setters)
-end
-
-- Citation
M.Citation = AstElement:make_subtype'Citation'