1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local exec_lua = helpers.exec_lua
describe('vim.lsp.util', function()
before_each(helpers.clear)
describe('stylize_markdown', function()
local stylize_markdown = function(content, opts)
return exec_lua([[
local bufnr = vim.uri_to_bufnr("file:///fake/uri")
vim.fn.bufload(bufnr)
local args = { ... }
local content = args[1]
local opts = args[2]
local stripped_content = vim.lsp.util.stylize_markdown(bufnr, content, opts)
return stripped_content
]], content, opts)
end
it('code fences', function()
local lines = {
"```lua",
"local hello = 'world'",
"```",
}
local expected = {
"local hello = 'world'",
}
local opts = {}
eq(expected, stylize_markdown(lines, opts))
end)
it('adds separator after code block', function()
local lines = {
"```lua",
"local hello = 'world'",
"```",
"",
"something",
}
local expected = {
"local hello = 'world'",
"─────────────────────",
"something",
}
local opts = { separator = true }
eq(expected, stylize_markdown(lines, opts))
end)
it('replaces supported HTML entities', function()
local lines = {
"1 < 2",
"3 > 2",
""quoted"",
"'apos'",
"   ",
"&",
}
local expected = {
"1 < 2",
"3 > 2",
'"quoted"',
"'apos'",
" ",
"&",
}
local opts = {}
eq(expected, stylize_markdown(lines, opts))
end)
end)
end)
|