简体   繁体   English

在WordPress中格式化C#的最佳方法是什么?

[英]What's best way to format C# in WordPress?

Hey bloggers out there! 嘿博主在那里! I've created Wordpress blog that I am hosting myself, and I'm having the hardest time figuring out the best way to add C# snippets to my blog. 我已经创建了自己托管的Wordpress博客,而且我正在努力找到将C#代码段添加到我博客的最佳方式。 What do you all use? 你们都用什么?

I'm currently using the "SyntaxHighlighter Evolved" plugin, and it works great for the most part - the only problem is that switching back to the Visual Editor removes all of the whitsepace padding. 我目前正在使用“SyntaxHighlighter Evolved”插件,它在大多数情况下都很有用 - 唯一的问题是切换回Visual Editor会删除所有的whitsepace填充。 I've tried wrapping the [sourcecode] tags in <pre>'s, but then the formatter doesn't work correctly. 我已经尝试在<pre>中包装[sourcecode]标签,但格式化程序无法正常工作。

Any help would be much appreciated. 任何帮助将非常感激。 I've spent about 10 hours trying to come up with a robust solution, and no luck. 我花了大约10个小时试图提出一个强大的解决方案,没有运气。 Cheers! 干杯!

请参阅在这个问题上博客文章 ,其中解释了如何使用SyntaxHighlighter并修复TinyMCE,以便它不会弄乱您的空白区域或标签(您可以在Wordpress中自定义一个tinymce文件,或使用插件为你做)。

Use the WP-Syntax plugin. 使用WP-Syntax插件。 To use it, you wrap the code with a pre tag with a language attribute. 要使用它,请使用带有language属性的pre标记包装代码。 Consolidates the effort. 巩固努力。

If Client-Side (JavaScript) Syntax Highlighting is also an option, I can recommend google-code-prettify , which works quite well. 如果客户端(JavaScript)语法突出显示也是一个选项,我可以推荐google-code-prettify ,这非常有用 Only a little Code escaping is needed to make it zero-friction for me as an author, as I detailed in a posting . 正如我在帖子中详细说明的那样 ,只需要一点代码转义就可以让我作为作者对其进行零摩擦。

您可以使用Windows Live Writer为您的博客撰写帖子并使用Steve Dunns live writer插件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM