#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

20 releases (8 stable)

4.0.1 Feb 29, 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

#44 in Command-line interface

Download history 1131/week @ 2024-01-05 1303/week @ 2024-01-12 1116/week @ 2024-01-19 1204/week @ 2024-01-26 1583/week @ 2024-02-02 1340/week @ 2024-02-09 1402/week @ 2024-02-16 1611/week @ 2024-02-23 1633/week @ 2024-03-01 2676/week @ 2024-03-08 6128/week @ 2024-03-15 4571/week @ 2024-03-22 4391/week @ 2024-03-29 4017/week @ 2024-04-05 4834/week @ 2024-04-12 7439/week @ 2024-04-19

21,399 downloads per month
Used in 24 crates (21 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

~7MB
~120K SLoC