Skip to content

Commit 8a71090

Browse files
feat: allow custom link icons to be disabled for images
## Details Currently when choosing an icon for image links we check the configured `link.custom` patterns based on the destination and if a match exists that is the icon that will be rendered. Some users would like to always see the `link.image` regardless of the destination. To support this have added a new `link.image_custom` option that defaults to `true`. When `true` the behavior remains unchanged, when `false` the destination is ignored and `link.image` is always used.
1 parent 4e14c0e commit 8a71090

6 files changed

Lines changed: 15 additions & 2 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,8 @@ require('render-markdown').setup({
800800
},
801801
-- Inlined with 'image' elements.
802802
image = '󰥶 ',
803+
-- Check custom for 'image' elements.
804+
image_custom = true,
803805
-- Inlined with 'email_autolink' elements.
804806
email = '󰀓 ',
805807
-- Fallback icon for 'inline_link' and 'uri_autolink' elements.
@@ -1594,6 +1596,8 @@ require('render-markdown').setup({
15941596
},
15951597
-- Inlined with 'image' elements.
15961598
image = '󰥶 ',
1599+
-- Check custom for 'image' elements.
1600+
image_custom = true,
15971601
-- Inlined with 'email_autolink' elements.
15981602
email = '󰀓 ',
15991603
-- Fallback icon for 'inline_link' and 'uri_autolink' elements.

doc/render-markdown.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,8 @@ Default Configuration ~
866866
},
867867
-- Inlined with 'image' elements.
868868
image = '󰥶 ',
869+
-- Check custom for 'image' elements.
870+
image_custom = true,
869871
-- Inlined with 'email_autolink' elements.
870872
email = '󰀓 ',
871873
-- Fallback icon for 'inline_link' and 'uri_autolink' elements.
@@ -1640,6 +1642,8 @@ Link Configuration ~
16401642
},
16411643
-- Inlined with 'image' elements.
16421644
image = '󰥶 ',
1645+
-- Check custom for 'image' elements.
1646+
image_custom = true,
16431647
-- Inlined with 'email_autolink' elements.
16441648
email = '󰀓 ',
16451649
-- Fallback icon for 'inline_link' and 'uri_autolink' elements.

lua/render-markdown/health.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local state = require('render-markdown.state')
66
local M = {}
77

88
---@private
9-
M.version = '8.11.10'
9+
M.version = '8.11.11'
1010

1111
function M.check()
1212
M.start('versions')

lua/render-markdown/render/inline/link.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function Render:setup()
3030
elseif self.node.type == 'image' then
3131
icon[1] = self.config.image
3232
local destination = self.node:child('link_destination')
33-
if destination then
33+
if destination and self.config.image_custom then
3434
self.context.config:set_link_text(destination.text, icon)
3535
end
3636
title = self.node:child('link_title')

lua/render-markdown/settings.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,7 @@ M.link = {}
12251225
---@class (exact) render.md.link.Config: render.md.base.Config
12261226
---@field footnote render.md.link.footnote.Config
12271227
---@field image string
1228+
---@field image_custom boolean
12281229
---@field email string
12291230
---@field hyperlink string
12301231
---@field highlight string
@@ -1297,6 +1298,8 @@ M.link.default = {
12971298
},
12981299
-- Inlined with 'image' elements.
12991300
image = '󰥶 ',
1301+
-- Check custom for 'image' elements.
1302+
image_custom = true,
13001303
-- Inlined with 'email_autolink' elements.
13011304
email = '󰀓 ',
13021305
-- Fallback icon for 'inline_link' and 'uri_autolink' elements.
@@ -1378,6 +1381,7 @@ function M.link.schema()
13781381
},
13791382
},
13801383
image = { type = 'string' },
1384+
image_custom = { type = 'boolean' },
13811385
email = { type = 'string' },
13821386
hyperlink = { type = 'string' },
13831387
highlight = { type = 'string' },

lua/render-markdown/types.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@
214214
---@class (exact) render.md.link.UserConfig: render.md.base.UserConfig
215215
---@field footnote? render.md.link.footnote.UserConfig
216216
---@field image? string
217+
---@field image_custom? boolean
217218
---@field email? string
218219
---@field hyperlink? string
219220
---@field highlight? string

0 commit comments

Comments
 (0)