Time pass by

Sunshine and rain of a developer

How to display source code in wordpress.com

Posted by vanguard33 on November 7, 2008

How do I post source code?

We have a shortcode you can wrap around source code that preserves its formatting and even provides syntax highlighting for certain languages, like so:
Wrap your code in these tags

..

Do not copy and paste this code – write it out. You can replace the language with one of the following language codes:

* cpp
* csharp
* css
* delphi
* html
* java
* jscript
* php
* python
* ruby
* sql
* vb
* xml

The language attribute is required! If we don’t have what you need pick the closest.
Code in between the tags will automatically be encoded for display, you don’t need to worry about HTML entities or anything.

We used the syntaxhighlighter Google Code project by Alex Gorbatchev to implement this feature.

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 )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.