#ansi #ansi-colors #convert-text #tui #ansi-term #colored-text #parser

ansi-to-tui

A library to convert ansi color coded text into ratatui::text::Text type from ratatui library

22 releases (9 stable)

5.0.0-rc.1 Jul 11, 2024
4.1.0 Jul 11, 2024
4.0.1 Feb 29, 2024
3.1.0 Jun 23, 2023
0.3.0 Jun 1, 2021

#42 in Command-line interface

Download history 4327/week @ 2024-03-31 4053/week @ 2024-04-07 6022/week @ 2024-04-14 8778/week @ 2024-04-21 8761/week @ 2024-04-28 8858/week @ 2024-05-05 9462/week @ 2024-05-12 9165/week @ 2024-05-19 6821/week @ 2024-05-26 2010/week @ 2024-06-02 4534/week @ 2024-06-09 4162/week @ 2024-06-16 3002/week @ 2024-06-23 2091/week @ 2024-06-30 2584/week @ 2024-07-07 2204/week @ 2024-07-14

10,195 downloads per month
Used in 29 crates (26 directly)

MIT license

24KB
462 lines

ansi-to-tui

drone build github build downloads

A nom parser to parse text with ANSI color codes and turn them into ratatui::text::Text.

For people still using tui-rs use version v2.* for people migrating to ratatui use version v3.* I recommend switching over to ratatui since tui-rs is currently unmaintained.

Color Supported Examples
24 bit \x1b[38;2;<R>;<G>;<B>m
8 bit \x1b[38;5;<N>m
4 bit \x1b[30..37;40..47m

Example

use ansi_to_tui::IntoText;
let buffer = std::fs::read("ascii/text.ascii").unwrap();
let output = buffer.into_text();

Dependencies

~7.5MB
~123K SLoC