Copy as Markdown Link

Consider the ants and bees – completely unable to relax and enjoy themselves.

In the sub-macro com.devon-technologies.think3:

Edit the lines in the JS source which define the title value:

title = record.name() + (
    hasPage ? (
        ` p${page} of ${pageCount}`
    ) : ''
);

reducing them to:

title = record.name();

1 Like

Doh. Thanks @ComplexPoint

It just shows how difficult it is to read code that you didn't write yourself. I've been coding for 30+ yrs and I missed the obvious.

fantastic app. Would it be possible to add Bear app?.
Bundle ID: net.shinyfrog.bear
thanks very much !

Hi @ronald - looking at the first post here it already lists net.shinyfrog.bear as being included…

Thanks very much. Thank you for noticing ! Unfortunately it does not work, which is why I assumed that it was absent.

image

Does Bear.app still have the menu path:

Note > Copy Link To Note

?

I notice that the existing macro for that bundleID tries the menu twice – suggesting that there had been an intemittent timing issue with it. (Bear.app may take a little time to get the link into the clipboard, for some reason)

So two steps:

  1. Let me know if that menu path has changed (I'm not running Bear.app here at the moment)
  2. If it hasn't, I suggest either a third click a that menu, or the insertion of a small pause, and possibly a wait until the clipboard has been updated by Bear.
1 Like

Thanks to your suggestions, I managed to make it work.

Yes, the menu path is the same.

I added multiple wait for clipboard to change actions, but it still did not work.
By replacing the menu path with the copy link to note shortcut, the macro is now at least partially working.

The macro output is a functional link, but the note title is not included, for example
bear://x-callback-url/open-note?id=9358A97B-DFF9-4B24-B427-3647A858C430-92972-0000D0227DC8C270 which is functional but not ideal because the title is missing.
Would you know where in the net.shinyfrog.bear the title is added?

Thanks again VERY much.

image

Curiously enough I've installed Bear.app now, and the existing sub-macro is working fine here on:

  • macOS 11.6.7
  • Bear 1.9.6 (9044)

Could you tell us a bit more about your OS version and hardware ?

I may need to put it a clipboard-clear and pause this evening. Bear seems just slightly sluggish, and it may need more time to populate the clipboard with the various different types of pasteBoard item which it puts in there. (public.utf8-plain-text, public.url, and net.shinyfrog.bear.url-name)

1 Like

thank you for your reply and interest

mac 10.15.7
Version 1.9.6 (9044)

Just to make sure that there is no misunderstanding, I can generate a fully functional link like
bear://x-callback-url/open-note?id=03A0839A-A772-4E8C-AC8A-667FD33F7C7B-92972-0000D5FF487628A8
but that link gives me no clue as to the title of the underlying note, which defeats the purpose.

what I can't generate is the title of the note as a functional link

example
[this is a test note](bear://x-callback-url/open-note?title=this%20is%20a%20test%20note&x-error=bear%3A%2F%2Fx%2Dcallback%2Durl%2Fcreate%3Ftitle%3Dthis%2520is%2520a%2520test
%2520note)

In Bear, the only way that I can generate this is a test note is by writing the note, and drag and drag that same note from the notes list into the body of the this is a test note, and the this is a test note is generated automatically

thanks again

As I say, MD link, label and url all composing fine here.

  • The MD Link comes from the public.utf8-plain-text pbBoardItem
  • the label (note header) comes from the net.shinyfrog.bear.url-name pBoardItem

(both in the clipboard created by Bear, albeit slowly, after Note > Copy Link To Note)

(It's possible, though it seems at first glance unlikely, that the macOS build is making a difference)

net.shinyfrog.bear.kmmacros (7.0 KB)

You could try replacing the existing sub-macro with this, which just aims to improve the Pause Until test.

I know one thing for sure:
Note > Copy Link To Note does not work and has to be replaced with the keyboard shortcut

If it is not asking too much, may I ask you how to insert delays in the code after

  • The MD Link comes from the public.utf8-plain-text pbBoardItem
  • the label (note header) comes from the net.shinyfrog.bear.url-name pBoardItem
    and I will try it.

thanks again

What you do mean by that ? It's working here.

It populates the clipboard in this pattern:

{
  "public.utf8-plain-text as string": "bear://x-callback-url/open-note?id=4865D6A6-7DBF-4E55-B6FD-EE0F46BAFC86-48921-00007C85132F55C2",
  "net.shinyfrog.bear.note-uuid-pasteboard-type as string": "4865D6A6-7DBF-4E55-B6FD-EE0F46BAFC86-48921-00007C85132F55C2",
  "public.url as string": "bear://x-callback-url/open-note?id=4865D6A6-7DBF-4E55-B6FD-EE0F46BAFC86-48921-00007C85132F55C2",
  "net.shinyfrog.bear.url-name as string": "This is the title"
}

If you paste into a text editor, you will only see the public.utf8-plain-text, content, since that's all that a text editor can directly use, but the other pboarditems are there too, and accessible to script.

Not quite sure that I understand that either. No pause is needed after the clipboard has been populated.


Have you tried the new sub-macro ?

Sub Macro: I had not seen your reply. I am an idiot. Terribly Sorry.

Excellent news - with the sub macro everything works, with 2 glitches:

  1. If I run the sub macro as a stand alone, it does not work with the error message Note > Copy Link To Note not found. I simply replaced Copy Link to Note with its shortcut and it now works fine. I am extremely happy thanks to you. This is not unheard of (having to replace menu paths with native app shortcuts) and happens often for example with Scrivener.

  2. If I run the submacro by running the Copy as Markdown link main macro, I get the following error message, probably because you have not yet linked both.
    Macro UUID :: undefined
    a script must be specified

Thanks very much!

2022-07-02_16-54-47

One last (hopefully) question and I will leave you in peace.

In terms of workflow, I would often want to paste the markdown link (in the exact same format as that generated by your macro) of the currently selected email in apple mail, note in bear note, item in DevonThink, tab in chrome, etc

Is it conceivable to create a variant of your macro to do so ?

You might be able to – the app from which the MD link is copied needs to have focus, so I'm not sure how you would decide which app was the paste target.

Outside the scope of the Copy As MD link macro itself, but you might get somewhere by experimentation.

1 Like

thank you !

Now, I am getting these error messages using apple mail which I did not have before. I never had problems with apple mail using your macro previously. I restarted apple mail and checked that com.apple.mail is present and enabled in the group.
Would you have any idea how to troubleshoot the issue ?.
thank you

@ComplexPoint

problem was solved by running the macro

Update map from bundleIDs to KM UUIDs (after new sub-macro added)

thanks again very much

1 Like

Updated the copy here: GitHub - RobTrew/copy-as-md-link: macOS Keyboard Maestro macro group – single keystroke to copy MD links from different applications.

to allow for direct pasting of formatted links into recent builds (69+) of Jesse Grosjean's Bike Outliner.

If you want to paste the copied link into a Bike.app document in plain text Markdown [label](url) format (rather than as a blue inline link), you can use a βŒ˜β‡§V Paste as plain text macro like this one:

Paste as plain text.kmmacros (5.0 KB)

2 Likes