Skip to content

Commit 82f49e0

Browse files
committed
update tests
Signed-off-by: rishichawda <[email protected]>
1 parent 59b5865 commit 82f49e0

File tree

8 files changed

+142
-66
lines changed

8 files changed

+142
-66
lines changed
Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,2 @@
1-
<blockquote class="remark-note bonus"><div class="remark-note-header"><span class="remark-note-icon"><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2-
<g stroke-linecap="round" stroke-linejoin="round"></g>
3-
<g>
4-
<path
5-
d="M9.23163 8.61762C7.26389 9.06284 6.28001 9.28545 6.04594 10.0382C5.81186 10.7909 6.4826 11.5753 7.82408 13.1439L8.17113 13.5498C8.55234 13.9955 8.74294 14.2184 8.82869 14.4942C8.91444 14.7699 8.88562 15.0673 8.82799 15.662L8.77552 16.2035C8.5727 18.2965 8.4713 19.343 9.08412 19.8082C9.69694 20.2734 10.6181 19.8492 12.4605 19.0009L12.9372 18.7815C13.4607 18.5404 13.7225 18.4199 14 18.4199C14.2775 18.4199 14.5393 18.5404 15.0628 18.7815L15.5395 19.0009C17.3819 19.8492 18.3031 20.2734 18.9159 19.8082C19.5287 19.343 19.4273 18.2965 19.2245 16.2035M20.1759 13.1439C21.5174 11.5753 22.1881 10.7909 21.9541 10.0382C21.72 9.28545 20.7361 9.06284 18.7684 8.61762L18.2593 8.50244C17.7001 8.37592 17.4205 8.31266 17.196 8.14225C16.9716 7.97183 16.8276 7.71355 16.5396 7.19699L16.2775 6.7267C15.2641 4.9089 14.7575 4 14 4C13.2425 4 12.7359 4.9089 11.7225 6.7267"
6-
stroke-width="1.5" stroke-linecap="round"></path>
7-
<path d="M2.08887 16C3.20445 15.121 4.68639 14.7971 6.08887 15.1257" stroke-width="1.5"
8-
stroke-linecap="round"></path>
9-
<path d="M2.08887 10.5C3.08887 10 3.37862 10.0605 4.08887 10" stroke-width="1.5"
10-
stroke-linecap="round"></path>
11-
<path d="M2 5.60867L2.20816 5.48676C4.41383 4.19506 6.75032 3.84687 8.95304 4.48161L9.16092 4.54152"
12-
stroke-width="1.5" stroke-linecap="round"></path>
13-
</g>
14-
</svg></span><span class="remark-note-title">bonus</span></div><div class="remark-note-content"><p>This is a bonus block.
1+
<blockquote class="remark-note remark-note-bonus"><div class="remark-note-header"><span class="remark-note-icon"><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g stroke-linecap="round" stroke-linejoin="round"></g><g><path d="M9.23163 8.61762C7.26389 9.06284 6.28001 9.28545 6.04594 10.0382C5.81186 10.7909 6.4826 11.5753 7.82408 13.1439L8.17113 13.5498C8.55234 13.9955 8.74294 14.2184 8.82869 14.4942C8.91444 14.7699 8.88562 15.0673 8.82799 15.662L8.77552 16.2035C8.5727 18.2965 8.4713 19.343 9.08412 19.8082C9.69694 20.2734 10.6181 19.8492 12.4605 19.0009L12.9372 18.7815C13.4607 18.5404 13.7225 18.4199 14 18.4199C14.2775 18.4199 14.5393 18.5404 15.0628 18.7815L15.5395 19.0009C17.3819 19.8492 18.3031 20.2734 18.9159 19.8082C19.5287 19.343 19.4273 18.2965 19.2245 16.2035M20.1759 13.1439C21.5174 11.5753 22.1881 10.7909 21.9541 10.0382C21.72 9.28545 20.7361 9.06284 18.7684 8.61762L18.2593 8.50244C17.7001 8.37592 17.4205 8.31266 17.196 8.14225C16.9716 7.97183 16.8276 7.71355 16.5396 7.19699L16.2775 6.7267C15.2641 4.9089 14.7575 4 14 4C13.2425 4 12.7359 4.9089 11.7225 6.7267" stroke-width="1.5" stroke-linecap="round"></path><path d="M2.08887 16C3.20445 15.121 4.68639 14.7971 6.08887 15.1257" stroke-width="1.5" stroke-linecap="round"></path><path d="M2.08887 10.5C3.08887 10 3.37862 10.0605 4.08887 10" stroke-width="1.5" stroke-linecap="round"></path><path d="M2 5.60867L2.20816 5.48676C4.41383 4.19506 6.75032 3.84687 8.95304 4.48161L9.16092 4.54152" stroke-linecap="round" stroke-width="1.5"></path></g></svg></span><span class="remark-note-title">bonus</span></div><div class="remark-note-content"><p>This is a bonus block.
152
Extra info for advanced users.</p></div></blockquote>
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
1-
<blockquote class="remark-note important"><div class="remark-note-header"><span class="remark-note-icon"><svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg" fill="currentColor">
2-
<g stroke-width="0"></g>
3-
<g stroke-linecap="round" stroke-linejoin="round"></g>
4-
<g>
5-
<path fill="currentColor" d="M9,14a1.5,1.5,0,1,1,1.5068-1.5A1.5035,1.5035,0,0,1,9,14Z"></path>
6-
<path fill="currentColor" d="M9,2A7,7,0,1,1,2,9,7.0079,7.0079,0,0,1,9,2M9,0a9,9,0,1,0,9,9A9,9,0,0,0,9,0Z"></path>
7-
<path fill="currentColor" d="M10,4H8a1,1,0,0,0-.97,1.2425l1,4a1,1,0,0,0,1.94,0l1-4A1,1,0,0,0,10,4Zm0,2h0Z"></path>
8-
</g>
9-
</svg></span><span class="remark-note-title">important</span></div><div class="remark-note-content"><p>This is an important block.
1+
<blockquote class="remark-note remark-note-important"><div class="remark-note-header"><span class="remark-note-icon"><svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path fill="currentColor" d="M9,14a1.5,1.5,0,1,1,1.5068-1.5A1.5035,1.5035,0,0,1,9,14Z"></path><path fill="currentColor" d="M9,2A7,7,0,1,1,2,9,7.0079,7.0079,0,0,1,9,2M9,0a9,9,0,1,0,9,9A9,9,0,0,0,9,0Z"></path><path fill="currentColor" d="M10,4H8a1,1,0,0,0-.97,1.2425l1,4a1,1,0,0,0,1.94,0l1-4A1,1,0,0,0,10,4Zm0,2h0Z"></path></g></svg></span><span class="remark-note-title">important</span></div><div class="remark-note-content"><p>This is an important block.
102
Pay attention to this!</p></div></blockquote>
Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,2 @@
1-
<blockquote class="remark-note note"><div class="remark-note-header"><span class="remark-note-icon"><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2-
<g stroke-linecap="round" stroke-linejoin="round" stroke-width="0.048">
3-
</g>
4-
<g>
5-
<path d="M8 2V5" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round">
6-
</path>
7-
<path d="M16 2V5" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round">
8-
</path>
9-
<path d="M21 8.5V17C21 20 19.5 22 16 22H8C4.5 22 3 20 3 17V8.5C3 5.5 4.5 3.5 8 3.5H16C19.5 3.5 21 5.5 21 8.5Z"
10-
stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round">
11-
</path>
12-
<path d="M8 11H16" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round">
13-
</path>
14-
<path d="M8 16H12" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round">
15-
</path>
16-
</g>
17-
</svg></span><span class="remark-note-title">note</span></div><div class="remark-note-content"><p>This is a note block.
1+
<blockquote class="remark-note remark-note-note"><div class="remark-note-header"><span class="remark-note-icon"><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g stroke-linecap="round" stroke-linejoin="round" stroke-width="0.048"></g><g><path d="M8 2V5" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path><path d="M16 2V5" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path><path d="M21 8.5V17C21 20 19.5 22 16 22H8C4.5 22 3 20 3 17V8.5C3 5.5 4.5 3.5 8 3.5H16C19.5 3.5 21 5.5 21 8.5Z" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path><path d="M8 11H16" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path><path d="M8 16H12" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path></g></svg></span><span class="remark-note-title">note</span></div><div class="remark-note-content"><p>This is a note block.
182
It supports <strong>bold</strong> and <em>italic</em> text.</p></div></blockquote>
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
<blockquote class="remark-note quote"><div class="remark-note-header"><span class="remark-note-icon"><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2-
<g stroke-linecap="round" stroke-linejoin="round"></g>
3-
<g>
4-
<path
5-
d="M14 15V14C14 13.0681 14 12.6022 14.1522 12.2346C14.3552 11.7446 14.7446 11.3552 15.2346 11.1522C15.6022 11 16.0681 11 17 11H17.5C18.9045 11 19.6067 11 20.1111 11.3371C20.3295 11.483 20.517 11.6705 20.6629 11.8889C21 12.3933 21 13.0955 21 14.5V15.3431C21 16.1606 21 16.5694 20.8478 16.9369C20.6955 17.3045 20.4065 17.5935 19.8284 18.1716L19.2396 18.7604C18.7822 19.2178 18 18.8938 18 18.2469V17.8787C18 17.3934 17.6066 17 17.1213 17H16C14.8954 17 14 16.1046 14 15Z"
6-
stroke-width="1.5" stroke-linejoin="round"></path>
7-
<path
8-
d="M3 9V8C3 7.06812 3 6.60218 3.15224 6.23463C3.35523 5.74458 3.74458 5.35523 4.23463 5.15224C4.60218 5 5.06812 5 6 5H6.5C7.90446 5 8.60669 5 9.11114 5.33706C9.32952 5.48298 9.51702 5.67048 9.66294 5.88886C10 6.39331 10 7.09554 10 8.5V9.34315C10 10.1606 10 10.5694 9.84776 10.9369C9.69552 11.3045 9.40649 11.5935 8.82843 12.1716L8.23965 12.7604C7.78219 13.2178 7 12.8938 7 12.2469V11.8787C7 11.3934 6.6066 11 6.12132 11H5C3.89543 11 3 10.1046 3 9Z"
9-
stroke-width="1.5" stroke-linejoin="round"></path>
10-
</g>
11-
</svg></span><span class="remark-note-title">quote</span></div><div class="remark-note-content"><p>This is a quote block.
1+
<blockquote class="remark-note remark-note-quote"><div class="remark-note-header"><span class="remark-note-icon"><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g stroke-linecap="round" stroke-linejoin="round"></g><g><path d="M14 15V14C14 13.0681 14 12.6022 14.1522 12.2346C14.3552 11.7446 14.7446 11.3552 15.2346 11.1522C15.6022 11 16.0681 11 17 11H17.5C18.9045 11 19.6067 11 20.1111 11.3371C20.3295 11.483 20.517 11.6705 20.6629 11.8889C21 12.3933 21 13.0955 21 14.5V15.3431C21 16.1606 21 16.5694 20.8478 16.9369C20.6955 17.3045 20.4065 17.5935 19.8284 18.1716L19.2396 18.7604C18.7822 19.2178 18 18.8938 18 18.2469V17.8787C18 17.3934 17.6066 17 17.1213 17H16C14.8954 17 14 16.1046 14 15Z" stroke-width="1.5" stroke-linejoin="round"></path><path d="M3 9V8C3 7.06812 3 6.60218 3.15224 6.23463C3.35523 5.74458 3.74458 5.35523 4.23463 5.15224C4.60218 5 5.06812 5 6 5H6.5C7.90446 5 8.60669 5 9.11114 5.33706C9.32952 5.48298 9.51702 5.67048 9.66294 5.88886C10 6.39331 10 7.09554 10 8.5V9.34315C10 10.1606 10 10.5694 9.84776 10.9369C9.69552 11.3045 9.40649 11.5935 8.82843 12.1716L8.23965 12.7604C7.78219 13.2178 7 12.8938 7 12.2469V11.8787C7 11.3934 6.6066 11 6.12132 11H5C3.89543 11 3 10.1046 3 9Z" stroke-width="1.5" stroke-linejoin="round"></path></g></svg></span><span class="remark-note-title">quote</span></div><div class="remark-note-content"><p>This is a quote block.
122
"To be or not to be."</p></div></blockquote>
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
1-
<blockquote class="remark-note tip"><div class="remark-note-header"><span class="remark-note-icon"><svg viewBox="-0.5 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
2-
<g stroke-linecap="round" stroke-linejoin="round"></g>
3-
<g>
4-
<path
5-
d="M19.0006 9.03002C19.0007 8.10058 18.8158 7.18037 18.4565 6.32317C18.0972 5.46598 17.5709 4.68895 16.9081 4.03734C16.2453 3.38574 15.4594 2.87265 14.5962 2.52801C13.7331 2.18336 12.8099 2.01409 11.8806 2.03002C10.0966 2.08307 8.39798 2.80604 7.12302 4.05504C5.84807 5.30405 5.0903 6.98746 5.00059 8.77001C4.95795 9.9595 5.21931 11.1402 5.75999 12.2006C6.30067 13.2609 7.10281 14.1659 8.09058 14.83C8.36897 15.011 8.59791 15.2584 8.75678 15.5499C8.91565 15.8415 8.99945 16.168 9.00059 16.5V18.03H15.0006V16.5C15.0006 16.1689 15.0829 15.843 15.24 15.5515C15.3971 15.26 15.6241 15.0121 15.9006 14.83C16.8528 14.1911 17.6336 13.328 18.1741 12.3167C18.7147 11.3054 18.9985 10.1767 19.0006 9.03002Z"
6-
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
7-
<path d="M15 21.04C14.1345 21.6891 13.0819 22.04 12 22.04C10.9181 22.04 9.86548 21.6891 9 21.04"
8-
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
9-
<path
10-
d="M11.9901 5.64001L10.3301 8.41998C10.2549 8.54184 10.2138 8.68167 10.2111 8.82483C10.2084 8.96799 10.2441 9.10925 10.3146 9.23389C10.3851 9.35852 10.4877 9.46195 10.6118 9.53339C10.7359 9.60482 10.8769 9.64165 11.0201 9.64001H13.0201C13.1617 9.63947 13.301 9.67657 13.4237 9.7475C13.5463 9.81843 13.6479 9.92063 13.7181 10.0437C13.7883 10.1668 13.8245 10.3063 13.8231 10.4479C13.8217 10.5896 13.7827 10.7283 13.7101 10.85L12.0301 13.64"
11-
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
12-
</g>
13-
</svg></span><span class="remark-note-title">tip</span></div><div class="remark-note-content"><p>This is a tip block.
1+
<blockquote class="remark-note remark-note-tip"><div class="remark-note-header"><span class="remark-note-icon"><svg viewBox="-0.5 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg"><g stroke-linecap="round" stroke-linejoin="round"></g><g><path d="M19.0006 9.03002C19.0007 8.10058 18.8158 7.18037 18.4565 6.32317C18.0972 5.46598 17.5709 4.68895 16.9081 4.03734C16.2453 3.38574 15.4594 2.87265 14.5962 2.52801C13.7331 2.18336 12.8099 2.01409 11.8806 2.03002C10.0966 2.08307 8.39798 2.80604 7.12302 4.05504C5.84807 5.30405 5.0903 6.98746 5.00059 8.77001C4.95795 9.9595 5.21931 11.1402 5.75999 12.2006C6.30067 13.2609 7.10281 14.1659 8.09058 14.83C8.36897 15.011 8.59791 15.2584 8.75678 15.5499C8.91565 15.8415 8.99945 16.168 9.00059 16.5V18.03H15.0006V16.5C15.0006 16.1689 15.0829 15.843 15.24 15.5515C15.3971 15.26 15.6241 15.0121 15.9006 14.83C16.8528 14.1911 17.6336 13.328 18.1741 12.3167C18.7147 11.3054 18.9985 10.1767 19.0006 9.03002Z" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M15 21.04C14.1345 21.6891 13.0819 22.04 12 22.04C10.9181 22.04 9.86548 21.6891 9 21.04" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11.9901 5.64001L10.3301 8.41998C10.2549 8.54184 10.2138 8.68167 10.2111 8.82483C10.2084 8.96799 10.2441 9.10925 10.3146 9.23389C10.3851 9.35852 10.4877 9.46195 10.6118 9.53339C10.7359 9.60482 10.8769 9.64165 11.0201 9.64001H13.0201C13.1617 9.63947 13.301 9.67657 13.4237 9.7475C13.5463 9.81843 13.6479 9.92063 13.7181 10.0437C13.7883 10.1668 13.8245 10.3063 13.8231 10.4479C13.8217 10.5896 13.7827 10.7283 13.7101 10.85L12.0301 13.64" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></g></svg></span><span class="remark-note-title">tip</span></div><div class="remark-note-content"><p>This is a tip block.
142
Use it for helpful advice.</p></div></blockquote>

