#ansi #ascii #tui #parser

ansi-to-tui

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

19 releases (7 stable)

4.0.0 Feb 15, 2024
3.1.0 Jun 23, 2023
3.0.0 Mar 21, 2023
2.0.2 Mar 21, 2023
0.3.0 Jun 1, 2021

#47 in Command-line interface

Download history 729/week @ 2023-11-06 894/week @ 2023-11-13 888/week @ 2023-11-20 832/week @ 2023-11-27 707/week @ 2023-12-04 779/week @ 2023-12-11 742/week @ 2023-12-18 807/week @ 2023-12-25 1344/week @ 2024-01-01 1300/week @ 2024-01-08 1253/week @ 2024-01-15 1297/week @ 2024-01-22 1670/week @ 2024-01-29 1628/week @ 2024-02-05 1568/week @ 2024-02-12 1834/week @ 2024-02-19

6,777 downloads per month
Used in 21 crates (18 directly)

MIT license

23KB
447 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
~132K SLoC