Meta 2: Pasting Code In WordPress

Who knew blogging had such a learning curve?

Today I’m just trying to paste code in my blog and have it look like maybe something that a fellow programmer might attempt to read for any reason other than pity. Personally I can’t stand code that’s been formatted into a pretty, proportional-width font. It feels like trying to use Microsoft Word as your IDE.

Frankly I can’t imagine anything more terrifying. So to spare myself that embarrassment, let’s give it a shot by heading to the only post editor on the WordPress site that isn’t likely to leave us tearing our hair out in frustration.

Username [Hover] Blog Name [Hover] New Post

My first instinct was to invoke the “Kitchen Sink” (Yes it’s really called the Kitchen Sink) and use “Preformatted” line styles for my code, but that just won’t work.  In fact, it’s completely awful! Every newline becomes a new preformatted code block separated by a white margin. You can remove the white margins between lines by deleting the newlines and then adding them back in with the return key, because that makes a lot of goddamn sense, but there doesn’t appear to be any other easy way.

But wait, I notice another option: “Visual” and “Text”, on the top right of the post editing area. These two tabs aren’t present on the other, weaker “New Post” sections.

In “Text” the editor is all fixed-width and formatting tags are visible. Amazingly, there’s a code button!

@interface ViewController : UIViewController {
NSString *state;

Wow. That doesn’t look half bad.

WordPress might be usable after all…


Leave a Reply

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

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

Google photo

You are commenting using your Google 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