Ensure correct compiler error styling and strip ANSI escape sequences. #810
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The compiler error output that's injected into the page hard-codes a background color of white, but didn't hard-code a corresponding text color. If the page had set a default text color that was too close to white, it would be hard or impossible to read without selecting the text on the page.
This change addresses this by hard-coding a text color of black, ensuring it can be read.
It also goes a step further and improves the display when dealing with ANSI escape sequences in the error output, making it difficult to read through or copy/paste meaningful results. We now apply a common regex for stripping away any typical ANSI escape sequences we should expect in such output, leaving behind only the plain text content.
Testing
Triggered a compilation error on a page that had a default text color of white, with a compiler that had many ANSI escape sequences present (rollup.js). I verified that I could now read the text and without the distraction of the escape sequences.
Ran
tox
. Unit tests pass.