First, instead of specifying the programming language, use diff after the backticks. Then at the beginning of any lines of code you want to show as removed, add a - . At the beginning of any lines of code you want to show as added, add a + . I have used this in tons of my coding tutorials, such as this one.
Many Markdown processors support syntax highlighting for fenced code blocks. This feature allows you to add color highlighting for whatever language your code was written in. To add syntax highlighting, specify a language next to the backticks before the fenced code block.
To link to multiple lines of highlighted code, select your first line of code and then CTRL+SHIFT click on the last line of code you want to highlight. Notice the URL is now appended with a range of line numbers (e.g. https://github.com/…/functions.php#L117-L148).
Github's markdown supports diff when formatting code. For example:
```diff
public class Hello1
{
public static void Main()
{
- System.Console.WriteLine("Hello, World!");
+ System.Console.WriteLine("Rock all night long!");
}
}
```
Output:
and it should give you the Diff looks you are looking for, highlighting in red what has been removed and in green what has been added.
Salvador's response is correct, however, I found out that you should add the diff header to the code snippet in order to highlight it:
``` diff
diff --git a/filea.extension b/fileb.extension
index d28nd309d..b3nu834uj 111111
--- a/filea.extension
+++ b/fileb.extension
@@ -1,6 +1,6 @@
-oldLine
+newLine
```
I hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With