diff --git a/scripts/js/gravity.js b/scripts/js/gravity.js index 265732469..c32da5a14 100644 --- a/scripts/js/gravity.js +++ b/scripts/js/gravity.js @@ -92,12 +92,26 @@ function parseLines(ta, str) { var lines = str.split(/(?=\r)/g); for (let i = 0; i < lines.length; i++) { + if (lines[i].search(/\[[\d;]+m/) !== -1) { + // This line contains a color escape sequence - replace + lines[i] = lines[i] + .replaceAll(/\[(\d;)?[39]0m/g, "") + .replaceAll(/\[(\d;)?[39]1m/g, "") + .replaceAll(/\[(\d;)?[39]2m/g, "") + .replaceAll(/\[(\d;)?[39]3m/g, "") + .replaceAll(/\[(\d;)?[39]4m/g, "") + .replaceAll(/\[(\d;)?[39]5m/g, "") + .replaceAll(/\[(\d;)?[39]6m/g, "") + .replaceAll("", "") + .replaceAll("", "") + .replaceAll("", ""); + } if (lines[i][0] === "\r") { // This line starts with the "OVER" sequence. Replace them with "\n" before print lines[i] = lines[i].replaceAll("\r", "\n").replaceAll("\r", "\n"); // Last line from the textarea will be overwritten, so we remove it - ta.text(ta.text().substring(0, ta.text().lastIndexOf("\n"))); + ta.html(ta.html().substring(0, ta.html().lastIndexOf("\n"))); } // Append the new text to the end of the output