From 36846264c91ecc8c19789e9d95944cf978caebae Mon Sep 17 00:00:00 2001 From: emilylime Date: Wed, 4 Sep 2024 09:35:49 +0300 Subject: [PATCH] Temporarily work around https://github.com/luser/strip-ansi-escapes/issues/20 --- src/main.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index a5fe10a..87fe1e3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,10 +9,6 @@ struct Args { /// The input path. If unset, stdin is used. input: Option, - /// Whether the input should be formatted to be Discord-compatible. - #[clap(short, long)] - discord: bool, - /// Wrap the output in a Discord-flavoured-markdown–style ANSI codeblock. #[clap(short, long, overrides_with = "_no_discord")] discord: bool, @@ -112,7 +108,9 @@ fn main() -> Result<()> { &input }; - if args.strip_ansi { + // If the input doesn't contain escape sequences, avoid processing it because strip-ansi-escapes + // also strips tabs unfortunately. (https://github.com/luser/strip-ansi-escapes/issues/20) + if args.strip_ansi && stripped.contains('\x1B') { input = strip_ansi_escapes::strip_str(stripped); stripped = &input; }