Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsMay 30, 2026·3 min de lecture

Glamour — Stylesheet-Based Markdown Rendering for CLI Apps

A Go library from Charm for rendering markdown in terminal applications with customizable stylesheets, ANSI color support, and word wrapping.

Prêt pour agents

Staging sûr pour cet actif

Cet actif est d'abord staged. Le prompt copié demande à l'agent d'inspecter les fichiers staged avant d'activer scripts, config MCP ou config globale.

Stage only · 29/100Policy : staging
Surface agent
Tout agent MCP/CLI
Type
CLI Tool
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Glamour
Commande de staging sûr
npx -y tokrepo@latest install 1fdd44a8-5be0-11f1-9bc6-00163e2b0d79 --target codex

Stage les fichiers d'abord; l'activation exige la revue du README et du plan staged.

Introduction

Glamour is a Go library by Charmbracelet that renders Markdown documents as styled ANSI terminal output. It provides a stylesheet system for controlling colors, indentation, and formatting, making it easy to display rich text content in CLI applications without building custom rendering logic.

What Glamour Does

  • Converts Markdown to beautifully formatted ANSI terminal output
  • Applies configurable stylesheets for dark, light, and custom themes
  • Handles headings, code blocks, tables, lists, and links with color coding
  • Wraps text to fit terminal width automatically
  • Supports GitHub-Flavored Markdown including task lists and strikethrough

Architecture Overview

Glamour parses Markdown using the goldmark parser and then applies a style tree to produce ANSI-escaped output. Each Markdown element type (heading, paragraph, code block) maps to a style definition that controls foreground/background colors, margins, padding, and text decoration. The library outputs plain strings with embedded ANSI codes, compatible with any terminal emulator.

Self-Hosting & Configuration

  • Add Glamour to your Go project with go get github.com/charmbracelet/glamour
  • Use the glamour.Render() function for quick single-call rendering
  • Create a custom glamour.TermRenderer with a specific style for reuse
  • Choose from built-in styles: DarkStyle, LightStyle, AutoStyle, or NoTTYStyle
  • Define custom JSON stylesheets to match your application's branding

Key Features

  • Zero external dependencies beyond the Go standard library and goldmark
  • Word wrapping that respects terminal width and avoids mid-word breaks
  • Syntax highlighting for fenced code blocks via the chroma library
  • Emoji rendering with Unicode support in code and prose
  • Integration with other Charm tools like Bubble Tea and Lip Gloss

Comparison with Similar Tools

  • Rich (Python) — similar terminal rendering but Python-only, not a Go library
  • termimad (Rust) — Markdown rendering for Rust terminals, smaller feature set
  • mdcat — standalone CLI for rendering Markdown, not an embeddable library
  • Glow (Charm) — CLI Markdown viewer built on Glamour for end-user use
  • ANSI Markdown — various language-specific solutions without stylesheet support

FAQ

Q: Can I use Glamour in a Bubble Tea TUI application? A: Yes. Glamour output is plain ANSI text that integrates naturally with Bubble Tea views.

Q: Does Glamour support HTML inside Markdown? A: HTML tags are stripped by default. Glamour focuses on standard Markdown elements for terminal rendering.

Q: How do I handle long documents? A: Set a max width on the renderer and pipe output through a pager like less -R for scrollable viewing.

Q: Is there a way to disable colors? A: Use the NoTTYStyle or set GLAMOUR_STYLE=notty to produce plain uncolored output for piping.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires