Whenever it is a long time I inserted some code in a post in this WordPress blog, when I have to do it again I do the same mistake … so it is worth to write a post for me and may be for you too!! 😉
The possible language
(or lang
) parameter controls are supported, as stated in this WordPress post:
- actionscript3
- bash
- clojure
- coldfusion
- cpp
- csharp
- css
- delphi
- diff
- erlang
- fsharp
- go
- groovy
- html
- java
- javafx
- javascript
- latex (you can also render LaTeX)
- matlab (keywords only)
- objc
- perl
- php
- powershell
- python
- r
- ruby
- scala
- sql
- text
- vb
- xml
We both know that there are some strings (e.g. [sourcecode language=”csharp”] Here your C# code [/sourcecode]) you have to add before and after the lines of code you want to add in your page in order to have it well indented properly … BUT, if it does not work properly when you see the page, what we have to remember too is to check in the Text tab if some <span> were automatically added by the editor and, in that case, correct command strings (and possibly also the code!) being in the Text tab (and not in the Visual one) … otherwise that escaped command strings will be shown as a simple lines of text in the page, as it is in the following:
[sourcecode language=”csharp”] Here your C# code [/sourcecode]
instead of what you would like, that is:
Here your C# code
Even adding some formatting feature like, for example, Italicizing some text (as in the following), can break the command feature you added and the related tag will be shown (e.g. the <em>…</em> in the case of Italicization):
<em>int Here your code</em>

WRONG WAY: if you go to the Text tab you could see that commands were possibly escaped and the code (you possibly paste) contains a lot of not useful <span> tags.
If you write the code correctly from the Text tab, even simply going to the Visual tab you can already see the code inside a grayed box (saying that you did the insertion in the right way!!), even thought the commands line are still visible and only seeing the page will give you the final view formatting.