andy4222 Posted January 8, 2022 Share Posted January 8, 2022 (edited) 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 January 8, 2022 by andy4222 Link to comment
deanishe Posted January 9, 2022 Share Posted January 9, 2022 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
andy4222 Posted January 9, 2022 Author Share Posted January 9, 2022 18 minutes ago, deanishe said: They only support plaintext input. But the input I am providing is plain text right? With empty lines. No styling or specific formatting Link to comment
deanishe Posted January 9, 2022 Share Posted January 9, 2022 3 hours ago, andy4222 said: But the input I am providing is plain text right? I don't know what input you're providing, but Alfred will only pass the plaintext version to a Universal Action set to accept Text. Link to comment
andy4222 Posted January 9, 2022 Author Share Posted January 9, 2022 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
deanishe Posted January 9, 2022 Share Posted January 9, 2022 I don't understand. What's the problem? Link to comment
andy4222 Posted January 9, 2022 Author Share Posted January 9, 2022 (edited) the input has multiple new lines, and the string that is received to the script is without any new lines Edited January 9, 2022 by andy4222 Link to comment
deanishe Posted January 9, 2022 Share Posted January 9, 2022 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
andy4222 Posted January 9, 2022 Author Share Posted January 9, 2022 Amazing, removed `echo` and it works. Thanks a lot @deanishe. You are awesome!! Link to comment
andy4222 Posted January 10, 2022 Author Share Posted January 10, 2022 (edited) 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 January 10, 2022 by andy4222 Link to comment
deanishe Posted January 10, 2022 Share Posted January 10, 2022 (edited) 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 January 10, 2022 by deanishe andy4222 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now