diff --git a/lua/render-markdown/render/markdown/heading.lua b/lua/render-markdown/render/markdown/heading.lua index 50cabe9..7068e54 100644 --- a/lua/render-markdown/render/markdown/heading.lua +++ b/lua/render-markdown/render/markdown/heading.lua @@ -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 @@ -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) diff --git a/tests/heading_spec.lua b/tests/heading_spec.lua index 538e8d1..4558643 100644 --- a/tests/heading_spec.lua +++ b/tests/heading_spec.lua @@ -21,6 +21,11 @@ describe('heading', function() 'Ext Heading 2', 'Ext Heading 2 Line 2', '---', + '', + '- # Heading', + ' - ## Heading 2', + '', + '> # Quote heading', } it('default', function() @@ -43,6 +48,11 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + '', + '󰫎 ● 󰲡 Heading', + '󰫎 ○ 󰲣 Heading 2', + '', + '󰫎 ▋ 󰲡 Quote heading', }) end) @@ -73,6 +83,15 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ● 󰲡 Heading', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ○ 󰲣 Heading 2', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ▋ 󰲡 Quote heading', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', }) end) @@ -103,6 +122,15 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + ' ▄▄▄▄▄▄▄▄▄', + '󰫎 ● 󰲡 Heading', + ' ▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ○ 󰲣 Heading 2', + ' ▀▀▀▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ▋ 󰲡 Quote heading', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', }) end) @@ -126,6 +154,11 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + '', + '󰫎 ● 󰲡 Heading', + '󰫎 ○ 󰲣 Heading 2', + '', + '󰫎 ▋ 󰲡 Quote heading', }) end) @@ -161,6 +194,17 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + '', + ' ▄▄▄▄▄▄▄▄▄', + '󰫎 ● 󰲡 Heading', + ' ▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ○ 󰲣 Heading 2', + ' ▀▀▀▀▀▀▀▀▀▀▀▀', + '', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ▋ 󰲡 Quote heading', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', }) end) @@ -191,6 +235,15 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + ' ▄▄▄▄▄▄▄▄▄', + '󰫎 ● 󰲡 Heading', + ' ▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ○ 󰲣 Heading 2', + ' ▀▀▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ▋ 󰲡 Quote heading', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', }) end) @@ -214,6 +267,11 @@ describe('heading', function() '', '󰫎 Ext Heading 2 󰲣', ' Ext Heading 2 Line 2', + '', + '󰫎 ● Heading 󰲡', + '󰫎 ○ Heading 2 󰲣', + '', + '󰫎 ▋ Quote heading 󰲡', }) end) @@ -244,6 +302,15 @@ describe('heading', function() '', '󰫎 Ext Heading 2 󰲣', ' Ext Heading 2 Line 2', + ' ▄▄▄▄▄▄▄▄▄▄', + '󰫎 ● Heading 󰲡', + ' ▀▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ○ Heading 2 󰲣', + ' ▀▀▀▀▀▀▀▀▀▀▀▀', + ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄', + '󰫎 ▋ Quote heading 󰲡', + ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀', }) end) @@ -267,6 +334,11 @@ describe('heading', function() '', '󰫎 󰲣 Ext Heading 2', ' Ext Heading 2 Line 2', + '', + '󰫎 ● 󰲡 Heading', + '󰫎 ○ 󰲣 Heading 2', + '', + '󰫎 ▋ 󰲡 Quote heading', }) end) @@ -290,6 +362,11 @@ describe('heading', function() '', '󰫎 Ext Heading 2 󰲣', ' Ext Heading 2 Line 2', + '', + '󰫎 ● Heading 󰲡', + '󰫎 ○ Heading 2 󰲣', + '', + '󰫎 ▋ Quote heading 󰲡', }) end) end) diff --git a/tests/minimal_init.lua b/tests/minimal_init.lua index fc6621c..b5449db 100644 --- a/tests/minimal_init.lua +++ b/tests/minimal_init.lua @@ -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