We have some limitations when we are hosting our blogs in WordPress.com with free plan.We can’t install many plugins to our blog, we can able to install only the limited plugins which is provided by the WordPress.com.

As tech guy, who write some awesome blogs about some technologies and want to highlight some source code on the blog they can’t simply add any plugin to the site :(.

But don’t worry, WordPress won’t let you down on this. Yes, WordPress.com will support some special shortcode which will help you in highlighting your source code.

code – is the shortcode which is supported by the WordPress.com.

#button {
    font-weight: bold;
    border: 2px solid #fff;
}

Code shortcode will support many languages for highlighting.

Those are;

  • actionscript3
  • bash
  • clojure
  • coldfusion
  • cpp
  • csharp
  • css
  • delphi
  • diff
  • erlang
  • fsharp
  • go
  • groovy
  • html
  • java
  • javafx
  • javascript
  • latex
  • matlab
  • objc
  • perl
  • php
  • powershell
  • python
  • r
  • ruby
  • scala
  • sql
  • text
  • vb
  • xml

There are more configuration options available.

  • autolinks (true/false) — Makes all URLs in your posted code clickable. Defaults to true.
  • collapse (true/false) — If true, the code box will be collapsed when the page loads, requiring the visitor to click to expand it. Good for large code posts. Defaults to false.
  • firstline (number) — Use this to change what number the line numbering starts at. It defaults to 1.
  • gutter (true/false) — If false, the line numbering on the left side will be hidden. Defaults to true.
  • highlight (comma-seperated list of numbers) — You can list the line numbers you want to be highlighted. For example “4,7,19”.
  • htmlscript (true/false) — If true, any HTML/XML in your code will be highlighted. This is useful when you are mixing code into HTML, such as PHP inside of HTML. Defaults to false and will only work with certain code languages.
  • light (true/false) — If true, the gutter (line numbering) and margin (see below) will be hidden. This is helpful when posting only one or two lines of code. Defaults to false.
  • padlinenumbers (true/false/integer) — Allows you to control the line number padding. true will result in automatic padding, false will result in no padding, and entering a number will force a specific amount of padding.
  • title (string) — Set a label for your code block. Can be useful when combined with the collapse parameter.

Example:

 #button { font-weight: bold; border: 2px solid #fff; } 
#button { 
    font-weight: bold;
    border: 2px solid #fff;
}

More info @ WordPress.com