I'm commenting on a GitHub issue and would like to suggest an edit to code posted in a previous comment. How can I format my markdown to highlight code to be removed in red and code to be added in green, like in git commit change summaries?
I've done this before but maybe not in GitHub, so is this even possible?
The color is added by syntax highlighting a diff
. Therefore, create a code block with diff
as the "language":
```diff
Unchanged Line
- Removed Line
+ Added Line
```
Notice that unchanged lines should be indented by two spaces. removed lines should be prefixed by a hyphen and a space, and added lines should be prefixed by a plus sign and a space. If you are making complex changes, it may be best to use a diff
tool to create the diff.
Github will then run that code block through their syntax highlighter and color the lines for you. You can see an example here (also see the raw document).
Here's a screenshot of what that looks like: