|
1 | 1 | import { describe, it, expect } from 'vitest' |
2 | 2 | import { rehypeTailwindClasses } from '@lib/markdown/plugins/rehype-tailwind' |
3 | | -import { processWithAstroSettings } from '@lib/markdown/helpers/processors' |
| 3 | +import { processWithAstroSettings, processWithFullPipeline } from '@lib/markdown/helpers/processors' |
4 | 4 |
|
5 | 5 | describe('rehype-tailwind-classes (Layer 2: With Astro Pipeline)', () => { |
6 | 6 | describe('Tailwind classes with GFM', () => { |
@@ -63,6 +63,8 @@ describe('rehype-tailwind-classes (Layer 2: With Astro Pipeline)', () => { |
63 | 63 |
|
64 | 64 | expect(html).toContain('<a') |
65 | 65 | expect(html).toContain('https://example.com') |
| 66 | + expect(html).toContain('hover:decoration-content-active') |
| 67 | + expect(html).toContain('focus-visible:outline-none') |
66 | 68 | }) |
67 | 69 | }) |
68 | 70 |
|
@@ -151,5 +153,21 @@ Content text |
151 | 153 | expect(html).toContain('<h1') |
152 | 154 | expect(html).toContain('Content text') |
153 | 155 | }) |
| 156 | + |
| 157 | + it('should not apply generic link classes to heading anchors', async () => { |
| 158 | + const markdown = ` |
| 159 | +## Components |
| 160 | +
|
| 161 | +Paragraph with a [regular link](https://example.com) |
| 162 | + `.trim() |
| 163 | + |
| 164 | + const html = await processWithFullPipeline(markdown) |
| 165 | + |
| 166 | + // Heading anchors are created by rehype-autolink-headings and should be styled via its config. |
| 167 | + expect(html).toContain('class="heading-anchor') |
| 168 | + // Regular links should not be marked as heading anchors. |
| 169 | + expect(html).toContain('href="https://example.com"') |
| 170 | + expect(html).not.toMatch(/href="https:\/\/example\.com"[^>]*class="[^"]*heading-anchor/) |
| 171 | + }) |
154 | 172 | }) |
155 | 173 | }) |
0 commit comments