Deprecated: Return type of I::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 62

Deprecated: Return type of I::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 91

Deprecated: Return type of I::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 71

Deprecated: Return type of I::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 101

Deprecated: Return type of I::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 53

Deprecated: Return type of Collection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/collection.php on line 80

Deprecated: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in /home/public/kirby/toolkit/lib/url.php on line 135
One Tap Less | Recursive action with multiple lines in Drafts

Recursive action with multiple lines in Drafts


Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

Warning: Trying to access array offset on value of type null in /home/public/kirby/vendors/parsedownextra.php on line 305

Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /home/public/kirby/vendors/parsedownextra.php on line 305

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.