Skip to content

Commit 631e03e

Browse files
fix: render table border below delimiter when there are no rows
1 parent c5f25ef commit 631e03e

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

Diff for: lua/render-markdown/handler/markdown.lua

+15-12
Original file line numberDiff line numberDiff line change
@@ -701,19 +701,22 @@ function Handler:table_full(parsed_table)
701701
return border[11]:rep(column.width)
702702
end, delim.columns)
703703

704-
local line_above = spaces > 0 and { { str.spaces(spaces), 'Normal' } } or {}
705-
table.insert(line_above, { border[1] .. table.concat(sections, border[2]) .. border[3], pipe_table.head })
706-
self:add(false, first.info.start_row, first.info.start_col, {
707-
virt_lines_above = true,
708-
virt_lines = { self:indent_virt_line(parsed_table.info, line_above) },
709-
})
704+
---@param info render.md.NodeInfo
705+
---@param above boolean
706+
---@param chars { [1]: string, [2]: string, [3]: string }
707+
local function table_border(info, above, chars)
708+
local line = spaces > 0 and { { str.spaces(spaces), 'Normal' } } or {}
709+
local highlight = above and pipe_table.head or pipe_table.row
710+
table.insert(line, { chars[1] .. table.concat(sections, chars[2]) .. chars[3], highlight })
711+
self:add(false, info.start_row, info.start_col, {
712+
virt_lines_above = above,
713+
virt_lines = { self:indent_virt_line(parsed_table.info, line) },
714+
})
715+
end
710716

711-
local line_below = spaces > 0 and { { str.spaces(spaces), 'Normal' } } or {}
712-
table.insert(line_below, { border[7] .. table.concat(sections, border[8]) .. border[9], pipe_table.row })
713-
self:add(false, last.info.start_row, last.info.start_col, {
714-
virt_lines_above = false,
715-
virt_lines = { self:indent_virt_line(parsed_table.info, line_below) },
716-
})
717+
local last_info = #parsed_table.rows == 1 and delim.info or last.info
718+
table_border(first.info, true, { border[1], border[2], border[3] })
719+
table_border(last_info, false, { border[7], border[8], border[9] })
717720
end
718721

719722
---@private

Diff for: lua/render-markdown/health.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local M = {}
55

66
---@private
77
---@type string
8-
M.version = '6.2.2'
8+
M.version = '6.2.3'
99

1010
function M.check()
1111
vim.health.start('render-markdown.nvim [version]')

0 commit comments

Comments
 (0)