Skip to content

Commit 123048b

Browse files
feature: Make callout matching case insensitive
## Details Request: #74 Make callout.raw comparison with text use string.lower().
1 parent 6aa19e9 commit 123048b

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ require('render-markdown').setup({
330330
-- Callouts are a special instance of a 'block_quote' that start with a 'shortcut_link'
331331
-- Can specify as many additional values as you like following the pattern from any below, such as 'note'
332332
-- The key in this case 'note' is for healthcheck and to allow users to change its values
333-
-- 'raw': Matched against the raw text of a 'shortcut_link'
333+
-- 'raw': Matched against the raw text of a 'shortcut_link', case insensitive
334334
-- 'rendered': Replaces the 'raw' value when rendering
335335
-- 'highlight': Highlight for the 'rendered' text and quote markers
336336
callout = {
@@ -601,7 +601,7 @@ require('render-markdown').setup({
601601
-- Callouts are a special instance of a 'block_quote' that start with a 'shortcut_link'
602602
-- Can specify as many additional values as you like following the pattern from any below, such as 'note'
603603
-- The key in this case 'note' is for healthcheck and to allow users to change its values
604-
-- 'raw': Matched against the raw text of a 'shortcut_link'
604+
-- 'raw': Matched against the raw text of a 'shortcut_link', case insensitive
605605
-- 'rendered': Replaces the 'raw' value when rendering
606606
-- 'highlight': Highlight for the 'rendered' text and quote markers
607607
callout = {

demo/callout.gif

7.19 KB
Loading

demo/callout.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
2727
# Caution
2828
29-
> [!CAUTION]
29+
> [!caution]
3030
> Cautionary tale
3131
3232
# Bug
3333
34-
> [!BUG]
34+
> [!bUg]
3535
> Custom bug

doc/render-markdown.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For 0.10.0 Last change: 2024 July 18
1+
*render-markdown.txt* For 0.10.0 Last change: 2024 July 19
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*
@@ -370,7 +370,7 @@ Full Default Configuration ~
370370
-- Callouts are a special instance of a 'block_quote' that start with a 'shortcut_link'
371371
-- Can specify as many additional values as you like following the pattern from any below, such as 'note'
372372
-- The key in this case 'note' is for healthcheck and to allow users to change its values
373-
-- 'raw': Matched against the raw text of a 'shortcut_link'
373+
-- 'raw': Matched against the raw text of a 'shortcut_link', case insensitive
374374
-- 'rendered': Replaces the 'raw' value when rendering
375375
-- 'highlight': Highlight for the 'rendered' text and quote markers
376376
callout = {
@@ -647,7 +647,7 @@ CALLOUTS *render-markdown-setup-callouts*
647647
-- Callouts are a special instance of a 'block_quote' that start with a 'shortcut_link'
648648
-- Can specify as many additional values as you like following the pattern from any below, such as 'note'
649649
-- The key in this case 'note' is for healthcheck and to allow users to change its values
650-
-- 'raw': Matched against the raw text of a 'shortcut_link'
650+
-- 'raw': Matched against the raw text of a 'shortcut_link', case insensitive
651651
-- 'rendered': Replaces the 'raw' value when rendering
652652
-- 'highlight': Highlight for the 'rendered' text and quote markers
653653
callout = {

lua/render-markdown/component.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ M.callout = function(text, comparison)
1515
---@return boolean
1616
local function matches(callout)
1717
if comparison == 'exact' then
18-
return text == callout.raw
18+
return text:lower() == callout.raw:lower()
1919
elseif comparison == 'contains' then
20-
return text:find(callout.raw, 1, true) ~= nil
20+
return text:lower():find(callout.raw:lower(), 1, true) ~= nil
2121
else
2222
error(string.format('Unhandled comparison: %s', comparison))
2323
end

lua/render-markdown/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ M.default_config = {
342342
-- Callouts are a special instance of a 'block_quote' that start with a 'shortcut_link'
343343
-- Can specify as many additional values as you like following the pattern from any below, such as 'note'
344344
-- The key in this case 'note' is for healthcheck and to allow users to change its values
345-
-- 'raw': Matched against the raw text of a 'shortcut_link'
345+
-- 'raw': Matched against the raw text of a 'shortcut_link', case insensitive
346346
-- 'rendered': Replaces the 'raw' value when rendering
347347
-- 'highlight': Highlight for the 'rendered' text and quote markers
348348
callout = {

0 commit comments

Comments
 (0)