Source formatting in WordPress

To enable code snippets in WordPress these plugins can be used:

You can now use the sourcecode tag to insert code blocks. With these two plugins you can use the HTML editor as well as the visual editor.

For use in the visual editor first enable the Kitchen Sink (button on toolbar) and click the Paste as Plain Text button on the toolbar. You get a dialog in which you can insert your plain text source code, when you are done editing select Insert and you’re done.


The code:

if (true) {

yields the following result:

if (true) {

Supported languages

The following languages are supported by the plugins: (<Language name>-<lang value>):

  • Bash — bash, sh
  • C++ — cpp, c, c++
  • C# — c#, c-sharp, csharp
  • CSS — css
  • Delphi — delphi, pascal
  • Java — java
  • JavaScript — js, jscript, javascript
  • PHP — php
  • Python — py, python
  • Ruby — rb, ruby, rails, ror
  • SQL — sql
  • VB — vb, vb.net
  • XML/HTML — xml, html, xhtml, xslt
Monday, December 8th, 2008 WordPress No Comments