Saturday, March 23, 2013

How to post Source code on a wordpress blog!

WordPress Logo

Since 1st March 2013, I have gotten busy learning coding on Codecademy.com and not only have I started learning to code, but I have also started posting my codes in Codecademy Forums as well as on My Wordpress Blog.

Why I chose wordpress instead of blogger to start this new blog?

I don't know, I just find wordpress somewhat cleaner and simple in terms of looks and feel. Its like iOS in the world of Mobile Operating Systems in comparison to blogger which is more like Android in the world of mobile operating system.

While one gives you utmost control over your blog and its inside elements (blogger.com), the other (wordpress.com) just keeps things simple and efficient rather than focusing on giving you a great deal of options to do one particular thing.
People have told me to try wordpress instead of blogger for quite some time as I like to blog about things, but I have always ignored and stayed upon with blogger. Now I am with blogger but also with wordpress to try and evaluate how things work there in comparison to blogger.

Coming back to our topic....

If you want to post source code on a wordpress blog, this is what you need to use:

[code language = "css"]
your code here
[/code]

the Language element
"css"
could be any of the below mentioned languages:

The language (or lang) parameter controls how the code is syntax highlighted. The following languages are supported:

  • 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

If the language parameter is not set, it will default to "text" (no syntax highlighting).

Code in between the source code tags will automatically be encoded for display, you don't need to worry about HTML entities or anything.

For more details on posting source code on Wordpress.com blogs, please visit Wordpress Support > Posting Source Code

Meanwhile, don't forget to visit my Wordpress blog: Learner's Learning Experiences
Google+