You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When exporting to SVG or HTML, rich-cli does not interpret ANSI escape codes from piped input. Instead of converting them into styled output, it writes the raw escape sequences directly into the file. This leads to broken exports where the ANSI codes appear as literal text or cause XML parsing errors.
should generate an SVG with "hello" in green. Instead, the file contains the raw ANSI codes, making the output unusable.
A solution could be to preprocess the input and convert ANSI sequences into Rich’s internal format before rendering. Adding a flag like --preprocess-ansi would ensure that exports correctly reflect the intended formatting.
This behavior is already possible in Python using rich.ansi.AnsiDecoder, as shown in this minimal script:
A similar approach within rich-cli would allow users to export properly formatted SVG or HTML files without losing ANSI colors. This would make exports consistent with Rich’s behavior in the terminal.
Would love to see this implemented—thanks for all the great work on rich! 🚀
The text was updated successfully, but these errors were encountered:
When exporting to SVG or HTML,
rich-cli
does not interpret ANSI escape codes from piped input. Instead of converting them into styled output, it writes the raw escape sequences directly into the file. This leads to broken exports where the ANSI codes appear as literal text or cause XML parsing errors.For example, running:
should generate an SVG with "hello" in green. Instead, the file contains the raw ANSI codes, making the output unusable.
A solution could be to preprocess the input and convert ANSI sequences into Rich’s internal format before rendering. Adding a flag like
--preprocess-ansi
would ensure that exports correctly reflect the intended formatting.This behavior is already possible in Python using
rich.ansi.AnsiDecoder
, as shown in this minimal script:A similar approach within
rich-cli
would allow users to export properly formatted SVG or HTML files without losing ANSI colors. This would make exports consistent with Rich’s behavior in the terminal.Would love to see this implemented—thanks for all the great work on
rich
! 🚀The text was updated successfully, but these errors were encountered: