Skip to content

Commit 7065c7d

Browse files
Rename custom checkbox fields to be more consistent with rest of plugin
# Details - text -> raw - icon -> rendered
1 parent d3cecc6 commit 7065c7d

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ require('render-markdown').setup({
174174
checked = '󰱒 ',
175175
-- Specify custom checkboxes, must be surrounded in square brackets
176176
custom = {
177-
todo = { text = '[-]', icon = '󰥔 ', highlight = '@markup.raw' },
177+
todo = { raw = '[-]', rendered = '󰥔 ', highlight = '@markup.raw' },
178178
},
179179
},
180180
-- Character that will replace the > at the start of block quotes
@@ -311,15 +311,15 @@ is used to hide the character.
311311
The checked `[ ]` & unchecked `[x]` are directly replaced with these values.
312312

313313
Additionally `custom` states can be specified, an example of this is provided
314-
with: `todo = { text = '[-]', icon = '󰥔 ', highlight = '@markup.raw' }`.
314+
with: `todo = { raw = '[-]', rendered = '󰥔 ', highlight = '@markup.raw' }`.
315315

316316
This requires neovim >= `0.10.0` since it relies on `inline` extmarks.
317317

318318
The key in the `custom` table is unused. The parts of the value are:
319319

320-
- `text`: matched against the raw text of a `shortcut_link`, in the same way as `callouts`
321-
- `icon`: replaces the `text` value when rendering
322-
- `highlight`: color used for `icon`
320+
- `raw`: matched against the raw text of a `shortcut_link`, in the same way as `callouts`
321+
- `rendered`: replaces the `raw` value when rendering
322+
- `highlight`: color used for `rendered` text
323323

324324
### quote
325325

doc/render-markdown.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Full Default Configuration ~
206206
checked = '󰱒 ',
207207
-- Specify custom checkboxes, must be surrounded in square brackets
208208
custom = {
209-
todo = { text = '[-]', icon = '󰥔 ', highlight = '@markup.raw' },
209+
todo = { raw = '[-]', rendered = '󰥔 ', highlight = '@markup.raw' },
210210
},
211211
},
212212
-- Character that will replace the > at the start of block quotes
@@ -348,15 +348,15 @@ CHECKBOX ~
348348
The checked `[ ]` & unchecked `[x]` are directly replaced with these values.
349349

350350
Additionally `custom` states can be specified, an example of this is provided
351-
with: `todo = { text = '[-]', icon = '󰥔 ', highlight = '@markup.raw' }`.
351+
with: `todo = { raw = '[-]', rendered = '󰥔 ', highlight = '@markup.raw' }`.
352352

353353
This requires neovim >= `0.10.0` since it relies on `inline` extmarks.
354354

355355
The key in the `custom` table is unused. The parts of the value are:
356356

357-
- `text`: matched against the raw text of a `shortcut_link`, in the same way as `callouts`
358-
- `icon`: replaces the `text` value when rendering
359-
- `highlight`: color used for `icon`
357+
- `raw`: matched against the raw text of a `shortcut_link`, in the same way as `callouts`
358+
- `rendered`: replaces the `raw` value when rendering
359+
- `highlight`: color used for `rendered` text
360360

361361

362362
QUOTE ~

lua/render-markdown/custom_checkbox.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local M = {}
66
---@return render.md.CustomCheckbox?
77
M.get_exact = function(value)
88
for _, checkbox in pairs(state.config.checkbox.custom) do
9-
if checkbox.text == value then
9+
if checkbox.raw == value then
1010
return checkbox
1111
end
1212
end
@@ -17,7 +17,7 @@ end
1717
---@return render.md.CustomCheckbox?
1818
M.get_starts = function(value)
1919
for _, checkbox in pairs(state.config.checkbox.custom) do
20-
if vim.startswith(value, checkbox.text) then
20+
if vim.startswith(value, checkbox.raw) then
2121
return checkbox
2222
end
2323
end

lua/render-markdown/handler/markdown_inline.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ M.render_node = function(namespace, buf, capture, node)
5454
return
5555
end
5656

57-
local checkbox_text = { str.pad_to(value, checkbox.icon), checkbox.highlight }
57+
local checkbox_text = { str.pad_to(value, checkbox.rendered), checkbox.highlight }
5858
vim.api.nvim_buf_set_extmark(buf, namespace, start_row, start_col, {
5959
end_row = end_row,
6060
end_col = end_col,

lua/render-markdown/init.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ local M = {}
4242
---@field public rendered any
4343

4444
---@class render.md.CustomCheckbox
45-
---@field public text string
46-
---@field public icon string
45+
---@field public raw string
46+
---@field public rendered string
4747
---@field public highlight string
4848

4949
---@class render.md.UserCheckbox
@@ -152,7 +152,7 @@ M.default_config = {
152152
checked = '󰱒 ',
153153
-- Specify custom checkboxes, must be surrounded in square brackets
154154
custom = {
155-
todo = { text = '[-]', icon = '󰥔 ', highlight = '@markup.raw' },
155+
todo = { raw = '[-]', rendered = '󰥔 ', highlight = '@markup.raw' },
156156
},
157157
},
158158
-- Character that will replace the > at the start of block quotes

0 commit comments

Comments
 (0)