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).
(() => {
"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.