Airo AV Proclaims – Shortcuts Rewind: Linking Methods Utilizing Markdown and Wealthy Textual content

Shortcuts Rewind: Linking Tricks Using Markdown and Rich Text

Editor’s Notice

Over the previous a number of years, Federico has constructed a whole lot of shortcuts which can be sprinkled all through the tales he’s written. Final spring we debuted the MacStories Shortcuts Archive, a one-stop vacation spot that collects all of these shortcuts organized by subject, so readers can discover them simply.

There’s no higher solution to learn to construct your personal shortcuts than by downloading another person’s, which is what makes the Archive such a useful useful resource to readers and considered one of MacStories’ hottest options. Nonetheless, it may be arduous to select up finest practices and patterns or different ideas and methods from experimentation and tinkering.

That’s why at the moment we’re introducing a brand new collection on MacStories known as Shortcuts Rewind so as to add context to the shortcuts within the Archive. Periodically all year long, we are going to decide a couple of shortcuts from the Archive that we expect would profit from an extra rationalization, whether or not that’s to assist new Shortcuts customers study the fundamentals, as an example a selected approach that can be utilized throughout a number of shortcuts, or to automate a process that you just may not have thought was attainable.

Tying Shortcuts Rewind collectively is a brand new graphical strategy to explaining shortcuts. As you’ll see, we’ve created a system that dispenses with distracting UI components and breaks shortcuts into logical units of actions. The strategy permits us to concurrently present step-by-step directions alongside commentary that we hope will assist readers obtain a deeper understanding of Shortcuts and help them in constructing their very own automations.

Let’s get began.

For this primary installment of Rewind, I wished to start out with a trio of comparatively easy shortcuts that illustrate the facility of Shortcuts’ capacity to streamline the transformation of 1 kind of content material into one other. All three shortcuts might be present in the Textual content part of the Shortcuts Archive, however there are additionally hyperlinks to them beneath. The muse of this course of is the Content material Graph, a core a part of Shortcuts courting again to its origins as Workflow. The concept is a straightforward however highly effective one which eliminates complexity for the person, dealing with a lot of the information compatibility and conversion chores behind the scenes with little or no effort on the a part of the person.

On the coronary heart of the three shortcuts mentioned beneath are transformations between plain textual content, wealthy textual content, and URLs. Because of the Content material Graph, Shortcuts has the flexibleness to create highly effective textual content and hyperlink dealing with performance.

Clear Up Wealthy Textual content

You’ve in all probability been there. You copy textual content from a webpage and paste it into an e-mail message, and the wealthy textual content copied contains a number of undesirable baggage just like the supply’s font, textual content shade, and background shade. That makes the pasted textual content look misplaced at finest, and infrequently unreadable.

This primary shortcut cleans up unpleasant wealthy textual content whereas preserving primary formatting like daring, italics, and hyperlinks. To make use of Clear Up Wealthy Textual content, merely run the shortcut after you’ve copied wealthy textual content however earlier than you paste it into one other app. In 4 easy steps that run virtually immediately, the shortcut will course of the textual content in your clipboard, changing the clipboard’s contents with the cleaned-up model, so you’ll be able to paste it elsewhere.

➊ Get Clipboard

Whenever you’re constructing a brand new shortcut, it pays to consider the context wherein you’ll use it as a result of that always dictates step one, the forms of enter it handles, and different points of the design of the shortcut. Clear Up Wealthy Textual content is constructed to get rid of undesirable formatting while you’re pasting wealthy textual content into one other app, which is why Step 1 is to seize the contents of the iOS clipboard utilizing the ‘Get Clipboard’ motion.

➋ Make Markdown from Clipboard

Step 2 of the shortcut converts the wealthy textual content pulled from the clipboard to plain textual content utilizing Markdown, the plain textual content markup syntax created by John Gruber, utilizing Shortcuts’ built-in ‘Make Markdown from Wealthy Textual content’ motion. The trick of this shortcut lies in its use of Markdown, which helps primary formatting like daring, italics, and hyperlinks, however not wealthy textual content formatting like textual content or background colours. Consequently, changing the wealthy textual content in your clipboard to Markdown leaves different formatting behind.

Nonetheless, we’re not fairly completed but. If we pasted the outcomes of Make Markdown from Wealthy Textual content into an e-mail message, we’d find yourself with one thing like this:

As a substitute, we wish the extra readable wealthy textual content model of the Markdown generated by Step three, which requires another conversion motion.

