0

I want to achieve something like this,

enter image description here

This is a screenshot from some digital ocean tutorial.

I want some colored variables using markdown in code snippets AND that header in which the file name is appearing. Is it possible ? If yes, then how ?

Luv33preet
  • 1,686
  • 7
  • 33
  • 66

1 Answers1

1

You can use tables containing inline code snippets.

In GitHub markdown:

| My Code                   |
|:-------------------------:|
| `int main() { return 0; }`| 

Renders as: preview

I hope this answered your question!

EDIT: There is also syntax highlighting, like YAML. To do that, you add the language after the ticks like so:

```bash
$ echo "hello world"
```

That will render as: syntax highlighting

Edit 2: Here is the link for the supported language highlighting keywords: https://github.com/github/linguist/blob/master/lib/linguist/languages.yml

  • Thanks for your answer. I know about that ``` thing. But can I get custom colors by that table way? – Luv33preet Jun 30 '17 at 21:28
  • It depends what flavor of markdown. On GitHub, I believe that you can use the table OR the syntax highlighting, not both. –  Jun 30 '17 at 21:33
  • This related comment might be of use to you: https://stackoverflow.com/a/36287428/8122577 –  Jun 30 '17 at 21:34