Skip to content

Commit 57b1f22

Browse files
committed
Remove remark-youtube plugin, now handled by social embeds component
1 parent 6f267da commit 57b1f22

14 files changed

Lines changed: 260 additions & 338 deletions

File tree

‎package-lock.json‎

Lines changed: 6 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@
199199
"remark-stringify": "^11.0.0",
200200
"remark-supersub": "^1.0.0",
201201
"remark-video": "^0.10.0",
202-
"remark-youtube": "^1.3.3",
203202
"resend": "^6.7.0",
204203
"retext": "^9.0.0",
205204
"retext-smartypants": "^6.2.0",

‎src/content/articles/demo/index.mdx‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -443,18 +443,6 @@ Embed videos in HTML5 markup that are in the `/public` folder
443443
/videos/sample-video-1.mp4
444444
:::
445445

446-
### remark-youtube
447-
448-
```markdown
449-
[Example Video 1](https://youtu.be/enTFE2c68FQ)
450-
451-
[Example Video 2](https://www.youtube.com/watch?v=enTFE2c68FQ)
452-
```
453-
454-
[Example Video 1](https://youtu.be/enTFE2c68FQ)
455-
456-
[Example Video 2](https://www.youtube.com/watch?v=enTFE2c68FQ)
457-
458446
## Components
459447

460448
### Includes from [other Markdown]('/articles/demo') files

‎src/content/test-fixtures/markdown/index.mdx‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,6 @@ Inline `attr-code`[[.attr-code data-qa="remark-attr-code"]] should have attribut
8181
/videos/sample-video-1.mp4
8282
:::
8383

84-
## YouTube (remark-youtube)
85-
86-
[Example Youtube Video 1](https://youtu.be/enTFE2c68FQ)
87-
88-
[Example Youtube Video 2](https://www.youtube.com/watch?v=enTFE2c68FQ)
89-
9084
## Supersub (remark-supersub)
9185

9286
Subscript: a~i~

‎src/lib/config/markdown.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ Object.defineProperty(remarkDirective, 'name', { value: 'remarkDirective' })
8585
import remarkVideo, { type Config as RemarkVideoConfig } from 'remark-video'
8686
Object.defineProperty(remarkVideo, 'name', { value: 'remarkVideo' })
8787

88-
import remarkYoutube from 'remark-youtube'
89-
Object.defineProperty(remarkYoutube, 'name', { value: 'remarkYoutube' })
90-
9188
import remarkMarkPlus from '../markdown/plugins/remark-mark-plus'
9289
Object.defineProperty(remarkMarkPlus, 'name', { value: 'remarkMarkPlus' })
9390

@@ -403,8 +400,6 @@ export const markdownConfig: Partial<MdxOptions> = {
403400
* Converts: -->, <--, <=>, 1/2, 2 x 4, +-, etc.
404401
*/
405402
remarkReplacements,
406-
/** Convert YouTube URLs into embedded iframes */
407-
remarkYoutube,
408403
/** Smart quotes, dashes, and ellipsis */
409404
[remarkSmartypants, remarkSmartypantsConfig],
410405
],

‎src/lib/markdown/__tests__/e2e/rehype-tailwind-classes.spec.tsx‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ This is a paragraph with some text.
6161
- List item two
6262
- List item three
6363
64+
## Horizontal rule
65+
66+
---
67+
68+
## Table
69+
70+
| Col A | Col B |
71+
| --- | --- |
72+
| A1 | B1 |
73+
| A2 | B2 |
74+
6475
## Code
6576
6677
Here is some \`inline code\`.
@@ -130,6 +141,31 @@ describe('Layer 3: E2E - rehypeTailwindClasses', () => {
130141
expect(link?.getAttribute('href')).toBe('https://example.com')
131142
})
132143

144+
it('should add Tailwind classes to horizontal rules', () => {
145+
const { container } = render(<MarkdownOutput html={html} />)
146+
147+
const hr = container.querySelector('hr')
148+
expectHasAtLeastOneValidClassAttribute(hr)
149+
})
150+
151+
it('should add Tailwind classes to tables (table/th/td)', () => {
152+
const { container } = render(<MarkdownOutput html={html} />)
153+
154+
const table = container.querySelector('table')
155+
expectHasAtLeastOneValidClassAttribute(table)
156+
157+
const header = container.querySelector('th')
158+
expectHasAtLeastOneValidClassAttribute(header)
159+
160+
const cell = container.querySelector('td')
161+
expectHasAtLeastOneValidClassAttribute(cell)
162+
163+
// Ensure table structure and content remain intact.
164+
expect(container.textContent).toContain('Col A')
165+
expect(container.textContent).toContain('A1')
166+
expect(container.textContent).toContain('B2')
167+
})
168+
133169
it('should not emit malformed class tokens anywhere', () => {
134170
const { container } = render(<MarkdownOutput html={html} />)
135171
const withClass = Array.from(container.querySelectorAll('[class]'))

‎src/lib/markdown/__tests__/e2e/remark-youtube.spec.tsx‎

Lines changed: 0 additions & 48 deletions
This file was deleted.

‎src/lib/markdown/__tests__/integration/rehype-tailwind-astro.spec.ts‎

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,39 @@
11
import { describe, it, expect } from 'vitest'
2+
import { JSDOM } from 'jsdom'
23
import { rehypeTailwindClasses } from '@lib/markdown/plugins/rehype-tailwind'
34
import { processWithAstroSettings, processWithFullPipeline } from '@lib/markdown/helpers/processors'
45

6+
function splitClassTokens(value: string | null): string[] {
7+
if (!value) return []
8+
return value
9+
.split(/\s+/g)
10+
.map(token => token.trim())
11+
.filter(Boolean)
12+
}
13+
14+
function isWellFormedCssClassToken(token: string): boolean {
15+
if (!token) return false
16+
if (/[\s"'`{};]/.test(token)) return false
17+
18+
for (const char of token) {
19+
const code = char.charCodeAt(0)
20+
if (code <= 0x1f || code === 0x7f) return false
21+
}
22+
23+
return true
24+
}
25+
26+
function expectHasAtLeastOneValidClassAttribute(element: Element | null, name: string): void {
27+
if (!element) throw new Error(`Expected to find element: ${name}`)
28+
29+
const classAttr = element.getAttribute('class')
30+
const tokens = splitClassTokens(classAttr)
31+
expect(tokens.length).toBeGreaterThan(0)
32+
tokens.forEach(token => {
33+
expect(isWellFormedCssClassToken(token)).toBe(true)
34+
})
35+
}
36+
537
describe('rehype-tailwind-classes (Layer 2: With Astro Pipeline)', () => {
638
describe('Tailwind classes with GFM', () => {
739
it('should add classes to GFM tables', async () => {
@@ -134,8 +166,12 @@ const x = 1;
134166
expect(html).toContain('<table')
135167
expect(html).toContain('<code')
136168
expect(html).toContain('<blockquote')
137-
expect(html).toContain('border-l-4')
138169
expect(html).toContain('<ul')
170+
171+
const document = new JSDOM(html).window.document
172+
expectHasAtLeastOneValidClassAttribute(document.querySelector('blockquote'), 'blockquote')
173+
expectHasAtLeastOneValidClassAttribute(document.querySelector('table'), 'table')
174+
expectHasAtLeastOneValidClassAttribute(document.querySelector('pre'), 'pre')
139175
})
140176

141177
it('should preserve existing classes through pipeline', async () => {

0 commit comments

Comments
 (0)