diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2017-12-22 20:08:51 +0100 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2017-12-22 20:09:37 +0100 |
commit | 23edb958dbf0210ff82fd0284563c8280ab79bf1 (patch) | |
tree | 6b99135e1a074c58a3d6eba6e823a39c7d49491b /test | |
parent | 9ddf84072b27553e9ffd578ae40003108f51015a (diff) | |
download | pandoc-23edb958dbf0210ff82fd0284563c8280ab79bf1.tar.gz |
Lua modules: add stringify function to pandoc.utils
The new function `pandoc.utils.stringify` converts any AST element to a
string with formatting removed.
Diffstat (limited to 'test')
-rw-r--r-- | test/Tests/Lua.hs | 1 | ||||
-rw-r--r-- | test/lua/test-pandoc-utils.lua | 19 |
2 files changed, 17 insertions, 3 deletions
diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs index 0e76249fe..57e7c5f0c 100644 --- a/test/Tests/Lua.hs +++ b/test/Tests/Lua.hs @@ -101,6 +101,7 @@ tests = map (localOption (QuickCheckTests 20)) , plain (str "failing pipe: OK") , plain (str "read: OK") , plain (str "failing read: OK") + , plain (str "stringify: OK") ]) ] diff --git a/test/lua/test-pandoc-utils.lua b/test/lua/test-pandoc-utils.lua index 7354496f9..ce3456d5d 100644 --- a/test/lua/test-pandoc-utils.lua +++ b/test/lua/test-pandoc-utils.lua @@ -1,4 +1,4 @@ -utils = require 'pandoc' +utils = require 'pandoc.utils' -- SHA1 ------------------------------------------------------------------------ @@ -22,7 +22,7 @@ function test_pipe () warn 'Did not find /bin/sed, skipping test' return true end - local pipe_result = utils.pipe('/bin/sed', {'-e', 's/a/b/'}, 'abc') + local pipe_result = pandoc.pipe('/bin/sed', {'-e', 's/a/b/'}, 'abc') return pipe_result == 'bbc' end @@ -31,7 +31,7 @@ function test_failing_pipe () warn 'Did not find /bin/false, skipping test' return true end - local res, err = pcall(utils.pipe, '/bin/false', {}, 'abc') + local res, err = pcall(pandoc.pipe, '/bin/false', {}, 'abc') return not res and err.command == '/bin/false' and err.error_code == 1 and @@ -51,6 +51,18 @@ function test_failing_read () return not res and err:match 'Unknown reader: nosuchreader' end +-- Stringify +------------------------------------------------------------------------ +function test_stringify () + local inline = pandoc.Emph{ + pandoc.Str 'Cogito', + pandoc.Space(), + pandoc.Str 'ergo', + pandoc.Space(), + pandoc.Str 'sum.', + } + return utils.stringify(inline) == 'Cogito ergo sum.' +end -- Return result ------------------------------------------------------------------------ @@ -65,5 +77,6 @@ function Para (el) pandoc.Plain{pandoc.Str("failing pipe: " .. run(test_failing_pipe))}, pandoc.Plain{pandoc.Str("read: " .. run(test_read))}, pandoc.Plain{pandoc.Str("failing read: " .. run(test_failing_read))}, + pandoc.Plain{pandoc.Str("stringify: " .. run(test_stringify))}, } end |