Skip to content

Commit e4a89b8

Browse files
fix(images): Ignore image link matches that does not have valid extension
1 parent d47f47d commit e4a89b8

File tree

1 file changed

+8
-3
lines changed
  • lua/orgmode/colors/highlighter/markup

1 file changed

+8
-3
lines changed

Diff for: lua/orgmode/colors/highlighter/markup/link.lua

+8-3
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,22 @@ function OrgLink:_set_directive()
3131
---@type TSNode
3232
local capture_id = pred[2]
3333
local node = match[capture_id]
34+
metadata['image.ignore'] = true
3435

3536
if not node or not self.has_extmark_url_support then
36-
metadata['image.ignore'] = true
3737
return
3838
end
3939

4040
local start_row, start_col = node:range()
4141
local line_cache = self.markup:get_links_for_line(source, start_row)
4242
if not line_cache or #line_cache == 0 then
43-
metadata['image.ignore'] = true
4443
return
4544
end
4645
local entry_for_node = vim.tbl_filter(function(item)
4746
return item.url and item.from.start_col == start_col and item.metadata.type == 'link_end'
4847
end, line_cache)[1]
4948

5049
if not entry_for_node then
51-
metadata['image.ignore'] = true
5250
return
5351
end
5452

@@ -57,6 +55,13 @@ function OrgLink:_set_directive()
5755
if prefix == 'file:' then
5856
url = url:sub(6)
5957
end
58+
local has_valid_ext = vim.iter(_G.Snacks.image.config.formats):find(function(ext)
59+
return vim.endswith(url, ext)
60+
end)
61+
if not has_valid_ext then
62+
return
63+
end
64+
metadata['image.ignore'] = nil
6065
metadata['image.src'] = url
6166
end, { force = true, all = false })
6267
end

0 commit comments

Comments
 (0)