diff options
| author | Albert Krewinkel <[email protected]> | 2024-12-10 11:36:00 +0100 |
|---|---|---|
| committer | Albert Krewinkel <[email protected]> | 2024-12-10 11:45:51 +0100 |
| commit | a0847310700d8c706203471c871a6805c221092c (patch) | |
| tree | 1090779b7c60469d7ea6343280c1d61ca9b41364 /pandoc-lua-engine | |
| parent | 64f45fefa7a8cb5597d1eb63ca3f276a56802ccf (diff) | |
Lua: support more elements as input to `pandoc.utils.stringify`.
Elements of type Caption, Cell, TableHead, and TableFoot can now be
stringified.
Fixes: #10450
Diffstat (limited to 'pandoc-lua-engine')
| -rw-r--r-- | pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Utils.hs | 4 | ||||
| -rw-r--r-- | pandoc-lua-engine/test/lua/module/pandoc-utils.lua | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Utils.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Utils.hs index fb0f3ee74..a19f353b5 100644 --- a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Utils.hs +++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Utils.hs @@ -316,7 +316,11 @@ stringify = defun "stringify" [ (fmap Shared.stringify . peekPandoc) , (fmap Shared.stringify . peekInline) , (fmap Shared.stringify . peekBlock) + , (fmap Shared.stringify . peekCaption) + , (fmap Shared.stringify . peekCell) , (fmap Shared.stringify . peekCitation) + , (fmap Shared.stringify . peekTableHead) + , (fmap Shared.stringify . peekTableFoot) , (fmap stringifyMetaValue . peekMetaValue) , (fmap (const "") . peekAttr) , (fmap (const "") . peekListAttributes) diff --git a/pandoc-lua-engine/test/lua/module/pandoc-utils.lua b/pandoc-lua-engine/test/lua/module/pandoc-utils.lua index 573a5987a..9694cd57b 100644 --- a/pandoc-lua-engine/test/lua/module/pandoc-utils.lua +++ b/pandoc-lua-engine/test/lua/module/pandoc-utils.lua @@ -223,6 +223,22 @@ return { local inlines = pandoc.Inlines{pandoc.Str 'a', pandoc.Subscript('b')} assert.are_equal('ab', utils.stringify(inlines)) end), + test('Caption', function () + local capt = pandoc.Caption(pandoc.Para{pandoc.Str 'a', pandoc.Emph('b')}) + assert.are_equal('ab', utils.stringify(capt)) + end), + test('Cell', function () + local cell = pandoc.Cell(pandoc.Para{pandoc.Str 'a', pandoc.Emph('b')}) + assert.are_equal('ab', utils.stringify(cell)) + end), + test('TableFoot', function () + local tf = pandoc.TableFoot{pandoc.Row{pandoc.Cell{pandoc.Plain "x y"}}} + assert.are_equal('x y', utils.stringify(tf)) + end), + test('TableHead', function () + local th = pandoc.TableHead{pandoc.Row{pandoc.Cell{pandoc.Plain "head1"}}} + assert.are_equal('head1', utils.stringify(th)) + end), test('Meta', function () local meta = pandoc.Meta{ a = pandoc.Inlines 'funny and ', |
