Support ANSI coloring in code blocks
It would be great if the following code block would support ANSI coloring:
[30m Black Text
[31m Red Text
[32m Green Text
[33m Yellow Text
[34m Blue Text
[35m Purple Text
[36m Cyan Text
[37m White Text
I tried txt, cmd, bash, shell but none seem to support this (yet..). This would be awesome for sharing log snippets and other console output.
I explicitly only want it in code blocks and not in regular markdown as I don't think it coloring must not be part of the formatting.
Maybe via for example the syntax keyword ansi if it should not be applied to all but I guess it makes sense to apply to all shell related formatters.
Related:
- bot closed https://github.com/github/markup/issues/1538
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
So, people are showing positive emojis but no response/triage from GitHub. Any chance this will be added? I understand not all ansi commands can be supported but coloring should be pretty easy.
Is maybe https://github.com/github-linguist/linguist a better repo?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Would absolutely love to see this! Unfortunately, I suspect it might need to be implemented somewhere else, based on the README:
This library is the first step of a journey that every markup file in a repository goes on before it is rendered on GitHub.com:
github-markupselects an underlying library to convert the raw markup to HTML. See the list of supported markup formats below.- The HTML is sanitized, aggressively removing things that could harm you and your kin—such as script tags, inline-styles, and
classoridattributes.- Syntax highlighting is performed on code blocks. See github/linguist for more information about syntax highlighting.
- The HTML is passed through other filters that add special sauce, such as emoji, task lists, named anchors, CDN caching for images, and autolinking.
- The resulting HTML is rendered on GitHub.com.
Please note that only the first step is covered by this gem — the rest happens on GitHub.com.
In other words, if markup were to automatically convert \e[32mERROR\e[0m to something like <span class="ansi-red">ERROR</span>, it wouldn't matter because:
- The sanitization step would remove the
classattribute - GitHub's CSS would need to be updated to include appropriate ANSI color/etc. classes. The current syntax highlighting classes are not appropriate for this, since they are not organized around colors, but rather the semantic meaning of a particular token (e.g.
pl-sis used for string literals, and happens to be blue).
So it sounds like this would need to be implemented somewhere in the vicinity of steps 3-5 (but also not within linguist since it doesn't actually output HTML 😞)
Edit Though I suppose this could be implemented in markup if 1. GitHub explicitly added CSS classes for ANSI colors and 2. explicitly whitelisted their usage in its sanitization logic. That would also generally solve this issue, since people could then use those classes outside of code blocks 🥳
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
not solved
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.