aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Lua/Module/Utils.hs4
-rw-r--r--test/lua/module/pandoc-utils.lua27
2 files changed, 29 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Lua/Module/Utils.hs b/src/Text/Pandoc/Lua/Module/Utils.hs
index eabb2b532..02307cf7a 100644
--- a/src/Text/Pandoc/Lua/Module/Utils.hs
+++ b/src/Text/Pandoc/Lua/Module/Utils.hs
@@ -197,10 +197,10 @@ from_simple_table :: SimpleTable -> LuaE PandocError NumResults
from_simple_table (SimpleTable capt aligns widths head' body) = do
Lua.push $ Table
nullAttr
- (Caption Nothing [Plain capt])
+ (Caption Nothing [Plain capt | not (null capt)])
(zipWith (\a w -> (a, toColWidth w)) aligns widths)
(TableHead nullAttr [blockListToRow head' | not (null head') ])
- [TableBody nullAttr 0 [] $ map blockListToRow body]
+ [TableBody nullAttr 0 [] $ map blockListToRow body | not (null body)]
(TableFoot nullAttr [])
return (NumResults 1)
where
diff --git a/test/lua/module/pandoc-utils.lua b/test/lua/module/pandoc-utils.lua
index 0475e96ec..4cf2c84a7 100644
--- a/test/lua/module/pandoc-utils.lua
+++ b/test/lua/module/pandoc-utils.lua
@@ -302,5 +302,32 @@ return {
-- reversible
assert.are_same(simple_table, utils.to_simple_table(tbl))
end),
+ test('empty caption', function ()
+ local simple_table = pandoc.SimpleTable(
+ {},
+ {pandoc.AlignDefault},
+ {0},
+ {{pandoc.Plain 'a'}},
+ {{{pandoc.Plain 'b'}}}
+ )
+ local tbl = utils.from_simple_table(simple_table)
+ assert.are_equal(
+ pandoc.Blocks{},
+ tbl.caption.long
+ )
+ assert.is_nil(tbl.caption.short)
+ end),
+ test('empty body', function ()
+ local simple_table = pandoc.SimpleTable(
+ pandoc.Inlines('a nice caption'),
+ {pandoc.AlignDefault},
+ {0},
+ {{pandoc.Plain 'a'}},
+ {}
+ )
+ local tbl = utils.from_simple_table(simple_table)
+ tbl.bodies:map(print)
+ assert.are_same(pandoc.List(), tbl.bodies)
+ end),
}
}