Skip to content

Commit 3f3eea9

Browse files
feat: configurable code block background inset
## Details Request: #643 Adds `code.background_inset` option that defines how far from the start and end of a code block background rendering should start. The default value of 1 keeps the existing behavior. By setting the value to 0 you can extend the background highlight logic to also include the delimitter lines. This interferes with `code.border` and `code.language` behavior so should only really be done if both of those are disabled.
1 parent d67113f commit 3f3eea9

7 files changed

Lines changed: 18 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- allow inline code left and right icon highlight to be specified [e9d7409](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/e9d7409c2d604dc12589c00ef922e08e3998e000)
88
- improve table start column tracking [2247dcd](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/2247dcd1ff0c223cfa7e317783f89b8d00457ce6)
9+
- ability to not conceal wikilink destination when there is an alias [d67113f](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/d67113f11384c0dad96fced2f7b91f1fc811e97f)
910

1011
### Bug Fixes
1112

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,8 @@ require('render-markdown').setup({
471471
-- Use a boolean to make behavior apply to all languages.
472472
-- Borders above & below blocks will continue to be rendered.
473473
disable_background = { 'diff' },
474+
-- Number of lines from start/end to skip rendering background.
475+
background_inset = 1,
474476
-- Width of the code block background.
475477
-- | block | width of the code block |
476478
-- | full | full width of the window |
@@ -1181,6 +1183,8 @@ require('render-markdown').setup({
11811183
-- Use a boolean to make behavior apply to all languages.
11821184
-- Borders above & below blocks will continue to be rendered.
11831185
disable_background = { 'diff' },
1186+
-- Number of lines from start/end to skip rendering background.
1187+
background_inset = 1,
11841188
-- Width of the code block background.
11851189
-- | block | width of the code block |
11861190
-- | full | full width of the window |

doc/render-markdown.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For NVIM v0.12.1 Last change: 2026 April 20
1+
*render-markdown.txt* For NVIM v0.12.1 Last change: 2026 April 26
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*
@@ -537,6 +537,8 @@ Default Configuration ~
537537
-- Use a boolean to make behavior apply to all languages.
538538
-- Borders above & below blocks will continue to be rendered.
539539
disable_background = { 'diff' },
540+
-- Number of lines from start/end to skip rendering background.
541+
background_inset = 1,
540542
-- Width of the code block background.
541543
-- | block | width of the code block |
542544
-- | full | full width of the window |
@@ -1241,6 +1243,8 @@ Code Block Configuration ~
12411243
-- Use a boolean to make behavior apply to all languages.
12421244
-- Borders above & below blocks will continue to be rendered.
12431245
disable_background = { 'diff' },
1246+
-- Number of lines from start/end to skip rendering background.
1247+
background_inset = 1,
12441248
-- Width of the code block background.
12451249
-- | block | width of the code block |
12461250
-- | full | full width of the window |

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.12.11'
9+
M.version = '8.12.12'
1010

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

lua/render-markdown/render/markdown/code.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ function Render:run()
108108

109109
local background = self:enabled(self.config.disable_background)
110110
if background then
111-
self:background(start_row + 1, end_row - 1)
111+
local inset = self.config.background_inset
112+
self:background(start_row + inset, end_row - inset)
112113
end
113114
self:padding(background)
114115
end

lua/render-markdown/settings.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ M.code = {}
390390
---@field language_pad number
391391
---@field disable string[]
392392
---@field disable_background boolean|string[]
393+
---@field background_inset integer
393394
---@field width render.md.code.Width
394395
---@field left_margin number
395396
---@field left_pad number
@@ -478,6 +479,8 @@ M.code.default = {
478479
-- Use a boolean to make behavior apply to all languages.
479480
-- Borders above & below blocks will continue to be rendered.
480481
disable_background = { 'diff' },
482+
-- Number of lines from start/end to skip rendering background.
483+
background_inset = 1,
481484
-- Width of the code block background.
482485
-- | block | width of the code block |
483486
-- | full | full width of the window |
@@ -559,6 +562,7 @@ function M.code.schema()
559562
disable_background = {
560563
union = { { list = { type = 'string' } }, { type = 'boolean' } },
561564
},
565+
background_inset = { type = 'number' },
562566
width = { enum = M.code.width },
563567
left_margin = { type = 'number' },
564568
left_pad = { type = 'number' },

lua/render-markdown/types.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
---@field language_pad? number
102102
---@field disable? string[]
103103
---@field disable_background? boolean|string[]
104+
---@field background_inset? integer
104105
---@field width? render.md.code.Width
105106
---@field left_margin? number
106107
---@field left_pad? number

0 commit comments

Comments
 (0)