➌ Make Wealthy Textual content from Markdown

Step three takes the Markdown you created within the final step and converts it again to wealthy textual content utilizing the ‘Make Wealthy Textual content from Markdown’ motion. Once more, Shortcuts is sensible sufficient to know that you almost certainly wish to convert the Markdown from Step 2, so it fills within the parameter for you routinely. As a result of Step 2 stripped undesirable formatting, the wealthy textual content generated by this motion will embrace simply the fundamental formatting supported by Markdown.

➍ Copy to Clipboard

Clear Up Wealthy Textual content ends very similar to it started, however as an alternative of grabbing the contents of the clipboard, Step four locations the outcomes of the shortcut again on the clipboard utilizing the ‘Copy to Clipboard’ motion. With the cleaned up wealthy textual content in your clipboard, now you can paste it into an e-mail message or another app that accepts wealthy textual content.

The results of Clear Up Wealthy Textual content is a a lot nicer, extra readable model of the textual content copied from a webpage that preserves the hyperlink and bulleted listing, however eliminates the blue background from the supply textual content. The shortcut additionally exhibits the way it pays to grasp the attributes of the information codecs dealt with by Shortcuts as a result of it’s the distinction between wealthy textual content and Markdown that permits Clear Up Wealthy Textual content to strip away the blue background on this instance.

You may obtain Clear Up Wealthy Textual content beneath or discover it within the MacStories Shortcuts Archive.

Shortcut Wealthy Hyperlink combines Markdown and wealthy textual content in a means that’s just like Clear Up Wealthy Textual content for a wholly totally different goal. This shortcut generates a wealthy hyperlink to considered one of your current shortcuts and locations it on the clipboard, so you’ll be able to paste it into one other app. Maybe you’ve a word associated to a challenge in Apple’s Notes app or a recurring process in Reminders the place you need quick entry to considered one of your shortcuts. With Shortcut Wealthy Hyperlink, you’ll be able to put a hyperlink to the shortcut you want the place you want it, so that you don’t must hunt round for it within the Shortcuts app.

This shortcut is a little bit longer than the final, so I’ve damaged it into two components.

Shortcuts makes use of a URL scheme to open particular person shortcuts that consists of a base URL which opens Shortcuts and a parameter based mostly on the identify of the shortcut you wish to open. Subsequently, to create a wealthy hyperlink to a shortcut, it is advisable to decide a shortcut, get its identify, construct a URL, after which apply the Markdown and wealthy textual content methods from the final shortcut to create a wealthy hyperlink.

➊ Get My Shortcuts

The very first thing you want is an inventory of your shortcuts. Step 1 makes use of the very meta motion ‘Get My Shortcuts’ to retrieve an inventory of your shortcuts. This can be a quite simple however helpful motion that doesn’t take any parameters.

➋ Select from Checklist

Step 2 makes use of considered one of Shortcuts’ scripting actions known as ‘Select from Checklist.’ Scripting is a whole part of the Shortcuts motion library containing dozens of helpful actions that don’t belong to a selected app or one other motion class. The Scripting part of the motion library is split into subsections, together with a Checklist part, which comprises three actions for dealing with Lists and the gadgets in them.

Select from Checklist shows an inventory of the shortcuts generated by Step 1. You’ll discover that on the backside of the motion is a ‘Present Extra’ button. Faucet that to disclose optionally available motion settings. For this shortcut, a ‘My Shortcuts’ immediate has been added, which supplies the listing a title by that identify. The ‘Choose A number of’ toggle is off as a result of we’re solely making a hyperlink to 1 shortcut.

➌ Textual content

Step three of Shortcut Wealthy Hyperlink makes use of a ‘Textual content’ motion to create the URL on your shortcut. Shortcuts makes use of a URL scheme that begins shortcuts://open-shortcut?identify= and is tough coded on this shortcut as a result of it gained’t ever change.

For those who’re constructing this shortcut from scratch, you’ll see an inventory of Magic Variables instantly beneath the editor, considered one of which is ‘Chosen Merchandise.’ Whenever you faucet it, a tokenized model with a gear icon seems on the finish of your Textual content motion. Under the editor is an inventory of information obtainable to you. The default is ‘Title,’ which is precisely what we have to full the URL, so no modifications are wanted. Simply faucet it, and ‘Chosen Merchandise’ modifications to ‘Title’ within the URL you constructed.

