This took me a little while to get the hang of because my source code didn’t maintain its formatting whenever I uploaded it to my blog. In order to get source code to format correctly, you need to use the “Text” tab in the “Add New Post” menu instead of the “Visual” tab in order for it to preserve tabs and spaces. It seems that, by default, the Visual tab’s behavior causes pastings of source code to remove or delete spaces and tabs. Here is a screenshot of where you should be when paste code in:
Once you’ve pasted it with correct formatting, just wrap your code in [code language=”X”] and [/code] tags, where the value of X is any one of the following values (representative of the language your code is written in and thus, the language you want your code to be parsed as):
- actionscript3
- bash
- clojure
- coldfusion
- cpp
- csharp
- css
- delphi
- erlang
- fsharp
- diff
- groovy
- html
- javascript
- java
- javafx
- matlab (keywords only)
- objc
- perl
- php
- text
- powershell
- python
- r
- ruby
- scala
- sql
- vb
- xml