Is there a simple "cleanup" action?

I’m looking for an action that will process some text by removing all extra spaces and line feeds. Couldn’t seem to find it in the actions archive. Is there such a thing?

Should be easy enough to put something together, if you can specify what an extra space is (potentially where in a line too) and what extra line feeds are.

One person’s “extra” may be another person’s “essential”.

Also worth considering how you might want to handle other whitespace characters such as tabs, non-breaking spaces, etc.

Something quick and dirty would be fine: all contiguous spaces greater than one would be reduced to one, and all line feeds would be removed.

I’m kind of dumbfounded that such basic text processing functions appear to be missing from Drafts. Are we expected to implement these via javascript?

1 Like

Here’s a quick and dirty one then - Compress spaces and blank/empty lines.

They aren’t missing. You just get to build Drafts out however you want and you are given all of the tools to do it. The action directory is partially populated by the developer to give some starting points, but it is mainly populated by the user community.

Others may have built the " basic text processing functions" you were seeking, but may simply not have published them in the directory. Also I think you might well be the first person to post a query about them here, which might be an indication of how universal it might be considered?

Consider also, my point above about the number of ways and edge cases that may be handled by this sort of thing. Different people may want to handle it in different ways. That’s exactly why tools like Text Soap exist on the Mac.

But hopefully the action above will get you to your desired outcome.

Hope that helps.

That’s exactly why tools like Text Soap exist on the Mac

Exactly, and that’s why I’m looking for similar functions in Drafts. For anyone who wants to copy text from PDFs, compressing spaces and blank/empty lines would appear to be helpful.

Not within Drafts, but if your looking for something like TextSoap on iOS you might want to try CleanText.

1 Like

I can see that Clean Text doesn’t work within Drafts – but why not? Why isn’t there the possibility to invoke the share menu?

Haven’t looked into that, it might be possible with url schemes. But there are other users here that are more into that.

In the “Basic” action group, there’s a ‘standard’ action called “Share” that send the entire Draft content as plain text to the share sheet.

If you wanted to use an app like Clean Text you can invoke the share sheet through an action (but you could create actions to send just a selection or just the body of the draft to the share sheet, etc.)

Clean Text does support x-callback-url (documentation], so you could create an action to round trip the data into Clean Text and back with a Drafts action that utilises the x-callback-url step.

1 Like

On iPad if I select the text then long press Share the Share menu pops up. I enabled CleanText and it offers lots of cleanings. It has a Copy button and then Cmd+V pastes over the top of the selected text.

The minor pity is the requirement to use the clipboard to overwrite the original text.

This on a 12.9” iPad Pro with an external Logitech keyboard - which made Cmd+V doable.

Thanks for this thread as it caused me to enable CleanText and experiment. (I also see TextTool in my share sheet, FWIW.)

Only an option for the people who grabbed a copy a few years back.

https://web.archive.org/web/20180308202530/http://www.blackfoginteractive.com/parting-glass.html