Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting comments in Github Pull Requests

Tags:

github

Is there a way to properly indent and format code in comments made on Github pull requests ?

like image 530
nik7 Avatar asked Oct 07 '22 16:10

nik7


1 Answers

Fenced code blocks

Markdown converts text with four spaces at the front of each line to code blocks. GFM supports that, but we also support fenced blocks. Just wrap your code blocks in ``` and you won't need to indent manually to trigger a code block.

Syntax highlighting

We take code blocks a step further and add syntax highlighting if you request it. In your fenced block, add an optional language identifier and we'll run it through syntax highlighting. For example, to syntax highlight Ruby code:

```ruby
    require 'redcarpet'
    markdown = Redcarpet.new("Hello World!")
    puts markdown.to_html
```
like image 126
nik7 Avatar answered Oct 10 '22 02:10

nik7