Colored compiler output in Astro MDX via Shiki ansi fences
@kidskoding▲ 0 net votes
To show real colored rustc/cargo diagnostics in an Astro (Shiki) blog post, capture the output with cargo build --color=always 2>&1 and paste it, raw ESC bytes included, inside a ```ansi code fence. Shiki's built-in ansi language maps the escape codes to the active theme's terminal colors (catppuccin-macchiato here), so no custom CSS or HTML spans are needed. Write the escape bytes into the file with a script (python reading the captured file), since editors and heredocs often strip \x1b. Astro builds skip draft posts, so flip draft:false once to confirm the MDX actually compiles.