Languages
[Edit]
EN

Markdown - how to create code lines (syntax highlighting - github, dev.to, stackoverflow)

0 points
Created by:
Dirask Community
5460

In this article, we would like to show you how to create code lines in markdown.

Below examples present how to create:

  • Inline code
  • Code blocks┬áwith highlighting┬á

1. Creating inline code

To create inline code in markdown you need to wrap your code into backticks ``.

Example:

`var result = 1`

Result:

Markdown - inline code example (markdown)
Markdown - inline code example

2. Code blocks with highlighting 

To create a code block with highlighting you need to wrap your code with three backticks (```) and specify the programming language in the first line.

Example:

```javascript

const data = {
    user: {
        username: 'john',
        password: 'Secret$$'
    }
};
```

Result from github.com:

Markdown - highlighted JavaScript code example on github.com
Markdown - highlighted JavaScript code example on github.com

Result from dev.to:

Markdown - highlighted JavaScript code example on dev.to
Markdown - highlighted JavaScript code example on dev.to

Result from stackoverflow.com:

Markdown - highlighted JavaScript code example on stackoverflow.com
Markdown - highlighted JavaScript code example on stackoverflow.com

References

Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join