How to display line numbers using GitHub Flavored Markdown "code"?

derek picture derek · Mar 21, 2016 · Viewed 39.7k times · Source

I know I can use "code" in GitHub Flavored Markdown to highlight a code snippet. But I am not able to display line numbers for a snippet. Is there a way to do so?

```javascript
var s = "JavaScript syntax highlighting";
alert(s);
```

I want a line number to be put at the beginning of each line, like this:

1    var s = "JavaScript syntax highlighting";
2    alert(s);

Answer

denysdovhan picture denysdovhan · Mar 21, 2016

As you may noticed in Markdown Cheatsheet, GitHub does not show line numbers in code blocks.