@@ -31,24 +31,22 @@ function OrgLink:_set_directive()
31
31
--- @type TSNode
32
32
local capture_id = pred [2 ]
33
33
local node = match [capture_id ]
34
+ metadata [' image.ignore' ] = true
34
35
35
36
if not node or not self .has_extmark_url_support then
36
- metadata [' image.ignore' ] = true
37
37
return
38
38
end
39
39
40
40
local start_row , start_col = node :range ()
41
41
local line_cache = self .markup :get_links_for_line (source , start_row )
42
42
if not line_cache or # line_cache == 0 then
43
- metadata [' image.ignore' ] = true
44
43
return
45
44
end
46
45
local entry_for_node = vim .tbl_filter (function (item )
47
46
return item .url and item .from .start_col == start_col and item .metadata .type == ' link_end'
48
47
end , line_cache )[1 ]
49
48
50
49
if not entry_for_node then
51
- metadata [' image.ignore' ] = true
52
50
return
53
51
end
54
52
@@ -57,6 +55,13 @@ function OrgLink:_set_directive()
57
55
if prefix == ' file:' then
58
56
url = url :sub (6 )
59
57
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
60
65
metadata [' image.src' ] = url
61
66
end , { force = true , all = false })
62
67
end
0 commit comments