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

2019-03-11 11:49发布

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!

4条回答
家丑人穷心不美
2楼-- · 2019-03-11 12:00

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.

查看更多
该账号已被封号
3楼-- · 2019-03-11 12:09

Use the WP-Syntax plugin. To use it, you wrap the code with a pre tag with a language attribute. Consolidates the effort.

查看更多
ゆ 、 Hurt°
4楼-- · 2019-03-11 12:22

You can use Windows Live Writer to write post for your blog and use Steve Dunns live writer plugin.

查看更多
爷、活的狠高调
5楼-- · 2019-03-11 12:26

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).

查看更多
登录 后发表回答