WordPress source code posting

I blogged about this before, but since I still haven’t managed to resuscitate my old blog, I’m just going to have to post it again. And maybe here it has some added relevance, since I’m interested in how it might work within RapidWeaver.

How to post source code within wordpress.

Unfortunately, I don’t get the results I was hoping for:

[sourcecode language=”python”]
# Open text file (comma delimited x/y coords):
f = open(‘points.txt’,”r”)
lines = f.readlines()

xi = []
yi = []

for line in lines:
fields = line.split(‘,’)
xi.append(float(fields[0]))
yi.append(float(fields[1]))
[/sourcecode]

Not good – even though I downloaded the syntax highlighter plugin. But even when I just use the plain old “code” tags, I still get a silly result. But I just went into my RapidWeaver’s styles.css document, and changed the hard-coded definition for the code tag, so that the font was courier, font size was dark grey, and the font size was a bit smaller. And here’s the result:

# Open text file (comma delimited x/y coords):
f = open('points.txt',"r")
lines = f.readlines()

xi = []
yi = []

for line in lines:
fields = line.split(',')
xi.append(float(fields[0]))
yi.append(float(fields[1]))

Looks like the color change didn’t take. I’ll have to look at this later…

Leave a Reply

Your email address will not be published. Required fields are marked *