@@ -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 })
6267end
0 commit comments