From 6e03d29f8527fee17eeab80f348581db89fe434b Mon Sep 17 00:00:00 2001 From: rascul Date: Wed, 22 Jun 2022 20:17:42 -0500 Subject: [PATCH] convert ansi colors to html and html escape stuff --- Cargo.lock | 32 ++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/client/mudlet.rs | 2 ++ 3 files changed, 35 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 674fde0..667a373 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -263,6 +263,17 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "ansi-to-html" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ee82de0545b181a17cbdef44fce80ecaf394e001da7ea279008bf2e0944bee" +dependencies = [ + "once_cell", + "regex", + "thiserror", +] + [[package]] name = "askama_escape" version = "0.10.3" @@ -1163,6 +1174,7 @@ dependencies = [ "actix-files", "actix-multipart", "actix-web", + "ansi-to-html", "chrono", "clap", "futures-util", @@ -1341,6 +1353,26 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" +[[package]] +name = "thiserror" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "time" version = "0.1.44" diff --git a/Cargo.toml b/Cargo.toml index 0d4ad62..1f1d8a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ edition = "2021" actix-files = "0.6.0" actix-multipart = "0.4.0" actix-web = "4.0.1" +ansi-to-html = { version = "0.1.0", features = ["lazy-init"] } chrono = { version = "0.4.19", features = ["serde"] } clap = { version = "3.1.18", features = ["derive"] } futures-util = "0.3.21" diff --git a/src/client/mudlet.rs b/src/client/mudlet.rs index e13c065..e6d65ad 100644 --- a/src/client/mudlet.rs +++ b/src/client/mudlet.rs @@ -1,5 +1,6 @@ use std::ops::Range; +use ansi_to_html::convert_escaped; use serde_json::{Map, Value}; type Result = std::result::Result>; @@ -76,6 +77,7 @@ pub fn parse_log(raw: &Vec) -> Result { } let text: String = String::from_utf8_lossy(&text_chunk).into(); + let text: String = convert_escaped(&text)?; let mut bm: Map = Map::new(); bm.insert("delta".into(), delta.into());