How charmbracelet/glamour works
Glamour is a Go library for stylesheet-driven Markdown rendering to ANSI-compatible terminal output. Its principal workflow accepts Markdown through the public renderer API, parses it with Goldmark, maps Markdown nodes to renderable ANSI elements, and produces styled text. Distinct capabilities include syntax-highlighted code, links and table link footers, emoji, and selectable built-in or file-based styles. The graph reflects the excerpts and README; unsampled renderer internals are represented only where documented, so uncertain implementation links are omitted.
Main entry points: elements.go AST Element Mapping · glamour.go Term Renderer · baseelement.go Styled Primitives · styles.go Built-in Styles
Components 16
Renderer API
- Term Renderer
glamour.go
Markdown Rendering
- Goldmark Parser
- AST Element Mapping
ansi/elements.go - Styled Primitives
ansi/baseelement.go - Margin Layout
ansi/margin.go
Style Configuration
- Style Selection
glamour.go - Style Configurations
ansi/style.go - Built-in Styles
styles/styles.go
Rendering Features
- Code Blocks
ansi/codeblock.go - Chroma Highlighter
- Hyperlinks
ansi/link.go - Table Link Footers
ansi/table_links.go - URL Shortening
internal/autolink/autolink.go - Emoji Extension
Other components
- Go Application
- ANSI Output
Connections 17
- Go Application → Term Renderer: provides Markdown
README.md - Term Renderer → Goldmark Parser: parses Markdown
glamour.go - Goldmark Parser → AST Element Mapping: supplies AST
- AST Element Mapping → Styled Primitives: maps elements
ansi/elements.go - AST Element Mapping → Code Blocks: creates code blocks
ansi/elements.go - Code Blocks → Chroma Highlighter: highlights code
ansi/codeblock.go - AST Element Mapping → Hyperlinks: creates links
ansi/elements.go - AST Element Mapping → Table Link Footers: collects table links
ansi/elements.go - AST Element Mapping → URL Shortening: shortens URLs
ansi/elements.go - Table Link Footers → URL Shortening: shortens URLs
ansi/table_links.go - Term Renderer → Emoji Extension: enables extension
glamour.go - Term Renderer → Style Selection: applies options
glamour.go - Style Selection → Built-in Styles: selects defaults
glamour.go - Built-in Styles → Style Configurations: defines styles
styles/styles.go - Styled Primitives → ANSI Output: writes styled text
- Margin Layout → ANSI Output: formats output
- Term Renderer → ANSI Output: returns rendered text
README.md