首页 > 解决方案 > 使用 markdown 突出显示代码会生成内联代码块

问题描述

我试图在我的网站上突出显示Jekyll 生成的代码块。目前,我正在使用 ``` markdown 格式来突出显示代码。但它不起作用。它不是突出显示整个块,而是突出显示像这样的单个行 - 在此处输入图像描述

我也尝试使用 {% highlight %} 标签,但产生相同的结果。如果我使用 {% highlight linenos %},它似乎会以某种方式工作并产生一个块。

生成的代码是 -

<pre><code class="language-C#">public override void AwakeFromNib()
{ 
 base.AwakeFromNib();
 AttributedStringValue = new NSAttributedString(StringValue, new NSStringAttributes()
 { 
     // You can change the color of link after uncommenting the following 
     // ForegroundColor = NSColor.Red,
     UnderlineStyle = NSUnderlineStyle.Single.GetHashCode()
 }); 
    
 hoverarea = new NSTrackingArea(Bounds, NSTrackingAreaOptions.MouseEnteredAndExited | NSTrackingAreaOptions.ActiveAlways, this, null);
 AddTrackingArea(hoverarea);
 cursor = NSCursor.CurrentSystemCursor;
}
</code></pre>

我无法弄清楚为什么没有突出显示整个块。

编辑:添加生成上述结果的代码块 -

6. {: .lh-copy }Now we need to style the text field so that it looks like a hyperlink. To do this we override the AwakeFromNib() method as below - 
```C#
public override void AwakeFromNib()
{ 
    base.AwakeFromNib();
    AttributedStringValue = new NSAttributedString(StringValue, new NSStringAttributes()
    { 
        // You can change the color of link after uncommenting the following 
        // ForegroundColor = NSColor.Red,
        UnderlineStyle = NSUnderlineStyle.Single.GetHashCode()
    }); 
    
    hoverarea = new NSTrackingArea(Bounds, NSTrackingAreaOptions.MouseEnteredAndExited | NSTrackingAreaOptions.ActiveAlways, this, null);
    AddTrackingArea(hoverarea);
    cursor = NSCursor.CurrentSystemCursor;
}
```

标签: markdownjekyllsyntax-highlightinggithub-pages

解决方案


推荐阅读