Jump to content

Text losing its formatting [when using universal actions]


Recommended Posts

I'm trying to build a text transformation for my needs via Universal Actions. A few of the text transformation work (upper case, lower case, json minify etc.) but a lot of them are failing since the text alfred passes to the javascript method removes all formatting. e.g.

 

INPUT selected and then trigger universal actions:

asdasdsadsad
<empty line placeholder>
<empty line placeholder>
asdasdasdasd
<empty line placeholder>
asdsadasdasd


///OUTPUT - trying to trigger "remove empty lines" action
console.log when javascript method receives it
Passing output 'asdasdsadsad asdasdasdasd asdsadasdasd`

 

same is causing issues with json transformations as well. Anything I can do so the javascript method receive the correct input @deanishe

 

 

 

workflow link: https://www.dropbox.com/s/4bajohqfdvpgcjc/Text Transformer - Mine - COPY.alfredworkflow?dl=0

 

Edited by andy4222
Link to comment
13 hours ago, andy4222 said:

Anything I can do so the javascript method receive the correct input

 

Not using Universal Actions, no. They only support plaintext input.

 

You'll have to read the rich text from the clipboard yourself, and perhaps trigger the copy as well, depending on how you want it to work.

 

I'm not sure how well modifying rich text with JavaScript will work, though. I'm not super familiar with the format, but it has some encoding quirks that might lead to errors if you're not careful, and a blank line in a rendered rich text file isn't a blank line in the source.

Link to comment
INPUT selected and then trigger universal actions:

asdasdsadsad
<empty line placeholder>
<empty line placeholder>
asdasdasdasd
<empty line placeholder>
asdsadasdasd


///OUTPUT - trying to trigger "remove empty lines" action
Passing output 'asdasdsadsad asdasdasdasd asdsadasdasd`
Link to comment
2 hours ago, andy4222 said:

the string that is received to the script is without any new lines

 

The input to the script is correct. Your echo is removing the newlines from the script's output.

 

This:

echo $( /usr/local/bin/node transformer.js "$operation" "$inputString" )

 

should be this:

/usr/local/bin/node transformer.js "$operation" "$inputString"

 

 

Link to comment

One last question @deanishe, in this workflow, the Script Filter is generating the list but it does not filter the items when I type. I have to explicitly check "Alfred filters results" to make it filter the results. Is this expected? I checked some other workflows created by the community and that setting is not checked but Alfred does filter the script filter results. Want it to have fuzzy search

 

workflow: https://www.dropbox.com/s/ha3riwcd67nooj9/Text Transformer - Mine.alfredworkflow?dl=0

Edited by andy4222
Link to comment
1 hour ago, andy4222 said:

I checked some other workflows created by the community and that setting is not checked but Alfred does filter the script filter results.

 

They filter their own results.

 

If you don't have "Alfred filters results" checked, Alfred passes the search query to the workflow script, and it should only return matching results.

 

1 hour ago, andy4222 said:

Want it to have fuzzy search

 

Then you'll have to implement it yourself, or use a shim script.

Edited by deanishe
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...