TextWrangler + tidy

as I didn’t get TidyService to work correctly with UTF8 umlauts, I created a UNIX Shell Script wrapper for html tidy as it comes with OS X that does the job at least for TextWrangler:

  1. open TextWranglers „Unix Filters Folder“
  2. create a file named e.g. „Tidy Html.sh“,
  3. paste the following lines into the file and save it:
    # run "tidy" on the file given as 1st (and only) parameter.
    /usr/bin/tidy -utf8 -asxhtml -indent -wrap 100 -quiet "$1" 2> /dev/null
  4. now you can run tidy on files opened in TextWrangler, even remote files.
  5. assign a keyboard shortcut (I used CTRL-T in the shot above) via the „Unix Filters“ Palette:

Comments 13

  1. akawee wrote:

    Hey Vielen Dank für Deinen Tipp funktioniert einwandfrei!

    Posted 17 Mai 2010 at 11:38 am
  2. Eric wrote:

    Awesome tip! Thanks for sharing!

    Posted 16 Nov 2010 at 3:55 am
  3. Thomas Beek wrote:

    Awesome tip. Thanks!

    Posted 01 Feb 2011 at 7:32 pm
  4. Neil Smith wrote:

    That was a fantastic tip, saved me so much time on a project.

    Posted 25 Apr 2011 at 3:32 pm
  5. Bryan wrote:

    Thank you so much for this tip!

    Posted 08 Jun 2011 at 10:31 pm
  6. Adrian wrote:

    That’s excellent! Thanks!

    Posted 26 Okt 2011 at 1:29 pm
  7. David Malouf wrote:

    Just started using Mac. Couldn’t get Tidy service to work at all (Lion – 10.7). Don’t even need it with your super-helpful script!! Thanks a TON!

    Posted 14 Dez 2011 at 7:42 pm
  8. Dave wrote:

    Worth mentioning that (at least on my installation) the new script is not usable until you quit and re-start TextWranger.

    Posted 20 Jan 2012 at 11:24 am
  9. David Malouf wrote:

    Whilst I love the simplicity of the script Marcus gave us, it doesn’t work with some of the XML I have to deal with that has ridiculous namespacing.

    This is because ‚tidy‘ can’t handle it.

    I did find the following site has a similar script that has a ‚work around‘ that works great for me: http://magp.ie/2010/02/15/format-xml-with-textwrangler/

    NO disrespect to Marcus for his awesome and simple script!

    Posted 09 Feb 2012 at 12:48 am
  10. Theo wrote:

    Any chance you can update this for Textwrangler 4.0.1? I can’t find the „Unix Filters“ menu. :-O

    Posted 19 Aug 2012 at 8:05 am
  11. Marcus Rohrmoser wrote:

    Hi Theo,
    actually I can’t find it no more, either (4.0.1).

    But pointing finder at „~/Library/Application Support/TextWrangler/Text Filters/“ reveals the scripts.

    Posted 05 Feb 2013 at 2:31 pm
  12. Benjamin wrote:

    To use this in the „Apply Text Filter“ menu, remove „$1“ (including the quotes) from the script and save it as „Tidy HTML“ in ~/Library/Application Support/TextWrangler/Text Filters

    Posted 15 Feb 2013 at 12:05 pm
  13. Fredrik wrote:

    The newest TextWrangler has updated menus.

    Windows -> Palettes -> Text Filters
    (add shortcuts to e.g pretty print xml text filter)

    Windows -> Palettes -> Scripts

    Posted 15 Mrz 2013 at 9:41 am

Trackbacks & Pingbacks 2

  1. From Format XML with TextWrangler | Magp.ie | Das OSX Log on 30 Okt 2014 at 5:01 am

    […] MRo Blog – TextWrangler + tidy. […]

  2. From HTML Tidy with Text Wrangler | Media Zoo on 01 Mrz 2015 at 9:27 pm

    […] getting around to automating HTML Tidy and found a useful blog post that […]

Post a Comment

Your email is never published nor shared. Required fields are marked *