bmscmoreira Posted April 15, 2013 Share Posted April 15, 2013 Hello all. I was wondering if there is anyone interested in creating an Alfred workflow to allow an easy way to use html tidy (http://tidy.sourceforge.net) and css tidy (http://csstidy.sourceforge.net). The workflow could be something like this: 1) user copies some html or css to the clipboard (CMD+C) 2) user invokes Alfred window (option+space); 3) user invokes keyword "tidyhtml" or "tidycss"; 4) user presses (enter); 5) a "tidied" version of the html or css is copied back to the clipboard replacing the older content (or directly pasted into an opened and with focus text editor). Is this doable ? Link to comment
jdfwarrior Posted April 15, 2013 Share Posted April 15, 2013 Hello all. I was wondering if there is anyone interested in creating an Alfred workflow to allow an easy way to use html tidy (http://tidy.sourceforge.net) and css tidy (http://csstidy.sourceforge.net). The workflow could be something like this: 1) user copies some html or css to the clipboard (CMD+C) 2) user invokes Alfred window (option+space); 3) user invokes keyword "tidyhtml" or "tidycss"; 4) user presses (enter); 5) a "tidied" version of the html or css is copied back to the clipboard replacing the older content (or directly pasted into an opened and with focus text editor). Is this doable ? It appears that both are binary executables so, yeah this should be very easily done. I'll throw a workflow together for you in a bit. Link to comment
bmscmoreira Posted April 15, 2013 Author Share Posted April 15, 2013 Thanks! I am sure it will be of great use to everyone Link to comment
jdfwarrior Posted April 16, 2013 Share Posted April 16, 2013 Thanks! I am sure it will be of great use to everyone May not be perfect yet but try this and let me know what you think Download This works as a result action. So.. select a file in Alfred, press right arrow, and select tidy. The formatted code from the file is set in the clipboard for pasting. Link to comment
bmscmoreira Posted April 16, 2013 Author Share Posted April 16, 2013 A start! Thanks. The navigation works although it's not very intuitive... it would be great to have the steps as suggested, i.e., executing the action on the clipboard contents (would allow, for eg. an user to select part of an html document and only tidy that part). But I don't know if it's possible, because I've run the workflow through Alfred navigation, and in the end, after pasting the result into the document, all line indents were removed (but I don't know if Tidy auto-indents the markup by itself – I have tried Tidy via BBEdit and it did). Anyway, thanks for starting this up! Link to comment
nolimits Posted July 27, 2015 Share Posted July 27, 2015 Hey All, Hopefully its okay to revive this thread, i would very much like to see the original request work. Do you think its possible to do this with CSS? 1. I put some css on the clipboard 2. Invoke tidyCSS or similar as keyword, with the clipboard as the argument automatically read 3. on cmd-v, the tidied css is pasted into whatever texteditor is open Thanks! Link to comment
deanishe Posted July 29, 2015 Share Posted July 29, 2015 The indentation of the HTML is an option to tidy. The following script will do what you want (for HTML). Stick it in a Run Script action with language = /bin/bash. Connect it to a Keyword or Hotkey to run it. export LANG=en_US.UTF-8 # needed to make pbpaste and pbcopy work properly pbpaste | /usr/local/bin/tidy -i -utf8 | pbcopy It should be simple enough to adapt for tidyCSS, but I don't have that. smarg19 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