Is there a way to properly indent and format code in comments made on Github pull requests ?
2 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
```
If you don't want to format your markdown code manually, you can, 6 years later (2018) use the brand new markdown toolbar (oct. 2018)
Pull request review comments in the ‘Conversation’ tab now have a text editing toolbar for quickly styling your comments and adding saved replies.
