Filter Clipboard to remove Markdown styling?

Use case:
I use Notion all day long. Formated text that is copied shows in the System Clipboard as Markdown, afaict. Here are three lines copied to the System Clipboard from Notion, with some text formatting, then copied from the Keyboard Maestro Clipboard Entry window:

Kirby Krieger

Learner Advocate + Course Architect

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

And (hopefully) shown here as text by using this dialog's "code" format:

### **Kirby Krieger**

`Learner Advocate + Course Architect`

*Lorem ipsum dolor sit amet*, **consectetur adipiscing elit**, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

How can I reduce that to plain, de-formatted text?

The KM Action "Filter system Clipboard with Remove Styles" does not change anything (I assume since Markdown is text).

I thought I'd ask before trying my hand at a Regex search-and-replace.

Thanks.

KM 9.2 on OS 10.14.6 (18G9323) (last OS that runs Aperture)

Hey Kirby,

Take a look at Pandoc.

Pandoc - Pandoc User’s Guide

-Chris

2 Likes

And in addition to pandoc, which is prodigiously flexible, there is also

  • multimarkdown, which you may already have at a path like /usr/local/bin/multimarkdown (otherwise brew install multimarkdown)
  • and for quick, on the fly conversions, the Marked.app Preview > Clipboard Preview

Using multimarkdown, perhaps this kind of thing, for a preliminary conversion to Rich Text clipboard content:

Copy Markdown as Rich Text.kmmacros (25.1 KB)

2 Likes

I've posted a modified version of this – closer to your use case – which copies any selected MD and populates the clipboard with:

  • Plain text with the MD markup removed (for pasting into plain text editors)
  • Rich text based on the markup (for pasting into rich text editors)

Copy Markdown as rich text and plain unmarked text - Macro Library - Keyboard Maestro Discourse

2 Likes

Thanks Chris! Pandoc looks both super-useful and easy-enough-for-me :slightly_smiling_face:.

(Sorry for the late reply β€” a family member took ill.)

1 Like