Apple Shortcuts "Shortcut Input" does not properly parse markdown links

Testing version: iOS 2.0.10

What were you doing: Running a “text transformation” Shortcut I’ve been using for ages

What feature did you use: Apple Shortcuts via the selected text share sheet (i.e., select some text, then tap Share… in the popup)

What happened: Shortcuts cannot “see” the url so it strips out the URL in a properly formatted markdown link

What did you expect to happen: For the returned text to include a properly formatted markdown link, including the URL


Background

I’ve had a Shortcut I call “Text Manipulator” for ages (long before the release of Bear 2). It basically takes any selected text in any app and performs a transformation on it, like converting lowercase to UPPERCASE and stuff like that. It also does some more complex stuff like converting my old style of Bear metadata to a YAML header.

The Issue in Detail

The problem is that Shortcuts can’t “see” a properly formatted markdown link in Bear. It must have something to do with the new editor because (as far as I can remember) this shortcut used to work just fine in Bear 1.

The way these Shortcuts work is by selecting some text, then tapping Share… in the popup. This works fine for any “normal” text (including bold, italic, etc), however, it doesn’t work for links.

To make it work with links, I had to modify the Shortcut to grab text off the clipboard (which obviously means I’ve got to remember to manually copy the text before running the Shortcut). When I manually copy the text, things work just fine.

To explain better, here are some visuals.

Here’s some old metadata:

## Metadata
Date: March 01, 2017
UID: 201703011645
Sources: [On Finding Your Purpose: An Extraordinary Letter by Hunter S. Thompson](https://tranquilmonkey.com/hunter-s-thompsons-extraordinary-letter-on-finding-your-purpose/)
Notes:

Obviously in Bear this text will look identical to the above, however, it will have wysiwyg formatting on the link, so it will look like this:

Screenshot 2023-09-12 at 5.21.37 PM

Okay, so far so good and when manually copying this text, it looks as you would expect.

However, when you’re using Shortcuts to grab the text automatically, by doing something like this…

…if you’ve got a markdown link in there, the resulting text would be:

Date: March 01, 2017
UID: 201703011645
Sources: [On Finding Your Purpose: An Extraordinary Letter by Hunter S. Thompson]()
Notes:

This is because, for whatever reason, Shortcuts cannot see the URL “hidden” behind Bear editor’s wysiwyg styling.

To get this to work properly, as stated above, I had to change the Shortcut to grab the clipboard, which means I’ve got to manually copy the text before running it. So the Shortcut currently has to look like this:

I’ve tested this out using a simple UPPERCASE converter, and the results are exactly the same. You can test this yourself by building a Shortcut like:

If you select a markdown link that’s inside a code block or YAML header and run this, it will work fine. However, if you run it on a markdown link that the editor has applied the wysiwyg styling to, it will return everything as expected, however, the URL will be stripped out.

I would love to hear back from @Matteo or one of the devs (or anyone willing to test this on their phone) if they can reproduce this weirdness :pray:

Hello,
if you change the Shortcut input from Text and Rich Text to just Text do you notice any change in the final result?

Nope same result. Try it on your end. Do you see the same thing or is this somehow just my system?

Yes, I get the same result. Are you 100% sure the above used to work in Bear 1? iOS doesn’t come with an API for overriding share and I don’t see other ways

Nope not 100%. I’ve been using Bear literally since day one and beta testing etc so it’s all a blur. I suspect it worked in Bear 1 but that’s as far as I’m willing to go.

What I am 100% on is this Shortcut has (and does) work on every other type of text I’ve thrown at it (in Bear and other apps). Literally the only thing it doesn’t work on is markdown links with wysiwig formatting in Bear, so it has something to do with that. Which is a shame because I use markdown links a lot :man_shrugging:

EDIT: just reread your post. Not sure what you mean by overriding share… I don’t think there’s any issue there unless I’m misunderstanding you. The issue seems to be the wysiwig formatting not exposing the URL for some reason.

Yes, the issue is wysiwig as the URL is “hidden” behind a text attachment. The first way that comes to my mind to overcome this issue is intercepting when you hit “share” and sending the markdown string instead of the editor content. This is not possible because of the lack of specific API apparently but I wondered how B1 used to work. I’ll investigate further.

Oh I see now.

I manipulate text in this way pretty much on a daily basis and being unsure if something is being “picked up” is a bummer.

Are there any other outliers that this could happen to? I haven’t noticed anything (and can’t think of anything that’s hidden in Bear like markdown links) but I want to update any Shortcuts where this might be an issue.

Such a shame because Bear’s URL hiding is such a wonderful feature!

Good luck!

I respectfully suggest a very simple solution here: Bear (and Panda) should have a “display raw markdown” mode, then the wysiwyg issue vanishes in a puff of logic,

1 Like