Support » Fixing WordPress » Publishing a preformatted code example from MS Word

  • I just created a blog in which I’d hoped to publish short articles about ActionScript and MXML code. Microsoft Word (Office 2007) provides support for editing blogs and even publishing directly to WordPress, and I was looking forward to being able to compose and publish blogs with just one tool. I should have known better.

    After a frustrating 45 minutes spent trying to publish a 3-line XML code example, I gave up. I did post (using Word!) all the sordid details here: http://hansmuller.wordpress.com/2009/03/23/publishing-code-with-ms-word-frustration/

    What I’d really like to know is this: is there some way to convince Word and WordPress to simply publish a code example exactly as I’ve written it. Without removing the indentation or adding any additional newlines?

Viewing 15 replies - 1 through 15 (of 20 total)
  • I don’t know where you heard that MS Word would work fine with WordPress. In fact, it’s highly advisable to you *avoid* using MS Word when writing WP content.

    MS Word uses formatting that is specific to MS Word. Ever gone to a website and seen weird characters – like a funky “A” or a diamond with a question mark in it? I’ll bet you $20 the site was built with the owner putting in pre-formatted content from MS Word.

    Word is a, oh what do you call it. One of those programs that are meant for printed formats. A publishing format – but not meant for the web. (I forget what the exact term is – it’s slipping my mind.) In the beginning, it could output HTML (all you had to do was save the document “as a Web Page”), but if you ever viewed the source code for it, the document had to export/embed Word-specific… everything from Word so it could be readable through a browser window – making for bloated code. (seriously, a file that had 2 sentences in it would be blown up to about 50 times larger than it should have been because Word had to embed it’s stuff into the document so it could be read on the web.)

    Basically, a browser, running the standard UTF-8 doctype, trying to read a Word document is like me handing you a Chinese newspaper (assuming you can’t read Chinese) and telling you to read it to me. NOW. You’d give me the same look (“?”) that you get from a browser – then you might try to kick my ass. LOL

    There’s plugins available to make it *nicer* for Word to play with WordPress – but you still have to import your content from Word into WordPress with an extra step. Your best bet is to just write your posts/content within WordPress. Word is for offline Publishing and document formatting (for nice, printed things.) It’s not meant for the web.

    Thanks for the thoughtful reply. I have to say that I can’t believe that mapping from a simply formatted document to HTML that can be correctly parsed and rendered by WordPress is comparable to me reading a Chinese newspaper. This general problem has been around for decades and this specific problem (a supported Word feature!) has seen just a little more effort invested then I’ve put into reading any foreign language.

    But I’m as cynical as anyone. Anyone including the WordPress folks themselves: http://faq.wordpress.com/2006/11/09/why-not-to-use-word/. I guess we’ll see natural language understanding before computers can share formatted text.

    I’m trying another tack now: Windows Live Writer. We shall see..

    For code examples, I use the WP-Syntax plugin.

    As for Word, see:

    http://wordpress.org/support/topic/215124

    >>I have to say that I can’t believe that mapping from a simply formatted document <<

    Thats’ the thing though – it *looks* simply formatted, but it’s not. MS Word doesn’t use UTF-8 as it’s “language type” – which is what most websites use, and what most browsers read (what language they speak). UTF-8 is a character set that these things use to interpret what it’s reading in the code.

    MS Word uses MS Word’s language. The text you format and see when you’re laying it out is readable and visible by you, but the actual language it’s using it’s it’s own. So when you try to upload a regular MS Word formatted document to the web – it’s like…an American trying to read a Chinese newspaper.

    >>This general problem has been around for decades <<

    Yes, and any fixed added to it (which aren’t many, I’m afraid) don’t really apply to Word 97 – something that came out over 10 years ago. It *might* be better in current versions, but I wouldn’t bet on it. I’d say the main reason it’s such an issue is *because* it’s a proprietary language developed my Microsoft for a Microsoft program.

    Like I said, there’s definitely plugins out there that can help (as iridax mentioned above – there are certainly others, and other options) but ALL of them require some kind of extra step between Word & whatever you’re using to put it on the web. That’s just the way it is.

    Moderator kmessinger

    (@kmessinger)

    I don’t know where you heard that MS Word would work fine with WordPress. In fact, it’s highly advisable to you *avoid* using MS Word when writing WP content.

    Word (at least Word 7) works fine with WordPress. You can publish from Word directly to WP using graphics and images. You can paste from Word using the WordPress paste from Word button. If you want to go very basic you can save the Word document as text and then cut and paste it.

    We have some using WordPress who feel more comfortable using Word. I remember one recent post that the person was going to loose his wife if he didn’t find a way for her to use Word with WP. Now that’s a serious problem!

    As WP has advanced over the years, so has Word making working with words much easier.

    >>You can publish from Word directly to WP using graphics and images.<<

    Now this is news to me! Everyone I’ve ever known to use Word ends up messing up their site. If course – rereading that statement, I could see how it’s true – but in all cases I’ve seen, they’re using text. I don’t have many clients who would just use graphics for post content.

    But the other stuff you said reiterates what I mentioned before: you need to add in a couple of extra steps to make it happen.

    Just a funny little anecdote to share in regards to this – I had a colleague – just for fun – ask me to write a function for a client’s WP installation, so that if they used Word to write up their content and post it (without using the “Paste from Word” button), then it would be replaced by a message telling them to go fix it. Said message was publicly viewable as well, so they would be in a rush to correct themselves. She’d gotten tired of them breaking the site because they wouldn’t follow her instructions.

    I’ve never used the function – but she has, and it broke them of the bad habit. (Personally I thought it was really funny that she wanted to do this, but whatever works, I guess!)

    Moderator kmessinger

    (@kmessinger)

    I don’t have many clients who would just use graphics for post content

    Sorry I wasn’t clear. You can publish from Word directly to your blog using word, graphic, images, includng a post title. One thing I just found is that it has hundreds of shapes, characters, etc. that will publish if you want to use them.

    I just tried it. Sample is here, http://www.savethecolors.com/ for a while. Code looks clean and this site still validates.

    Myself, I don’t use Word. I just key my short posts directly in but Word looks pretty convenient.

    If you don’t mind, Messinger – would you share *how* to do that? because if you really can, and what you say is true, it would be *much* easier to tell my clients how to use Word (which is what they’re used to) properly, rather than “cut and paste” which is what they *always* do, and it ends up breaking everything. I’d *love* to know how to do it just through Word, if only to pass it along to my clients who insist on using it. I, myself, am on a Mac – so I dont’ know if there’s a difference between my version of Word (Office Mac 2008 – which I would imagine is much different than Word 97 for PC!) and one you’d have for a PC, but if you’d share, that would be awesome! I’ve never heard of doing that before.

    You can publish from Word 2007 by configuring your blog in Word. Just open Word, click the MS icon (upper left), select “Blank and recent” under “Templates” and then click “New Blog Post”. You will then be prompted to enter your WP connection details.

    However, from my experience, you will still run into a lot of formatting problems if you use this method of posting.

    Awesome to know. Thanks! If I can dig out my old Word disk, I’ll give it a shot and see what happens. Thank you 🙂

    Moderator kmessinger

    (@kmessinger)

    doodlebee – http://office.microsoft.com/en-us/word/HA101640211033.aspx will give you more information.

    It might be worth fnding a PC at Kinkos or somewhere that had Word 7 on it and you try it.

    It is set up to be able to publish to many different blog hosts/software, etc.

    figaro

    However, from my experience, you will still run into a lot of formatting problems if you use this method of posting.

    Have you used it a lot? I think I will start using it as a test so I can figure out the pros and cons. It seems to me that just using Word for your blog would make it a lot easier for some folks. Especially for those who want nothing to do with the backend.

    Moderator kmessinger

    (@kmessinger)

    Going back to the original question, I added some code to the test post at http://www.savethecolors.com and it looks ok to me.

    Have you used it a lot? I think I will start using it as a test so I can figure out the pros and cons. It seems to me that just using Word for your blog would make it a lot easier for some folks.

    I don’t use it myself, but I’m always looking for easier ways to use technology.

    I teach two and sometimes three graduate educational technology classes every term, and in those classes I do a 3-hour module in a computer lab where I teach teachers to use WordPress as a classroom website. I normally have 20 or so students in each class. I always spend 15 minutes or so, to show them how to configure Word to publish to their blog, but invariably 5 or 6 of them run into formatting problems when publishing from Word. I only teach it because it is a way for the complete tech novice (who does know how to use Word) to be able to publish to a website. I haven’t really noted the specific problems, but it’s enough for me to conclude that it’s still pretty buggy and not something I would want to use as a primary means of publishing to my blog.

    Just chucking in 2 more bits:

    My clients that just “gotta have Word” do pretty well with Windows Live Writer instead. It feels enough like Word that they’re not totally out to sea… but seems to work well with WordPress (heck, I frequently use it myself when on Windows machines).

    I posed the original question on this thread because I found that a Word document that contained preformatted (XML) code examples didn’t work well. I did not mean to imply that publishing from Word 2007 to WordPress didn’t work. In most respects it seems to do the job pretty nicely. I’d read that Windows Live Writer was a better alternative for publishing to WordPress, so I gave that a try. I wrote about the results here: http://hansmuller.wordpress.com. Summary: in my view Writer is a relatively primitive tool that doesn’t offer any advantages over Word for publishing code examples.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Publishing a preformatted code example from MS Word’ is closed to new replies.