TextSoap List Content Management30 Nov 2023
There is a wonderfully powerful utility app on the app called TextSoap that has been around on the Mac long before I ever really started using Macs. Its premise is simple - it cleans up text; but its power is huge. The app is really approachable and allows non-programmers to build sophisticated processes for not just “cleaning” text up, but for transforming it in any number of ways. If you aren’t a Unix nerd who was
sed tattooed on their left knuckles,
awk on their right and has either
emacs emblazoned on their chest, then TextSoap might be the text processing utility for you.
For small, frequent jobs, I will be honest and say I usually just default to the built-in functions of my text editors (or Drafts), or a bit of regular expression manipulation. But for the more involved multi-step things, I turn to TextSoap, and in this post I’m going to share a tip for using lists in TextSoap.
What is a TextSoap List?
Lists in TextSoap are a way of defining sets of related text items that can be used by list processing actions. The processing actions read each row in a list as a record, and each column or cell in that row as a field that can then be utilised in some way.
For example you might have a simple list like this that you use for finding and replacing mis-typed terms.
You could also build up more complicated lists with more than two columns for more complex transformations, but a 1-2-1 mapping for find and replace is undoubtedly the most common use case.
Applying a List
A simple cleaner to utilise the list above might look something like this. The first step defines the list to use. The second step indicates that the list will be processed (it does not have to be the subsequent action, but this is a simple example), and within that second step is a third step that uses some tokens to say for every row in the list, find the value in column A and replace it with the content of column B. This cleaner is run against some text and will carry out three find and replace operations on that text for “mac OS”, “MacOS”, and “iPhoneOS”.
Editing the list, we can see that the entries are held in a tabular format.
This tabular/grid format is nice, but it isn’t easy to navigate, and there are no hot keys to do things like add new rows.
The Big List Problem With the Grid
I can find myself working with large find and replace lists, and trying to manually maintain them in the grid is painful. I’m often pulling these lists from other sources, and it isn’t simply a case of pasting them into the grid like you might do in a spreadsheet app. It is a case of manually transferring each cell one by one.
Now that sounds like something you could automate. Well, yes, you could, but as I noted the navigation isn’t as nice as you might hope so automating it could become clunky very quickly.
Fortunately, TextSoap does provide a way to deal with this. I had expected it to be an import function, but it is simpler than that, and yet I didn’t find any mention of it in the documentation, hence I’m documenting it here. After all, I can’t be the only one who didn’t fancy adding several thousand lines of list content by hand.
In the TextSoap settings, take a look at the Advanced Settings tab. At the bottom is an option to Show Developer menu in menu bar. Make sure that this is checked so that you have that menu available to you.
From the Developer menu, check the Invert List Edit option.
This mysteriously named option will switch from a tabular format for the list to a plain text format for the list, with each column entry being separated by a tab character.
This means you can take tab separated text from your favourite text editor and paste it straight into the list editor. No manual entry of each element, no need to go through any sort of import process. Just paste it straight in, OK the content and the cleaner is updated and ready to go.
For small lists, then this isn’t a big deal, but as soon as you want to bring in external content such as from a GitHub gist, or from the output of another application then knowing these settings are available is quite honestly a game changer. List processing is a powerful action framework within TextSoap and being able to prime that easily with large data volumes means that you can accomplish some fantastic things with relatively little effort.
This is something I am doing at the moment. I am building a couple of cleaners for a project I have been working on for the past year. The painstaking process is building my lists and I was dreading having to build a slow and likely unreliable automation to try and speed up the manual entry into the grid, so I was delighted to discover the above when I was digging around in the app settings to see if I could find anything to help me get the data into the app more easily.
Hopefully, this will make large volume list operations in TextSoap a viable option for you too.