Skip to content

Support for Colored/terminal escape codes #72

@ZedThree

Description

@ZedThree

Thanks for the nifty package, it's very cool! I'd love to be able to use it with Colored, but using coloured text in a table breaks the layout:

use colored::Colorize;
use termimad::{MadSkin};

fn main() {
    let header = "|:-|:-\n|**Example**|**Table**|\n|-|-";
    let col1 = "Colourful text".bright_red();
    let col2 = "breaks the table :(".bold();
    let rest = format!("| {col1} | {col2} |");
    let table = format!("{header}\n{rest}\n|-");

    MadSkin::default().print_text(&table);
}
$ cargo run
┌───────────────────────┬───────────────────────────┐
│Example                │Table                      │
├───────────────────────┼───────────────────────────┤
│Colourful text│breaks the table :(│
└───────────────────────┴───────────────────────────┘
Image

My guess is it's counting escape codes when it shouldn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions