Jump to content

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 5/TextSoap Cleaners 9.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.

 

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 changed on 11/22/2022

 

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

 

Current Version: 6.0

 

Just updated to Alfred 5. This workflow no longer uses environment variables. It still uses node.js if the compiled version of the internal program isn't used.

 

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

 

Richard Guay

Edited by raguay.customct
Version Update
Link to comment

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
Link to comment
  • 2 weeks later...

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.

Link to comment
  • 4 weeks later...

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.

Link to comment
  • 1 month later...
  • 1 month later...
  • 4 months later...
  • 3 weeks later...

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.

Link to comment
  • 4 weeks later...
  • 1 month later...
  • 7 months later...

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.

Link to comment
  • 3 weeks later...

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?

Link to comment

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.

Link to comment
  • 11 months later...
  • 1 month later...
  • 1 month later...

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
Link to comment

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
Link to comment

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! :-)

Link to comment

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
×
×
  • Create New...