Conversation
- Add lib/images.ts for image processing and rendering - Support Kitty graphics protocol for native image display in Ghostty - Fall back to ANSI block rendering for other terminals - Use placeholder-based approach to avoid marked escaping Kitty sequences - Remove styleImage from renderers (replaced by images.ts)
- Resolve reference-style images ![alt][ref] to inline syntax - Handle linked images [](url) as single unit - Resolve reference-style linked images [![alt][imgref]][linkref] - Skip SVG files (can't be rendered by terminal-image) - Remove "(failed to load)" from fallback output - Show link URL instead of image URL for linked image fallbacks - Update tests for new image handling
- Remove replaceImageBlocks (not compatible with Kitty protocol) - Add 5s timeout for remote image fetches - Strip reference definition lines after resolving - Update tests to use prepareImages directly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Adds inline image rendering to glowm, the terminal markdown renderer. Images display directly in the terminal using the Kitty graphics protocol (for Ghostty/Kitty) or ANSI block characters as fallback.
Key Changes
New
lib/images.tsmodule handles all image processingterminal-imagefor other terminalsReference-style markdown support
![alt][ref]images resolved to inline syntax before processing[![alt][imgref]][linkref]linked images handled as single unitsImage presentation
Design Decisions
The Kitty protocol writes directly to stdout rather than returning a string. To avoid escape sequences being mangled by the markdown parser, images are replaced with null-byte placeholders before
markedprocesses the document. After rendering, the output is streamed segment by segment, with actual image data written when placeholders are encountered.For linked images like
[](link), the fallback displays the outer link URL rather than the image URL since badges are typically SVGs (which can't render) and the link destination is more useful information.Overall Flow
sequenceDiagram participant M as Markdown Input participant R as resolveReferenceImages participant P as prepareImages participant X as marked() participant O as outputWithImages participant T as Terminal M->>R: Raw markdown R->>P: Resolved references P->>P: Replace images with placeholders P->>X: Markdown with placeholders X->>O: Rendered HTML-ish string O->>T: Stream text segments O->>T: Write Kitty/ANSI images at placeholdersExample