How to insert source code in Google Docs or WordPress

For Google Docs like document, go to this website: http://colorer.sourceforge.net/php/ input what you want and select the proper language. The output is colored with nice style. Simply copy them into your document.

For wordpress, just wrap your code with tag

To accomplish the above, just wrap your code in these tags "sourcecode" directly in the “visual” edit interface (HTML is not necessary), most common languages are supported, like java, php, python, etc. The attributes for this tag are: language, For more: http://en.support.wordpress.com/code/posting-source-code/

A sample:

package org.myorg;

public class test {

    public static void main(String[] args) throws Exception {
        String arg = "Hello World!";
        System.out.println(arg);
    }
}
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