aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Lua/Marshaling/AST.hs3
-rw-r--r--test/lua/module/pandoc.lua20
2 files changed, 22 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Lua/Marshaling/AST.hs b/src/Text/Pandoc/Lua/Marshaling/AST.hs
index 9cf683055..6a0e5d077 100644
--- a/src/Text/Pandoc/Lua/Marshaling/AST.hs
+++ b/src/Text/Pandoc/Lua/Marshaling/AST.hs
@@ -247,6 +247,9 @@ peekMetaValue = retrieving "MetaValue $ " . \idx -> do
optional (LuaUtil.getTag idx) >>= \case
Just tag -> peekTagged tag
Nothing -> peekUntagged
+ Lua.TypeUserdata -> -- Allow singleton Inline or Block elements
+ (MetaInlines . (:[]) <$!> peekInline idx) <|>
+ (MetaBlocks . (:[]) <$!> peekBlock idx)
_ -> failPeek "could not get meta value"
typeBlock :: LuaError e => DocumentedType e Block
diff --git a/test/lua/module/pandoc.lua b/test/lua/module/pandoc.lua
index b191bcb3c..2849eedbf 100644
--- a/test/lua/module/pandoc.lua
+++ b/test/lua/module/pandoc.lua
@@ -735,7 +735,25 @@ return {
assert.are_equal((pandoc.MetaMap{}).tag, (pandoc.MetaMap{}).t)
assert.are_equal((pandoc.MetaInlines{}).tag, (pandoc.MetaInlines{}).t)
assert.are_equal((pandoc.MetaBlocks{}).tag, (pandoc.MetaBlocks{}).t)
- end)
+ end),
+ },
+ group 'Meta' {
+ test('inline list is treated as MetaInlines', function ()
+ local meta = pandoc.Pandoc({}, {test = {pandoc.Emph 'check'}}).meta
+ assert.are_same(meta.test, {pandoc.Emph{pandoc.Str 'check'}})
+ end),
+ test('inline element is treated as MetaInlines singleton', function ()
+ local meta = pandoc.Pandoc({}, {test = pandoc.Emph 'check'}).meta
+ assert.are_same(meta.test, {pandoc.Emph{pandoc.Str 'check'}})
+ end),
+ test('block list is treated as MetaBlocks', function ()
+ local meta = pandoc.Pandoc({}, {test = {pandoc.Plain 'check'}}).meta
+ assert.are_same(meta.test, {pandoc.Plain{pandoc.Str 'check'}})
+ end),
+ test('block element is treated as MetaBlocks singleton', function ()
+ local meta = pandoc.Pandoc({}, {test = pandoc.Plain 'check'}).meta
+ assert.are_same(meta.test, {pandoc.Plain{pandoc.Str 'check'}})
+ end),
},
group 'Other types' {
group 'Citation' {