diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f74264..a045bce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ - footnote text superscript rendering [#241](https://github.com/MeanderingProgrammer/render-markdown.nvim/issues/241) [634acd5](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/634acd5da964c32f6947cd0c7802d7a116662665) [1b5d117](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/1b5d11734122d9451d2e5e2e567fd61a62822293) +- code border none [#246](https://github.com/MeanderingProgrammer/render-markdown.nvim/issues/246) + [f3cda24](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/f3cda24c71261f6a52f5ddafb95786684d862d87) +- expand default custom links [#245](https://github.com/MeanderingProgrammer/render-markdown.nvim/issues/245) + [61850bf](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/61850bf7df4af8398e97559a35b62378ba8435b1) ### Bug Fixes diff --git a/doc/render-markdown.txt b/doc/render-markdown.txt index 2ff5adf..4a4c4c4 100644 --- a/doc/render-markdown.txt +++ b/doc/render-markdown.txt @@ -1,4 +1,4 @@ -*render-markdown.txt* For 0.10.0 Last change: 2024 December 02 +*render-markdown.txt* For 0.10.0 Last change: 2024 December 03 ============================================================================== Table of Contents *render-markdown-table-of-contents* diff --git a/lua/render-markdown/handler/markdown_inline.lua b/lua/render-markdown/handler/markdown_inline.lua index 242d665..26aa644 100644 --- a/lua/render-markdown/handler/markdown_inline.lua +++ b/lua/render-markdown/handler/markdown_inline.lua @@ -31,6 +31,7 @@ function Handler.new(buf) (full_reference_link) (image) (inline_link) + (uri_autolink) ] @link ((inline) @inline_highlight diff --git a/lua/render-markdown/health.lua b/lua/render-markdown/health.lua index cd06c87..cf2978e 100644 --- a/lua/render-markdown/health.lua +++ b/lua/render-markdown/health.lua @@ -4,7 +4,7 @@ local state = require('render-markdown.state') local M = {} ---@private -M.version = '7.6.5' +M.version = '7.6.6' function M.check() M.start('version') diff --git a/lua/render-markdown/render/link.lua b/lua/render-markdown/render/link.lua index 6d9b0a2..75ec58f 100644 --- a/lua/render-markdown/render/link.lua +++ b/lua/render-markdown/render/link.lua @@ -18,19 +18,52 @@ function Render:setup() return false end - local text, highlight, conceal = self.link.hyperlink, nil, false if self.node.type == 'email_autolink' then - text, conceal = self.link.email .. self.node.text:sub(2, -2), true + local email = self.node.text:sub(2, -2) + self.data = { + text = self.link.email .. email, + highlight = self.link.highlight, + conceal = true, + } + elseif self.node.type == 'full_reference_link' then + self.data = { + text = self.link.hyperlink, + highlight = self.link.highlight, + conceal = false, + } elseif self.node.type == 'image' then - text = self.link.image + self.data = { + text = self.link.image, + highlight = self.link.highlight, + conceal = false, + } elseif self.node.type == 'inline_link' then local destination = self.node:child('link_destination') - local link_component = destination ~= nil and self:link_component(destination.text) or nil - if link_component ~= nil then - text, highlight = link_component.icon, link_component.highlight + local component = destination ~= nil and self:link_component(destination.text) or nil + local text, highlight = self.link.hyperlink, nil + if component ~= nil then + text, highlight = component.icon, component.highlight end + self.data = { + text = text, + highlight = highlight or self.link.highlight, + conceal = false, + } + elseif self.node.type == 'uri_autolink' then + local destination = self.node.text:sub(2, -2) + local component = self:link_component(destination) + local text, highlight = self.link.hyperlink, nil + if component ~= nil then + text, highlight = component.icon, component.highlight + end + self.data = { + text = text .. destination, + highlight = highlight or self.link.highlight, + conceal = true, + } + else + return false end - self.data = { text = text, highlight = highlight or self.link.highlight, conceal = conceal } return true end diff --git a/lua/render-markdown/render/shortcut.lua b/lua/render-markdown/render/shortcut.lua index 66a2a37..a95cb76 100644 --- a/lua/render-markdown/render/shortcut.lua +++ b/lua/render-markdown/render/shortcut.lua @@ -99,15 +99,13 @@ function Render:wiki_link() end local parts = Str.split(self.node.text:sub(2, -2), '|') - local link_component = self:link_component(parts[1]) + local component = self:link_component(parts[1]) local icon, highlight = self.link.wiki.icon, nil - if link_component ~= nil then - icon, highlight = link_component.icon, link_component.highlight + if component ~= nil then + icon, highlight = component.icon, component.highlight end - highlight = highlight or self.link.wiki.highlight - local link_text = icon .. parts[#parts] self.marks:add_over('link', self.node, { - virt_text = { { link_text, highlight } }, + virt_text = { { icon .. parts[#parts], highlight or self.link.wiki.highlight } }, virt_text_pos = 'inline', conceal = '', }, { 0, -1, 0, 1 }) diff --git a/tests/ad_hoc_spec.lua b/tests/ad_hoc_spec.lua index 5ce76be..2cc6825 100644 --- a/tests/ad_hoc_spec.lua +++ b/tests/ad_hoc_spec.lua @@ -74,6 +74,11 @@ describe('ad_hoc.md', function() link(row:get(), 2, 20, '󰀓 test@example.com', 'Link', ''), }) + vim.list_extend(expected, { + util.bullet(row:increment(), 0, 1), + link(row:get(), 2, 26, '󰊤 http://www.github.com/', 'Link', ''), + }) + vim.list_extend(expected, { util.bullet(row:increment(), 0, 1), link(row:get(), 2, 61, '󰗃 ', 'Link', nil), @@ -96,10 +101,11 @@ describe('ad_hoc.md', function() ' 8 ● 󱗖 Basic One Then normal text', ' 9 ● 󱗖 With Alias Something important', ' 10 ● 󰀓 test@example.com Email', - ' 11 ● 󰗃 Youtube Link', - ' 12 ● Footnote Link ¹ ᴵⁿᶠᵒ', - ' 13', - ' 14 ¹ ᴵⁿᶠᵒ: Some Info', + ' 11 ● 󰊤 http://www.github.com/ Bare URL', + ' 12 ● 󰗃 Youtube Link', + ' 13 ● Footnote Link ¹ ᴵⁿᶠᵒ', + ' 14', + ' 15 ¹ ᴵⁿᶠᵒ: Some Info', }) end) end) diff --git a/tests/data/ad_hoc.md b/tests/data/ad_hoc.md index 498477b..5093e85 100644 --- a/tests/data/ad_hoc.md +++ b/tests/data/ad_hoc.md @@ -8,6 +8,7 @@ Heading 2 Line 2 - [[Basic One]] Then normal text - [[Nickname|With Alias]] Something important - Email +- Bare URL - [Youtube Link](https://www.youtube.com/watch?v=dQw4w9WgXcQ) - Footnote Link [^1 Info]