Diff syntax highlighting in Github Markdown

前端 未结 2 455
一整个雨季
一整个雨季 2021-02-01 11:50

I\'m writing documents that should explain code in C# using Markdown.

I use the ```csharp to get csharp highlighting.

I sometimes want to highlight

2条回答
  •  孤街浪徒
    2021-02-01 12:04

    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.

提交回复
热议问题