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. 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. I’ve tried wrapping the [sourcecode] tags in <pre>’s, but then the formatter doesn’t work correctly.
Any help would be much appreciated. I’ve spent about 10 hours trying to come up with a robust solution, and no luck.
Cheers!
See the blog post that I wrote on this exact question, which explains how to use SyntaxHighlighter and fix TinyMCE so that it doesn’t mess up your white space or tags (you can either customize one of the tinymce files in WordPress, or use a plugin to do it for you).
Use the WP-Syntax plugin. To use it, you wrap the code with a pre tag with a language attribute. Consolidates the effort.
If Client-Side (JavaScript) Syntax Highlighting is also an option, I can recommend google-code-prettify, which works quite well. Only a little Code escaping is needed to make it zero-friction for me as an author, as I detailed in a posting.
You can use Windows Live Writer to write post for your blog and use Steve Dunns live writer plugin.