diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2021-11-06 11:00:26 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-11-06 09:04:29 -0700 |
commit | 6b462e59332242c18ea38a721ae672b88f33d621 (patch) | |
tree | c33d9d0fe2835cfbaddb7d84b58e2ae5736d9381 /test | |
parent | ee2f0021f9b59f0bca6eabf4884641da7a09e21d (diff) | |
download | pandoc-6b462e59332242c18ea38a721ae672b88f33d621.tar.gz |
Lua: allow to pass custom reader options to `pandoc.read`
Reader options can now be passed as an optional third argument to
`pandoc.read`. The object can either be a table or a ReaderOptions value
like `PANDOC_READER_OPTIONS`. Creating new ReaderOptions objects is
possible through the new constructor `pandoc.ReaderOptions`.
Closes: #7656
Diffstat (limited to 'test')
-rw-r--r-- | test/lua/module/pandoc.lua | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/test/lua/module/pandoc.lua b/test/lua/module/pandoc.lua index 4da663f07..5a58914ef 100644 --- a/test/lua/module/pandoc.lua +++ b/test/lua/module/pandoc.lua @@ -809,7 +809,25 @@ return { ) assert.are_same(expected_table, new_table) end) - } + }, + group 'ReaderOptions' { + test('returns a userdata value', function () + local opts = pandoc.ReaderOptions {} + assert.are_equal(type(opts), 'userdata') + end), + test('can construct from table', function () + local opts = pandoc.ReaderOptions {columns = 66} + assert.are_equal(opts.columns, 66) + end), + test('can construct from other ReaderOptions value', function () + local orig = pandoc.ReaderOptions{columns = 65} + local copy = pandoc.ReaderOptions(orig) + for k, v in pairs(orig) do + assert.are_same(copy[k], v) + end + assert.are_equal(copy.columns, 65) + end), + }, }, group 'clone' { @@ -896,6 +914,16 @@ return { 'Extension empty_paragraphs not supported for gfm' ) end), + test('read with other indented code classes', function() + local indented_code = ' return true' + local expected = pandoc.Pandoc({ + pandoc.CodeBlock('return true', {class='foo'}) + }) + assert.are_same( + expected, + pandoc.read(indented_code, 'markdown', {indented_code_classes={'foo'}}) + ) + end), test('failing read', function () assert.error_matches( function () pandoc.read('foo', 'nosuchreader') end, |