charmbracelet/glow · error
unable to render markdown: %w
Error message
unable to render markdown: %w
What it means
r.Render(content) runs the (possibly code-wrapped) markdown through glamour's goldmark-based ANSI renderer. It fails when the render pipeline errors - typically a malformed custom style that survives construction but breaks at render time, or an edge case in the content. With built-in styles this error is rare.
Source
Thrown at main.go:311
r, err := glamour.NewTermRenderer(
utils.GlamourStyle(style, isCode),
glamour.WithWordWrap(int(width)), //nolint:gosec
glamour.WithBaseURL(baseURL),
glamour.WithPreservedNewLines(),
)
if err != nil {
return fmt.Errorf("unable to create renderer: %w", err)
}
content := string(b)
ext := filepath.Ext(src.URL)
if isCode {
content = utils.WrapCodeBlock(string(b), ext)
}
out, err := r.Render(content)
if err != nil {
return fmt.Errorf("unable to render markdown: %w", err)
}
// display
switch {
case pager || cmd.Flags().Changed("pager"):
pagerCmd := os.Getenv("PAGER")
if pagerCmd == "" {
pagerCmd = "less -r"
}
fields, err := shell.Fields(pagerCmd, os.Getenv)
if err != nil || len(fields) == 0 {
return fmt.Errorf("unable to parse PAGER command: %s", pagerCmd)
}
c := exec.Command(fields[0], fields[1:]...) //nolint:gosec
c.Stdin = strings.NewReader(out)
c.Stdout = os.Stdout
if err := c.Run(); err != nil {View on GitHub (pinned to e3970c813d)
Solutions
- Retry with a built-in style: glow -s dark <file>
- Bisect the markdown: split the file to find the block that triggers the failure
- Rebuild the custom style from the current default style template for your glamour version
- Report upstream at charmbracelet/glamour if a minimal repro fails with built-in styles
Defensive patterns
Strategy: try-catch
Try / catch
out, err := r.Render(content)
if err != nil {
fb, ferr := glamour.NewTermRenderer(glamour.WithStandardStyle("dark"))
if ferr == nil {
if out2, rerr := fb.Render(content); rerr == nil {
out = out2
err = nil
}
}
}
if err != nil { return fmt.Errorf("unable to render markdown: %w", err) } Prevention
- Soak-test custom styles against real-world documents
- Fall back to a standard style when custom-style rendering fails
- Update or regenerate style files when bumping glamour versions
When it happens
Trigger: Custom style missing required entries at render time; pathological or extremely large markdown exhausting memory; glamour version incompatible with the style file's keys; embedded content triggering a renderer error path.
Common situations: After upgrading glow/glamour with old custom styles, rendering documents with unusual constructs (huge tables, deeply nested blocks), styles copied from a different glamour major version.
Related errors
AI-assisted analysis of charmbracelet/glow@e3970c813d (2026-08-15).
Data as JSON: /api/errors/90ece146d3ce3a9d.
Report an issue: GitHub.