Skip to content

Commit 2542276

Browse files
Update docs, improve types in unit test, remove usage of plenary async tests
1 parent ddb4547 commit 2542276

12 files changed

+132
-79
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
- Code highlight border with notermguicolors [#77](https://github.com/MeanderingProgrammer/markdown.nvim/issues/77)
5555
[#81](https://github.com/MeanderingProgrammer/markdown.nvim/pull/81)
5656
- Hide cursor row in active buffer only [56d92af](https://github.com/MeanderingProgrammer/markdown.nvim/commit/56d92af432141346f2d414213726f7a45e82b2b3)
57+
- Remove gifs from repo, fix concel on window change [51eec4e](https://github.com/MeanderingProgrammer/markdown.nvim/commit/51eec4e4cab69faf7e37c183d23df6b9614952db)
58+
- Wrap get_parser in pcall [#101](https://github.com/MeanderingProgrammer/markdown.nvim/issues/101)
59+
[ddb4547](https://github.com/MeanderingProgrammer/markdown.nvim/commit/ddb454792dd85c0f6039ec14006aecaee67e782d)
5760

5861
### Collaborator Shoutouts
5962

doc/limitations.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,36 @@
66

77
`LaTeX` formula evaluations are placed above text rather than overlayed.
88

9+
A way around this is to use a separate plugin for `LaTeX` and disable that feature
10+
in this plugin.
11+
12+
As an example you can use [latex.nvim](https://github.com/ryleelyman/latex.nvim):
13+
14+
```lua
15+
{
16+
'ryleelyman/latex.nvim',
17+
config = function()
18+
require('latex').setup({})
19+
end,
20+
}
21+
```
22+
23+
Then disable `LaTeX` from this plugin:
24+
25+
```lua
26+
require('render-markdown').setup({
27+
latex = { enabled = false },
28+
win_options = {
29+
conceallevel = { rendered = 2 },
30+
},
31+
})
32+
```
33+
34+
> [!NOTE]
35+
>
36+
> These plugins can rely on a specific `conceallevel` to work properly, which
37+
> you will need to configure in this plugin like in the example above.
38+
939
## Does Not Run in Telescope Preview
1040

1141
[ISSUE #98](https://github.com/MeanderingProgrammer/markdown.nvim/issues/98)

tests/box_dash_quote_spec.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
local async_tests = require('plenary.async.tests')
1+
---@module 'luassert'
22
local util = require('tests.util')
33

4-
async_tests.describe('box_dash_quote.md', function()
5-
async_tests.it('default', function()
4+
describe('box_dash_quote.md', function()
5+
it('default', function()
66
util.setup('demo/box_dash_quote.md')
77

88
local expected = {}

tests/callout_spec.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local async_tests = require('plenary.async.tests')
1+
---@module 'luassert'
22
local util = require('tests.util')
33

44
---@param row integer
@@ -8,6 +8,7 @@ local util = require('tests.util')
88
---@param highlight string
99
---@return render.md.MarkInfo
1010
local function callout(row, start_col, end_col, text, highlight)
11+
---@type render.md.MarkInfo
1112
return {
1213
row = { row, row },
1314
col = { start_col, end_col },
@@ -16,8 +17,8 @@ local function callout(row, start_col, end_col, text, highlight)
1617
}
1718
end
1819

19-
async_tests.describe('callout.md', function()
20-
async_tests.it('default', function()
20+
describe('callout.md', function()
21+
it('default', function()
2122
util.setup('demo/callout.md')
2223

2324
local info = 'Info'

tests/custom_handler_spec.lua

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
local async_tests = require('plenary.async.tests')
1+
---@module 'luassert'
22
local util = require('tests.util')
33

4+
---@param namespace integer
5+
---@param root TSNode
6+
---@param buf integer
47
local function render_conceal_escape(namespace, root, buf)
58
local query = vim.treesitter.query.parse('markdown_inline', '(backslash_escape) @escape')
69
for _, node in query:iter_captures(root, buf) do
@@ -13,12 +16,16 @@ local function render_conceal_escape(namespace, root, buf)
1316
end
1417
end
1518

19+
---@param root TSNode
20+
---@param buf integer
21+
---@return render.md.Mark[]
1622
local function parse_conceal_escape(root, buf)
17-
local query = vim.treesitter.query.parse('markdown_inline', '(backslash_escape) @escape')
1823
local marks = {}
24+
local query = vim.treesitter.query.parse('markdown_inline', '(backslash_escape) @escape')
1925
for _, node in query:iter_captures(root, buf) do
2026
local start_row, start_col, end_row, _ = node:range()
21-
table.insert(marks, {
27+
---@type render.md.Mark
28+
local mark = {
2229
conceal = true,
2330
start_row = start_row,
2431
start_col = start_col,
@@ -27,7 +34,8 @@ local function parse_conceal_escape(root, buf)
2734
end_col = start_col + 1,
2835
conceal = '',
2936
},
30-
})
37+
}
38+
table.insert(marks, mark)
3139
end
3240
return marks
3341
end
@@ -36,15 +44,16 @@ end
3644
---@param col integer
3745
---@return render.md.MarkInfo
3846
local function backslash(row, col)
47+
---@type render.md.MarkInfo
3948
return {
4049
row = { row, row },
4150
col = { col, col + 1 },
4251
conceal = '',
4352
}
4453
end
4554

46-
async_tests.describe('custom_handler.md', function()
47-
async_tests.it('default', function()
55+
describe('custom_handler.md', function()
56+
it('default', function()
4857
util.setup('tests/data/custom_handler.md')
4958

5059
local expected = {}
@@ -57,7 +66,7 @@ async_tests.describe('custom_handler.md', function()
5766
util.marks_are_equal(expected, actual)
5867
end)
5968

60-
async_tests.it('custom override deprecated render', function()
69+
it('custom override deprecated render', function()
6170
util.setup('tests/data/custom_handler.md', {
6271
custom_handlers = {
6372
---@diagnostic disable-next-line: missing-fields
@@ -79,7 +88,7 @@ async_tests.describe('custom_handler.md', function()
7988
util.marks_are_equal(expected, actual)
8089
end)
8190

82-
async_tests.it('custom override parse', function()
91+
it('custom override parse', function()
8392
util.setup('tests/data/custom_handler.md', {
8493
custom_handlers = {
8594
markdown_inline = {
@@ -100,7 +109,7 @@ async_tests.describe('custom_handler.md', function()
100109
util.marks_are_equal(expected, actual)
101110
end)
102111

103-
async_tests.it('custom extends', function()
112+
it('custom extends', function()
104113
util.setup('tests/data/custom_handler.md', {
105114
custom_handlers = {
106115
markdown_inline = {

tests/ft_override_spec.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
local async_tests = require('plenary.async.tests')
1+
---@module 'luassert'
22
local util = require('tests.util')
33

4-
async_tests.describe('ft_override.md', function()
5-
async_tests.it('default', function()
4+
describe('ft_override.md', function()
5+
it('default', function()
66
util.setup('tests/data/ft_override.md')
77

88
local actual = util.get_actual_marks()

tests/heading_code_spec.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
local async_tests = require('plenary.async.tests')
1+
---@module 'luassert'
22
local util = require('tests.util')
33

4-
async_tests.describe('heading_code.md', function()
5-
async_tests.it('default', function()
4+
describe('heading_code.md', function()
5+
it('default', function()
66
util.setup('demo/heading_code.md')
77

88
local expected = {}

tests/latex_spec.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
local async_tests = require('plenary.async.tests')
1+
---@module 'luassert'
22
local stub = require('luassert.stub')
33
local util = require('tests.util')
4-
54
local eq = assert.are.same
65

76
---@param start_row integer
@@ -22,8 +21,8 @@ local function latex(start_row, end_row, start_col, end_col, lines)
2221
}
2322
end
2423

25-
async_tests.describe('latex.md', function()
26-
async_tests.it('default', function()
24+
describe('latex.md', function()
25+
it('default', function()
2726
stub.new(vim.fn, 'executable', function(expr)
2827
eq('latex2text', expr)
2928
return 1

tests/list_table_spec.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
local async_tests = require('plenary.async.tests')
1+
---@module 'luassert'
22
local util = require('tests.util')
33

4-
async_tests.describe('list_table.md', function()
5-
async_tests.it('default', function()
4+
describe('list_table.md', function()
5+
it('default', function()
66
util.setup('demo/list_table.md')
77

88
local expected = {}

tests/state_spec.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
---@module 'luassert'
2-
32
local util = require('tests.util')
4-
53
local eq = assert.are.same
64

75
describe('state', function()

0 commit comments

Comments
 (0)