Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lua/render-markdown/render/markdown/heading.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ function Render:background(box)
local win_col = 0
if self.data.width == 'block' then
padding:pad(vim.o.columns * 2)
win_col = box.margin + box.body + self:indent():size(self.data.level)
win_col = self.node.start_col
+ box.margin
+ box.body
+ self:indent():size(self.data.level)
end
local col = self.node.start_col
for row = self.node.start_row, self.node.end_row - 1 do
Expand Down Expand Up @@ -276,7 +279,7 @@ function Render:border(box, above)
local width = self.data.width == 'block' and box.body or vim.o.columns
local icon = above and self.config.above or self.config.below

local line = self:line():pad(box.margin)
local line = self:line():pad(self.node.start_col):pad(box.margin)
line:rep(icon, box.padding, bg)
line:rep(icon, prefix, fg)
line:rep(icon, width - box.padding - prefix, bg)
Expand Down
77 changes: 77 additions & 0 deletions tests/heading_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ describe('heading', function()
'Ext Heading 2',
'Ext Heading 2 Line 2',
'---',
'',
'- # Heading',
' - ## Heading 2',
'',
'> # Quote heading',
}

it('default', function()
Expand All @@ -43,6 +48,11 @@ describe('heading', function()
'',
'󰫎 󰲣 Ext Heading 2',
' Ext Heading 2 Line 2',
'',
'󰫎 ● 󰲡 Heading',
'󰫎 ○ 󰲣 Heading 2',
'',
'󰫎 ▋ 󰲡 Quote heading',
})
end)

Expand Down Expand Up @@ -73,6 +83,15 @@ describe('heading', function()
'',
'󰫎 󰲣 Ext Heading 2',
' Ext Heading 2 Line 2',
' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄',
'󰫎 ● 󰲡 Heading',
' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀',
' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄',
'󰫎 ○ 󰲣 Heading 2',
' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀',
' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄',
'󰫎 ▋ 󰲡 Quote heading',
' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀',
})
end)

Expand Down Expand Up @@ -103,6 +122,15 @@ describe('heading', function()
'',
'󰫎 󰲣 Ext Heading 2',
' Ext Heading 2 Line 2',
' ▄▄▄▄▄▄▄▄▄',
'󰫎 ● 󰲡 Heading',
' ▀▀▀▀▀▀▀▀▀',
' ▄▄▄▄▄▄▄▄▄▄▄▄',
'󰫎 ○ 󰲣 Heading 2',
' ▀▀▀▀▀▀▀▀▀▀▀▀',
' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄',
'󰫎 ▋ 󰲡 Quote heading',
' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀',
})
end)

Expand All @@ -126,6 +154,11 @@ describe('heading', function()
'',
'󰫎 󰲣 Ext Heading 2',
' Ext Heading 2 Line 2',
'',
'󰫎 ● 󰲡 Heading',
'󰫎 ○ 󰲣 Heading 2',
'',
'󰫎 ▋ 󰲡 Quote heading',
})
end)

Expand Down Expand Up @@ -161,6 +194,17 @@ describe('heading', function()
'',
'󰫎 󰲣 Ext Heading 2',
' Ext Heading 2 Line 2',
'',
' ▄▄▄▄▄▄▄▄▄',
'󰫎 ● 󰲡 Heading',
' ▀▀▀▀▀▀▀▀▀',
' ▄▄▄▄▄▄▄▄▄▄▄▄',
'󰫎 ○ 󰲣 Heading 2',
' ▀▀▀▀▀▀▀▀▀▀▀▀',
'',
' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄',
'󰫎 ▋ 󰲡 Quote heading',
' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀',
})
end)

Expand Down Expand Up @@ -191,6 +235,15 @@ describe('heading', function()
'',
'󰫎 󰲣 Ext Heading 2',
' Ext Heading 2 Line 2',
' ▄▄▄▄▄▄▄▄▄',
'󰫎 ● 󰲡 Heading',
' ▀▀▀▀▀▀▀▀▀',
' ▄▄▄▄▄▄▄▄▄▄▄',
'󰫎 ○ 󰲣 Heading 2',
' ▀▀▀▀▀▀▀▀▀▀▀',
' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄',
'󰫎 ▋ 󰲡 Quote heading',
' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀',
})
end)

Expand All @@ -214,6 +267,11 @@ describe('heading', function()
'',
'󰫎 Ext Heading 2 󰲣',
' Ext Heading 2 Line 2',
'',
'󰫎 ● Heading 󰲡',
'󰫎 ○ Heading 2 󰲣',
'',
'󰫎 ▋ Quote heading 󰲡',
})
end)

Expand Down Expand Up @@ -244,6 +302,15 @@ describe('heading', function()
'',
'󰫎 Ext Heading 2 󰲣',
' Ext Heading 2 Line 2',
' ▄▄▄▄▄▄▄▄▄▄',
'󰫎 ● Heading 󰲡',
' ▀▀▀▀▀▀▀▀▀▀',
' ▄▄▄▄▄▄▄▄▄▄▄▄',
'󰫎 ○ Heading 2 󰲣',
' ▀▀▀▀▀▀▀▀▀▀▀▀',
' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄',
'󰫎 ▋ Quote heading 󰲡',
' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀',
})
end)

Expand All @@ -267,6 +334,11 @@ describe('heading', function()
'',
'󰫎 󰲣 Ext Heading 2',
' Ext Heading 2 Line 2',
'',
'󰫎 ● 󰲡 Heading',
'󰫎 ○ 󰲣 Heading 2',
'',
'󰫎 ▋ 󰲡 Quote heading',
})
end)

Expand All @@ -290,6 +362,11 @@ describe('heading', function()
'',
'󰫎 Ext Heading 2 󰲣',
' Ext Heading 2 Line 2',
'',
'󰫎 ● Heading 󰲡',
'󰫎 ○ Heading 2 󰲣',
'',
'󰫎 ▋ Quote heading 󰲡',
})
end)
end)
2 changes: 1 addition & 1 deletion tests/minimal_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ end

-- settings
vim.o.columns = 80
vim.o.lines = 40
vim.o.lines = 60
vim.o.tabstop = 4
vim.o.wrap = false

Expand Down