Skip to content

Commit dde0cba

Browse files
chore: update code.highlight_border to false|string instead of boolean|string
## Details Setting `code.highlight_border` to `true` really makes no sense, since the point is to disable border highlighting, which means the same things as disabling the border. Update the type definition and usage to only allow for `false` rather than handling `true` in the same way.
1 parent ac3e74f commit dde0cba

File tree

6 files changed

+12
-14
lines changed

6 files changed

+12
-14
lines changed

doc/render-markdown.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For NVIM v0.11.2 Last change: 2025 June 11
1+
*render-markdown.txt* For NVIM v0.11.2 Last change: 2025 June 12
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*

lua/render-markdown/config/code.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
---@field inline_pad integer
2020
---@field highlight string
2121
---@field highlight_language? string
22-
---@field highlight_border string|boolean
22+
---@field highlight_border false|string
2323
---@field highlight_fallback string
2424
---@field highlight_inline string
2525

@@ -151,7 +151,7 @@ function M.validate(spec)
151151
spec:type('inline_pad', 'number')
152152
spec:type('highlight', 'string')
153153
spec:type('highlight_language', { 'string', 'nil' })
154-
spec:type('highlight_border', { 'string', 'boolean' })
154+
spec:one_of('highlight_border', { false }, 'string')
155155
spec:type('highlight_fallback', 'string')
156156
spec:type('highlight_inline', 'string')
157157
spec:check()

lua/render-markdown/debug/validator.lua

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function Spec:type(keys, ts)
7272
end
7373

7474
---@param keys string|string[]
75-
---@param values string[]
75+
---@param values any[]
7676
---@param ts? type|type[]
7777
function Spec:one_of(keys, values, ts)
7878
local options = Iter.list.map(values, vim.inspect)
@@ -138,7 +138,7 @@ function Spec:nested_list(keys, t, ts)
138138
end
139139

140140
---@param keys string|string[]
141-
---@param values string[]
141+
---@param values any[]
142142
---@param ts? type|type[]
143143
function Spec:one_or_list_of(keys, values, ts)
144144
local body = table.concat(Iter.list.map(values, vim.inspect), '|')
@@ -147,17 +147,15 @@ function Spec:one_or_list_of(keys, values, ts)
147147
self:add(keys, Kind.type, message, function(value)
148148
if vim.tbl_contains(types, type(value)) then
149149
return true
150-
elseif type(value) == 'string' then
150+
elseif type(value) ~= 'table' then
151151
return vim.tbl_contains(values, value)
152-
elseif type(value) == 'table' then
152+
else
153153
for i, item in ipairs(value) do
154154
if not vim.tbl_contains(values, item) then
155155
return false, ('[%d] is %s'):format(i, item)
156156
end
157157
end
158158
return true
159-
else
160-
return false
161159
end
162160
end)
163161
end

lua/render-markdown/health.lua

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

77
---@private
8-
M.version = '8.5.1'
8+
M.version = '8.5.2'
99

1010
function M.check()
1111
M.start('version')

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ function Render:language(language, delim)
122122
return false
123123
end
124124

125-
local highlight = {}
125+
local highlight = {} ---@type string[]
126126
local fallback_highlight = self.config.highlight_fallback
127127
highlight[#highlight + 1] = (icon_highlight or fallback_highlight)
128128
local border_highlight = self.config.highlight_border
129-
if type(border_highlight) == 'string' then
129+
if border_highlight ~= false then
130130
highlight[#highlight + 1] = border_highlight
131131
end
132132

@@ -163,7 +163,7 @@ end
163163
function Render:border(node, icon, empty)
164164
local kind = self.config.border
165165
local highlight = self.config.highlight_border
166-
if not node or kind == 'none' or type(highlight) == 'boolean' then
166+
if not node or kind == 'none' or highlight == false then
167167
return
168168
end
169169
local row = node.start_row

lua/render-markdown/types.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
---@field inline_pad? integer
103103
---@field highlight? string
104104
---@field highlight_language? string
105-
---@field highlight_border? string|boolean
105+
---@field highlight_border? false|string
106106
---@field highlight_fallback? string
107107
---@field highlight_inline? string
108108

0 commit comments

Comments
 (0)