aboutsummaryrefslogtreecommitdiff
path: root/test/lua
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2017-12-23 22:39:05 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2017-12-23 23:29:24 +0100
commit59a47454574d9eab424ef3d6d9ef6b238515f479 (patch)
tree68f755bcaba5e013966357e972ff9d11779c8fdd /test/lua
parent790dc2546b965853dbcaa8db1a36dd05b147ef85 (diff)
downloadpandoc-59a47454574d9eab424ef3d6d9ef6b238515f479.tar.gz
Lua modules: add function pandoc.utils.hierarchicalize
Convert list of Pandoc blocks into (hierarchical) list of Elements.
Diffstat (limited to 'test/lua')
-rw-r--r--test/lua/test-pandoc-utils.lua16
1 files changed, 16 insertions, 0 deletions
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))},