如何显示在网页的格式码 [英] How to display formatted code in webpage
问题描述
我试图写博客,我想在一个整洁格式化的方式来显示C#代码。有没有办法给它。我喜欢做它的确切方式堆栈溢出不包括颜色。 :)
I am trying to write a blog and I want to display c# code in a neat formatted way. Is there a way to it. I like to do it exactly the way stack overflow does including color. :)
推荐答案
您的好几个选项的这里,但我会建议不要使用JavaScript格式化程序。如果用户脚本禁用,你仍然要代码好看。
You have quite a few options here, but I would recommend against using a JavaScript formatter. If a user has scripts disabled, you still want the code to look good.
如果您正在使用Visual Studio,生产力电动工具加载有复制HTML选项:结果
的 http://blogs.msdn.com/b/kirillosenkov/archive/2010/06/07/copy-code-in-html-format-with-visual -Studio-2010.aspx
乔恩斯基特提供给公众使用代码格式:结果
< A HREF =http://csharpindepth.com/CodeFormatterTool.aspx> http://csharpindepth.com/CodeFormatterTool.aspx
如果你正在使用PHP,称作GeSHi是一个很好的服务器端选项:结果
http://qbnz.com /荧光笔/
我相信,栈溢出使用谷歌代码,美化:结果
< A HREF =http://code.google.com/p/google-code-prettify/> http://code.google.com/p/google-code-prettify/
是SyntaxHighlighter的另一个很好的客户端解决方案:结果
的 http://alexgorbatchev.com/SyntaxHighlighter/
这篇关于如何显示在网页的格式码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!