Jump to content
raguay.customct

TextSoap cleaners on the Clipboard

Recommended Posts

Description:

 

Just created a quick and easy TextSoap Cleaners workflow to allow for the execution of any of the TextSoap cleaners on the current clipboard contents. It is using the applescript interface to the TextSoap Menu application. Therefore the full application does not need to be running. It works faster than the PopClip extension for TextSoap.

 

This will also remember past used cleaners and give them back to you as an option. That way you can build your most used list here as well. It can also pop up a list of all cleaners in Alfred for you to pick from.

 

Download: https://github.com/raguay/MyAlfred/blob/master/Alfred 3/TextSoapCleaners.alfredworkflow

 

Readme:

 

This workflow is for using the TextSoap cleaners on text. Each keyword is described below:

 

To Use: The "tc:clean" keyword to select from a list of cleaners or a previously used cleaner. The particular TextSoap cleaner will be performed on the contents of the clipboard. If you hold down the FN key, it will delete that cleaner from the list of most used cleaners.

 

You can use a hot-key to launch the last cleaner automatically on the current selection and copy the results back in place. It also has a hot key to copy the current selection, show a list of available cleaners, perform the cleaner, and copy the results back.

 

The "tc:full" keyword will list every cleaner available and perform the selected cleaner on the clipboard contents.

 

The "tc:fulla" keyword does the same as the "tc:full", but copies the result into the top most application.

 

In order to have the list of every cleaner, you should run the keyword “tc:getcleaners" each time you add a new cleaner to Text Soap.

 

You can set an editor to use to edit your personal cleaner list using the "tc:seteditor" keyword. You can then use the "tc:editlist" to edit your list of most used cleaners.

 

You can get a line, word, character count of what is in the clipboard using “tc:count”. It will clean out formatting first (HTML to plain text). If you pass a string with the command, it will count that string. You can set a hotkey to count the selected text. The count is placed back into the clipboard.

 

tc:loadpopclipext This will load the popclip extension for executing the last cleaner on the highlighted text.
 
There are also three places to set your hotkeys: one for doing a character/word/line count of your selection, one for evoking the last cleaner on selected text, and one for choosing from the full list of cleaner to apply on the currently selected text.
 

 

Current Version: 2.3   changed on 06/26/2014

 

I refactored and cleaned up a lot of code. Added the line, word, character counting as well. Just fixed problem with sorting cleaners by location in list and use. Now, Alfred sorts each cleaner by times used only.

 

Current Version: 3.0

 

The link above has been changed to the 3.0 version. Sorry for the inconvenience of not updating this sooner.

 

Let me know if you need more functionality or you find a bug.

 

Richard Guay

Edited by raguay.customct

Share this post


Link to post

I just fixed the way previously selected cleaners are presented to be less confusing. Also, it does semi-fuzzy matching on cleaner names to narrow down the list. Let me know if you think of any other improvements! You can update with AlleyOOP workflow.

Edited by raguay.customct

Share this post


Link to post

I just added a quick addition to perform the last text cleaner done with "tclean" (after updating the workflow) on the currently selected text and paste it back in. I have done some testing with it, but not much. I mostly work in the clipboard, but this functionality was requested. Please check it out and let me know how it goes.

Share this post


Link to post

Just added two new commands:

 

"tclean:getcleaners"  This is to store a list of cleaners that you have in your copy of TextSoap and save them to a file for use in the next command.

 

"tclfull" Same as the "tclean", but allows searching through the full list of cleaners obtained in the "tclean:getcleaners" command.

 

This was done on request from @apkawel. Let me know if you have a special need as well.

Share this post


Link to post

Just added a hotkey (shift-cmd-L) that will copy the current selection, ask for a cleaner from the entire list of cleaners, apply to the selection, and paste it back in place.

 

I have tested it some, but would like to get feedback on how this works. Thanks.

Share this post


Link to post

Hi, I finally got the last few bugs out and now use the Alfred list for all cleaners instead of the TextSoap popup. This version has two new hotkeys and many new functions. I updated the first post with all of the commands.

 

If there is a new feature you need, just let me know about it.

Share this post


Link to post

Just fixed a problem with Alfred sorting cleaners by location in list and number of times used. Now, even if you add or remove cleaners from your list, it sorts by the number of times that cleaner is used. The ID is now based solely on the cleaner's name and not position in the list of cleaners.

Share this post


Link to post

