2024-04-20 08:44:13 -07:00
|
|
|
local t = require('test.testutil')
|
|
|
|
local n = require('test.functional.testnvim')()
|
|
|
|
|
|
|
|
local exec_lua = n.exec_lua
|
2024-04-08 02:03:20 -07:00
|
|
|
local eq = t.eq
|
2024-02-15 10:16:04 -07:00
|
|
|
|
2024-02-27 08:20:32 -07:00
|
|
|
local function md_to_vimdoc(text, start_indent, indent, text_width)
|
2024-02-15 10:16:04 -07:00
|
|
|
return exec_lua(
|
|
|
|
[[
|
2024-02-27 08:20:32 -07:00
|
|
|
local text, start_indent, indent, text_width = ...
|
|
|
|
start_indent = start_indent or 0
|
|
|
|
indent = indent or 0
|
|
|
|
text_width = text_width or 70
|
2024-10-04 02:13:31 -07:00
|
|
|
local util = require('scripts/util')
|
|
|
|
return util.md_to_vimdoc(table.concat(text, '\n'), start_indent, indent, text_width)
|
2024-02-15 10:16:04 -07:00
|
|
|
]],
|
2024-02-27 08:20:32 -07:00
|
|
|
text,
|
|
|
|
start_indent,
|
|
|
|
indent,
|
|
|
|
text_width
|
2024-02-15 10:16:04 -07:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2024-02-27 08:20:32 -07:00
|
|
|
local function test(what, act, exp, ...)
|
|
|
|
local argc, args = select('#', ...), { ... }
|
|
|
|
it(what, function()
|
|
|
|
eq(table.concat(exp, '\n'), md_to_vimdoc(act, unpack(args, 1, argc)))
|
|
|
|
end)
|
2024-02-15 10:16:04 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
describe('md_to_vimdoc', function()
|
|
|
|
before_each(function()
|
2024-04-20 08:44:13 -07:00
|
|
|
n.clear()
|
2024-02-15 10:16:04 -07:00
|
|
|
end)
|
|
|
|
|
2024-02-27 08:20:32 -07:00
|
|
|
test('can render para after fenced code', {
|
|
|
|
'- Para1',
|
|
|
|
' ```',
|
|
|
|
' code',
|
|
|
|
' ```',
|
|
|
|
' Para2',
|
|
|
|
}, {
|
|
|
|
'• Para1 >',
|
|
|
|
' code',
|
|
|
|
'<',
|
|
|
|
' Para2',
|
|
|
|
'',
|
|
|
|
})
|
|
|
|
|
|
|
|
test('start_indent only applies to first line', {
|
|
|
|
'para1',
|
|
|
|
'',
|
|
|
|
'para2',
|
|
|
|
}, {
|
|
|
|
'para1',
|
|
|
|
'',
|
|
|
|
' para2',
|
|
|
|
'',
|
|
|
|
}, 0, 10, 78)
|
2024-03-08 05:25:18 -07:00
|
|
|
|
|
|
|
test('inline 1', { '(`string`)' }, { '(`string`)', '' })
|
2024-02-15 10:16:04 -07:00
|
|
|
end)
|