Skip to content

Commit

Permalink
fix: Fixed a bug causing patterns to be matched inside inline codes
Browse files Browse the repository at this point in the history
Characters are now escaped and then matched. `noice.nvim` README's table
now correctly renders!
  • Loading branch information
OXY2DEV committed Aug 25, 2024
1 parent 1e79753 commit 1193286
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lua/markview/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ local display_width = function (text, config)
inl_conf.corner_right or ""
}));

final_string = final_string:gsub("`" .. inline_code .. "`", table.concat({
local escaped = inline_code:gsub("%p", "%%%1");

final_string = final_string:gsub("`" .. escaped .. "`", table.concat({
inl_conf.corner_left or "",
inl_conf.padding_left or "",

inline_code or "",
inline_code:gsub(".", "|"),

inl_conf.padding_right or "",
inl_conf.corner_right or ""
Expand Down Expand Up @@ -227,7 +229,7 @@ local display_width = function (text, config)
end
end

for pattern in final_string:gmatch("%[([^%]]*)%]") do
for pattern in final_string:gmatch("%[([^%]]+)%]") do
d_width = d_width - 2;
final_string = final_string:gsub( "[" .. pattern .. "]", pattern);
end
Expand Down
2 changes: 1 addition & 1 deletion markview.nvim.wiki

0 comments on commit 1193286

Please sign in to comment.