Bike links in Shortcuts?

I’m working on a shortcut for Bike - but I’ve encountered a problem: I can’t seem to create rows with Bike links as hyperlinks! (Like this: bike://N0LBH9nL/#dW)

I saw that I can’t select links as a a row type when creating. But then I saw, in your video @jessegrosjean, that I could use Markdown. However, here’s the issue:

  • Doing [this]( works as expected, and returns:
    • “Doing this works as expected”
  • but [this](bike://N0LBH9nL/#dW) only strips the URL part, and returns:
    • “but this only strips the URL”

Even the editor here on Discourse recognises the bike URL as such - but I guess there might be something in the way Bike’s shortcut actions interprets markdown links?

The concrete thing I’m trying to do, is to replace the first line with the second:

Some cool text

Some [cool](bike://N0LBH9nL/#dW) text

If there’s another way to do it than using Markdown, I’d like to know that as well. :slightly_smiling_face:

This is what works if the clipboard has an https:// link, but not if it has a bike:// link:

Hmm, it turns out this action has the same problem. Maybe Bike is using that in the backend or something…?

And I thought I could give even more context: This is an example of one solution I tried, that I think should work. :stuck_out_tongue: (Here the problem is the Make rich text action, though.)

The reason I’m not just pasting, is that this is happening in a file in the background. I tried to bring it to the front, but “Open Outline” doesn’t change focus to that file again. And “Focus row” only does the focus-zoom-in (which I don’t want), and still in the background.

I’m looking at this now. For me simple markdown works. Here’s a link to my test shortcut that creates a row using the Markdown Hello [world](bike://8BW8IraR/#3C):

I’m not sure, but I think maybe it’s the replace action, or interaction with the clipboard that’s messing the bike link up, not the “Create Body with Markdown” call. Can you verify that “Updated Text” is really what you expect it to be?

Is Open Outline not working at all, or is it activating Bike, but with another outline in the foreground then the one that you opened? For me Open Outline works as expected when only one outline is open, but I see a bug with multiple outlines. Will try to fix that now.

Glad you are trying out Bike’s shortcuts!

Thanks for looking into this!

I will do some more testing after dinner, and report back. :smiling_face:

If I say so myself, the shortcut is going to be pretty great! :sunglasses: (I’m also making it so that others can use it.) I also have plans for making it integrate with TaskPaper as well!

Re: Open Outline:
If I have only Outline A open and uses Shortcuts to open Outline B, it opens that and changes focus to B. But if I then want to Open Outline A (which is now open in a background tab), it doesn’t change focus back to A.

Is this the same bug you’re thinking of?

Yes, I have a fix for it, will post later today.

Cool - but can we keep the bugged behaviour as an option? :grin:

Because, what I’m doing, is:

  1. In Outline A
  2. Create Outline B, and change focus there
  3. Copy a link to Outline B
  4. Move back to Outline A, to paste a link to Outline B

And in this context, it’s nice to be able to write in Outline A without the focus changing. :smiling_face:

I’m pretty sure the Updated Text is correct. I added a “Show result” to test it:

Here’s a GIF of me running the action. To me that link looks correct! :upside_down_face:

CleanShot 2024-04-04 at 20.14.39

(That’s not where I want to paste it, but that’s an issue to solve later.)

Your shortcut did work!

Can you share your shortcut? There should be a share button that allows you to copy an iCloud link to the shortcut.


Ok, I think I found root of problem. When you use AppleScript to put the link on the clipboard it must be using some old string encoding. And then when Shortcuts passes in the clipboard data the string has a null character after every character by the time the clipboard string gets to my application code. And the markdown parser code isn’t liking that. I can create some related problems like this:

I don’t think, but am not 100% sure that I’m doing anything wrong that would create this problem. I guess I can clean the text before passing to the markdown parser, but that seems like it shouldn’t be necessary, so I’m thinking a bit.

I’m not sure, but I think, your script will work if you manually copy the row link before running the action, instead of using AppleScript to get it.

Hmm, interesting.

Do you have another idea for how I can get the Bike URL? (I’ll see if I can find a way to clean it in the meantime.)

As you probably can tell, I wouldn’t mind an option to get a link here: :wink:

Edit: I found a way! Doing this, instead of going via the clipboard, works!

(I went the clipboard route because I thought I had to paste to create the hyperlink in Bike. But even though I have to do that, I could use a “Copy to clipboard” action in shortcuts instead of having AppleScript handle that part.)

Also, I’m working on getting file:// links to work. But I can’t seem to open them from Bike. It does work from TaskPaper, but not Bike…

Also, I’m working on getting file:// links to work. But I can’t seem to open them from Bike. It does work from TaskPaper, but not Bike…

If I understand correctly this is because TaskPaper is not sandboxed while Bike is. You should be able to give Bike to open file links to specific locations on your computer through Bikes Settings > Sandbox panel.

Ugh, I’m so close!

Only problem now, is that I want to change a line from:

Hello World


Hello [World](bike://1234)

But where the Create action can take Markdown, the Set action cannot… Why?

I also tried to add an action to turn the markdown to rich text, but that stripped the URL again, even though it doesn’t have the same bug with the extra characters…

I also checked to see if there was any extra spaces or anything… But here’s an example link created:

[Cool Title](bike://yVr5HWYo/#Zo)

I also tried to do the “Create with Markdown” thing on that specific action, and that works. I just can’t set a previous row to the markdown content…

I don’t have time to look into this today, but I’m pretty sure we can get it working. I’ll add more API to Bike’s actions if needed.

That’s OK - I have to go to bed anyway. :smiling_face:

But 1.0 of the shortcut is done, apart from some of those pesky Markdown links.

Here’s a sneak peek! :point_down:t2:

CleanShot 2024-04-05 at 00.44.21

(For 2.0, I’m planning on supporting Markdown and TaskPaper documents with the same flow. So that you’re asked which of the three document types you want to create.)

Shoot… I was thinking about this. Then thinking where I would ad to code. And then I noticed it was already there. Rows have a URL property that you can use directly!

Sorry I didn’t think of that sooner!

Ah, nice! Then I’ll remove the AppleScripts tomorrow, to make it cleaner. :slightly_smiling_face:

(I write a post at the same time as this - so check out that one for a GIF!)

Now I got the 2.0 (almost) working, @jessegrosjean!

If you want to create a new document, from the Bike Hub, you can hit the hotkey for the shortcut:

  1. If you have selected text, that becomes the title. If not, you type in a new title.
  2. Then you get asked if you want it do be a Bike outline, Markdown file or TaskPaper file.
  3. Then it creates the file, with the title and content you’ve specified in the shortcut, and a link back to the Bike Hub.
  4. Lastly, it creates a link to the newly made document in the Bike Hub. For .md and .taskpaper files, those are file:// links. (But I think I’ll make it non-generic personally, and have the .md module create callback-URLs to NotePlan.)

Now, all I need is to somehow go from a Markdown link to be able to Set a row with it.

For instance, if I could say “Set Rich Text of Original row to New Hub Content from Markdown

Here it is in action!

(The GIF was too large for the forum…)

The markdown file in NotePlan:

Clicking this link also takes me to Bike, of course.

1 Like

Ha, this is looking good!

Now, all I need is to somehow go from a Markdown link to be able to Set a row with it.

I’ll get that out soon, but while I’m in the code I’m trying to figure out why rich text isn’t working. Are you aware of any third party apps that support actions that accept rich text… and work? I feel like I have things setup correctly, but when I say my actions accepts rich text, it receives text with no attributes and with spaces removed too.

Hmm, good question…

Maybe check out Drafts or Text Workflow?

I’ve just tried a bunch of apps and they all have same buggy behavior as in this example:

When I run this I get plain text Helloworld appended to the note.

Addition Another odd case if instead I make the input **Hello** world (without italics on world) then I still get no formatting, but the space is no longer lost.

If I click on the “Rich Text from Markdown” input and change “type” to “text” and then get “text” I see different behavior. There is no formatting (as expected), but also the space character is no longer lost.

Also if I just pass the “Text” directly then I get the plain text with spaces preserved and also with the markdown characters preserved. Again as expected.

So the problem case is result of Make rich text just doesn’t seem to work as far as I can tell if he goal is to pass into another actions parameter list. I expect maybe it works for old style actions, but maybe not for the new swift based api.

I “think” that’s the story anyway, please let me know if you see any different behavior.