diff --git a/README.md b/README.md
index b1c348b..f9bcf8e 100644
--- a/README.md
+++ b/README.md
@@ -16,16 +16,16 @@ An experimental `markdown` previewer for Neovim.
Markview.nvim comes with a ton of features such as,
- Close to `full render` of markdown documents. Currently supported items are,
- * Block quotes(includes `callouts`/`alerts`
- * Chekboxes(checked, unchecked & pending state)
- * Headings(atx_headings & setext_headings)
- * Horizontal rules
- * Html support(only for simple tags, e.g. `Underline`)
- * Html entites(both `&;` and `&` support)
- * Inline codes
- * Links(hyprlinks, images & email support)
- * List item(ordered & unordered)
- * Tables
+ * Block quotes(includes `callouts`/`alerts`.
+ * Chekboxes(checked, unchecked, pending & custom states, e.g. `[~]` for in progress).
+ * Headings(atx_headings & setext_headings).
+ * Horizontal rules.
+ * Html support(only for simple tags, e.g. `Underline`).
+ * Html entites(both `&;` and `&` support).
+ * Inline codes.
+ * Links(hyprlinks, images & email support).
+ * List item(ordered & unordered).
+ * Tables.
- Fully customisable setup! You can customise everything to your needs!
- A `hybrid mode` that allows rendering in real-time! It will even unconceal nodes under the cursor.
- Dynamic `highlight groups` that allows support for almost any colorscheme!
@@ -278,6 +278,17 @@ Checkboxes use these highlight groups,
- MarkviewCheckboxUnhecked, from `DiagnosticError`.
- MarkviewCheckboxPending, from `DiagnosticWarn`.
+Markview also comes with 2 custom checkbox states,
+
+>[!Note]
+> These are purely for custom notes and aren't taken from external tools(e.g. Obsidian).
+
+- MarkviewCheckboxProgress, from `Keyword`.
+ Checkboes using `[~]`.
+
+- MarkviewCheckboxCancelled, from `Comment`.
+ Checkboxes using `[o]`.
+
### 💻 Code blocks & inline codes
Code blocks use the following highlight group,
diff --git a/lua/definitions.lua b/lua/definitions.lua
index d237c98..5ef3090 100644
--- a/lua/definitions.lua
+++ b/lua/definitions.lua
@@ -463,12 +463,18 @@
---
--- Configuration table for the unchecked state
---@field unchecked markview.render_config.checkbox.state
+---
+--- Configuration table for the unchecked state
+---@field custom markview.render_config.checkbox.state[]?
--- Configuration table for the checkbox state
---@class markview.render_config.checkbox.state
---
---- Text to use as the ustom checkbox
+--- The text inside [] checkboxes to match
+---@field match string?
+---
+--- Text to use as the custom checkbox
---@field text string
---
--- Highlight group for text
diff --git a/lua/markview.lua b/lua/markview.lua
index cf61331..89011e9 100644
--- a/lua/markview.lua
+++ b/lua/markview.lua
@@ -899,6 +899,31 @@ markview.configuration = {
return { fg = fg, default = true };
end
},
+ {
+ group_name = "CheckboxProgress",
+ value = function ()
+ local fg = markview.colors.get({
+ markview.colors.get_hl_value(0, "Conditional", "fg"),
+ markview.colors.get_hl_value(0, "Keyword", "fg"),
+
+ vim.o.background == "dark" and "#cba6f7" or "#8839ef"
+ });
+
+ return { fg = fg, default = true };
+ end
+ },
+ {
+ group_name = "CheckboxCancelled",
+ value = function ()
+ local fg = markview.colors.get({
+ markview.colors.get_hl_value(0, "Comment", "fg"),
+
+ vim.o.background == "dark" and "#6c7086" or "#9ca0b0";
+ });
+
+ return { fg = fg, default = true };
+ end
+ },
{
@@ -1415,6 +1440,18 @@ markview.configuration = {
},
unchecked = {
text = "✘", hl = "MarkviewCheckboxUnchecked"
+ },
+ custom = {
+ {
+ match = "~",
+ text = "â—•",
+ hl = "MarkviewCheckboxProgress"
+ },
+ {
+ match = "o",
+ text = "ó°©¹",
+ hl = "MarkviewCheckboxCancelled"
+ }
}
},
diff --git a/lua/markview/parser.lua b/lua/markview/parser.lua
index 6932b02..adf4afd 100644
--- a/lua/markview/parser.lua
+++ b/lua/markview/parser.lua
@@ -525,13 +525,15 @@ parser.md_inline = function (buffer, TStree, from, to)
local line = vim.api.nvim_buf_get_lines(buffer, row_start, row_start + 1, false);
local title = string.match(line ~= nil and line[1] or "", "%b[]%s*(.*)$")
- if capture_text == "[-]" then
+ if capture_text:match("%[(.)%]") then
for _, extmark in ipairs(parser.parsed_content) do
if extmark.type == "list_item" and extmark.row_start == row_start then
+ local marker = capture_text:match("%[(.)%]");
+
local start_line = extmark.list_lines[1] or "";
- local atStart = start_line:match("%-%s+(%[%-%])%s+");
+ local atStart = start_line:match("[+%-*]%s+(%[%" .. marker .. "%])%s+");
- local chk_start, _ = start_line:find("%[%-%]");
+ local chk_start, _ = start_line:find("%[%" .. marker .. "%]");
if not atStart or not chk_start or chk_start - 1 ~= col_start then
goto invalid;
@@ -540,7 +542,7 @@ parser.md_inline = function (buffer, TStree, from, to)
table.insert(parser.parsed_content, {
node = capture_node,
type = "checkbox",
- state = "pending",
+ state = capture_text:match("%[(.)%]") == "-" and "pending" or capture_text:match("%[(.)%]"),
row_start = row_start,
row_end = row_end,
diff --git a/lua/markview/renderer.lua b/lua/markview/renderer.lua
index 2a2d11e..ae85f1b 100644
--- a/lua/markview/renderer.lua
+++ b/lua/markview/renderer.lua
@@ -1574,6 +1574,12 @@ renderer.render_checkboxes = function (buffer, content, config_table)
chk_config = config_table.unchecked;
elseif content.state == "pending" then
chk_config = config_table.pending;
+ elseif vim.islist(config_table.custom) then
+ for _, config in ipairs(config_table.custom) do
+ if content.state == config.match then
+ chk_config = config;
+ end
+ end
end
if not chk_config or type(chk_config.text) ~= "string" then
diff --git a/markview.nvim.wiki b/markview.nvim.wiki
index 84e3092..c3c6b88 160000
--- a/markview.nvim.wiki
+++ b/markview.nvim.wiki
@@ -1 +1 @@
-Subproject commit 84e3092829cd3eec8b6f9ffe532284c5b4b47cce
+Subproject commit c3c6b88d0104871a4aff28cf134f16fabf1efcc8