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

Add a renderer for log files that can render ansi colours #673

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

rebkwok
Copy link
Contributor

@rebkwok rebkwok commented Sep 25, 2024

Convert the text of the log file to HTML using ansi2html, which converts ANSI colour codes to css classes so we get the colour formatting from the original log.

It produces a full HTML file, which isn't what we want to display. We just extract the <pre> tag which contains the log content, and the <style> tag which contains the relevant inline css.

Before:
Screenshot from 2024-09-25 18-08-11

After:
Screenshot from 2024-09-25 18-07-32

Convert the text of the log file to HTML using ansi2html, which
converts ANSI colour codes to css classes so we get the colour
formatting from the original log.

It produces a full HTML file, which isn't what we want to display.
We just extract the <pre></pre> tag which contains the log content,
and the <style> which contains the relevant inline css.
Copy link
Contributor

@evansd evansd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh brilliant! Thanks for picking this up and glad it doesn't take all that much code (though I'm sure there was some faff getting it working).

@rebkwok
Copy link
Contributor Author

rebkwok commented Sep 26, 2024

There was actually surprisingly little faff to get it working 🙂

@rebkwok rebkwok merged commit c92ed33 into main Sep 26, 2024
10 checks passed
@rebkwok rebkwok deleted the log-formatter branch September 26, 2024 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants