1local tasty = require 'tasty'
2local utils = require 'pandoc.utils'
4local assert = tasty.assert
5local test = tasty.test_case
6local group = tasty.test_group
9 group 'blocks_to_inlines' {
10 test('default separator', function ()
12 pandoc.Para { pandoc.Str 'Paragraph1' },
13 pandoc.Para { pandoc.Emph { pandoc.Str 'Paragraph2' } }
16 pandoc.Str 'Paragraph1',
17 pandoc.Space(), pandoc.Str '¶', pandoc.Space(),
18 pandoc.Emph { pandoc.Str 'Paragraph2' }
22 utils.blocks_to_inlines(blocks)
25 test('custom separator', function ()
27 pandoc.Para{ pandoc.Str 'Paragraph1' },
28 pandoc.Para{ pandoc.Emph 'Paragraph2' }
31 pandoc.Str 'Paragraph1',
33 pandoc.Emph { pandoc.Str 'Paragraph2' }
37 utils.blocks_to_inlines(blocks, { pandoc.LineBreak() })
42 group 'hierarchicalize' {
43 test('sanity check', function ()
45 pandoc.Header(1, {pandoc.Str 'First'}),
46 pandoc.Header(2, {pandoc.Str 'Second'}),
47 pandoc.Header(2, {pandoc.Str 'Third'}),
49 local hblks = utils.hierarchicalize(blks)
50 -- cannot create Elements directly; performing only an approximate
51 -- sanity checking instead of a full equality comparison.
52 assert.are_equal('Sec', hblks[1].t)
53 assert.are_equal('Sec', hblks[1].contents[1].t)
54 assert.are_equal(1, hblks[1].contents[2].numbering[1])
55 assert.are_equal(2, hblks[1].contents[2].numbering[2])
59 group 'normalize_date' {
60 test('09 Nov 1989', function ()
61 assert.are_equal('1989-11-09', utils.normalize_date '09 Nov 1989')
63 test('12/31/2017', function ()
64 assert.are_equal('2017-12-31', utils.normalize_date '12/31/2017')
69 test('hashing', function ()
70 local ref_hash = '0a0a9f2a6772942557ab5355d76af442f8f65e01'
71 assert.are_equal(ref_hash, utils.sha1 'Hello, World!')
76 test('inlines', function ()
77 local inline = pandoc.Emph{
84 assert.are_equal('Cogito ergo sum.', utils.stringify(inline))
88 group 'to_roman_numeral' {
89 test('convertes number', function ()
90 assert.are_equal('MDCCCLXXXVIII', utils.to_roman_numeral(1888))
92 test('fails on non-convertible argument', function ()
93 assert.is_falsy(pcall(utils.to_roman_numeral, 'not a number'))
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list