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

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

     hljs.initHighlightingOnLoad();  

我需要显示下面的C#代码,

  

 
  ///  /// Main class of the project ///  class Program { ///  /// Main entry point of the program ///  /// Command line args static void Main(string[] args) { //Do stuff } }  

此代码添加在此.md文件中 , 此文件 显示在此处 。

除了

标签之外,所有内容都会被渲染。 荧光笔是否误解为普通HTML?

题:

开发人员如何确保在这种情况下使用Highlight.js显示包含

标签的

  

内容?

code HTML标记使用短语内容 ,这意味着它会将常规HTML标记(例如

视为常规HTML代码,因此会省略输出。

要避免此问题,您必须正确编码所有标记:

 
  /// <summary> /// Summary description for the function or property goes here /// </summary>  

Jekyll在板上突出显示标签和css( _sass/_syntax-highlighting.scss )。

 {% highlight csharp %} ///  /// Main class of the project ///  class Program { ///  /// Main entry point of the program ///  /// Command line args static void Main(string[] args) { //Do stuff } } {% endhighlight %} 

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