Skip to content

Commit f0eb589

Browse files
fix: bullet padding indenting heading borders
## Details Issue: #297 Tree sitter parser has the last list item extending to the next section. Since heading borders are added as overlay lines when space is available they will end up getting the padding that was added there for the list item. Fix is to have a special case for the last line in a list when it is empty, not the best but seems to work well enough.
1 parent d7b646f commit f0eb589

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

doc/render-markdown.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For 0.10.0 Last change: 2025 January 10
1+
*render-markdown.txt* For 0.10.0 Last change: 2025 January 14
22

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

lua/render-markdown/health.lua

+1-1
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 = '7.8.6'
8+
M.version = '7.8.7'
99

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

lua/render-markdown/render/list_item.lua

+19-5
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,31 @@ function Render:padding(root)
121121
return
122122
end
123123
local left_col = root ~= nil and root.start_col or self.node.start_col
124-
125-
local next_list = self.node:child('list')
126-
local end_row = next_list ~= nil and next_list.start_row or self.node.end_row
127-
128-
for row = self.node.start_row, end_row - 1 do
124+
for row = self.node.start_row, self:end_row(root) - 1 do
129125
local right_col = row == self.node.start_row and self.data.marker.end_col - 1 or left_col
130126
self:padding_mark(row, left_col, self.bullet.left_pad)
131127
self:padding_mark(row, right_col, self.bullet.right_pad)
132128
end
133129
end
134130

131+
---@private
132+
---@param root? render.md.Node
133+
---@return integer
134+
function Render:end_row(root)
135+
local next_list = self.node:child('list')
136+
if next_list ~= nil then
137+
return next_list.start_row
138+
end
139+
local end_row = self.node.end_row
140+
-- On the last item of the root list ignore the last line if it is empty
141+
if root ~= nil and root.end_row == end_row then
142+
if Str.width(self.node:line('last', 0)) == 0 then
143+
return end_row - 1
144+
end
145+
end
146+
return end_row
147+
end
148+
135149
---@private
136150
---@param row integer
137151
---@param col integer

0 commit comments

Comments
 (0)