Skip to content

Commit 45fc18e

Browse files
committed
Fix to support case-insensitive titles
Closes #20
1 parent bf9b8c0 commit 45fc18e

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ type NameFilter = ((title: string) => boolean) | string[]
6767

6868
export function nameFilter(filter: NameFilter) {
6969
return (title: string) => {
70-
return typeof filter == 'function' ? filter(title) : filter.includes(title)
70+
return typeof filter == 'function'
71+
? filter(title)
72+
: filter.map((f) => f.toLowerCase()).includes(title.toLowerCase())
7173
}
7274
}

test/__snapshots__/index.spec.ts.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ exports[`GitHub beta blockquote-based admonitions with titles like [!NOTE] > sho
5555
</div>"
5656
`;
5757

58+
exports[`GitHub beta blockquote-based admonitions with titles like [!NOTE] > should transform with case-insensitive titles from issue #20 1`] = `
59+
"<h1>Admonitions</h1>
60+
<div class="admonition">
61+
<p class="admonition-title">nOTe</p>
62+
<p>test</p>
63+
</div>"
64+
`;
65+
5866
exports[`GitHub beta blockquote-based admonitions with titles like [!NOTE] > should transform with nested ones 1`] = `
5967
"<h1>Admonitions</h1>
6068
<div class="admonition">

test/index.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ describe('GitHub beta blockquote-based admonitions with titles like [!NOTE]', fu
107107
},
108108
})
109109

110+
defineCase('should transform with case-insensitive titles from issue #20', {
111+
input: `\
112+
# Admonitions
113+
> [!nOTe]
114+
> test
115+
`,
116+
assertions(html) {
117+
const elem = selectOne('div.admonition > p.admonition-title:first-child', parseDocument(html))
118+
expect(elem).to.have.nested.property('firstChild.data', 'nOTe')
119+
},
120+
})
121+
110122
defineCase('should not transform when title is not in form [!NOTE] but legacy **Note**', {
111123
input: `\
112124
# Admonitions

0 commit comments

Comments
 (0)