Just fixed a bug with the "tc:fulla" macro. It now saves favorite cleaners using an external trigger. It is now working correctly. Please download the update and let me know if you have any problems. Thanks!

Share this post


Link to post

Well, if you do you will not be disappointed. I have not used Awk once since I purchased it. It is a great little utility (especially if you do a lot of text work).

Share this post


Link to post

Hi, I just made a lot of bug fixes on this workflow and added some external triggers and a PopClip extension that will make use of the external trigger to perform a cleaner on the selected text. One action making use of three programs! Automation at it's best.

Share this post


Link to post

Hi,

 

I just updated all of the Script Filters to a Haskell program for speed. You can download from the above sources. Let me know if this did speed you up or not. I am trying to figure out how much improvement a dedicated program will be over scripts. Haskell produces much smaller programs than golang. So, I have been switching to it.

Share this post


Link to post

I get an unexpected error (in the debugger) when attempting to run the tc:clean command

 

[ERROR: alfred.workflow.input.scriptfilter] Code 1: textsoap: /Users/woody/Library/Application Support/Alfred 2/Workflow Data/com.customct.TextSoapCleaners/cleaners.txt: openFile: does not exist (No such file or directory)

 

The cleaners.txt file was created by tc:getcleaners and IS at the path specified in the error. 

 

Any hints as to what's going wrong here?

Share this post


Link to post

This error is only shown if that file doesn't exist, which is the case if you have just started using the workflow. First time to run a cleaner, use "tc:full" and select a cleaner. That routine creates the cleaners.txt file that stores all the cleaners you have made use of.

 

Anyway, I fixed the file not found error. It will now work, but say it could not find any. You still need to use the tc:full to select all the cleaners. I made this separation to make the tc:clean run faster (My full has over 200 cleaners, but my short version only has 50 that I use all the time). The new version is on Packal and my GitHub accounts.

 

Let me know if you have any other problems.

Share this post


Link to post

I just updated the workflow to work with TextSoap 8. If you haven't upgraded to this version, you should. It runs much faster and lots of bug fixes. The workflow currently only works with version 8. If you haven't upgraded, then just use the older version. I haven't added any other features.

Share this post


Link to post

The latest release of TextSoap 8 fixes all of the bugs with this workflow. Please update to version 8.0.5. This fixes the issues with new cleaners not showing up in the "tc:getcleaners" command. Please let me know if you find any other problems.

Share this post


Link to post

I'm using TextSoap 8 together with this workflow a lot. It is very powerful, thank you for creating it! I have just a minor comment: The function for counting lines, words and characters sometimes counts one line less than what I expect if there is no newline character ending the last line. The built-in function in TextSoap 8 "Word Count - Notification" then counts one more paragraph than the number of lines given by your workflow. Would it be appropriate to add +1 to the line counter variable?

Edited by cands

Share this post


Link to post

I'm using TextSoap 8 together with this workflow a lot. It is very powerful, thank you for creating it! I have just a minor comment: The function for counting lines, words and characters sometimes counts one line less than what I expect if there is no newline character ending the last line. The built-in function in TextSoap 8 "Word Count - Notification" then counts one more paragraph than the number of lines given by your workflow. Would it be appropriate to add +1 to the line counter variable?

 

Thanks. I am glad you like the workflow. It is the workflow I use the most too!

 

If you do not copy the last lines carriage return, then it doesn't count that line as a full line. I always copy past the last line to get the carriage return and the count always comes out fine. I'll look into adding a detector for the last line not having a carriage return and add one if needed. That would be a more robust solution. But, I've converted everything to Alfred 3 now. Since they do not want us updating everything until Alfred 3 is out completely, you will need to wait until Alfred 3 is fully released to get the full update. For now, just copy past the last CR and your count will be fine.

 

The routine uses the wc command line program. It is a peculiarity with that program. I also noticed that I did not package the "Clean For Word Count" cleaner with the workflow. If you create a cleaner with that name, you can specify actions to clean unwanted items (ie: - / \ * and the like) from the text before counting it. That way, your character count will be accurate to actual words and not punctuations. The wc program doesn't always get it right .

Edited by raguay.customct

Share this post


Link to post

In case anyone browses the forum to figure out why this workflow stopped working after upgrading to Alfred 3, just go through the workflow and update scripts as follows: [e.g., tell application] "Alfred 2" → "Alfred 3".

 

@raguay.customct, this workflow is indeed the best. Thank you once again!

 

It may be my imagination, but it seems that this workflow is even faster on Alfred 3. Fantastic! :-)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×