Challenges with the automatic “RTF to Markdown” converter

How did you execute my example? Via the Script Editor.app? This works as expected on Catalina & Big Sur, nothing’s escaped afterwards.

Via Script Debugger and now also via Script Editor. Both yield escaped links when pasted via CMD + V.

I have an idea how to work around. Let me try

-- Set clipboard to plain text

use AppleScript version "2.7"
use framework "AppKit"
use scripting additions

set theStr to "[Markdown Test](x-devonthink-item://3C86525C-B290-48CD-ACD6-9BF5918C8EAE)"

set thePasteboard to current application's NSPasteboard's generalPasteboard()
thePasteboard's clearContents()
(thePasteboard's setString:(theStr) forType:(current application's NSPasteboardTypeString))


This works.

As it seems it’s not possible to set the clipboard only to plain text in Mojave and setting the clipboard via script isn’t the general way to use it I think it will be fine to use AppleScriptObjC for this edge case. :slight_smile:

Thanks!


Edit:

@cgrunenberg I still think the automatic conversion should be made optional. Altering the copied text should be an explicit choice made by the user, not the default.

It puts cognitive load on the user to always be aware from where text was copied and makes such a simple thing like pasting unnecessary complicated, at least over here.

So please consider to add an option that disables the automatic conversion.

2 Likes

Although I understand the use case where a user may wish to have DT alter what they’re pasting into a Markdown document, it’s not my preferred behaviour. I paste a lot of code snippets into Markdown notes and I always forget it’s not ⌘-V any longer unless I want a bunch of escaped gibberish. And I don’t want to have to use the four mystery keys to get “Paste and Match Style” (I can play complicated Bach fugues on the piano, but getting my fingers around the Paste and Match Style shortcut is somehow beyond my digital agility!)

So I changed changed the keyboard shortcut in DT for “Paste and Match Style” to command-V in System Preferences → Keyboard → Shortcuts. Now ⌘-V gives me the expected unescaped content from the clipboard.

If the use wants to the flexibility to Paste vs Paste and Match Style, then obviously some other solution is required…

1 Like

Exactly. Changing the shortcut is no option over here as I also want to paste rich text … There really shouldn’t be an automatic conversion without an option to disable it.

I understand that automatic conversion might be handy for some users but it obviously makes it very hard for others. It’s a bad decision.

I’ve found I only have an issue with this if I have PlainTextIsMarkdown set to TRUE. I had to turn that off (even though I work almost exclusively in Markdown), because as has been mentioned the pasteboard in DT3 does not paste what is copied to it. Until I worked out that it seemed to be linked with the above hidden setting, I was doing my Markdown work elswhere.

For the record, I don’t believe any app should alter what is on the pasteboard, unless explicitly requested. That request should be via another command not the CMD+V that is in everyone’s muscle memory. Muscle memory requires things to be the same or workflows suffer.

1 Like

What did you exactly copy in which app?

I copied a url into a markdown document and got escaped “:”.

And in which app did you copy the URL first to the clipboard?

From a plain text document and from a browser. Tried both.

The name of the apps would be good so that we could try to reproduce this, the conversion is applied only if the clipboard contains rich text which it shouldn’t according to your description.

BBEdit & Firefox

Did you copy the link in Firefox from the address bar or via the contextual menu of a link? And do you use the latest release (3.7)? Thank you!

Using Firefox 88.0 (64-bit). I tend to copy from the address bar. I also use BBEdit version 13.5.5 (415108, 64-bit Intel, sandboxed).

And do you use DEVONthink 3.7?

Yes!

@UncleWalrus I tried your suggestion of switching shortcuts some days ago, i.e. setting

  • Paste And Match Style to ⌘V
  • Paste to ⌥⇧⌘V

It seemed to be a doable workaround.

Now, without thinking about the changed shortcuts, I tried to paste an image into a RTF record and got very confused because ⌘V didn’t paste the image.

After I finally found out why the shortcut didn’t work (Paste And Match Style is disabled if there’s an image on the clipboard) I created a Keyboard Maestro macro that uses Paste And Match Style if it’s available, otherwise it uses Paste.

It’s a trade-of:

  • do I want to get confused when pasting into a RTF record doesn’t work as expected

or

  • do I want to get confused when pasting into a Markdown record doesn’t work as expected
    (This of course would also be the case without the macro, due to the automatic RTF to Markdown conversion that can’t be disabled)

It’s plain wrong that a user has to make this choice.

A core functionality like pasting should simply work as expected.

@pete31 I’m not disagreeing with you; I was only offering the solution as a temporizing measure should the developer decide not to implement the changes. I haven’t run into this conflict yet, because I practically only work in Markdown.

1 Like

I just checked this again but after copying the URL from the address bar the clipboard doesn’t contain rich text actually and nothing’s converted over here when pasting it into a Markdown document. Do you use any Firefox extensions, which macOS version do you use?