Hookmark 5 richlink paste in Bike, becomes garbled code

First, I don’t know where to ask this software collaboration issue, I apologize if I have posted in the wrong place.

Hookmark 4 generated links can always be pasted normally into Bike;
Hookmark 5 links can also be pasted normally as richlinks in other software (TextEdit, Apple Notes, Bear).
But in Hookmark 5, it can’t paste links from any other places to Bike, it will become a string of garbled code.

Let me take web pages and local folders as an example:

↑ Copy directly from browser

Title: ÒZ$classnameX$classesUNSURL¢XNSObject$)27ILQSX^emt€‚„† ¥°¹¿ÂË
URL: bplist00%C3%94%01%02%03%04%05%06%07%0AX$versionY$archiverT$topX$objects%12%00%01%C2%86%C2%A0_%10%0FNSKeyedArchiver%C3%91%08%09Troot%C2%80%01%C2%A4%0B%0C%13%14U$null%C3%93%0D%0E%0F%10%11%12WNS.baseV$class%5BNS.relative%C2%80%00%C2%80%03%C2%80%02_%10%17https://www.google.com/%C3%92%15%16%17%18Z$classnameX$classesUNSURL%C2%A2%17%19XNSObject%08%11%1A$)27ILQSX%5Eemt%C2%80%C2%82%C2%84%C2%86%C2%A0%C2%A5%C2%B0%C2%B9%C2%BF%C3%82%00%00%00%00%00%00%01%01%00%00%00%00%00%00%00%1A%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%C3%8B

↑ What I got when paste same link from Hookmark

/Users/xxx/Desktop/abc123
↑ A folder from Finder

Title: MuDTZXMtA

URL: bplist00%C3%94%01%02%03%04%05%06%07%0AX$versionY$archiverT$topX$objects%12%00%01%C2%86%C2%A0_%10%0FNSKeyedArchiver%C3%91%08%09Troot%C2%80%01%C2%A4%0B%0C%13%14U$null%C3%93%0D%0E%0F%10%11%12WNS.baseV$class%5BNS.relative%C2%80%00%C2%80%03%C2%80%02_%105hook://file/MuDTZXMtA?p=ZGFuaXMvRGVza3RvcA==&n=abc123%C3%92%15%16%17%18Z$classnameX$classesUNSURL%C2%A2%17%19XNSObject%08%11%1A$)27ILQSX%5Eemt%C2%80%C2%82%C2%84%C2%86%C2%BE%C3%83%C3%8E%C3%97%C3%9D%C3%A0%00%00%00%00%00%00%01%01%00%00%00%00%00%00%00%1A%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%C3%A9

↑ What I got when paste same link from Hookmark


This is the General Clipboard items, when I use Hookmark made the link from google.com.
I guess it would be great if Bike could get the second rtf link (richlink).

In the meanwhile, there’s a Copy as Labelled Link in the form of a Keyboard Maestro macro, which copies in Bike rich text format, as well as in plain text and public.rtf formats:

Copy as Markdown Link - Macro Library - Keyboard Maestro Discourse

and the current version of it can always be found here:

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

(Click the green Code button)

3 Likes

Bike tries to read the public.url pasteboard item first. I think for Bike this is the correct thing to do.

Hookmark appears to be putting a valid (throws no errors when I read it), but indecipherable URL for that value. I wonder if that’s intended or if it’s a bug they can fix? @Luc_P_Beaudoin. I’m using URL(dataRepresentation: data, relativeTo: nil) to get a URL from the pasteboard data.

1 Like

In the interim, in case of delay in fixing Hookmark’s public.url pasteboard item,

here is a draft of an alternative paste ( ⌘⇧V ) for Keyboard Maestro, which you could put in a Bike-only macro group.

Screenshot 2023-01-24 at 13.36.12


It aims (if the clipboard turns out to be created by Hook) to use the public.rtf pasteboard item, discarding Hook 5’s (apparently faulty) public.url pasteboard item.

(with clipboards from other applications, it just pastes as normal)

I don’t have Hook on my system, so not fully tested. Let me know if it doesn’t immediately seem to work.

If it does work, you could reassign it to ⌘V for Bike until the Hookmark 5 issue is fixed.

Draft of Alternative paste (band-aid to bypass Hook public.url).kmmacros 2.zip (13.7 KB)

Expand disclosure triangle to view JS source
(() => {
    "use strict";

    ObjC.import("AppKit");

    // Band-aid for defective Hookmark 5 `public.url`
    // pasteboard item.
    // (Discards and uses the `public.rtf` item instead)

    const
        pBoard = $.NSPasteboard.generalPasteboard,
        typesFound = ObjC.deepUnwrap(
            ObjC.unwrap(pBoard.pasteboardItems)[0]
            .types
        );

    return typesFound.includes(
        "com.cogsciapps.hook"
    ) && typesFound.includes("public.rtf") ? (() => {
            const
                rtf = ObjC.deepUnwrap(
                    $.NSString.alloc.initWithDataEncoding(
                        pBoard
                        .dataForType("public.rtf"),
                        $.NSUTF8StringEncoding
                    )
                );

            return (
                pBoard.clearContents,
                pBoard.setStringForType(
                    $(rtf), "public.rtf"
                ),
                "Clipboard reset to public.rtf"
            );
        })() : "";
})();


2 Likes

It works well and fast, thank you!

I’m also researching alternatives to Hooks such as Copy as Markdown Link.

1 Like

Hookmark’s Copy Markdown Link should work for you. Someone at CogSci Apps is looking into the issue. ( Hookmark puts a variety of information in the clipboard).

1 Like

@Luc_P_Beaudoin I’ve also seen this bug in Hookmark 5. Forgot to report it though.

@zsbenke do you mean you saw a garbled paste of Hookmark copied links in Bike? Or in other software?

Please try this preview release to fix reading of Hookmark urls:

1 Like

Just in Bike.

When I have Bike deep linking enabled, and I copy a row link with Hookmark.

Pasting back into a different row is used to include the row text. Now the link text shows the row ID instead.

1 Like

This is what used to happen in Bike using Hookmark 4.

1 Like