Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"Is it really a huge surprise that something as complicated as Word formatting doesn't come out clean when converted?"

No, but it's a huge surprise to users that copying and pasting from Word into a completely different program (say, a rich text editor in a web browser) brings all that crap along. Unless it's pasting into another Word window, it should paste the plain text. There is absolutely no situation where pasting Word's pseudo-HTML into a non-Microsoft program is the right thing to do. As you mention, Word's formatting is hideously complex, so why even bother? It isn't going to work. Just paste the text.



OLE, or whatever it's called these days, is magic - the other day, i set up a label printer and all the bundled programs it came with. I right-clicked to copy a jpeg in Chrome, hit paste in the label editor, without knowing if it would work - and it did. This is an image, going between a cross-platform Skia program and contracted fixed-function bundleware i'll never use twice, made by two completely different companies, and it... blew my mind a little. I have a resolved respect for the native platform capabilities. I mean, sure, it's just a tag in the clipboard code somewhere, but... fascinating.

Anyways, the point of that was, coercing the data type down to the simplest format isn't always the right thing to do. Word should be able to paste formatted text into anything else that handles formatted text (you can paste word formatted text into TinyMCE, that's also pretty impressive)


What's actually impressive is the amount of work the TinyMCE folks have gone to in order to clean up the mess. Check out the source tree.


It's pretty likely that your example case involved the two programs both using a standard clipboard format (a bitmap), not something more sophisticated.


It's worth pointing out that for a _large_ number of users, the primary copy/paste flow from a Word document is into another Office application (quite often Outlook).

The end result is that you end up with two common flows:

* The program I'm pasting into is another Office app and supports (roughly) the same formatting, or

* The program I'm pasting into is a very rudimentary text-handling program and will just look for the plain-text version of whatever was copied.

Yes, there are a number of apps that fall into the uncanny valley by trying and failing to parse Office's output, but I suspect for most people this is a huge red herring.

p.s. I'm a Microsoft employee, but I have nothing to do with how Office handles copy/paste. This is just my opinion.


"Yes, there are a number of apps that fall into the uncanny valley"

"A number of apps" meaning "every textarea on the web with contenteditable set to true"?

And it isn't "trying and failing to parse Office's output" -- it's more like "taking Office's word for it that the garbage on the clipboard is actually HTML, when it isn't".


From what I understand, the copy command will put some content into clipboard, then the paste command can be programmed to read that content and print or convert it accordingly.

For example, if I copy some content with formatting from Word and paste it into Google Docs it will try to preserve the format. Is that expected behavior? I dont know, but that's how it's designed and I think that makes a lot of sense. If I have a table in Word why shouldn't I be able to copy that to Google Docs?

I dont know enough about the clipboard programming to know if the program that calls copy can determine what comes out based on the paste program.

Also, I think the garbage formatting lines in that article will never be shown to the user. That will only be shown if you try to look at the formatting directly or if you're reading the HTML.


I don't know about Google docs per se, but most rich text editors produce horribly broken results when Word's "HTML" is pasted in. Many of them have add-ons or special procedures to attempt to clean up the mess, but it's an iffy proposition at best.


When you copy some content from MS Word into the clipboard, it gets copied in a number of formats, including plain text. When you paste it to another application, it is for the application to choose which format to use from the clipboard. I think that the author tried to paste the content to GMail and GMail tried to preserve the original formatting and failed.


You're misunderstanding the problem.

1) You have a contenteditable region (or a rich text editor that otherwise can handle HTML).

2) User copies something from Word. One of the choices on the clipboard claims to be HTML. It isn't. It's pure garbage, understandable only to other Microsoft products.

The rich text editor has two choices: disable pasting HTML altogether (even from within itself, or from another application that actually does put real HTML on the clipboard) or deal with the garbage that comes in from someone pasting from Word.

The fundamental problem here is that Word puts garbage on the clipboard and lies about it, claiming that it's HTML.


To both of your points, in the example from the article, the author is not describing how Word converts documents to HTML. He is describing the XML markup that the newer versions of Word use, and which can be carried along when you cut and paste text from Word.


Actual sample of what happens when you copy and paste from Word into an HTML editor: http://contraterrene.com/blog/?p=44




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: