Reputation: 2006
Is there a way to preserve the colors of a terminal output when creating github flavored markdown? For example if I want to include some examples of a terminal including the results of ls
which would have different colors for directories, executable etc?
image for example:
Upvotes: 7
Views: 6272
Reputation: 4564
Usually, Markdown is parsed into HTML. You can try use <span style="color: red;">...</span>
tags and your parser might let that through.
Note that you wouldn't be able to use HTML tags inside a code block. You would have to implement the code blocks themselves with HTML and CSS, and at that point it kind of stops bring worth it.
Even worse, sometimes Markdown to HTML parsers will strip all or most HTML tags. If you're posting on GitHub, I think this would be the case. Then your only option would be to embed an image.
Upvotes: 2
Reputation: 2613
```console
foo@bar:~$ whoami
foo
```
```shell-session
foo@bar:~$ whoami
foo
```
from: https://stackoverflow.com/a/49004070/2193455
Upvotes: 4
Reputation: 2191
Short answer: No.
Longer answer: If you're running you're own MD parser and are willing to edit it, you could modify it to add in some sort of markers for indicating colors. It's not out of the box, and you'd need to manually add the markers where needed.
Upvotes: 0