How charmbracelet/glow works
Glow is a terminal Markdown reader with two principal routes: CLI rendering/paging and an interactive browser for local Markdown files. In the CLI, arguments become readable sources, which are rendered and displayed; the TUI discovers local files, lets users browse them, and opens documents in its pager. GitHub/GitLab README lookup, configuration, styling, and terminal text sizing are additional capabilities. The excerpts show key entry points and UI behavior; unsampled source limits some internal wiring, so undocumented links are omitted.
Main entry points: main.go CLI workflow · ui.go TUI coordinator · url.go README URL lookup · utils.go Render utilities
Components 19
CLI Reading
- CLI workflow
main.go - Source loading
main.go - Configuration command
config_cmd.go
Remote Sources
- README URL lookup
url.go - GitHub README fetch
github.go - GitLab README fetch
gitlab.go
Interactive Browser
- TUI coordinator
ui/ui.go - Local file discovery
ui/ui.go - Document browser
ui/stash.go - Document pager
ui/pager.go - Pager controls
ui/stashhelp.go
Rendering & Presentation
- Markdown rendering
main.go - Render utilities
utils/utils.go - Terminal text sizing
utils/textsize.go - Terminal UI styles
ui/styles.go - Style command
style.go
Other components
- Reader
- HTTP services
- Configured pager
Connections 22
- Reader → CLI workflow: provides input
README.md - CLI workflow → Source loading: loads source
main.go - Source loading → README URL lookup: resolves README
README.md - README URL lookup → GitHub README fetch: routes lookup
url.go - README URL lookup → GitLab README fetch: routes lookup
url.go - GitHub README fetch → HTTP services: requests README
github.go - GitLab README fetch → HTTP services: requests README
gitlab.go - CLI workflow → Markdown rendering: renders document
main.go - CLI workflow → Configured pager: runs pager
README.md - CLI workflow → TUI coordinator: starts browser
main.go - CLI workflow → Configuration command: offers config
main.go - Reader → TUI coordinator: browses files
README.md - TUI coordinator → Local file discovery: searches locally
ui/ui.go - TUI coordinator → Document browser: updates browser
ui/ui.go - TUI coordinator → Document pager: coordinates pager
ui/ui.go - Document pager → Render utilities: uses utilities
ui/pager.go - CLI workflow → Render utilities: formats code
main.go - CLI workflow → Terminal text sizing: sizes output
main.go - Render utilities → Terminal text sizing: marks headings
utils/utils.go - TUI coordinator → Terminal UI styles: creates styles
ui/ui.go - CLI workflow → Style command: supports style options
- Document browser → Pager controls: shows help