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 'make_sections' {
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.make_sections(true, 1, blks)
50 assert.are_equal('Div', hblks[1].t)
51 assert.are_equal('Header', hblks[1].content[1].t)
52 assert.are_equal('1', hblks[1].content[1].attributes['number'])
56 group 'normalize_date' {
57 test('09 Nov 1989', function ()
58 assert.are_equal('1989-11-09', utils.normalize_date '09 Nov 1989')
60 test('12/31/2017', function ()
61 assert.are_equal('2017-12-31', utils.normalize_date '12/31/2017')
66 test('hashing', function ()
67 local ref_hash = '0a0a9f2a6772942557ab5355d76af442f8f65e01'
68 assert.are_equal(ref_hash, utils.sha1 'Hello, World!')
73 test('inlines', function ()
74 local inline = pandoc.Emph{
81 assert.are_equal('Cogito ergo sum.', utils.stringify(inline))
85 group 'to_roman_numeral' {
86 test('convertes number', function ()
87 assert.are_equal('MDCCCLXXXVIII', utils.to_roman_numeral(1888))
89 test('fails on non-convertible argument', function ()
90 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