__tests__/custom-prefix.ts

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/**
2+
* Test custom class prefix option
3+
*/
4+
5+
import { test } from 'node:test'
6+
import assert from 'node:assert/strict'
7+
import { unified } from 'unified'
8+
import remarkParse from 'remark-parse'
9+
import remarkRehype from 'remark-rehype'
10+
import rehypeRaw from 'rehype-raw'
11+
import rehypeStringify from 'rehype-stringify'
12+
import remarkNotes from '../index.js'
13+
14+
test('remark-notes: custom classPrefix should apply to all elements', async () => {
15+
const markdown = '> [!tip]\n> This is a tip'
16+
17+
const file = await unified()
18+
.use(remarkParse)
19+
.use(remarkNotes, { classPrefix: 'my' })
20+
.use(remarkRehype, { allowDangerousHtml: true })
21+
.use(rehypeRaw)
22+
.use(rehypeStringify)
23+
.process(markdown)
24+
25+
const output = String(file)
26+
27+
// Container should have both base and type modifier classes with prefix prepended
28+
assert.ok(output.includes('class="my-remark-note my-remark-note-tip"'),
29+
'Container should have prefix prepended to standard remark-note classes')
30+
31+
// Header, icon, title, and content should all use the prefix prepended to remark-note
32+
assert.ok(output.includes('class="my-remark-note-header"'),
33+
'Header should use prefix-remark-note-header pattern')
34+
assert.ok(output.includes('class="my-remark-note-icon"'),
35+
'Icon should use prefix-remark-note-icon pattern')
36+
assert.ok(output.includes('class="my-remark-note-title"'),
37+
'Title should use prefix-remark-note-title pattern')
38+
assert.ok(output.includes('class="my-remark-note-content"'),
39+
'Content should use prefix-remark-note-content pattern')
40+
41+
// Should still contain 'remark-note' as part of the class names
42+
assert.ok(output.includes('remark-note'),
43+
'Should contain remark-note as part of class names')
44+
})
45+
46+
test('remark-notes: all note types work with custom prefix', async () => {
47+
const noteTypes = ['note', 'tip', 'important', 'quote', 'bonus']
48+
const customPrefix = 'custom'
49+
50+
for (const type of noteTypes) {
51+
const markdown = `> [!${type}]\n> Test ${type}`
52+
53+
const file = await unified()
54+
.use(remarkParse)
55+
.use(remarkNotes, { classPrefix: customPrefix })
56+
.use(remarkRehype, { allowDangerousHtml: true })
57+
.use(rehypeRaw)
58+
.use(rehypeStringify)
59+
.process(markdown)
60+
61+
const output = String(file)
62+
63+
// Check for prefix prepended to remark-note in container classes
64+
assert.ok(
65+
output.includes(`class="${customPrefix}-remark-note ${customPrefix}-remark-note-${type}"`),
66+
`${type} should have prefix prepended: ${customPrefix}-remark-note ${customPrefix}-remark-note-${type}`
67+
)
68+
69+
// Check for prefix prepended to remark-note in all sub-elements
70+
assert.ok(output.includes(`class="${customPrefix}-remark-note-header"`),
71+
`${type} header should use ${customPrefix}-remark-note-header`)
72+
assert.ok(output.includes(`class="${customPrefix}-remark-note-icon"`),
73+
`${type} icon should use ${customPrefix}-remark-note-icon`)
74+
assert.ok(output.includes(`class="${customPrefix}-remark-note-title"`),
75+
`${type} title should use ${customPrefix}-remark-note-title`)
76+
assert.ok(output.includes(`class="${customPrefix}-remark-note-content"`),
77+
`${type} content should use ${customPrefix}-remark-note-content`)
78+
}
79+
})
80+
81+
test('remark-notes: injectStyles option controls style injection', async () => {
82+
const markdown = '> [!note]\n> Test note'
83+
84+
// Test with injectStyles: true (default)
85+
const fileWithStyles = await unified()
86+
.use(remarkParse)
87+
.use(remarkNotes, { injectStyles: true })
88+
.use(remarkRehype, { allowDangerousHtml: true })
89+
.use(rehypeStringify, { allowDangerousHtml: true })
90+
.process(markdown)
91+
92+
const outputWithStyles = String(fileWithStyles)
93+
assert.ok(outputWithStyles.includes('<style>'),
94+
'Styles should be injected when injectStyles is true')
95+
96+
// Test with injectStyles: false
97+
const fileWithoutStyles = await unified()
98+
.use(remarkParse)
99+
.use(remarkNotes, { injectStyles: false })
100+
.use(remarkRehype, { allowDangerousHtml: true })
101+
.use(rehypeStringify, { allowDangerousHtml: true })
102+
.process(markdown)
103+
104+
const outputWithoutStyles = String(fileWithoutStyles)
105+
assert.ok(!outputWithoutStyles.includes('<style>'),
106+
'Styles should NOT be injected when injectStyles is false')
107+
})
108+
109+
test('remark-notes: combining custom prefix with injectStyles false', async () => {
110+
const markdown = '> [!important]\n> Important message'
111+
112+
const file = await unified()
113+
.use(remarkParse)
114+
.use(remarkNotes, {
115+
classPrefix: 'alert',
116+
injectStyles: false
117+
})
118+
.use(remarkRehype, { allowDangerousHtml: true })
119+
.use(rehypeRaw)
120+
.use(rehypeStringify)
121+
.process(markdown)
122+
123+
const output = String(file)
124+
125+
// Should have prefix prepended to remark-note classes
126+
assert.ok(output.includes('class="alert-remark-note alert-remark-note-important"'),
127+
'Should use prefix prepended to remark-note classes')
128+
129+
// Should NOT have styles
130+
assert.ok(!output.includes('<style>'),
131+
'Should not inject styles')
132+
})
133+
134+
console.log('\n✅ All custom prefix tests completed!')

__tests__/styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test('remark-notes: styles should be automatically injected', async () => {
1919
const output = String(file)
2020

2121
assert.ok(output.includes('<style>'), 'Styles should be injected')
22-
assert.ok(output.includes('.remark-note'), 'CSS classes should be in injected styles')
22+
assert.ok(output.includes('[class*="remark-note-icon"]'), 'CSS attribute selectors should be in injected styles')
2323
})
2424

2525
test('remark-notes: styles should only be injected once', async () => {

0 commit comments

Comments
 (0)