From b9222e5cb1d8d1d3217f65c6a91886b897956dde Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sun, 28 Nov 2021 15:07:30 +0100 Subject: Lua: add constructors `pandoc.Blocks` and `pandoc.Inlines` The functions convert their argument into a list of Block and Inline values, respectively. --- doc/lua-filters.md | 37 +++++++++++++++++++++++++++++++++++- src/Text/Pandoc/Lua/Module/Pandoc.hs | 2 ++ test/lua/module/pandoc.lua | 6 ++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/doc/lua-filters.md b/doc/lua-filters.md index db5d1ccac..f24a66579 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -2074,7 +2074,7 @@ format, and functions to filter and modify a subtree. Returns: [MetaBool] object -## Blocks +## Block [`BlockQuote (content)`]{#pandoc.blockquote} @@ -2254,6 +2254,20 @@ format, and functions to filter and modify a subtree. Returns: [Table](#type-table) object +## Blocks + +[`Blocks (block_like_elements)`]{#pandoc.blocks} + +: Creates a [Blocks](#type-blocks) list. + + Parameters: + + `block_like_elements`: + : List where each element can be treated as a [Block] + value, or a single such value. + + Returns: [Blocks] list + ## Inline [`Cite (content, citations)`]{#pandoc.cite} @@ -2543,6 +2557,27 @@ format, and functions to filter and modify a subtree. Returns: [Underline](#type-underline) object +## Inlines + +[`Inlines (inline_like_elements)`]{#pandoc.inlines} + +: Converts its argument into an [Inlines](#type-inlines) list: + + - copies a list of [Inline] elements into a fresh list; any + string `s` within the list is treated as `pandoc.Str(s)`; + - turns a single [Inline] into a singleton list; + - splits a string into `Str`-wrapped words, treating + interword spaces as `Space`s or `SoftBreak`s. + + Parameters: + + `inline_like_elements`: + : List where each element can be treated as an [Inline] + values, or just a single such value. + + Returns: [Inlines] list + + ## Element components [`Attr ([identifier[, classes[, attributes]]])`]{#pandoc.attr} diff --git a/src/Text/Pandoc/Lua/Module/Pandoc.hs b/src/Text/Pandoc/Lua/Module/Pandoc.hs index 085d904cf..e932ca59a 100644 --- a/src/Text/Pandoc/Lua/Module/Pandoc.hs +++ b/src/Text/Pandoc/Lua/Module/Pandoc.hs @@ -117,7 +117,9 @@ otherConstructors = , mkMeta , mkAttr , mkAttributeList + , mkBlocks , mkCitation + , mkInlines , mkListAttributes , mkSimpleTable diff --git a/test/lua/module/pandoc.lua b/test/lua/module/pandoc.lua index 1cf777675..892ffee03 100644 --- a/test/lua/module/pandoc.lua +++ b/test/lua/module/pandoc.lua @@ -19,9 +19,15 @@ return { test('pandoc.AttributeList is a function', function () assert.are_equal(type(pandoc.AttributeList), 'function') end), + test('pandoc.Blocks is a function', function () + assert.are_equal(type(pandoc.Blocks), 'function') + end), test('pandoc.Citation is a function', function () assert.are_equal(type(pandoc.Citation), 'function') end), + test('pandoc.Inlines is a function', function () + assert.are_equal(type(pandoc.Inlines), 'function') + end), test('pandoc.SimpleTable is a function', function () assert.are_equal(type(pandoc.SimpleTable), 'function') end), -- cgit v1.2.3