1

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 ?

2
  • You mean syntax highlight? Commented Jun 30, 2017 at 21:18
  • like that "My First Node" is in red, and that whole text is in a code snippet. I want to know how to achieve this. Commented Jun 30, 2017 at 21:21

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your answer. I know about that ``` thing. But can I get custom colors by that table way?
It depends what flavor of markdown. On GitHub, I believe that you can use the table OR the syntax highlighting, not both.
This related comment might be of use to you: stackoverflow.com/a/36287428/8122577

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.