Dr.Avalanche
Dr.Avalanche

Reputation: 2006

github markdown - preserve Linux terminal output

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:

enter image description here

Upvotes: 7

Views: 6272

Answers (4)

Yatharth Agarwal
Yatharth Agarwal

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

mwag
mwag

Reputation: 4065

Have you tried ```none?

```none
no colors applied
```

?

Upvotes: 0

kangear
kangear

Reputation: 2613

1

```console
foo@bar:~$ whoami
foo
```

enter image description here

2

```shell-session
foo@bar:~$ whoami
foo
```

from: https://stackoverflow.com/a/49004070/2193455

Upvotes: 4

Will
Will

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

Related Questions