Help: Drafts Action to Convert Clipboard to Markdown, Replace Contents of Current Draft

I use drafts as a writing environment. Part of my editing workflow involves copying the draft as rich text, pasting into Grammarly, and moving it back to drafts with corrections. I’ve been trying to cobble together something to make that last step easier.

Here’s the ideal of what I’m looking for:

  1. Shows a preview of clipboard contents with a confirmation and option to abort.
  2. Converts rich text on clipboard to markdown.
  3. Replaces clipboard contents with markdown.
  4. Replaces the contents of the current draft with the clipboard

I haven’t had any luck finding something that can do this. If anyone can help, I’d appreciate it!

This is the closest I’ve found: HTML > Markdown | Drafts Directory.

But I can’t figure out how to have it pull from my clipboard rather than the current draft. Also need it to go from rich text to markdown rather than html to markdown.

You might get some mileage in roping in textutil and pandoc. Drafts has support for shell script within actions, so you could integrate tham with other action steps.

Quick follow-up question. Have you tried just copying the Markdown version back and forth?

For me, Grammarly seems to just ignore the syntax used to mark up the text.

I hadn’t thought of that. I suspect that it might throw a hissy fit about urls in hyperlinks. I’ll try that next time I run it through.