Repository navigation
Pictures, please!
Glamour can now show images! Right in the terminal, right where they sit in your Markdown. Links got a cleaner look, too, and rendering got faster along the way.
Images
Images now render inline using the Kitty graphics protocol or Sixel. PNG, JPEG, GIF and SVG are all supported, and SVG even handles rgba() colors (thank @CLHatch).
r, _ := glamour.NewTermRenderer(
glamour.WithAutoStyle(),
glamour.WithImageProtocol(ansi.ImageProtocolKitty),
glamour.WithMaxImageSize(80, 20),
)Images are off by default, so nothing changes until you ask for them. Without a protocol, images keep rendering as styled text and links, just like before.
Images in TUIs
Building a full-screen app with Bubble Tea? Use ansi.ImageProtocolKittyPlaceholders. Images are placed with Unicode placeholders, so they survive cell-based renderers and scroll along with the text without being sent again. Write the commands from GraphicsCommands() to the terminal before showing the document.
Safe by default
Remote images stay off until you turn them on with WithRemoteImages(). Fetching them shares your reader's IP with the image's host, much like a tracking pixel. When they're off, Glamour adds a short note after the image URL. Change it, or remove it, with WithRemoteImageNotLoadedNote().
Huge images are skipped before they're decoded, so a giant file can't eat all your memory. Set your own limit with WithMaxImagePixels().
Prettier links 🔗
Show only the link text, underlined and clickable, with the URL tucked away:
glamour.WithHyperlinkMode(ansi.HyperlinkModeInline)The default stays link text followed by the URL.
Big thanks to everyone who contributed to this release! 💘
Have a great, picture-worth week,
Charm XX ☄️
Changelog
New!
- a91c74f: feat: hyperlink mode (#603) (@andrinoff)
- e8e818d: feat: image display (#598) (@andrinoff)
Fixed
- 010543c: fix(ansi): always resolve relative URL (#639) (@heaths)
- 796d313: fix(ansi): build the chroma style per render instead of registering it once (#634) (@janearc)
- d51d81f: fix(ansi): support rgba() colors in SVG images (#663) (@CLHatch)
- f71347d: fix: decode HTML entities inside links (#635) (@andrinoff)
Docs
- 9fd8fa0: docs(readme): update godoc link to /v2 (@andreynering)
- 0edb652: docs: add install and v2 upgrade info (#665) (@andrinoff)
Other stuff
- c81971c: ci: bump up and down the deps (#661) (@andrinoff)
- d0a7199: ci: sync dependabot config (#600) (@charmcli)
- bec8f2d: perf(ansi): build the padding and indent cells once (@taciturnaxolotl)
- 8c9050c: perf(ansi): forward whole lines through the indent and padding writers (@taciturnaxolotl)
- 2faf2f4: perf(ansi): size the render buffer and drop the unused margin wrap writer (@taciturnaxolotl)
- e673700: v2.1.0 (@andrinoff)
Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.
