diff options
Diffstat (limited to 'test/lua/module')
-rw-r--r-- | test/lua/module/pandoc.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/lua/module/pandoc.lua b/test/lua/module/pandoc.lua index ca2168805..1725d275b 100644 --- a/test/lua/module/pandoc.lua +++ b/test/lua/module/pandoc.lua @@ -171,4 +171,42 @@ return { ) end) }, + + group 'walk_block' { + test('block walking order', function () + local acc = {} + local nested_nums = pandoc.Div { + pandoc.Para{pandoc.Str'1'}, + pandoc.Div{ + pandoc.Para{pandoc.Str'2'}, + pandoc.Para{pandoc.Str'3'} + }, + pandoc.Para{pandoc.Str'4'} + } + pandoc.walk_block( + nested_nums, + {Para = function (p) table.insert(acc, p.content[1].text) end} + ) + assert.are_equal('1234', table.concat(acc)) + end) + }, + + group 'walk_inline' { + test('inline walking order', function () + local acc = {} + local nested_nums = pandoc.Span { + pandoc.Str'1', + pandoc.Emph { + pandoc.Str'2', + pandoc.Str'3' + }, + pandoc.Str'4' + } + pandoc.walk_inline( + nested_nums, + {Str = function (s) table.insert(acc, s.text) end} + ) + assert.are_equal('1234', table.concat(acc)) + end) + } } |