Publishing Code With MS Word: Frustration

I’m using WordPress as the host for this blog because I’ve heard good things about it and because MW Word appears to support blog editing and uploading. This sounds like a huge advantage relative to the way I’ve used Blogger and Moveable Type, a painful combination of editing HTML by hand in emacs and hassling with someone’s idea of “helpful” automatic blog formatting software. In theory, support for composing and posting with a modern WYSIWYG document editor, should make the process pretty painless.

One aspect of publishing with Blogger that’s driven other code bloggers to distraction, is the difficulty of simply inserting a code example. I’m hoping that the following test case makes it to WordPress unscathed:

<Application xmlns=”>

<Label text=”Hello World/>


That’s a “preformatted HTML” paragraph pasted directly from FlexBuilder, so it’s picked up the pretty printing attributes.


OK, that totally did not work. Here’s what the MXML example above looked like in Word:


Looking at the generated HTML using the WordPress editor reveals that the Word has not simply created an HTML <pre>…</pre> element, but instead has stood on its head with spans and styles to try and reproduce exactly what I’d pasted. Except that it did not work. Not even close on the spacing front, since I didn’t include all of those extra newlines, and the indentation, which is rather important for code, was just dropped. I’m beginning to feel hateful.


Twenty minutes spent trying to modify the “HTML Preformatted” style yields no better than this, based on changing the parent style to “No Spacing”.



<Application xmlns="">



    <Label text="Hello World"/>




As you can see, now the indentation is right.  But WordPress has gone completely bonkers with the newlines.   And to add insult to injury the WordPress “preview” of this masterpiece doesn’t match the horror you’re looking at now.  The preview led me to believe that they’d only doubled the number of newlines from the original.   This reminds of the old story about the traveler who asked his hotel not to leave little bars of soap in the bathroom, since he’d brought his own.   The difference here is: that was a funny story. 

Here’s what this looks like (selected) in Word:

Notice the difference? All attempts to improve the situation by fiddling with the line spacing properties in the paragraph format dialog produce no improvement. At this point I’m feeling genuine loathing for Word. Why should creating a document with little more than paragraphs, a couple of pictures, and God forbid, a CODE EXAMPLE, be so painful?

I guess this nonsense will reduce me to quoting and inserting code examples into the running text as a by-hand post processing step, using the WordPress editor. Given the computing resources that (in theory) I have at my disposal, this seems beyond dumb. It’s like walking into a biologist’s laboratory, seeing millions of dollars worth of the latest gleaming technology, only to find the biologist trying to dissect a mouse with a hatchet.

<Application xmlns="">
    <Label text="Hello World"/>

The text above was inserted by hand.


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

%d bloggers like this: