Github Markdown中的差异语法突出显示 [英] Diff syntax highlighting in Github Markdown
问题描述
我正在编写应使用Markdown在C#中解释代码的文档.
I'm writing documents that should explain code in C# using Markdown.
我使用```csharp
进行csharp突出显示.
I use the ```csharp
to get csharp highlighting.
有时我想使用粗体或其他内容突出显示代码中的特定内容.
I sometimes want to highlight something specific in the code using bold or anything.
我了解<pre>
等...但是它带走了我的csharp突出显示.
I know about <pre>
etc... but it takes away my csharp highlighting.
最佳情况-用某种方式突出显示```csharp
部分中的代码.
Best case scenario - some way to highlight code in the ```csharp
section.
下一个最好的事情-我可以将代码写为diff-使用+和-突出显示内容,但是如何告诉Github使用红色和绿色背景色突出显示diff语法?
Next best thing - I can write the code as diff - using + and - to highlight stuff, but how do I tell Github to highlight diff syntax with the red and green backcolor?
是否可以同时使用diff和csharp语法突出显示?
Is there a way to use both diff and csharp syntax highlighting?
推荐答案
在格式化代码时,Github的markdown支持diff.例如:
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!");
}
}
```
,它应该会给您您正在寻找的Diff外观 ,以红色突出显示已删除的内容,并以绿色突出显示已添加的内容.
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.
这篇关于Github Markdown中的差异语法突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!