glow detects whether it’s writing to a real terminal. When called from a script or subprocess (like Python’s subprocess.run), it sees no TTY and strips all ANSI color codes, you get plain text.
Fix it with two env vars:
CLICOLOR_FORCE=1 COLORTERM=truecolor glow --style dark file.md
CLICOLOR_FORCE=1 tells color-aware CLI tools to emit color regardless of TTY detection. COLORTERM=truecolor tells glow to use 24-bit color instead of falling back to 8-color mode.
In Python:
import subprocess, os
env = {**os.environ, "CLICOLOR_FORCE": "1", "COLORTERM": "truecolor"}
result = subprocess.run(["glow", "--style", "dark", "file.md"],
capture_output=True, text=True, env=env)
This came up while building a curl-friendly personal site that pre-renders Markdown to ANSI at build time.