3

I have an Automator service that takes selected text and saves it in a file. However, bold, italics, and linked URLS aren't preserved. Is there a way I can convert it to Markdown before I save it? When I searched Google, I only found guides to convert plain text to HTML.

3

HTML to Markdown

Brett Terpstra has written these automator services to help manipulate markdown in OSX.

One of these services does convert HTML to Markdown (which answers one part of your question), and any of these services can be individually added and assigned a shortcut if you so please. I myself use Markdown to RTF to send pretty emails written in md.

However, none of the services seem to do RTF to Markdown. And so deeper into the rabbit hole of RTF clipboard extraction I went...

RTF to Markdown

First I found this post and this SO question. The key, I found, is to use OSX built-in pbpaste (or osascript) and textutil.

And so, I've written a simple RTF to Markdown service for anyone who is still looking to compliment Brett's services mentioned above, it simply converts input to HTML and pipes result to the "HTML to Markdown" service.

Note: RTF HTML output is not always what you are looking at because of how the style is converted, so I would go with HTML to Markdown where possible.

1

Mark It Down - XSLT transform

I don't know if it's exactly what you wanted, but I found the in browser tool Mark It Down and its source code:

The conversion happens entirely on the client (in the browser) using Saxon-CE and an XSLT.

  • 1
    How would you integrate this into an Automator workflow? – nohillside Sep 22 '14 at 18:42
  • @GrahamMiln Thanks for fixing the links. It doesn't address the fundamental issue with this answer though (integrating this service into an Automator workflow), Any idea on how to solve this? – nohillside Sep 18 at 9:06
  • One approach would be to use /usr/bin/xsltproc with the XSLT files in the above project. An Automator workflow could pass the input file to xsltproc and either pipe out the results, or save the output to a folder. – Graham Miln Sep 18 at 9:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .