From 493c054c6463156f1c584cffe006b2fc9ed2d34c Mon Sep 17 00:00:00 2001 From: Shawon Date: Mon, 7 Oct 2024 08:11:13 +0600 Subject: [PATCH] fix: Fixed callouts rendering --- lua/markview.lua | 48 +++++++++++++++++++-------------------- lua/markview/parser.lua | 8 +++---- lua/markview/renderer.lua | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lua/markview.lua b/lua/markview.lua index 379c7d2..19a987c 100644 --- a/lua/markview.lua +++ b/lua/markview.lua @@ -132,7 +132,7 @@ markview.configuration = { hl = "MarkviewBlockQuoteNote", title = true, - icon = "󱉫 ", + icon = "󱉫", border = "▋" }, @@ -142,7 +142,7 @@ markview.configuration = { preview = "󱉫 Summary", title = true, - icon = "󱉫 ", + icon = "󱉫", border = "▋" }, @@ -152,7 +152,7 @@ markview.configuration = { preview = "󱉫 Tldr", title = true, - icon = "󱉫 ", + icon = "󱉫", border = "▋" }, @@ -162,7 +162,7 @@ markview.configuration = { preview = " Todo", title = true, - icon = " ", + icon = "", border = "▋" }, @@ -172,7 +172,7 @@ markview.configuration = { preview = " Info", custom_title = true, - icon = " ", + icon = "", border = "▋" }, @@ -182,7 +182,7 @@ markview.configuration = { preview = "󰗠 Success", title = true, - icon = "󰗠 ", + icon = "󰗠", border = "▋" }, @@ -192,7 +192,7 @@ markview.configuration = { preview = "󰗠 Check", title = true, - icon = "󰗠 ", + icon = "󰗠", border = "▋" }, @@ -202,7 +202,7 @@ markview.configuration = { preview = "󰗠 Done", title = true, - icon = "󰗠 ", + icon = "󰗠", border = "▋" }, @@ -212,7 +212,7 @@ markview.configuration = { preview = "󰋗 Question", title = true, - icon = "󰋗 ", + icon = "󰋗", border = "▋" }, @@ -222,7 +222,7 @@ markview.configuration = { preview = "󰋗 Help", title = true, - icon = "󰋗 ", + icon = "󰋗", border = "▋" }, @@ -231,8 +231,8 @@ markview.configuration = { hl = "MarkviewBlockQuoteWarn", preview = "󰋗 Faq", - custom_title = true, - custom_icon = "󰋗 ", + title = true, + icon = "󰋗", border = "▋" }, @@ -242,7 +242,7 @@ markview.configuration = { preview = "󰅙 Failure", title = true, - icon = "󰅙 ", + icon = "󰅙", border = "▋" }, @@ -252,7 +252,7 @@ markview.configuration = { preview = "󰅙 Fail", title = true, - icon = "󰅙 ", + icon = "󰅙", border = "▋" }, @@ -262,7 +262,7 @@ markview.configuration = { preview = "󰅙 Missing", title = true, - icon = "󰅙 ", + icon = "󰅙", border = "▋" }, @@ -272,7 +272,7 @@ markview.configuration = { preview = " Danger", title = true, - icon = "  ", + icon = "", border = "▋" }, @@ -282,7 +282,7 @@ markview.configuration = { preview = " Error", title = true, - icon = "  ", + icon = "", border = "▋" }, @@ -292,7 +292,7 @@ markview.configuration = { preview = " Bug", title = true, - icon = "  ", + icon = "", border = "▋" }, @@ -302,7 +302,7 @@ markview.configuration = { preview = "󱖫 Example", title = true, - icon = " 󱖫 ", + icon = "󱖫", border = "▋" }, @@ -312,7 +312,7 @@ markview.configuration = { preview = " Quote", title = true, - icon = "  ", + icon = "", border = "▋" }, @@ -322,7 +322,7 @@ markview.configuration = { preview = " Cite", title = true, - icon = "  ", + icon = "", border = "▋" }, @@ -332,7 +332,7 @@ markview.configuration = { preview = " Hint", title = true, - icon = "  ", + icon = "", border = "▋" }, @@ -342,7 +342,7 @@ markview.configuration = { preview = " Attention", title = true, - icon = "  ", + icon = "", border = "▋" }, @@ -392,7 +392,7 @@ markview.configuration = { preview = "󰠳 Custom", custom_title = true, - custom_icon = " 󰠳 ", + custom_icon = "󰠳", border = "▋" } diff --git a/lua/markview/parser.lua b/lua/markview/parser.lua index b73d9f5..e3b9ed7 100644 --- a/lua/markview/parser.lua +++ b/lua/markview/parser.lua @@ -842,15 +842,15 @@ parser.md_inline = function (buffer, TStree, from, to) col_start = col_start, col_end = col_end, }); - elseif before:match("%>$") then - local title = string.match(line or "", "%b[](.*)$") + elseif before:match("%> ?$") then + local title = string.match(line or "", "%](.*)$") for _, extmark in ipairs(parser.parsed_content) do if extmark.type == "block_quote" and extmark.row_start == row_start - and extmark.col_start == col_start - 1 + and extmark.col_start == col_start - before:match("(%> ?)$"):len() then - extmark.callout = string.match(capture_text, "%[!([^%]]+)%]"); + extmark.callout = string.match(capture_text, "%[!(.-)%]"); extmark.title = title; extmark.line_width = vim.fn.strchars(line); diff --git a/lua/markview/renderer.lua b/lua/markview/renderer.lua index ae5ff85..7a47640 100644 --- a/lua/markview/renderer.lua +++ b/lua/markview/renderer.lua @@ -1569,7 +1569,7 @@ renderer.render_block_quotes = function (buffer, content, config_table) { qt_config.icon or qt_config.custom_icon, list_clamp(qt_config.preview_hl or qt_config.callout_preview_hl or qt_config.hl, 1) }, }, - end_col = content.col_start + vim.fn.strdisplaywidth(">[!" .. content.callout .. "]" .. (content.title:match("^(%s)") or "")), + end_col = content.col_start + vim.fn.strdisplaywidth(">[!" .. content.callout .. "]"), conceal = "" });