From 92944fa4cca6a24fb75e104b88efc10b6d7ecfb1 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sun, 13 Aug 2023 14:01:57 -0600 Subject: [PATCH] strip ansi control characters (I hope) from output --- README.md | 2 -- package.json | 3 ++- src/index.ts | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b9d451f..8dea0d4 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,6 @@ The webpage is a bit basic. While this entire project doesn't need much complica ***If you have a large stack of containers, OR you have containers that contain a significant number of log entries, the page will not be available until all log entries are processed. This may take a minute or two to accomplish*** -Some containers use "special characters" that your terminal program interprets as color codes. These will show up in the logs as the control characters. This will be improved in future versions. - The page does not auto-scroll to the bottom. This will be improved in future versions. If a container SHOULD be running, but it is not, the webpage will not show it. This will be improved in future versions. diff --git a/package.json b/package.json index b26be2a..ac30ce2 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ }, "dependencies": { "jquery": "^3.7.0", - "socket.io-client": "^4.7.2" + "socket.io-client": "^4.7.2", + "strip-ansi": "^7.1.0" } } diff --git a/src/index.ts b/src/index.ts index b514141..e7321c2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import { io, Socket } from "socket.io-client"; +import stripAnsi from "strip-ansi"; declare const window: any; let containers: any = {}; @@ -103,7 +104,7 @@ window.show_logs = function (name: any) { }; function generate_log_element(log: any) { - return `

${log}

`; + return `

${stripAnsi(log)}

`; } function generate_li_element(name: String) {