显示C#<总结>使用Highlight.js杰基尔Github的页面标签 [英] Showing C# <summary> tags in Jekyll Github pages using Highlight.js

查看:289
本文介绍了显示C#<总结>使用Highlight.js杰基尔Github的页面标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要使用简单的HTML 的成功表明 codeS,我加的 Highlight.js 在我的杰基尔基于博客这是在 Github的页面

\r
\r

<! - 加入Highlight.js https://highlightjs.org/下载/ - >\r
<链接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

\r
\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">

    /// &lt;summary&gt;
    /// Summary description for the function or property goes here
    /// &lt;/summary&gt;

</code>
</pre>

这篇关于显示C#&LT;总结&gt;使用Highlight.js杰基尔Github的页面标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