Blog

[Tip] How to add syntax highlighting to wordpress.com blog

Hum..

I’m a new blogger on wordpress.com. My blog is primarily share my experience about programming.

At the first, I intended to post a entry about “dot dot dot notation in C++”, but I was so surprise because I didn’t know how to highlight my code. And of course, I tried to install a syntax highlighting plugin to do this. But…

After an half-hour researching, I found that this host blogging doesn’t support me to install any plug-in. That was a nightmare.

I had been continuing searching for an half-hour again and fortunately, I found this page:

http://en.support.wordpress.com/code/posting-source-code/

It say that: “While WordPress.com doesn’t allow you to use potentially dangerous code on your blog, there is a way to post source code for viewing. We have created a shortcode you can wrap around source code that preserves its formatting and even provides syntax highlighting for certain languages, like so:

[sourcecode="your_programming_language"]
// Your code
[sourcecode]

With your_programming_language is any language signature listed bellow.

It’s clearly to understand, let’s take an example now:

// Your C# code
Console.WriteLine("Hello C#");

Awesome, now, let’s take your eyes for all language that you can highlight as bellow:

  • 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

Enjoy and hope that help you  save a lot of time.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s