Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gravity update: Handle color escape sequences #3191

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion scripts/js/gravity.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,26 @@
var lines = str.split(/(?=\r)/g);

for (let i = 0; i < lines.length; i++) {
if (lines[i].search(/\[[\d;]+m/) !== -1) {

Check warning on line 95 in scripts/js/gravity.js

View check run for this annotation

codefactor.io / CodeFactor

scripts/js/gravity.js#L95

Unexpected control character(s) in regular expression: \x1b. (no-control-regex)
// This line contains a color escape sequence - replace
lines[i] = lines[i]
.replaceAll(/\[(\d;)?[39]0m/g, "<span class=\"log-gray\">")

Check warning on line 98 in scripts/js/gravity.js

View check run for this annotation

codefactor.io / CodeFactor

scripts/js/gravity.js#L98

Unexpected control character(s) in regular expression: \x1b. (no-control-regex)
.replaceAll(/\[(\d;)?[39]1m/g, "<span class=\"log-red\">")

Check warning on line 99 in scripts/js/gravity.js

View check run for this annotation

codefactor.io / CodeFactor

scripts/js/gravity.js#L99

Unexpected control character(s) in regular expression: \x1b. (no-control-regex)
.replaceAll(/\[(\d;)?[39]2m/g, "<span class=\"log-green\">")

Check warning on line 100 in scripts/js/gravity.js

View check run for this annotation

codefactor.io / CodeFactor

scripts/js/gravity.js#L100

Unexpected control character(s) in regular expression: \x1b. (no-control-regex)
.replaceAll(/\[(\d;)?[39]3m/g, "<span class=\"log-yellow\">")

Check warning on line 101 in scripts/js/gravity.js

View check run for this annotation

codefactor.io / CodeFactor

scripts/js/gravity.js#L101

Unexpected control character(s) in regular expression: \x1b. (no-control-regex)
.replaceAll(/\[(\d;)?[39]4m/g, "<span class=\"log-blue\">")

Check warning on line 102 in scripts/js/gravity.js

View check run for this annotation

codefactor.io / CodeFactor

scripts/js/gravity.js#L102

Unexpected control character(s) in regular expression: \x1b. (no-control-regex)
.replaceAll(/\[(\d;)?[39]5m/g, "<span class=\"log-purple\">")

Check warning on line 103 in scripts/js/gravity.js

View check run for this annotation

codefactor.io / CodeFactor

scripts/js/gravity.js#L103

Unexpected control character(s) in regular expression: \x1b. (no-control-regex)
.replaceAll(/\[(\d;)?[39]6m/g, "<span class=\"log-cyan\">")

Check warning on line 104 in scripts/js/gravity.js

View check run for this annotation

codefactor.io / CodeFactor

scripts/js/gravity.js#L104

Unexpected control character(s) in regular expression: \x1b. (no-control-regex)
.replaceAll("", "</span>")
.replaceAll("", "<span class=\"text-bold\">")
.replaceAll("", "<span class=\"text-underline\">");
}
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
Expand Down
Loading