显示C#&LT;总结&gt;使用Highlight.js杰基尔Github的页面标签 [英] Showing C# <summary> tags in Jekyll Github pages using Highlight.js
问题描述
要使用简单的HTML 的成功表明 codeS,我加的 Highlight.js 在我的杰基尔基于博客这是在 Github的页面
&LT;! - 加入Highlight.js https://highlightjs.org/下载/ - &GT;\r
&LT;链接rel =stylesheet属性HREF =// cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/styles/default.min.css\">\r
&LT;脚本的src =// cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/highlight.min.js\"></script>\r
\r
&LT;! - 使用Highight.js https://highlightjs.org/usage/-->\r
&LT;脚本&GT;\r
hljs.initHighlightingOnLoad();\r
&LT; / SCRIPT&GT;
\r
我需要显示下方的 C#code 即℃之间一切; pre&GT; &LT; code类=CSHARP&GT;
和&LT; / code&GT; &LT; / pre&GT;
:
&LT; pre&GT;
&LT; code类=CSHARP&GT;///&LT;总结&gt;
/// Main类项目
///&LT; /总结&gt;
类节目
{
///&LT;总结&gt;
///程序的主要入口点
///&LT; /总结&gt;
///&LT; PARAM NAME =ARGS&GT;命令行参数&LT; /参数&GT;
静态无效的主要(字串[] args)
{
//做东西
}
}&LT; / code&GT;
&LT; / pre&GT;
这code在<一加href=\"https://github.com/xameeramir/xameeramir.github.io/blob/master/_posts/2015-11-22-vs-documentation.md\"相对=nofollow>这个 .MD
文件是的这里显示。
一切都越来越呈现,除了 &LT;总结&gt;
标签。的 误解它作为普通的HTML荧光笔?的
问:
如何开发人员确保℃之间一切; pre&GT; &LT; code类=CSHARP&GT;
和&LT; / code&GT; &LT; / pre&GT;
包括 &LT;总结&gt;
是使用显示标签 Highlight.js 在这样的情况下?
的 code
HTML标记用途的措词内容这意味着它将把普通的HTML标签,如&LT;总结&gt;
作为常规HTML code,因此省略了输出。
要避免这个问题,你必须正确地连接code所有标签:
&LT; pre&GT;
&LT; code类=CSHARP&GT; ///&放大器; LT;总结和放大器; GT;
///的功能或属性摘要介绍到这里
///&放大器; LT; /总结和放大器; GT;&LT; / code&GT;
&LT; / pre&GT;
To show codes successfully with simple HTML, I have added Highlight.js in my Jekyll based blog which is running on Github pages
<!--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>
I need to show the below C# code i.e. everything between <pre> <code class="csharp">
and </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>
This code is added in this .md
file which is displayed here.
Everything is getting rendered, except <summary>
tags. Is the Highlighter misunderstanding it as normal HTML?
Question:
How do a developer make sure that everything between <pre> <code class="csharp">
and </code> </pre>
including that <summary>
tag is displayed using Highlight.js in such scenarios?
The code
HTML Tag uses Phrasing Content which means it will treat regular HTML Tags such as <summary>
as regular HTML Code and therefore omits the output.
To avoid this problem you'd have to properly encode all tags:
<pre>
<code class="csharp">
/// <summary>
/// Summary description for the function or property goes here
/// </summary>
</code>
</pre>
这篇关于显示C#&LT;总结&gt;使用Highlight.js杰基尔Github的页面标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!