Archive for March, 2009

Round 3: Windows Live Writer, Plugin: Fail

March 25, 2009

I was advised to give Windows Live Writer (WLW) one more try, by adding a free plugin that made it easier to insert code examples.

I’ve gone to http://gallery.live.com/ and taken a look at the Windows Live Writer extensions for inserting code examples in blogs.   I decided to try Code snippet Plugin since it had been updated recently and there were loads of positive reviews.

Here’s my three line MXML example again:

   1: <Application xmlns="http://ns.adobe.com/mxml/2009">

   2:     <Label text="Hello World"/>

   3: </Application>

On the upside, inserting my code “snippet” was pretty painless.   The old fashioned line printer style presentation is nice and the JavaScript pretty-printing works fine for MXML.  On the down side, here in the editor I’m looking at a pair of scrollbars, neither of which is needed, and when I publish the code snippet the alternate line highlighting has disappeared and the extra blank lines are back.

If I switch to Live Writer’s “Preview” tab, all looks the way I’d expect, however switching back to “Edit” adds some additional gratuitous resizing to produce this (a screenshot of what I’m looking at in WLW):

code-snippet-screenshot

The real problem here is that code I inserted at the top of the page does not look the way it does in WLW, there are extra blank lines, not unlike the ones produced by MS Word.   Since this trivial example doesn’t really work, I’d rate this approach as a failure.   It’s possible there’s a WLW code plugin out there that does the job correctly, but I’m not patient enough to find it.

Publishing Code: Round 2, Windows Live Writer

March 24, 2009

I’ve given up trying to use Word after some “you’re doomed” advice from another WordPress user and similar advice from no less than the WordPress FAQ.    So this time around I’m trying the latest version of Windows Live Writer.  This application is miles from Word 2007, and it pains me to give up all the fancy features and support for drawing and all the rest.   However the acid test isn’t how good the app is at picking grammatical errors, and it’s going to have to be a shame that it’s borderline ugly, just as long as I can append a snippet of code without pulling what’s left of my hair out.

Here goes.

Failure.   There’s no built in support for the <pre> tag so I’ve been reduced to entering HTML directly from within the editor’s “Source” tab. If I return to the “Edit” tab the editor attempts to improve the HTML I’ve entered in directly, which just confuses matters. If I enter text within the preformatted element from the “Edit” tab, HTML with explicit line breaks and other madness appears.

To be fair, it is possible to insert XML with the source tab, so long as I carefully escape special characters.   No doubt I could equally well insert any code sample in the same way.   Still, this isn’t just a step backwards, it’s going back decades.

<Application xmlns="http://ns.adobe.com/mxml/2009">
    <Label text="Hello World"/>
</Application>

There must be a way to enjoy the advantages of a modern desktop word processor without punting support for publishing those processed words in a blog.   There must.

Publishing Code With MS Word: Frustration

March 23, 2009

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=”http://ns.adobe.com/mxml/2009>


<Label text=”Hello World/>

</Application>

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="http://ns.adobe.com/mxml/2009">

 

 

    <Label text="Hello World"/>

 

 

</Application>

 
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="http://ns.adobe.com/mxml/2009">
    <Label text="Hello World"/>
</Application>

 
The text above was inserted by hand.

I’ve Moved, I’m Here

March 23, 2009

About a year ago I moved from Sun Microsystems to Adobe, from the Java Client group to Adobe’s Flex SDK team, from an office in Santa Clara, to a cube in San Francisco. While I was at Sun I occasionally published a technical blog about the projects I was working on. That was http://weblogs.java.net/blog/hansmuller/. Since I’ve been at Adobe I’ve written a few entries in a personal blog, http://hansmuller.blogspot.com, but have not yet published anything technical. I’ve been working on the new version of Flex for about 8 months now on layout, scrolling, and “virtualization”, but haven’t published anything. The time has finally come, and this is the place.