I frequently have the need to copy and paste a chunk of a google doc and turn it into HTML. Copying google doc text places an rtf snippet into the clipboard. I have Textsoap that seems to be always missing exactly the one conversion tool that I need. There are online converters, but I don't want to use those. It would seem like a pretty common use case -- we all need HTML to put into emails and apps. Is there a Keyboard Maestro macro that does this?
It depends a bit on what kind of HTML (and what kind of HTML pasting) you have in mind.
When you copy from Google Docs,
public.html is one of the formats in the clipboard, and if you wanted to simply paste that as literal HTML tagged markup, you could do something like this:
but Google Docs HTML has a lot of detail which you probably don't want, and it sounds as if literal HTML code may not be quite what you are after ?
I actually need to take a look at how that multiformat clipboard copy works: I only saw RTF being pasted. In any case, I certainly do not want the horrible html that google docs produces, all I care about is links, paragraphs, bolds, and italics.
Not sure what kind of editor you are pasting into, but if there is any conversion to RTF taking place, it may be done by the application's paste handling.
Looking at it more closely, I see that Google Docs itself doesn't itself place any RTF in the clipboard, only:
For clipboard inspection methods, see, for example:
If you have a file named
Test.rtf and run this command:
textutil -convert html Test.rtf
You will get an HTML file called
This could be turned into a Keyboard Maestro macro. (Let me know if you need help with it.)
It’s not as streamlined as I’d like, but what I find myself doing to get ‘clean’ HTML is copy Rich Text, paste to Bear (which will convert it to Markdown) and then turn that into HTML. I really ought to automate that, but I haven’t yet.