The rest of Shortcut Wealthy Hyperlink transforms the textual content generated above right into a URL, builds a Markdown model of the hyperlink to your shortcut, after which converts it to a wealthy hyperlink.


Step three used a Textual content motion to piece collectively the components of the URL that may hyperlink to the shortcut you picked. Nonetheless, it’s not a URL but; it’s simply textual content. To create a URL that hyperlinks to the shortcut, a ‘URL’ motion is required.

Whenever you add the URL motion to the editor in Step four, you’ll discover that it’s not related to the textual content motion above it but, and there’s an empty parameter for a URL. Lengthy-press on the parameter, faucet Choose Magic Variable, after which decide the ‘Textual content’ variable that seems slightly below the Textual content motion. That connects the URL motion to the Textual content motion above it, and ‘Textual content’ now seems within the URL motion to indicate that the textual content output from the earlier motion will probably be used to create the URL.

❺ – ➐ Markdown → Wealthy Textual content → Clipboard

Steps 5, 6, and seven of the shortcut will look acquainted as a result of they’re just like those utilized in Clear Up Wealthy Textual content, however as an alternative of changing a wealthy hyperlink to Markdown and again once more to strip undesirable formatting, Step 5 builds a Markdown-formatted hyperlink utilizing a Textual content motion and two Magic Variables: the identify of the shortcut picked in Step 2 and the URL generated by Step four. That Markdown hyperlink is then transformed to wealthy textual content utilizing a Wealthy Textual content from Markdown motion in Step 6, which is copied to the clipboard utilizing a Copy to Clipboard motion in Step 7.

What I like about Shortcut Wealthy Hyperlink is that the identical hyperlink creation approach utilized in Clear Wealthy Hyperlink to strip formatting is used to construct a tappable hyperlink. The shortcut is a terrific instance of how remixing the identical actions can lead to very totally different shortcuts.

You may obtain Shortcut Wealthy Hyperlink beneath or discover it within the MacStories Shortcuts Archive.

The ultimate shortcut I wish to cowl is Create Hyperlink, which takes the hyperlink creation approach from the shortcuts above and combines it with circulate logic to achieve totally different outcomes relying on what’s fed to the shortcut.

Create Hyperlink can pull URLs out of your clipboard and use them to create hyperlinks no matter what else is on the clipboard. Which means whether or not you’ve an inventory of uncooked URLs or a paragraph of textual content copied from a webpage that features linked textual content, Create Hyperlink can use the URLs in your clipboard to create a hyperlink.

This shortcut is a bit more concerned than the earlier two as a result of it contains circulate logic to take care of three situations the place: there is no such thing as a URL on the clipboard, wherein case the shortcut alerts you to that truth, there’s one URL on the clipboard, wherein case there is no such thing as a cause to make you decide from an inventory, and there are a number of URLs on the clipboard, wherein case the shortcut asks you to select one.

➊ – ➋ Get Clipboard and Get URLs from Enter

The primary two steps of Create Hyperlink are simple. The Get Clipboard motion in Step 1 takes the contents of your clipboard and sends it to the ‘Get URLs from Enter’ motion in Step 2, which defaults to utilizing the contents of the clipboard from Step 1.

➌ Depend

Step 2 passes the URLs extracted from the clipboard to a utility motion known as ‘Depend’ in Step three, which does as you’d anticipate. By default, while you add it after Step 2, the motion will rely the ‘Gadgets’ in ‘URLs,’ which is what we wish. If for some cause, you wished to rely one thing aside from the gadgets from Step 2, you’ll be able to lengthy press on Gadgets or URLs to select one thing else.

Half 2 of Create Hyperlink is the place the branching logic comes into play. There are three attainable situations that should be addressed:

  • There aren’t any URLs on the clipboard
  • There’s one URL on the clipboard
  • There are a number of URLs on the clipboard

To deal with these three choices, Create Hyperlink makes use of nested ‘If’ actions. An If motion is comprised of three components: the If motion, an ‘In any other case’ motion, and an ‘Finish If’ motion. A single If motion is all you want you probably have simply two choices to take care of, however as I’ll clarify beneath, it is advisable to nest two extra If actions inside the primary If motion to deal with all three of the situations described above.

➍🅰 If actions and Present Alert

