diff options
author | Albert Krewinkel <albert+github@zeitkraut.de> | 2018-07-30 19:55:25 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-07-30 10:55:25 -0700 |
commit | fb94c0f6a1b98d4f7ff34107d3b63c2c1d0afe1f (patch) | |
tree | eb0a736a0ced7d45e9ead922db35fb564f3e431e /test | |
parent | bf56181204a6e5df919da24006ef8a58b595f76a (diff) | |
download | pandoc-fb94c0f6a1b98d4f7ff34107d3b63c2c1d0afe1f.tar.gz |
Lua Utils module: add function blocks_to_inlines (#4799)
Exposes a function converting which flattenes a list of blocks into a
list of inlines. An example use case would be the conversion of Note
elements into other inlines.
Diffstat (limited to 'test')
-rw-r--r-- | test/Tests/Lua.hs | 3 | ||||
-rw-r--r-- | test/lua/test-pandoc-utils.lua | 15 |
2 files changed, 17 insertions, 1 deletions
diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs index 9d2d3b635..f00142f1d 100644 --- a/test/Tests/Lua.hs +++ b/test/Tests/Lua.hs @@ -109,7 +109,8 @@ tests = map (localOption (QuickCheckTests 20)) assertFilterConversion "pandoc.utils doesn't work as expected." "test-pandoc-utils.lua" (doc $ para "doesn't matter") - (doc $ mconcat [ plain (str "hierarchicalize: OK") + (doc $ mconcat [ plain (str "blocks_to_inlines: OK") + , plain (str "hierarchicalize: OK") , plain (str "normalize_date: OK") , plain (str "pipe: OK") , plain (str "failing pipe: OK") diff --git a/test/lua/test-pandoc-utils.lua b/test/lua/test-pandoc-utils.lua index 21f937edb..4421603ec 100644 --- a/test/lua/test-pandoc-utils.lua +++ b/test/lua/test-pandoc-utils.lua @@ -1,5 +1,19 @@ utils = require 'pandoc.utils' +-- Squash blocks to inlines +------------------------------------------------------------------------ +function test_blocks_to_inlines () + local blocks = { + pandoc.Para{ pandoc.Str 'Paragraph1' }, + pandoc.Para{ pandoc.Emph 'Paragraph2' } + } + local inlines = utils.blocks_to_inlines(blocks, {pandoc.LineBreak()}) + return #inlines == 3 + and inlines[1].text == "Paragraph1" + and inlines[2].t == 'LineBreak' + and inlines[3].content[1].text == "Paragraph2" +end + -- hierarchicalize ------------------------------------------------------------------------ function test_hierarchicalize () @@ -110,6 +124,7 @@ end function Para (el) return { + pandoc.Plain{pandoc.Str("blocks_to_inlines: " .. run(test_blocks_to_inlines))}, 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))}, |