Skip to content

Commit

Permalink
fix: Added support for n) type number list
Browse files Browse the repository at this point in the history
Closes #129

fix: Custom links now inherit from `default` value

Ref: #121
  • Loading branch information
OXY2DEV committed Aug 28, 2024
1 parent 1fd1138 commit a954ec8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
3 changes: 0 additions & 3 deletions lua/markview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1390,19 +1390,16 @@ markview.configuration = {
match = "https://(.+)$",

icon = "󰞉 ",
hl = "MarkviewHyperlink",
},
{
match = "http://(.+)$",

icon = "󰕑 ",
hl = "MarkviewHyperlink",
},
{
match = "[%.]md$",

icon = "",
hl = "MarkviewHyperlink",
}
}
},
Expand Down
13 changes: 7 additions & 6 deletions lua/markview/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ parser.get_md_len = function (text)
return len, final_string;
end

parser.fiter_lines = function (buffer, from, to)
parser.filter_lines = function (buffer, from, to)
local captured_lines = vim.api.nvim_buf_get_lines(buffer, from, to, false);
local filtered_lines = {};
local indexes = {};
Expand Down Expand Up @@ -92,7 +92,7 @@ parser.fiter_lines = function (buffer, from, to)
if l ~= 1 then
if withinCodeBlock ~= true and line:match("^%s*([+%-*])") then
break;
elseif withinCodeBlock ~= true and line:match("^%s*(%d+%.)") then
elseif withinCodeBlock ~= true and line:match("^%s*(%d+[%.%)])") then
break;
end
end
Expand All @@ -105,8 +105,8 @@ parser.fiter_lines = function (buffer, from, to)

if line:match("^%s*([+%-*])") then
parent_marker = line:match("^%s*([+%-*])");
elseif line:match("^%s*(%d+%.)") then
parent_marker = line:match("^%s*(%d+%.)");
elseif line:match("^%s*(%d+[%.%)])") then
parent_marker = line:match("^%s*(%d+[%.%)])");
end

if line:match("(```)") and withinCodeBlock ~= true then
Expand All @@ -130,7 +130,7 @@ parser.fiter_lines = function (buffer, from, to)
insideDescription = false;
end

if not line:match("^%s*([+%-*])") and not line:match("^%s*(%d+%.)") and parent_marker then
if not line:match("^%s*([+%-*])") and not line:match("^%s*(%d+[%.%)])") and parent_marker then
spaces_before = math.max(0, spaces_before - vim.fn.strchars((parent_marker or "") .. " "));

if line:match("(```)") then
Expand Down Expand Up @@ -511,8 +511,9 @@ parser.md = function (buffer, TStree, from, to)
local marker = capture_node:named_child(0);
local marker_text = vim.treesitter.get_node_text(marker, buffer);
local symbol = marker_text:gsub("%s", "");
symbol = symbol:gsub("%)", "%%)")

local list_lines, lines, spaces, align_spaces, starts = parser.fiter_lines(buffer, row_start, row_end);
local list_lines, lines, spaces, align_spaces, starts = parser.filter_lines(buffer, row_start, row_end);
local spaces_before_marker = list_lines[1]:match("^(%s*)" .. symbol .. "%s*");

local c_end, _ = parser.get_list_end_range(buffer, row_start, row_end, symbol)
Expand Down
4 changes: 2 additions & 2 deletions lua/markview/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ renderer.render_links = function (buffer, content, config_table)

for _, conf in ipairs(config_table.hyperlinks.custom or {}) do
if conf.match and string.match(content.address or "", conf.match) then
lnk_conf = conf
lnk_conf = vim.tbl_extend("force", lnk_conf or {}, conf);
end
end

Expand Down Expand Up @@ -1561,7 +1561,7 @@ renderer.render_lists = function (buffer, content, config_table)
ls_conf = config_table.marker_plus or {};
elseif string.match(content.marker_symbol, "*") then
ls_conf = config_table.marker_star or {};
elseif string.match(content.marker_symbol, "[.]") then
elseif string.match(content.marker_symbol, "[.%)]") then
ls_conf = config_table.marker_dot or {};
end

Expand Down

0 comments on commit a954ec8

Please sign in to comment.