Recursive action with multiple lines in Drafts

In its latest update, Drafts add ranges to the [[line]] tag, meaning you can slim your selection to only a few paragraphs using, for example, [[line|2..5]] to select from the second line to the fifth line. But this feature also allows ranges, [[line|..3]], would select every line, starting with the third, before it; or [[line|3..]] which will select every line, starting with the third, after it.

It is easy to visualize a purpose for the after range, like I showed in the previous article, it lets you create an action using a third tag with multiple lines, like in an email with recipient and subject. The before range often suggests that you know the number of lines you gonna use, which makes it more case-specific, in my opinion.

You already know my admiration for Eric Pramono and his Fantastical workflow to add several events using the app's natural language input, x-callback-url support, I consider it as the action that defines the potential for x-callback-url and Drafts itself.

And it is time to take it to the next level.

For this example, I'll use Pinner, a Pinboard client with a quite nice url scheme, supporting several parameters. You can check its documentation here.

Bookmark with Pinner (or Pin Them All)

pinner://x-callback-url/bookmark?href=[[title]]&tags=[[line|2]]&x-source=Drafts&x-success={{drafts://x-callback-url/create?text=[[line|3..]]&action=Pin%20Them%20All&afterSuccess=Delete&allowEmpty=NO}}&x-cancel={{drafts://x-callback-url/create?text=[[line|3..]]&action=Pin%20Them%20All&afterSuccess=Delete&allowEmpty=NO}}

Update: You may have noticed that this action brings an error by the end because Drafts 3.5 also included actions with an empty document, to fix it, Greg included a allowEmpty parameter in Drafts 3.5.3 which accepts a YES or NO value. As you can guess, using allowEmpty=NO fix the aforementioned error. Add this tag to your callback parameters or just download the action again.

It looks unusually long, but there aren't many changes compared to Eric's original action. Now we're using two parameters from Pinner, href, which is mandatory, and tags. Instead of bouncing back after we bookmark our url and create a new draft from the [[body]] of the original draft, we use [[line|3]], to skip the first two lines, those we used in the first batch. If we were using more parameters, we'd just keep adding the range. If you want the geek way, use this equation: [[line|n]] where n is equal to the number of lines used plus 1.

As usual, what you can do with this action is up to you. Check the x-callback-url library available in this blog to find the right inspiration and let me know what you came up with.