使用Highlight.js在Jekyll Github页面中显示C#<summary>标签

xam*_*mir 3 javascript c# highlight jekyll github-pages

为了使用简单的HTML成功显示代码,我在我的基于Jekyll的博客中添加了Highlight.js,该博客在Github页面上运行

<!--Add Highlight.js https://highlightjs.org/download/ -->
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/highlight.min.js"></script>

<!-- Using Highight.js https://highlightjs.org/usage/-->
<script>
  hljs.initHighlightingOnLoad();
</script>
Run Code Online (Sandbox Code Playgroud)

我需要显示下面的C#代码,即:<pre> <code class="csharp">和之间的所有内容</code> </pre>:

<pre>
<code class="csharp">

/// <summary>
/// Main class of the project
/// </summary>
class Program
{
    /// <summary>
    /// Main entry point of the program
    /// </summary>
    /// <param name="args">Command line args</param>
    static void Main(string[] args)
    {
        //Do stuff
    }
}

</code>
</pre>
Run Code Online (Sandbox Code Playgroud)

此代码是在加入该.md文件被显示在这里.

除了<summary>标签之外,一切都在渲染.荧光笔是否将其误解为普通HTML?

题:

如何开发人员确保之间的一切<pre> <code class="csharp">和</code> </pre>包括<summary>标签使用显示Highlight.js在这样的情况下?

Dav*_*uel 7

Jekyll在_sass/_syntax-highlighting.scss板上有高亮标记和css().

{% highlight csharp %}
/// <summary>
/// Main class of the project
/// </summary>
class Program
{
    /// <summary>
    /// Main entry point of the program
    /// </summary>
    /// <param name="args">Command line args</param>
    static void Main(string[] args)
    {
        //Do stuff
    }
}
{% endhighlight %}
Run Code Online (Sandbox Code Playgroud)

这开箱即用,无需客户端过载.所有Pygment词法分析器都在这里.