Skip to content

Commit 5879827

Browse files
feature: Add support for full_reference_link nodes
## Details Requested: #75 Adds hyperlink icon in front of full_reference_link nodes.
1 parent 62252c7 commit 5879827

File tree

8 files changed

+14
-9
lines changed

8 files changed

+14
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ require('render-markdown').setup({
154154
155155
(shortcut_link) @callout
156156
157-
[(inline_link) (image)] @link
157+
[(inline_link) (full_reference_link) (image)] @link
158158
]],
159159
-- Query to be able to identify links in nodes
160-
inline_link_query = '[(inline_link) (image)] @link',
160+
inline_link_query = '[(inline_link) (full_reference_link) (image)] @link',
161161
-- The level of logs to write to file: vim.fn.stdpath('state') .. '/render-markdown.log'
162162
-- Only intended to be used for plugin development / debugging
163163
log_level = 'error',

demo/list_table.gif

46.8 KB
Loading

demo/list_table.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- Nested List 2 Item 1
88
- Nested List 3 Item 1
99
- Nested List 4 Item 1
10-
+ List Item 3
10+
+ List Item 3: with [reference link][example]
1111

1212
# Ordered List
1313

@@ -21,3 +21,5 @@
2121
| ---------------- | ------------------ |
2222
| Regular Item | **Bold Item** |
2323
| `Item Inline` | [Link Item](/test) |
24+
25+
[example]: https://example.com

doc/render-markdown.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ Full Default Configuration ~
194194

195195
(shortcut_link) @callout
196196

197-
[(inline_link) (image)] @link
197+
[(inline_link) (full_reference_link) (image)] @link
198198
]],
199199
-- Query to be able to identify links in nodes
200-
inline_link_query = '[(inline_link) (image)] @link',
200+
inline_link_query = '[(inline_link) (full_reference_link) (image)] @link',
201201
-- The level of logs to write to file: vim.fn.stdpath('state') .. '/render-markdown.log'
202202
-- Only intended to be used for plugin development / debugging
203203
log_level = 'error',

lua/render-markdown/handler/shared.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ M.link_icon = function(info)
1717
if not util.has_10 then
1818
return nil
1919
end
20-
if info.type == 'inline_link' then
20+
if vim.tbl_contains({ 'inline_link', 'full_reference_link' }, info.type) then
2121
return link.hyperlink
2222
elseif info.type == 'image' then
2323
return link.image

lua/render-markdown/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ M.default_config = {
168168
169169
(shortcut_link) @callout
170170
171-
[(inline_link) (image)] @link
171+
[(inline_link) (full_reference_link) (image)] @link
172172
]],
173173
-- Query to be able to identify links in nodes
174-
inline_link_query = '[(inline_link) (image)] @link',
174+
inline_link_query = '[(inline_link) (full_reference_link) (image)] @link',
175175
-- The level of logs to write to file: vim.fn.stdpath('state') .. '/render-markdown.log'
176176
-- Only intended to be used for plugin development / debugging
177177
log_level = 'error',

tests/list_table_spec.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ async_tests.describe('list_table.md', function()
2020
util.bullet(7, 8, 4), -- Nested List 3 Item 1
2121
util.bullet(8, 10, 1), -- Nested List 4 Item 1
2222
util.bullet(9, 0, 1), -- List Item 3
23+
util.link(9, 20, 45, false), -- List Item 3, link
2324
})
2425

2526
-- Ordered list

tests/util.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,11 @@ end
183183
---@param image boolean
184184
---@return render.md.MarkInfo
185185
M.link = function(row, start_col, end_col, image)
186-
local icon = '󰌹 '
186+
local icon
187187
if image then
188188
icon = '󰥶 '
189+
else
190+
icon = '󰌹 '
189191
end
190192
return {
191193
row = { row, row },

0 commit comments

Comments
 (0)