github charmbracelet/glamour v2.1.0

46 minutes ago

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!

Fixed

Docs

Other stuff


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.

Don't miss a new glamour release

NewReleases is sending notifications on new releases.