为了使用简单的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
}
} …Run Code Online (Sandbox Code Playgroud)