Step 4A covers the case the place the clipboard comprises no URLs. As quickly as you add your first If motion, Shortcuts assumes you wish to base it on the variety of Gadgets from Step three, which is right. All it is advisable to do is faucet the Situation parameter within the If motion and decide from the 9 totally different strategies of evaluating values. For this primary If motion, the primary choice, ‘is,’ works as a result of we wish to measure if the variety of URLs counted is zero. After selecting the ‘is’ parameter, a brand new parameter for a quantity seems. Faucet it then kind zero.

If there aren’t any URLs on the clipboard, we wish to show an alert to that impact, so add a ‘Present Alert’ motion to the shortcut. The Present Alert motion will seem after your If motion block, so drag it between the If motion and the In any other case motion. Then, you’ll be able to change the textual content of the alert to one thing just like the language used within the model discovered within the MacStories Shortcuts Archive: “Your clipboard doesn’t include any URLs in the mean time. Run this shortcut once more after copying a hyperlink.”

➍🅱 Set Variable

Step 4B is the place we add the primary nested If motion. Add an If motion to the shortcut such as you did above and drag it between the In any other case and Finish If actions of your first If motion.

This second If motion likewise assumes you wish to management what occurs based mostly on the rely of the gadgets from Step three, which is right. Faucet the ‘Situation’ parameter, select ‘is’ from the listing, after which set the Quantity to 1.

Create Hyperlink was created earlier than an replace to Shortcuts that can be utilized to simplify the shortcut a little bit. Shortcuts makes use of variables, together with Magic Variables, to retailer information briefly that can be utilized by different actions within the shortcut. Beforehand, you needed to ‘get’ a variable each time you wished to set it to a different worth. Now, you’ll be able to skip the ‘Get’ actions you see in Steps 4B and C, and go on to the ‘Set Variable’ motion. The Create Hyperlink shortcut within the MacStories Shortcuts Archive nonetheless works with the Get actions, however in case you’re creating it from scratch, proceed to the Set Variable motion, which defines a brand new variable known as ‘Hyperlink’ and assigns it the URL Magic Variable output from Step 2.

➍🅲 Select from Checklist and Set Variable

Step 4C requires one other If motion to be dragged after Step 4B’s In any other case motion. This time, nevertheless, set the situation so it reads ‘If Depend is larger than 1.’ If there’s multiple URL on the clipboard we have to decide one, so add a Select from Checklist motion, just like the one we used within the Shortcut Wealthy Hyperlink above. Whenever you drag the motion into place after the If motion, Shortcuts will assume you wish to decide from the Depend variable, however we wish the URLs as an alternative so lengthy press on Depend, faucet Choose Magic Variable, and decide URLs, which seems simply after Step 2.

Lastly, add a Set Variable motion and set it to the Hyperlink variable. Shortcuts will routinely counsel setting Hyperlink to Chosen Merchandise, which is what we wish, so no change must be made there. For those who’ve set the nested If actions up accurately, they are going to finish in an In any other case motion adopted by three Finish If actions.

The ultimate a part of Create Hyperlink takes the URL from Half 2 and makes use of it to generate a hyperlink.

➎ Ask for Enter

Step 5 makes use of an ‘Ask for Enter’ motion, which would be the textual content to which the URL is linked. The shortcut makes use of an ‘Enter Hyperlink Textual content’ immediate to let the person know what enter is being requested.

➏ – ➑ Markdown → Wealthy Textual content → Clipboard

The ultimate three steps ought to be acquainted by now. Step 6 builds a Markdown hyperlink that mixes the textual content enter in Step 5 and the URL from Half 2 above. Subsequent, Step 7 converts the Markdown hyperlink to a wealthy textual content hyperlink, and eventually, Step eight copies the hyperlink to the clipboard for pasting in one other app.

You may obtain Create Hyperlink beneath or discover it within the MacStories Shortcuts Archive.

My favourite a part of these three shortcuts is the flexibleness they display regardless of being comparatively easy. There are occasions and locations for extra advanced shortcuts, however typically it’s the only shortcuts that turn out to be useful probably the most. Which means even in case you’re a newbie, you’ll be able to construct shortcuts that may prevent effort and time straight away, whereas concurrently studying methods you’ll be able to construct on to create extra advanced shortcuts later.

Keep tuned for future installments of Shortcuts Rewind. Though this inaugural story is geared toward freshmen, our plan is to construct on it and publish quite a lot of tales that may attraction to Shortcuts customers of all expertise ranges.

Jonathan Cartu Spyware and adware Software program

Author: Jonathan Cartu

Leave a Reply

Your email address will not be published. Required fields are marked *