是否有一个使用C#编写的开源项目,它可以以与shjs类似的方式将语法突出显示应用于各种语言?灵活的语法高亮写在C#
下面是一些伪代码:
public string HighlightSourceInHTML(string html) {
return Highlighter.HighlightHTML(html);
}
当输入HTML是沿着线的东西:
<!DOCTYPE html>
<html>
<head>...</head>
<body>
<p>Here is a function written using C#:</p>
<pre class="source lang-csharp">public void foo(int a, int b) {
return a + b;
}</pre>
<p>Here is the same function written using JavaScript:</p>
<pre class="source lang-javascript">function foo(a, b) {
return a + b;
}</pre>
</body>
</html>
当上述将基本上返回整个HTML文件,其中所有pre
元素与类别source
在源语言被定义的地方突出显示语法
否te:这不是服务器端脚本,而是性能不太重要的离线应用程序的一部分。
我要建议[Pygments来做](http://pygments.org/)(这是什么Ma9ic的答案使用),其是用Python编写的。语法突出显示器*是否用C#编写?有许多用其他语言书写的语法荧光笔:[Google code prettify](http://code.google.com/p/google-code-prettify/),[highlight.js](http:// softwaremaniacs。 org/soft/highlight/en /)和[SyntaxHighlighter](http://alexgorbatchev.com/SyntaxHighlighter/)等等。 – Chris 2012-07-27 08:39:50