From 59a47454574d9eab424ef3d6d9ef6b238515f479 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sat, 23 Dec 2017 22:39:05 +0100 Subject: Lua modules: add function pandoc.utils.hierarchicalize Convert list of Pandoc blocks into (hierarchical) list of Elements. --- test/lua/test-pandoc-utils.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/lua') diff --git a/test/lua/test-pandoc-utils.lua b/test/lua/test-pandoc-utils.lua index b79f033f8..c732d2f85 100644 --- a/test/lua/test-pandoc-utils.lua +++ b/test/lua/test-pandoc-utils.lua @@ -1,5 +1,20 @@ utils = require 'pandoc.utils' +-- hierarchicalize +------------------------------------------------------------------------ +function test_hierarchicalize () + local blks = { + pandoc.Header(1, {pandoc.Str 'First'}), + pandoc.Header(2, {pandoc.Str 'Second'}), + pandoc.Header(2, {pandoc.Str 'Third'}), + } + local hblks = utils.hierarchicalize(blks) + return hblks[1].t == "Sec" + and hblks[1].contents[1].t == "Sec" + and hblks[1].contents[2].numbering[1] == 1 + and hblks[1].contents[2].numbering[2] == 2 +end + -- SHA1 ------------------------------------------------------------------------ function test_sha1 () @@ -87,6 +102,7 @@ end function Para (el) return { + pandoc.Plain{pandoc.Str("hierarchicalize: " .. run(test_hierarchicalize))}, pandoc.Plain{pandoc.Str("normalize_date: " .. run(test_normalize_date))}, pandoc.Plain{pandoc.Str("pipe: " .. run(test_pipe))}, pandoc.Plain{pandoc.Str("failing pipe: " .. run(test_failing_pipe))}, -- cgit v1.2.3