Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've got a WordPress blog on WordPress.com. When posting something I'm including some sample Java code in the <code tags, is there any way I can have this formatted better? Such as syntax highlighting and line numbers etc?

An example of what I have is here, even though I have the code tags it doesnt seem to make it any more readable than normal text

Am I limited in choices as I've gone for the free option?

share|improve this question
    
I assume you mean wordpress.com as "the wordpress site". –  hakre Sep 4 '10 at 12:10
1  
@hakre: There you go again with the improper casing of the trademarked term WordPress. I know you think it's a statement but it makes you (and the site) look sloppy. –  MikeSchinkel Sep 4 '10 at 19:14
    
@MikeSchinkel: From what I see in the revision history, I never edited that answer. –  hakre Feb 3 '11 at 11:35
add comment

2 Answers

up vote 7 down vote accepted

wordpress.com supports code syntax-highliting. You can read all about it here: http://en.support.wordpress.com/code/posting-source-code/

for your specific example use:

[sourcecode language="java"]
package com.jameselsey.domain;

import java.util.ArrayList;
import java.util.List;
import com.google.android.maps.GeoPoint;
import android.app.Application;

/**
* This is a global POJO that we attach data to which we
* want to use across the application
* @author James Elsey
*
*/
public class GlobalState extends Application
{
private String testMe;

public String getTestMe() {
return testMe;
}
public void setTestMe(String testMe) {
this.testMe = testMe;
}
}
[/sourcecode]
share|improve this answer
    
You can use "lang" instead of "language" if you're into the whole brevity thing. –  Mr_Chimp Jun 15 '11 at 13:45
add comment

Yes you can. It's [code] *your code here* [/code] and you can even hint the language: [code lang="php"]<?php echo 'test'; ?>[/code].

This is the method I prefer (quick to write). There seem to be other ways as the following resource explains: Support: Code » Posting Source Code (wordpress.com)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.