Skip to content

Implement caption element for Slipstream#217

Merged
jverkoey merged 3 commits into
mainfrom
claude/implement-caption-element-011CUoceYvcc5UrBed1CCrHb
Nov 4, 2025
Merged

Implement caption element for Slipstream#217
jverkoey merged 3 commits into
mainfrom
claude/implement-caption-element-011CUoceYvcc5UrBed1CCrHb

Conversation

@jverkoey

@jverkoey jverkoey commented Nov 4, 2025

Copy link
Copy Markdown
Collaborator

Add the Caption element to represent table captions in HTML. The Caption element follows the W3CElement protocol pattern used by other table elements and provides a SwiftUI-like interface for adding captions to tables.

The implementation includes:

  • Caption.swift: Main element implementation using W3CElement protocol
  • CaptionTests.swift: Comprehensive tests covering empty blocks, text content, and attributes

Add the Caption element to represent table captions in HTML. The Caption
element follows the W3CElement protocol pattern used by other table elements
and provides a SwiftUI-like interface for adding captions to tables.

The implementation includes:
- Caption.swift: Main element implementation using W3CElement protocol
- CaptionTests.swift: Comprehensive tests covering empty blocks, text content, and attributes
Add a convenience initializer to Caption that accepts a String directly,
following the same pattern as H1 and other heading elements. This makes
the API more ergonomic for simple use cases.

Usage:
  Caption("Products and Prices")

Instead of:
  Caption { DOMString("Products and Prices") }

Updated documentation example to prefer the convenience initializer and
added test coverage for the new string literal initialization.
@jverkoey jverkoey enabled auto-merge (squash) November 4, 2025 22:25
Caption, like other table elements (TableBody, TableHeader, etc.), renders
with newlines and indentation. Updated test expectations to match this
behavior:
- withText(): expects multi-line output with newline before/after content
- withStringLiteral(): expects multi-line output with newline before/after content

This aligns with the rendering behavior of other W3CElement table components.
@jverkoey jverkoey merged commit 1fc88fe into main Nov 4, 2025
2 checks passed
@jverkoey jverkoey deleted the claude/implement-caption-element-011CUoceYvcc5UrBed1CCrHb branch November 4, 2025 22:36
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.

2 participants