Copy outline with links

I used to know how to do this, but … I seem to have forgotten. I have a rather long Bike document that contains several liinks to webpages and YT videos. How can I copy the Bike document so that when I paste the contents somewhere else I get both the content and the linked items in the content?

I typically work in markdown when doing regular writing (as opposed to outlining in Bike).

You mean into plain text, rather than RTF ?

( Label and link are automatically available if you copy and paste to an RTF context )


One plain text route is to go from the HTML source file, or through Copy as HTML Source in the UI for smaller sections.

You can then use an HTML → Markdown converter, like:


Copying as HTML Source:

BIKE - Copy as HTML source.kmmacros.zip (14.0 KB)

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

    ObjC.import("AppKit");

    // Get any public.html content in the pasteboard
    // as utf8 plain text source.

    const main = () =>
        bindLR(
            clipOfTypeLR("public.html")
        )(
            setClipOfTextType("public.utf8-plain-text")
        );


    // ----------------------- JXA -----------------------

    // clipOfTypeLR :: String -> Either String String
    const clipOfTypeLR = utiOrBundleID => {
        const
            clip = ObjC.deepUnwrap(
                $.NSString.alloc.initWithDataEncoding(
                    $.NSPasteboard.generalPasteboard
                    .dataForType(utiOrBundleID),
                    $.NSUTF8StringEncoding
                )
            );

        return 0 < clip.length
            ? Right(clip)
            : Left(
                "No clipboard content found " + (
                    `for type '${utiOrBundleID}'`
                )
            );
    };

    // setClipOfTextType :: String -> String -> IO String
    const setClipOfTextType = utiOrBundleID =>
        txt => {
            const pb = $.NSPasteboard.generalPasteboard;

            return (
                pb.clearContents,
                pb.setStringForType(
                    $(txt),
                    utiOrBundleID
                ),
                txt
            );
        };

    // --------------------- GENERIC ---------------------

    // Left :: a -> Either a b
    const Left = x => ({
        type: "Either",
        Left: x
    });

    // Right :: b -> Either a b
    const Right = x => ({
        type: "Either",
        Right: x
    });

    // bindLR (>>=) :: Either a ->
    // (a -> Either b) -> Either b
    const bindLR = m =>
        mf => m.Left
            ? m
            : mf(m.Right);

    // MAIN
    return main();
})();

and another route would be through Pandoc’s HTML reader.

Those routes, don’t however, at the moment, include row type formatting.


FWIW I’ve started some Pandoc work to do that, and I’ll aim to spend some more time on it this week.

2 Likes

Got it! This helps a lot. Thanks so much.

1 Like

A post was split to a new topic: Bike is failing to paste Hookmark link