Skip to content

Conversation

@corylanou
Copy link
Member

@corylanou corylanou commented Jan 4, 2026

Summary

  • Add native <youtube> element for embedding YouTube videos in Hype markdown documents
  • Validate video IDs (11 alphanumeric characters with - and _)
  • Render responsive iframe embeds with accessibility attributes
  • Added documentation to quickstart guide
  • Added integration test example

Usage

# My Video Post

Here's an embedded video:

<youtube id="dQw4w9WgXcQ"></youtube>

With an optional title for accessibility:

<youtube id="dQw4w9WgXcQ" title="Introduction to Error Handling"></youtube>

Output

The element renders as:

<div class="youtube-embed">
  <iframe src="https://www.youtube.com/embed/VIDEO_ID"
    title="Video Title"
    frameborder="0"
    allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
    referrerpolicy="strict-origin-when-cross-origin"
    allowfullscreen></iframe>
</div>

Files Changed

  • youtube.go - YouTube element implementation
  • youtube_test.go - Unit tests
  • hype.go - Register YouTube parser
  • testdata/json/youtube.json - JSON test fixture
  • docs/quickstart/hype.md - Documentation for YouTube embedding
  • testdata/auto/youtube/hype.md - Integration test input
  • testdata/auto/youtube/hype.gold - Integration test expected output

Test plan

  • Test_YouTube_MarshalJSON - JSON serialization
  • Test_YouTube_String - HTML rendering with custom title
  • Test_YouTube_String_DefaultTitle - Default title handling
  • Test_YouTube_ValidationError_MissingID - Error on missing ID
  • Test_YouTube_ValidationError_InvalidID - Error on malformed IDs
  • Test_YouTube_VideoID - Video ID accessor
  • Test_YouTube_Title - Title accessor
  • Test_YouTube_MD - Markdown export
  • Test_Testdata_Auto_Modules/youtube - Integration test
  • All tests pass with race detector

Closes #49

🤖 Generated with Claude Code

Add native support for embedding YouTube videos using the <youtube> element.
Users can now embed videos directly in markdown with:

  <youtube id="VIDEO_ID"></youtube>
  <youtube id="VIDEO_ID" title="My Video Title"></youtube>

Features:
- Validates YouTube video IDs (11 alphanumeric characters)
- Renders responsive iframe embeds with proper attributes
- Default title "YouTube video player" if not specified
- Full JSON serialization support for document analysis

Documentation:
- Added YouTube section to docs/quickstart/hype.md
- Added integration test in testdata/auto/youtube/

Closes #49

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@corylanou corylanou force-pushed the issue-49-feature-request-youtube-video-embedding-support branch from 3446818 to 01b9d43 Compare January 4, 2026 02:10
@corylanou corylanou merged commit a4d418f into main Jan 4, 2026
@corylanou corylanou deleted the issue-49-feature-request-youtube-video-embedding-support branch January 4, 2026 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: YouTube video embedding support

2 participants