aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2021-11-23 18:32:53 +0100
committerGitHub <noreply@github.com>2021-11-23 09:32:53 -0800
commitbffd74323cfd91f5c44ca34e09633247d1d28954 (patch)
tree2036e51b9043c15b4e88e513c9c9bdc20a4b469c /test
parent0c0945b93c2ae502c0629d93e9ad520dbe17c625 (diff)
downloadpandoc-bffd74323cfd91f5c44ca34e09633247d1d28954.tar.gz
Lua: add function `pandoc.utils.text` (#7710)
The function converts a string to `Inlines`, treating interword spaces as `Space`s or `SoftBreak`s. If you want a `Str` with literal spaces, use `pandoc.Str`. Closes: #7709
Diffstat (limited to 'test')
-rw-r--r--test/lua/module/pandoc-utils.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/lua/module/pandoc-utils.lua b/test/lua/module/pandoc-utils.lua
index 9bd903f2d..21f550177 100644
--- a/test/lua/module/pandoc-utils.lua
+++ b/test/lua/module/pandoc-utils.lua
@@ -82,6 +82,34 @@ return {
end)
},
+ group 'text' {
+ test('string is converted to inlines', function ()
+ local expected = {
+ pandoc.Str 'Madness', pandoc.Space(), pandoc.Str '-', pandoc.Space(),
+ pandoc.Str 'Our', pandoc.Space(), pandoc.Str 'House'
+ }
+ assert.are_same(pandoc.utils.text('Madness - Our House'), expected)
+ end),
+ test('tabs are treated as space', function ()
+ local expected = {
+ pandoc.Str 'Linkin', pandoc.Space(), pandoc.Str 'Park', pandoc.Space(),
+ pandoc.Str '-', pandoc.Space(), pandoc.Str 'Papercut'
+ }
+ assert.are_same(pandoc.utils.text('Linkin Park\t-\tPapercut'), expected)
+ end),
+ test('newlines are treated as softbreaks', function ()
+ local expected = {
+ pandoc.Str 'Porcupine', pandoc.Space(), pandoc.Str 'Tree',
+ pandoc.SoftBreak(), pandoc.Str '-', pandoc.SoftBreak(),
+ pandoc.Str 'Blackest', pandoc.Space(), pandoc.Str 'Eyes'
+ }
+ assert.are_same(
+ pandoc.utils.text('Porcupine Tree\n-\nBlackest Eyes'),
+ expected
+ )
+ end),
+ },
+
group 'to_roman_numeral' {
test('convertes number', function ()
assert.are_equal('MDCCCLXXXVIII', utils.to_roman_numeral(1888))